35 #ifndef _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
177 template<
typename Type
214 enum { smpAssignable = 1 };
222 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
223 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
225 template<
typename Other,
size_t M,
size_t N >
229 template<
typename MT,
bool SO2 >
inline DynamicMatrix(
const Matrix<MT,SO2>& m );
245 inline Type*
data ();
246 inline const Type*
data ()
const;
247 inline Type*
data (
size_t i );
248 inline const Type*
data (
size_t i )
const;
261 template<
typename Other,
size_t M,
size_t N >
262 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
266 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator= (
const Matrix<MT,SO2>& rhs );
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 );
271 template<
typename Other >
272 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
273 operator*=( Other rhs );
275 template<
typename Other >
276 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
277 operator/=( Other rhs );
284 inline size_t rows()
const;
288 inline size_t capacity(
size_t i )
const;
290 inline size_t nonZeros(
size_t i )
const;
292 inline void reset(
size_t i );
294 void resize (
size_t m,
size_t n,
bool preserve=
true );
295 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
296 inline void reserve(
size_t elements );
298 template<
typename Other >
inline DynamicMatrix& scale( Other scalar );
306 template<
typename MT >
308 struct VectorizedAssign {
309 enum { value = vectorizable && MT::vectorizable &&
310 IsSame<Type,typename MT::ElementType>::value };
317 template<
typename MT >
319 struct VectorizedAddAssign {
320 enum { value = vectorizable && MT::vectorizable &&
321 IsSame<Type,typename MT::ElementType>::value &&
322 IntrinsicTrait<Type>::addition };
329 template<
typename MT >
331 struct VectorizedSubAssign {
332 enum { value = vectorizable && MT::vectorizable &&
333 IsSame<Type,typename MT::ElementType>::value &&
334 IntrinsicTrait<Type>::subtraction };
343 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
344 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
355 template<
typename MT >
356 inline typename DisableIf< VectorizedAssign<MT> >::Type
357 assign(
const DenseMatrix<MT,SO>& rhs );
359 template<
typename MT >
360 inline typename EnableIf< VectorizedAssign<MT> >::Type
361 assign(
const DenseMatrix<MT,SO>& rhs );
363 template<
typename MT >
inline void assign(
const DenseMatrix<MT,!SO>& rhs );
364 template<
typename MT >
inline void assign(
const SparseMatrix<MT,SO>& rhs );
365 template<
typename MT >
inline void assign(
const SparseMatrix<MT,!SO>& rhs );
367 template<
typename MT >
368 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
369 addAssign(
const DenseMatrix<MT,SO>& rhs );
371 template<
typename MT >
372 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
373 addAssign(
const DenseMatrix<MT,SO>& rhs );
375 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,!SO>& rhs );
376 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
377 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,!SO>& rhs );
379 template<
typename MT >
380 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
381 subAssign(
const DenseMatrix<MT,SO>& rhs );
383 template<
typename MT >
384 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
385 subAssign(
const DenseMatrix<MT,SO>& rhs );
387 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,!SO>& rhs );
388 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
389 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,!SO>& rhs );
444 template<
typename Type
465 template<
typename Type
470 , nn_ ( adjustColumns( n ) )
475 for(
size_t i=0UL; i<
m_; ++i ) {
476 for(
size_t j=
n_; j<
nn_; ++j )
477 v_[i*nn_+j] = Type();
493 template<
typename Type
498 , nn_ ( adjustColumns( n ) )
502 for(
size_t i=0UL; i<m; ++i ) {
503 for(
size_t j=0UL; j<
n_; ++j )
507 for(
size_t j=n_; j<
nn_; ++j )
508 v_[i*nn_+j] = Type();
538 template<
typename Type
540 template<
typename Other >
544 , nn_ ( adjustColumns( n ) )
548 for(
size_t i=0UL; i<m; ++i ) {
549 for(
size_t j=0UL; j<n; ++j )
550 v_[i*
nn_+j] = array[i*n+j];
553 for(
size_t j=n; j<
nn_; ++j )
554 v_[i*nn_+j] = Type();
582 template<
typename Type
584 template<
typename Other
590 , nn_ ( adjustColumns( N ) )
594 for(
size_t i=0UL; i<M; ++i ) {
595 for(
size_t j=0UL; j<N; ++j )
596 v_[i*
nn_+j] = array[i][j];
599 for(
size_t j=N; j<
nn_; ++j )
600 v_[i*nn_+j] = Type();
615 template<
typename Type
637 template<
typename Type
639 template<
typename MT
644 , nn_ ( adjustColumns(
n_ ) )
649 for(
size_t i=0UL; i<
m_; ++i ) {
651 v_[i*nn_+j] = Type();
671 template<
typename Type
695 template<
typename Type
714 template<
typename Type
735 template<
typename Type
753 template<
typename Type
770 template<
typename Type
788 template<
typename Type
809 template<
typename Type
831 template<
typename Type
853 template<
typename Type
875 template<
typename Type
897 template<
typename Type
919 template<
typename Type
959 template<
typename Type
961 template<
typename Other
966 resize( M, N,
false );
968 for(
size_t i=0UL; i<M; ++i )
969 for(
size_t j=0UL; j<N; ++j )
970 v_[i*nn_+j] = array[i][j];
983 template<
typename Type
987 for(
size_t i=0UL; i<
m_; ++i )
988 for(
size_t j=0UL; j<
n_; ++j )
1005 template<
typename Type
1009 if( &rhs ==
this )
return *
this;
1011 resize( rhs.
m_, rhs.
n_,
false );
1028 template<
typename Type
1030 template<
typename MT
1034 if( (~rhs).canAlias(
this ) ) {
1060 template<
typename Type
1062 template<
typename MT
1067 throw std::invalid_argument(
"Matrix sizes do not match" );
1069 if( (~rhs).canAlias(
this ) ) {
1092 template<
typename Type
1094 template<
typename MT
1099 throw std::invalid_argument(
"Matrix sizes do not match" );
1101 if( (~rhs).canAlias(
this ) ) {
1124 template<
typename Type
1126 template<
typename MT
1130 if( (~rhs).
rows() !=
n_ )
1131 throw std::invalid_argument(
"Matrix sizes do not match" );
1148 template<
typename Type
1150 template<
typename Other >
1167 template<
typename Type
1169 template<
typename Other >
1194 template<
typename Type
1208 template<
typename Type
1227 template<
typename Type
1241 template<
typename Type
1261 template<
typename Type
1277 template<
typename Type
1281 size_t nonzeros( 0UL );
1283 for(
size_t i=0UL; i<
m_; ++i )
1284 for(
size_t j=0UL; j<
n_; ++j )
1299 template<
typename Type
1305 const size_t jend( (i+1UL)*nn_ );
1306 size_t nonzeros( 0UL );
1308 for(
size_t j=i*nn_; j<jend; ++j )
1322 template<
typename Type
1328 for(
size_t i=0UL; i<
m_; ++i )
1329 for(
size_t j=0UL; j<
n_; ++j )
1330 reset( v_[i*nn_+j] );
1346 template<
typename Type
1353 for(
size_t j=0UL; j<
n_; ++j )
1354 reset( v_[i*nn_+j] );
1366 template<
typename Type
1370 resize( 0UL, 0UL,
false );
1408 template<
typename Type
1414 if( m ==
m_ && n ==
n_ )
return;
1416 const size_t nn( adjustColumns( n ) );
1421 const size_t min_m( min( m,
m_ ) );
1422 const size_t min_n( min( n,
n_ ) );
1424 for(
size_t i=0UL; i<min_m; ++i )
1425 for(
size_t j=0UL; j<min_n; ++j )
1426 v[i*nn+j] = v_[i*nn_+j];
1440 for(
size_t i=0UL; i<m; ++i )
1441 for(
size_t j=n; j<nn; ++j )
1442 v_[i*nn+j] = Type();
1466 template<
typename Type
1470 resize(
m_+m,
n_+n, preserve );
1484 template<
typename Type
1497 for(
size_t i=
capacity_; i<elements; ++i )
1515 template<
typename Type
1532 template<
typename Type
1534 template<
typename Other >
1537 for(
size_t i=0UL; i<
m_; ++i )
1538 for(
size_t j=0UL; j<
n_; ++j )
1539 v_[i*nn_+j] *= scalar;
1553 template<
typename Type
1572 template<
typename Type
1577 return minColumns + ( IT::size - ( minColumns % IT::size ) ) % IT::size;
1578 else return minColumns;
1601 template<
typename Type
1603 template<
typename Other >
1606 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1621 template<
typename Type
1623 template<
typename Other >
1626 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1640 template<
typename Type
1659 template<
typename Type
1683 template<
typename Type
1697 return load( v_+i*nn_+j );
1717 template<
typename Type
1730 return loadu( v_+i*nn_+j );
1751 template<
typename Type
1764 store( v_+i*nn_+j, value );
1785 template<
typename Type
1797 storeu( v_+i*nn_+j, value );
1818 template<
typename Type
1831 stream( v_+i*nn_+j, value );
1847 template<
typename Type
1849 template<
typename MT >
1856 const size_t jend(
n_ &
size_t(-2) );
1859 for(
size_t i=0UL; i<
m_; ++i ) {
1860 for(
size_t j=0UL; j<jend; j+=2UL ) {
1861 v_[i*nn_+j ] = (~rhs)(i,j );
1862 v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
1865 v_[i*nn_+jend] = (~rhs)(i,jend);
1883 template<
typename Type
1885 template<
typename MT >
1899 for(
size_t i=0UL; i<
m_; ++i )
1900 for(
size_t j=0UL; j<
n_; j+=IT::size )
1905 const size_t jend(
n_ &
size_t(-IT::size*4) );
1908 for(
size_t i=0UL; i<
m_; ++i ) {
1910 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1911 store( v_+i*nn_+j , it.load() ); it += IT::size;
1912 store( v_+i*nn_+j+IT::size , it.load() ); it += IT::size;
1913 store( v_+i*nn_+j+IT::size*2UL, it.load() ); it += IT::size;
1914 store( v_+i*nn_+j+IT::size*3UL, it.load() ); it += IT::size;
1916 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
1917 store( v_+i*nn_+j, it.load() );
1936 template<
typename Type
1938 template<
typename MT >
1944 const size_t block( 16UL );
1946 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
1947 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
1948 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
1949 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
1950 for(
size_t i=ii; i<iend; ++i ) {
1951 for(
size_t j=jj; j<jend; ++j ) {
1952 v_[i*nn_+j] = (~rhs)(i,j);
1972 template<
typename Type
1974 template<
typename MT >
1980 for(
size_t i=0UL; i<
m_; ++i )
1981 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
1982 v_[i*nn_+element->index()] = element->value();
1998 template<
typename Type
2000 template<
typename MT >
2006 for(
size_t j=0UL; j<
n_; ++j )
2007 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2008 v_[element->index()*nn_+j] = element->value();
2024 template<
typename Type
2026 template<
typename MT >
2033 const size_t jend(
n_ &
size_t(-2) );
2036 for(
size_t i=0UL; i<
m_; ++i ) {
2037 for(
size_t j=0UL; j<jend; j+=2UL ) {
2038 v_[i*nn_+j ] += (~rhs)(i,j );
2039 v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2042 v_[i*nn_+jend] += (~rhs)(i,jend);
2060 template<
typename Type
2062 template<
typename MT >
2074 const size_t jend(
n_ &
size_t(-IT::size*4) );
2077 for(
size_t i=0UL; i<
m_; ++i ) {
2079 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2080 store( v_+i*nn_+j ,
load( v_+i*nn_+j ) + it.load() ); it += IT::size;
2081 store( v_+i*nn_+j+IT::size ,
load( v_+i*nn_+j+IT::size ) + it.load() ); it += IT::size;
2082 store( v_+i*nn_+j+IT::size*2UL,
load( v_+i*nn_+j+IT::size*2UL ) + it.load() ); it += IT::size;
2083 store( v_+i*nn_+j+IT::size*3UL,
load( v_+i*nn_+j+IT::size*3UL ) + it.load() ); it += IT::size;
2085 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2086 store( v_+i*nn_+j,
load( v_+i*nn_+j ) + it.load() );
2104 template<
typename Type
2106 template<
typename MT >
2112 const size_t block( 16UL );
2114 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2115 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2116 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2117 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2118 for(
size_t i=ii; i<iend; ++i ) {
2119 for(
size_t j=jj; j<jend; ++j ) {
2120 v_[i*nn_+j] += (~rhs)(i,j);
2140 template<
typename Type
2142 template<
typename MT >
2148 for(
size_t i=0UL; i<
m_; ++i )
2149 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2150 v_[i*nn_+element->index()] += element->value();
2166 template<
typename Type
2168 template<
typename MT >
2174 for(
size_t j=0UL; j<
n_; ++j )
2175 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2176 v_[element->index()*nn_+j] += element->value();
2192 template<
typename Type
2194 template<
typename MT >
2201 const size_t jend(
n_ &
size_t(-2) );
2204 for(
size_t i=0UL; i<
m_; ++i ) {
2205 for(
size_t j=0UL; j<jend; j+=2UL ) {
2206 v_[i*nn_+j ] -= (~rhs)(i,j );
2207 v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2210 v_[i*nn_+jend] -= (~rhs)(i,jend);
2228 template<
typename Type
2230 template<
typename MT >
2242 const size_t jend(
n_ &
size_t(-IT::size*4) );
2245 for(
size_t i=0UL; i<
m_; ++i ) {
2247 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2248 store( v_+i*nn_+j ,
load( v_+i*nn_+j ) - it.load() ); it += IT::size;
2249 store( v_+i*nn_+j+IT::size ,
load( v_+i*nn_+j+IT::size ) - it.load() ); it += IT::size;
2250 store( v_+i*nn_+j+IT::size*2UL,
load( v_+i*nn_+j+IT::size*2UL ) - it.load() ); it += IT::size;
2251 store( v_+i*nn_+j+IT::size*3UL,
load( v_+i*nn_+j+IT::size*3UL ) - it.load() ); it += IT::size;
2253 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2254 store( v_+i*nn_+j,
load( v_+i*nn_+j ) - it.load() );
2272 template<
typename Type
2274 template<
typename MT >
2280 const size_t block( 16UL );
2282 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2283 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2284 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2285 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2286 for(
size_t i=ii; i<iend; ++i ) {
2287 for(
size_t j=jj; j<jend; ++j ) {
2288 v_[i*nn_+j] -= (~rhs)(i,j);
2308 template<
typename Type
2310 template<
typename MT >
2316 for(
size_t i=0UL; i<
m_; ++i )
2317 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2318 v_[i*nn_+element->index()] -= element->value();
2334 template<
typename Type
2336 template<
typename MT >
2342 for(
size_t j=0UL; j<
n_; ++j )
2343 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2344 v_[element->index()*nn_+j] -= element->value();
2369 template<
typename Type >
2405 enum { smpAssignable = 1 };
2413 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
2414 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
2416 template<
typename Other,
size_t M,
size_t N >
2417 explicit inline DynamicMatrix(
const Other (&array)[M][N] );
2420 template<
typename MT,
bool SO >
inline DynamicMatrix(
const Matrix<MT,SO>& m );
2436 inline Type*
data ();
2437 inline const Type*
data ()
const;
2438 inline Type*
data (
size_t j );
2439 inline const Type*
data (
size_t j )
const;
2452 template<
typename Other,
size_t M,
size_t N >
2453 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
2457 template<
typename MT,
bool SO >
inline DynamicMatrix& operator= (
const Matrix<MT,SO>& rhs );
2458 template<
typename MT,
bool SO >
inline DynamicMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2459 template<
typename MT,
bool SO >
inline DynamicMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2460 template<
typename MT,
bool SO >
inline DynamicMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2462 template<
typename Other >
2463 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2464 operator*=( Other rhs );
2466 template<
typename Other >
2467 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2468 operator/=( Other rhs );
2475 inline size_t rows()
const;
2476 inline size_t columns()
const;
2477 inline size_t spacing()
const;
2479 inline size_t capacity(
size_t j )
const;
2481 inline size_t nonZeros(
size_t j )
const;
2482 inline void reset();
2483 inline void reset(
size_t j );
2484 inline void clear();
2485 void resize (
size_t m,
size_t n,
bool preserve=
true );
2486 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
2487 inline void reserve(
size_t elements );
2489 template<
typename Other >
inline DynamicMatrix& scale( Other scalar );
2497 template<
typename MT >
2498 struct VectorizedAssign {
2499 enum { value = vectorizable && MT::vectorizable &&
2500 IsSame<Type,typename MT::ElementType>::value };
2506 template<
typename MT >
2507 struct VectorizedAddAssign {
2508 enum { value = vectorizable && MT::vectorizable &&
2509 IsSame<Type,typename MT::ElementType>::value &&
2510 IntrinsicTrait<Type>::addition };
2516 template<
typename MT >
2517 struct VectorizedSubAssign {
2518 enum { value = vectorizable && MT::vectorizable &&
2519 IsSame<Type,typename MT::ElementType>::value &&
2520 IntrinsicTrait<Type>::subtraction };
2528 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2529 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2540 template<
typename MT >
2541 inline typename DisableIf< VectorizedAssign<MT> >::Type
2542 assign(
const DenseMatrix<MT,true>& rhs );
2544 template<
typename MT >
2545 inline typename EnableIf< VectorizedAssign<MT> >::Type
2546 assign(
const DenseMatrix<MT,true>& rhs );
2548 template<
typename MT >
inline void assign(
const DenseMatrix<MT,false>& rhs );
2549 template<
typename MT >
inline void assign(
const SparseMatrix<MT,true>& rhs );
2550 template<
typename MT >
inline void assign(
const SparseMatrix<MT,false>& rhs );
2552 template<
typename MT >
2553 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2554 addAssign(
const DenseMatrix<MT,true>& rhs );
2556 template<
typename MT >
2557 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2558 addAssign(
const DenseMatrix<MT,true>& rhs );
2560 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,false>& rhs );
2561 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,true>& rhs );
2562 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,false>& rhs );
2564 template<
typename MT >
2565 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2566 subAssign (
const DenseMatrix<MT,true>& rhs );
2568 template<
typename MT >
2569 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2570 subAssign (
const DenseMatrix<MT,true>& rhs );
2572 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,false>& rhs );
2573 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,true>& rhs );
2574 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,false>& rhs );
2582 inline size_t adjustRows(
size_t minRows )
const;
2629 template<
typename Type >
2651 template<
typename Type >
2654 , mm_ ( adjustRows( m ) )
2659 if( IsNumeric<Type>::value ) {
2660 for(
size_t j=0UL; j<
n_; ++j )
2661 for(
size_t i=
m_; i<mm_; ++i ) {
2662 v_[i+j*mm_] = Type();
2680 template<
typename Type >
2683 , mm_ ( adjustRows( m ) )
2688 for(
size_t j=0UL; j<
n_; ++j ) {
2689 for(
size_t i=0UL; i<
m_; ++i )
2692 if( IsNumeric<Type>::value ) {
2693 for(
size_t i=m_; i<mm_; ++i )
2694 v_[i+j*mm_] = Type();
2726 template<
typename Type >
2727 template<
typename Other >
2730 , mm_ ( adjustRows( m ) )
2735 for(
size_t j=0UL; j<n; ++j ) {
2736 for(
size_t i=0UL; i<m; ++i )
2737 v_[i+j*mm_] = array[i+j*m];
2739 if( IsNumeric<Type>::value ) {
2740 for(
size_t i=m; i<mm_; ++i )
2741 v_[i+j*mm_] = Type();
2771 template<
typename Type >
2772 template<
typename Other
2777 , mm_ ( adjustRows( M ) )
2782 for(
size_t j=0UL; j<N; ++j ) {
2783 for(
size_t i=0UL; i<M; ++i )
2784 v_[i+j*mm_] = array[i][j];
2786 if( IsNumeric<Type>::value ) {
2787 for(
size_t i=M; i<mm_; ++i )
2788 v_[i+j*mm_] = Type();
2805 template<
typename Type >
2828 template<
typename Type >
2829 template<
typename MT
2832 : m_ ( (~m).
rows() )
2833 , mm_ ( adjustRows( m_ ) )
2838 if( IsNumeric<Type>::value ) {
2839 for(
size_t j=0UL; j<
n_; ++j )
2840 for(
size_t i=( IsSparseMatrix<MT>::value )?( 0UL ):( m_ ); i<mm_; ++i ) {
2841 v_[i+j*mm_] = Type();
2863 template<
typename Type >
2888 template<
typename Type >
2908 template<
typename Type >
2930 template<
typename Type >
2949 template<
typename Type >
2967 template<
typename Type >
2986 template<
typename Type >
3003 template<
typename Type >
3021 template<
typename Type >
3039 template<
typename Type >
3057 template<
typename Type >
3062 return Iterator( v_ + j*mm_ + m_ );
3075 template<
typename Type >
3093 template<
typename Type >
3134 template<
typename Type >
3135 template<
typename Other
3138 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Other (&array)[M][N] )
3140 resize( M, N,
false );
3142 for(
size_t j=0UL; j<N; ++j )
3143 for(
size_t i=0UL; i<M; ++i )
3144 v_[i+j*mm_] = array[i][j];
3159 template<
typename Type >
3160 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( Type rhs )
3162 for(
size_t j=0UL; j<
n_; ++j )
3163 for(
size_t i=0UL; i<
m_; ++i )
3182 template<
typename Type >
3183 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const DynamicMatrix& rhs )
3185 if( &rhs ==
this )
return *
this;
3187 resize( rhs.m_, rhs.n_,
false );
3206 template<
typename Type >
3207 template<
typename MT
3209 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Matrix<MT,SO>& rhs )
3211 if( (~rhs).canAlias(
this ) ) {
3212 DynamicMatrix tmp( ~rhs );
3217 if( IsSparseMatrix<MT>::value )
3239 template<
typename Type >
3240 template<
typename MT
3242 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
3244 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3245 throw std::invalid_argument(
"Matrix sizes do not match" );
3247 if( (~rhs).canAlias(
this ) ) {
3272 template<
typename Type >
3273 template<
typename MT
3275 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
3277 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3278 throw std::invalid_argument(
"Matrix sizes do not match" );
3280 if( (~rhs).canAlias(
this ) ) {
3305 template<
typename Type >
3306 template<
typename MT
3308 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
3310 if( (~rhs).
rows() != n_ )
3311 throw std::invalid_argument(
"Matrix sizes do not match" );
3313 DynamicMatrix tmp( *
this * (~rhs) );
3330 template<
typename Type >
3331 template<
typename Other >
3332 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3333 DynamicMatrix<Type,true>::operator*=( Other rhs )
3350 template<
typename Type >
3351 template<
typename Other >
3352 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3353 DynamicMatrix<Type,true>::operator/=( Other rhs )
3378 template<
typename Type >
3393 template<
typename Type >
3411 template<
typename Type >
3426 template<
typename Type >
3442 template<
typename Type >
3459 template<
typename Type >
3462 size_t nonzeros( 0UL );
3464 for(
size_t j=0UL; j<
n_; ++j )
3465 for(
size_t i=0UL; i<
m_; ++i )
3482 template<
typename Type >
3487 const size_t iend( (j+1UL)*mm_ );
3488 size_t nonzeros( 0UL );
3490 for(
size_t i=j*mm_; i<iend; ++i )
3506 template<
typename Type >
3511 for(
size_t j=0UL; j<
n_; ++j )
3512 for(
size_t i=0UL; i<
m_; ++i )
3513 reset( v_[i+j*mm_] );
3529 template<
typename Type >
3535 for(
size_t i=0UL; i<
m_; ++i )
3536 reset( v_[i+j*mm_] );
3550 template<
typename Type >
3553 resize( 0UL, 0UL,
false );
3593 template<
typename Type >
3598 if( m == m_ && n == n_ )
return;
3600 const size_t mm( adjustRows( m ) );
3605 const size_t min_m( min( m, m_ ) );
3606 const size_t min_n( min( n, n_ ) );
3608 for(
size_t j=0UL; j<min_n; ++j )
3609 for(
size_t i=0UL; i<min_m; ++i )
3610 v[i+j*mm] = v_[i+j*mm_];
3623 if( IsNumeric<Type>::value ) {
3624 for(
size_t j=0UL; j<n; ++j )
3625 for(
size_t i=m; i<mm; ++i )
3626 v_[i+j*mm] = Type();
3652 template<
typename Type >
3655 resize( m_+m, n_+n, preserve );
3671 template<
typename Type >
3682 if( IsNumeric<Type>::value ) {
3683 for(
size_t i=
capacity_; i<elements; ++i )
3703 template<
typename Type >
3706 DynamicMatrix tmp(
trans(*
this) );
3721 template<
typename Type >
3722 template<
typename Other >
3723 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale( Other scalar )
3725 for(
size_t j=0UL; j<
n_; ++j )
3726 for(
size_t i=0UL; i<
m_; ++i )
3727 v_[i+j*mm_] *= scalar;
3743 template<
typename Type >
3763 template<
typename Type >
3764 inline size_t DynamicMatrix<Type,true>::adjustRows(
size_t minRows )
const
3766 if( IsNumeric<Type>::value )
3767 return minRows + ( IT::size - ( minRows % IT::size ) ) % IT::size;
3768 else return minRows;
3793 template<
typename Type >
3794 template<
typename Other >
3797 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3814 template<
typename Type >
3815 template<
typename Other >
3818 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3834 template<
typename Type >
3854 template<
typename Type >
3878 template<
typename Type >
3879 inline typename DynamicMatrix<Type,true>::IntrinsicType
3891 return load( v_+i+j*mm_ );
3912 template<
typename Type >
3913 inline typename DynamicMatrix<Type,true>::IntrinsicType
3924 return loadu( v_+i+j*mm_ );
3946 template<
typename Type >
3958 store( v_+i+j*mm_, value );
3980 template<
typename Type >
3991 storeu( v_+i+j*mm_, value );
4014 template<
typename Type >
4026 stream( v_+i+j*mm_, value );
4044 template<
typename Type >
4045 template<
typename MT >
4046 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4052 const size_t iend( m_ &
size_t(-2) );
4055 for(
size_t j=0UL; j<
n_; ++j ) {
4056 for(
size_t i=0UL; i<iend; i+=2UL ) {
4057 v_[i +j*mm_] = (~rhs)(i ,j);
4058 v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
4061 v_[iend+j*mm_] = (~rhs)(iend,j);
4081 template<
typename Type >
4082 template<
typename MT >
4083 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4096 for(
size_t j=0UL; j<
n_; ++j )
4097 for(
size_t i=0UL; i<
m_; i+=IT::size )
4102 const size_t iend( m_ &
size_t(-IT::size*4) );
4105 for(
size_t j=0UL; j<
n_; ++j ) {
4107 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4108 store( v_+i+j*mm_ , it.load() ); it += IT::size;
4109 store( v_+i+j*mm_+IT::size , it.load() ); it += IT::size;
4110 store( v_+i+j*mm_+IT::size*2UL, it.load() ); it += IT::size;
4111 store( v_+i+j*mm_+IT::size*3UL, it.load() ); it += IT::size;
4113 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4114 store( v_+i+j*mm_, it.load() );
4135 template<
typename Type >
4136 template<
typename MT >
4142 const size_t block( 16UL );
4144 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4145 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4146 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4147 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4148 for(
size_t j=jj; j<jend; ++j ) {
4149 for(
size_t i=ii; i<iend; ++i ) {
4150 v_[i+j*mm_] = (~rhs)(i,j);
4172 template<
typename Type >
4173 template<
typename MT >
4176 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4177 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4178 v_[element->index()+j*mm_] = element->value();
4196 template<
typename Type >
4197 template<
typename MT >
4200 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4201 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4202 v_[i+element->index()*mm_] = element->value();
4220 template<
typename Type >
4221 template<
typename MT >
4222 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4228 const size_t iend( m_ &
size_t(-2) );
4231 for(
size_t j=0UL; j<
n_; ++j ) {
4232 for(
size_t i=0UL; i<iend; i+=2UL ) {
4233 v_[i +j*mm_] += (~rhs)(i ,j);
4234 v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4237 v_[iend+j*mm_] += (~rhs)(iend,j);
4257 template<
typename Type >
4258 template<
typename MT >
4259 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4270 const size_t iend( m_ &
size_t(-IT::size*4) );
4273 for(
size_t j=0UL; j<
n_; ++j ) {
4275 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4276 store( v_+i+j*mm_ ,
load( v_+i+j*mm_ ) + it.load() ); it += IT::size;
4277 store( v_+i+j*mm_+IT::size ,
load( v_+i+j*mm_+IT::size ) + it.load() ); it += IT::size;
4278 store( v_+i+j*mm_+IT::size*2UL,
load( v_+i+j*mm_+IT::size*2UL ) + it.load() ); it += IT::size;
4279 store( v_+i+j*mm_+IT::size*3UL,
load( v_+i+j*mm_+IT::size*3UL ) + it.load() ); it += IT::size;
4281 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4282 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) + it.load() );
4302 template<
typename Type >
4303 template<
typename MT >
4309 const size_t block( 16UL );
4311 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4312 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4313 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4314 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4315 for(
size_t j=jj; j<jend; ++j ) {
4316 for(
size_t i=ii; i<iend; ++i ) {
4317 v_[i+j*mm_] += (~rhs)(i,j);
4339 template<
typename Type >
4340 template<
typename MT >
4343 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4344 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4345 v_[element->index()+j*mm_] += element->value();
4363 template<
typename Type >
4364 template<
typename MT >
4367 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4368 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4369 v_[i+element->index()*mm_] += element->value();
4387 template<
typename Type >
4388 template<
typename MT >
4389 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4395 const size_t iend( m_ &
size_t(-2) );
4398 for(
size_t j=0UL; j<
n_; ++j ) {
4399 for(
size_t i=0UL; i<iend; i+=2UL ) {
4400 v_[i +j*mm_] -= (~rhs)(i ,j);
4401 v_[i+1+j*mm_] -= (~rhs)(i+1,j);
4404 v_[iend+j*mm_] -= (~rhs)(iend,j);
4425 template<
typename Type >
4426 template<
typename MT >
4427 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4438 const size_t iend( m_ &
size_t(-IT::size*4) );
4441 for(
size_t j=0UL; j<
n_; ++j ) {
4443 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4444 store( v_+i+j*mm_ ,
load( v_+i+j*mm_ ) - it.load() ); it += IT::size;
4445 store( v_+i+j*mm_+IT::size ,
load( v_+i+j*mm_+IT::size ) - it.load() ); it += IT::size;
4446 store( v_+i+j*mm_+IT::size*2UL,
load( v_+i+j*mm_+IT::size*2UL ) - it.load() ); it += IT::size;
4447 store( v_+i+j*mm_+IT::size*3UL,
load( v_+i+j*mm_+IT::size*3UL ) - it.load() ); it += IT::size;
4449 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4450 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) - it.load() );
4470 template<
typename Type >
4471 template<
typename MT >
4474 const size_t block( 16UL );
4476 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4477 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4478 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4479 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4480 for(
size_t j=jj; j<jend; ++j ) {
4481 for(
size_t i=ii; i<iend; ++i ) {
4482 v_[i+j*mm_] -= (~rhs)(i,j);
4504 template<
typename Type >
4505 template<
typename MT >
4508 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4509 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4510 v_[element->index()+j*mm_] -= element->value();
4528 template<
typename Type >
4529 template<
typename MT >
4532 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4533 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4534 v_[i+element->index()*mm_] -= element->value();
4555 template<
typename Type,
bool SO >
4556 inline void reset( DynamicMatrix<Type,SO>& m );
4558 template<
typename Type,
bool SO >
4559 inline void clear( DynamicMatrix<Type,SO>& m );
4561 template<
typename Type,
bool SO >
4562 inline bool isDefault(
const DynamicMatrix<Type,SO>& m );
4564 template<
typename Type,
bool SO >
4565 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) ;
4577 template<
typename Type
4593 template<
typename Type
4620 template<
typename Type
4625 for(
size_t i=0UL; i<m.
rows(); ++i )
4626 for(
size_t j=0UL; j<m.
columns(); ++j )
4627 if( !
isDefault( m(i,j) ) )
return false;
4630 for(
size_t j=0UL; j<m.
columns(); ++j )
4631 for(
size_t i=0UL; i<m.
rows(); ++i )
4632 if( !
isDefault( m(i,j) ) )
return false;
4649 template<
typename Type
4668 template<
typename T,
bool SO >
4669 struct IsResizable< DynamicMatrix<T,SO> > :
public TrueType
4675 template<
typename T,
bool SO >
4676 struct IsResizable< const DynamicMatrix<T,SO> > :
public TrueType
4682 template<
typename T,
bool SO >
4683 struct IsResizable< volatile DynamicMatrix<T,SO> > :
public TrueType
4689 template<
typename T,
bool SO >
4690 struct IsResizable< const volatile DynamicMatrix<T,SO> > :
public TrueType
4709 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4710 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4712 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4715 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4716 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4718 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4721 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4722 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4724 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4727 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4728 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4730 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4733 template<
typename T1,
bool SO,
typename T2 >
4734 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4736 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4739 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4740 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4742 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4758 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4759 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4761 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4764 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4765 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4767 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4770 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4771 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4773 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4776 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4777 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4779 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4782 template<
typename T1,
bool SO,
typename T2 >
4783 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4785 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4788 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4789 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4791 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4807 template<
typename T1,
bool SO,
typename T2 >
4808 struct MultTrait< DynamicMatrix<T1,SO>, T2 >
4810 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4814 template<
typename T1,
typename T2,
bool SO >
4815 struct MultTrait< T1, DynamicMatrix<T2,SO> >
4817 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4821 template<
typename T1,
bool SO,
typename T2,
size_t N >
4822 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
4824 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4827 template<
typename T1,
size_t N,
typename T2,
bool SO >
4828 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
4830 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4833 template<
typename T1,
bool SO,
typename T2,
size_t N >
4834 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
4836 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4839 template<
typename T1,
size_t N,
typename T2,
bool SO >
4840 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
4842 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4845 template<
typename T1,
bool SO,
typename T2 >
4846 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
4848 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4851 template<
typename T1,
typename T2,
bool SO >
4852 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
4854 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4857 template<
typename T1,
bool SO,
typename T2 >
4858 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
4860 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4863 template<
typename T1,
typename T2,
bool SO >
4864 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
4866 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4869 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4870 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4872 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4875 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4876 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4878 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4881 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4882 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4884 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4900 template<
typename T1,
bool SO,
typename T2 >
4901 struct DivTrait< DynamicMatrix<T1,SO>, T2 >
4903 typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
4920 template<
typename T1,
bool SO,
typename T2 >
4921 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4923 typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
4924 typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
4940 template<
typename T1,
bool SO >
4941 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
4943 typedef DynamicMatrix<T1,SO> Type;
4959 template<
typename T1,
bool SO >
4960 struct RowTrait< DynamicMatrix<T1,SO> >
4962 typedef DynamicVector<T1,true> Type;
4978 template<
typename T1,
bool SO >
4979 struct ColumnTrait< DynamicMatrix<T1,SO> >
4981 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:698
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:405
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:1486
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4579
#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.
const size_t OPENMP_DMATASSIGN_THRESHOLD
OpenMP dense matrix assignment threshold.This threshold specifies when an assignment with a plain den...
Definition: Thresholds.h:536
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:856
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:408
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:151
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:751
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:4622
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:197
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1410
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:1210
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:1787
Header file for the sparse matrix SMP implementation.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2528
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
DynamicMatrix()
The default constructor for DynamicMatrix.
Definition: DynamicMatrix.h:446
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:1229
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:179
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4595
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:195
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:2530
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:673
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:189
Header file for the SparseMatrix base class.
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:114
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: DynamicMatrix.h:1279
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1574
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:121
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:922
Header file for the multiplication trait.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:1642
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1720
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:4558
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:192
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
#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:183
Header file for the dense matrix SMP implementation.
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:188
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:194
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.
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1468
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1196
#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:1324
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:878
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2386
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:190
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1243
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:91
Header file for the IsNumeric type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:406
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1753
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:1368
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:4651
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:737
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:404
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:812
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:1624
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:2387
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:1555
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1686
T * allocate(size_t size)
Aligned array allocation.
Definition: Memory.h:83
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:196
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: DynamicMatrix.h:1661
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2529
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:199
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:193
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:407
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2379
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:198
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2385
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:348
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.
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: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:1604
DynamicMatrix & transpose()
Transposing the matrix.
Definition: DynamicMatrix.h:1517
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:197
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:191
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:1820