35 #ifndef _BLAZE_MATH_VIEWS_DENSEROW_H_
36 #define _BLAZE_MATH_VIEWS_DENSEROW_H_
308 template<
typename MT
309 ,
bool SO = IsRowMajorMatrix<MT>::value >
364 enum { vectorizable = MT::vectorizable };
367 enum { smpAssignable = MT::smpAssignable };
373 explicit inline DenseRow( MT& matrix,
size_t index );
403 template<
typename VT >
inline DenseRow&
operator= (
const Vector<VT,true>& rhs );
404 template<
typename VT >
inline DenseRow& operator+=(
const Vector<VT,true>& rhs );
405 template<
typename VT >
inline DenseRow& operator-=(
const Vector<VT,true>& rhs );
406 template<
typename VT >
inline DenseRow& operator*=(
const Vector<VT,true>& rhs );
408 template<
typename Other >
409 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
410 operator*=( Other rhs );
412 template<
typename Other >
413 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
414 operator/=( Other rhs );
421 inline size_t size()
const;
425 template<
typename Other >
inline DenseRow& scale(
const Other& scalar );
432 template<
typename VT >
434 struct VectorizedAssign {
435 enum { value = vectorizable && VT::vectorizable &&
436 IsSame<ElementType,typename VT::ElementType>::value };
443 template<
typename VT >
445 struct VectorizedAddAssign {
446 enum { value = vectorizable && VT::vectorizable &&
447 IsSame<ElementType,typename VT::ElementType>::value &&
448 IntrinsicTrait<ElementType>::addition };
455 template<
typename VT >
457 struct VectorizedSubAssign {
458 enum { value = vectorizable && VT::vectorizable &&
459 IsSame<ElementType,typename VT::ElementType>::value &&
460 IntrinsicTrait<ElementType>::subtraction };
467 template<
typename VT >
469 struct VectorizedMultAssign {
470 enum { value = vectorizable && VT::vectorizable &&
471 IsSame<ElementType,typename VT::ElementType>::value &&
472 IntrinsicTrait<ElementType>::multiplication };
481 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
482 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
493 template<
typename VT >
494 inline typename DisableIf< VectorizedAssign<VT> >::Type
495 assign(
const DenseVector<VT,true>& rhs );
497 template<
typename VT >
498 inline typename EnableIf< VectorizedAssign<VT> >::Type
499 assign(
const DenseVector<VT,true>& rhs );
501 template<
typename VT >
inline void assign(
const SparseVector<VT,true>& rhs );
503 template<
typename VT >
504 inline typename DisableIf< VectorizedAddAssign<VT> >::Type
505 addAssign(
const DenseVector<VT,true>& rhs );
507 template<
typename VT >
508 inline typename EnableIf< VectorizedAddAssign<VT> >::Type
509 addAssign(
const DenseVector<VT,true>& rhs );
511 template<
typename VT >
inline void addAssign(
const SparseVector<VT,true>& rhs );
513 template<
typename VT >
514 inline typename DisableIf< VectorizedSubAssign<VT> >::Type
515 subAssign(
const DenseVector<VT,true>& rhs );
517 template<
typename VT >
518 inline typename EnableIf< VectorizedSubAssign<VT> >::Type
519 subAssign(
const DenseVector<VT,true>& rhs );
521 template<
typename VT >
inline void subAssign(
const SparseVector<VT,true>& rhs );
523 template<
typename VT >
524 inline typename DisableIf< VectorizedMultAssign<VT> >::Type
525 multAssign(
const DenseVector<VT,true>& rhs );
527 template<
typename VT >
528 inline typename EnableIf< VectorizedMultAssign<VT> >::Type
529 multAssign(
const DenseVector<VT,true>& rhs );
531 template<
typename VT >
inline void multAssign(
const SparseVector<VT,true>& rhs );
571 template<
typename MT
578 throw std::invalid_argument(
"Invalid row access index" );
597 template<
typename MT
602 return matrix_(row_,index);
613 template<
typename MT
618 return matrix_(row_,index);
630 template<
typename MT
634 return matrix_.data( row_ );
646 template<
typename MT
650 return matrix_.data( row_ );
662 template<
typename MT
666 return matrix_.begin( row_ );
678 template<
typename MT
682 return matrix_.cbegin( row_ );
694 template<
typename MT
698 return matrix_.cbegin( row_ );
710 template<
typename MT
714 return matrix_.end( row_ );
726 template<
typename MT
730 return matrix_.cend( row_ );
742 template<
typename MT
746 return matrix_.cend( row_ );
765 template<
typename MT
769 const size_t columns( size() );
771 for(
size_t j=0UL; j<
columns; ++j )
772 matrix_(row_,j) = rhs;
789 template<
typename MT
793 if( &rhs ==
this )
return *
this;
795 if( size() != rhs.
size() )
796 throw std::invalid_argument(
"Row sizes do not match" );
798 const size_t columns( size() );
800 for(
size_t j=0UL; j<
columns; ++j )
801 matrix_(row_,j) = rhs[j];
818 template<
typename MT
820 template<
typename VT >
826 if( size() != (~rhs).size() )
827 throw std::invalid_argument(
"Vector sizes do not match" );
829 if( (~rhs).canAlias( &matrix_ ) ) {
854 template<
typename MT
856 template<
typename VT >
862 if( size() != (~rhs).size() )
863 throw std::invalid_argument(
"Vector sizes do not match" );
865 if( (~rhs).canAlias( &matrix_ ) ) {
888 template<
typename MT
890 template<
typename VT >
896 if( size() != (~rhs).size() )
897 throw std::invalid_argument(
"Vector sizes do not match" );
899 if( (~rhs).canAlias( &matrix_ ) ) {
923 template<
typename MT
925 template<
typename VT >
931 if( size() != (~rhs).size() )
932 throw std::invalid_argument(
"Vector sizes do not match" );
954 template<
typename MT
956 template<
typename Other >
960 return operator=( (*
this) * rhs );
974 template<
typename MT
976 template<
typename Other >
982 return operator=( (*
this) / rhs );
1000 template<
typename MT
1004 return matrix_.columns();
1014 template<
typename MT
1018 return matrix_.capacity( row_ );
1031 template<
typename MT
1035 return matrix_.nonZeros( row_ );
1045 template<
typename MT
1049 matrix_.reset( row_ );
1060 template<
typename MT
1062 template<
typename Other >
1065 for(
size_t j=0UL; j<size(); ++j ) {
1066 matrix_(row_,j) *= scalar;
1091 template<
typename MT
1093 template<
typename Other >
1096 return static_cast<const void*
>( &matrix_ ) == static_cast<const void*>( alias );
1111 template<
typename MT
1113 template<
typename Other >
1116 return static_cast<const void*
>( &matrix_ ) == static_cast<const void*>( alias );
1130 template<
typename MT
1134 return matrix_.isAligned();
1149 template<
typename MT
1170 template<
typename MT
1174 return matrix_.load( row_, index );
1191 template<
typename MT
1195 return matrix_.loadu( row_, index );
1213 template<
typename MT
1217 matrix_.store( row_, index, value );
1235 template<
typename MT
1239 matrix_.storeu( row_, index, value );
1257 template<
typename MT
1261 matrix_.stream( row_, index, value );
1277 template<
typename MT
1279 template<
typename VT >
1285 const size_t jend( (~rhs).size() &
size_t(-2) );
1286 for(
size_t j=0UL; j<jend; j+=2UL ) {
1287 matrix_(row_,j ) = (~rhs)[j ];
1288 matrix_(row_,j+1UL) = (~rhs)[j+1UL];
1290 if( jend < (~rhs).size() )
1291 matrix_(row_,jend) = (~rhs)[jend];
1307 template<
typename MT
1309 template<
typename VT >
1317 const size_t columns( size() );
1321 for(
size_t j=0UL; j<
columns; j+=IT::size ) {
1322 matrix_.stream( row_, j, (~rhs).
load(j) );
1327 const size_t jend( columns &
size_t(-IT::size*4) );
1328 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1331 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1332 matrix_.store( row_, j , it.load() ); it += IT::size;
1333 matrix_.store( row_, j+IT::size , it.load() ); it += IT::size;
1334 matrix_.store( row_, j+IT::size*2UL, it.load() ); it += IT::size;
1335 matrix_.store( row_, j+IT::size*3UL, it.load() ); it += IT::size;
1337 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1338 matrix_.store( row_, j, it.load() );
1356 template<
typename MT
1358 template<
typename VT >
1363 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1364 matrix_(row_,element->index()) = element->value();
1380 template<
typename MT
1382 template<
typename VT >
1388 const size_t jend( (~rhs).size() &
size_t(-2) );
1389 for(
size_t j=0UL; j<jend; j+=2UL ) {
1390 matrix_(row_,j ) += (~rhs)[j ];
1391 matrix_(row_,j+1UL) += (~rhs)[j+1UL];
1393 if( jend < (~rhs).size() )
1394 matrix_(row_,jend) += (~rhs)[jend];
1410 template<
typename MT
1412 template<
typename VT >
1420 const size_t columns( size() );
1422 const size_t jend( columns &
size_t(-IT::size*4) );
1423 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1426 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1427 matrix_.store( row_, j , matrix_.load(row_,j ) + it.load() ); it += IT::size;
1428 matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) + it.load() ); it += IT::size;
1429 matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) + it.load() ); it += IT::size;
1430 matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) + it.load() ); it += IT::size;
1432 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1433 matrix_.store( row_, j, matrix_.load(row_,j) + it.load() );
1450 template<
typename MT
1452 template<
typename VT >
1457 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1458 matrix_(row_,element->index()) += element->value();
1474 template<
typename MT
1476 template<
typename VT >
1482 const size_t jend( (~rhs).size() &
size_t(-2) );
1483 for(
size_t j=0UL; j<jend; j+=2UL ) {
1484 matrix_(row_,j ) -= (~rhs)[j ];
1485 matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
1487 if( jend < (~rhs).size() )
1488 matrix_(row_,jend) -= (~rhs)[jend];
1504 template<
typename MT
1506 template<
typename VT >
1514 const size_t columns( size() );
1516 const size_t jend( columns &
size_t(-IT::size*4) );
1517 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1520 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1521 matrix_.store( row_, j , matrix_.load(row_,j ) - it.load() ); it += IT::size;
1522 matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) - it.load() ); it += IT::size;
1523 matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) - it.load() ); it += IT::size;
1524 matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) - it.load() ); it += IT::size;
1526 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1527 matrix_.store( row_, j, matrix_.load(row_,j) - it.load() );
1544 template<
typename MT
1546 template<
typename VT >
1551 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1552 matrix_(row_,element->index()) -= element->value();
1568 template<
typename MT
1570 template<
typename VT >
1576 const size_t jend( (~rhs).size() &
size_t(-2) );
1577 for(
size_t j=0UL; j<jend; j+=2UL ) {
1578 matrix_(row_,j ) *= (~rhs)[j ];
1579 matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
1581 if( jend < (~rhs).size() )
1582 matrix_(row_,jend) *= (~rhs)[jend];
1598 template<
typename MT
1600 template<
typename VT >
1608 const size_t columns( size() );
1610 const size_t jend( columns &
size_t(-IT::size*4) );
1611 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1614 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1615 matrix_.store( row_, j , matrix_.load(row_,j ) * it.load() ); it += IT::size;
1616 matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) * it.load() ); it += IT::size;
1617 matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) * it.load() ); it += IT::size;
1618 matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) * it.load() ); it += IT::size;
1620 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1621 matrix_.store( row_, j, matrix_.load(row_,j) * it.load() );
1638 template<
typename MT
1640 template<
typename VT >
1649 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1650 matrix_(row_,element->index()) = tmp[element->index()] * element->value();
1675 template<
typename MT >
1698 typedef DenseRow<MT,false>
This;
1699 typedef typename RowTrait<MT>::Type
ResultType;
1709 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
1715 template<
typename MatrixType >
1726 enum { returnConst = IsConst<MatrixType>::value };
1732 typedef typename SelectType< returnConst, typename MT::ConstReference, typename MT::Reference >::Type
Reference;
1734 typedef std::random_access_iterator_tag IteratorCategory;
1735 typedef RemoveReference<Reference> ValueType;
1736 typedef ValueType* PointerType;
1738 typedef ptrdiff_t DifferenceType;
1741 typedef IteratorCategory iterator_category;
1742 typedef ValueType value_type;
1743 typedef PointerType pointer;
1744 typedef ReferenceType reference;
1745 typedef DifferenceType difference_type;
1755 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column )
1767 template<
typename MatrixType2 >
1768 inline RowIterator(
const RowIterator<MatrixType2>& it )
1771 , column_( it.column_ )
1781 inline RowIterator& operator+=(
size_t inc ) {
1793 inline RowIterator& operator-=(
size_t dec ) {
1804 inline RowIterator& operator++() {
1815 inline const RowIterator operator++(
int ) {
1816 const RowIterator tmp( *
this );
1827 inline RowIterator& operator--() {
1838 inline const RowIterator operator--(
int ) {
1839 const RowIterator tmp( *
this );
1851 inline ReferenceType
operator[](
size_t index )
const {
1861 inline ReferenceType
operator*()
const {
1871 inline PointerType operator->()
const {
1872 return &(*matrix_)(
row_,column_);
1882 template<
typename MatrixType2 >
1883 inline bool operator==(
const RowIterator<MatrixType2>& rhs )
const {
1884 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1894 template<
typename MatrixType2 >
1895 inline bool operator!=(
const RowIterator<MatrixType2>& rhs )
const {
1896 return !( *
this == rhs );
1906 template<
typename MatrixType2 >
1907 inline bool operator<( const RowIterator<MatrixType2>& rhs )
const {
1908 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ < rhs.column_ );
1918 template<
typename MatrixType2 >
1919 inline bool operator>(
const RowIterator<MatrixType2>& rhs )
const {
1920 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ > rhs.column_ );
1930 template<
typename MatrixType2 >
1931 inline bool operator<=( const RowIterator<MatrixType2>& rhs )
const {
1932 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ <= rhs.column_ );
1942 template<
typename MatrixType2 >
1943 inline bool operator>=(
const RowIterator<MatrixType2>& rhs )
const {
1944 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ >= rhs.column_ );
1954 inline DifferenceType
operator-(
const RowIterator& rhs )
const {
1955 return column_ - rhs.column_;
1966 friend inline const RowIterator
operator+(
const RowIterator& it,
size_t inc ) {
1967 return RowIterator( *it.matrix_, it.row_, it.column_+inc );
1978 friend inline const RowIterator
operator+(
size_t inc,
const RowIterator& it ) {
1979 return RowIterator( *it.matrix_, it.row_, it.column_+inc );
1990 friend inline const RowIterator
operator-(
const RowIterator& it,
size_t dec ) {
1991 return RowIterator( *it.matrix_, it.row_, it.column_-dec );
2003 template<
typename MatrixType2 >
friend class RowIterator;
2013 typedef typename SelectType< useConst, ConstIterator, RowIterator<MT> >::Type
Iterator;
2018 enum { vectorizable = 0 };
2021 enum { smpAssignable = MT::smpAssignable };
2027 explicit inline DenseRow( MT& matrix,
size_t index );
2055 template<
typename VT >
inline DenseRow&
operator= (
const Vector<VT,true>& rhs );
2056 template<
typename VT >
inline DenseRow& operator+=(
const Vector<VT,true>& rhs );
2057 template<
typename VT >
inline DenseRow& operator-=(
const Vector<VT,true>& rhs );
2058 template<
typename VT >
inline DenseRow& operator*=(
const Vector<VT,true>& rhs );
2060 template<
typename Other >
2061 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
2062 operator*=( Other rhs );
2064 template<
typename Other >
2065 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
2066 operator/=( Other rhs );
2073 inline size_t size()
const;
2076 inline void reset();
2077 template<
typename Other >
inline DenseRow& scale(
const Other& scalar );
2085 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2086 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2091 template<
typename VT >
inline void assign (
const DenseVector <VT,true>& rhs );
2092 template<
typename VT >
inline void assign (
const SparseVector<VT,true>& rhs );
2093 template<
typename VT >
inline void addAssign (
const DenseVector <VT,true>& rhs );
2094 template<
typename VT >
inline void addAssign (
const SparseVector<VT,true>& rhs );
2095 template<
typename VT >
inline void subAssign (
const DenseVector <VT,true>& rhs );
2096 template<
typename VT >
inline void subAssign (
const SparseVector<VT,true>& rhs );
2097 template<
typename VT >
inline void multAssign(
const DenseVector <VT,true>& rhs );
2098 template<
typename VT >
inline void multAssign(
const SparseVector<VT,true>& rhs );
2138 template<
typename MT >
2144 throw std::invalid_argument(
"Invalid row access index" );
2165 template<
typename MT >
2169 return matrix_(row_,index);
2182 template<
typename MT >
2186 return matrix_(row_,index);
2200 template<
typename MT >
2203 return Iterator( matrix_, row_, 0UL );
2217 template<
typename MT >
2234 template<
typename MT >
2251 template<
typename MT >
2254 return Iterator( matrix_, row_, size() );
2268 template<
typename MT >
2285 template<
typename MT >
2309 template<
typename MT >
2312 const size_t columns( size() );
2314 for(
size_t j=0UL; j<
columns; ++j )
2315 matrix_(row_,j) = rhs;
2334 template<
typename MT >
2337 if( &rhs ==
this )
return *
this;
2339 if( size() != rhs.size() )
2340 throw std::invalid_argument(
"Row sizes do not match" );
2342 const size_t columns( size() );
2344 for(
size_t j=0UL; j<
columns; ++j )
2345 matrix_(row_,j) = rhs[j];
2364 template<
typename MT >
2365 template<
typename VT >
2372 if( size() != (~rhs).size() )
2373 throw std::invalid_argument(
"Vector sizes do not match" );
2375 if( (~rhs).canAlias( &matrix_ ) ) {
2380 if( IsSparseVector<VT>::value )
2402 template<
typename MT >
2403 template<
typename VT >
2404 inline DenseRow<MT,false>& DenseRow<MT,false>::operator+=(
const Vector<VT,true>& rhs )
2409 if( size() != (~rhs).size() )
2410 throw std::invalid_argument(
"Vector sizes do not match" );
2412 if( (~rhs).canAlias( &matrix_ ) ) {
2437 template<
typename MT >
2438 template<
typename VT >
2439 inline DenseRow<MT,false>& DenseRow<MT,false>::operator-=(
const Vector<VT,true>& rhs )
2444 if( size() != (~rhs).size() )
2445 throw std::invalid_argument(
"Vector sizes do not match" );
2447 if( (~rhs).canAlias( &matrix_ ) ) {
2473 template<
typename MT >
2474 template<
typename VT >
2475 inline DenseRow<MT,false>& DenseRow<MT,false>::operator*=(
const Vector<VT,true>& rhs )
2480 if( size() != (~rhs).size() )
2481 throw std::invalid_argument(
"Vector sizes do not match" );
2483 if( (~rhs).canAlias( &matrix_ ) || IsSparseVector<VT>::value ) {
2505 template<
typename MT >
2506 template<
typename Other >
2507 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2508 DenseRow<MT,false>::operator*=( Other rhs )
2510 for(
size_t j=0UL; j<size(); ++j )
2511 matrix_(row_,j) *= rhs;
2528 template<
typename MT >
2529 template<
typename Other >
2530 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2531 DenseRow<MT,false>::operator/=( Other rhs )
2535 typedef typename DivTrait<ElementType,Other>::Type DT;
2536 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2540 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2541 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2542 for(
size_t j=0UL; j<size(); ++j )
2543 matrix_(row_,j) *= tmp;
2546 for(
size_t j=0UL; j<size(); ++j )
2547 matrix_(row_,j) /= rhs;
2570 template<
typename MT >
2573 return matrix_.columns();
2585 template<
typename MT >
2588 return matrix_.columns();
2603 template<
typename MT >
2606 const size_t columns( size() );
2607 size_t nonzeros( 0UL );
2609 for(
size_t j=0UL; j<
columns; ++j )
2625 template<
typename MT >
2629 const size_t columns( size() );
2630 for(
size_t j=0UL; j<
columns; ++j )
2631 reset( matrix_(row_,j) );
2644 template<
typename MT >
2645 template<
typename Other >
2646 inline DenseRow<MT,false>& DenseRow<MT,false>::scale(
const Other& scalar )
2648 for(
size_t j=0UL; j<size(); ++j ) {
2649 matrix_(row_,j) *= scalar;
2676 template<
typename MT >
2677 template<
typename Other >
2680 return static_cast<const void*
>( &matrix_ ) == static_cast<const void*>( alias );
2697 template<
typename MT >
2698 template<
typename Other >
2701 return static_cast<const void*
>( &matrix_ ) == static_cast<const void*>( alias );
2717 template<
typename MT >
2737 template<
typename MT >
2758 template<
typename MT >
2759 template<
typename VT >
2764 const size_t jend( (~rhs).size() &
size_t(-2) );
2765 for(
size_t j=0UL; j<jend; j+=2UL ) {
2766 matrix_(row_,j ) = (~rhs)[j ];
2767 matrix_(row_,j+1UL) = (~rhs)[j+1UL];
2769 if( jend < (~rhs).size() )
2770 matrix_(row_,jend) = (~rhs)[jend];
2788 template<
typename MT >
2789 template<
typename VT >
2794 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2795 matrix_(row_,element->index()) = element->value();
2813 template<
typename MT >
2814 template<
typename VT >
2819 const size_t jend( (~rhs).size() &
size_t(-2) );
2820 for(
size_t j=0UL; j<jend; j+=2UL ) {
2821 matrix_(row_,j ) += (~rhs)[j ];
2822 matrix_(row_,j+1UL) += (~rhs)[j+1UL];
2824 if( jend < (~rhs).size() )
2825 matrix_(row_,jend) += (~rhs)[jend];
2843 template<
typename MT >
2844 template<
typename VT >
2849 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2850 matrix_(row_,element->index()) += element->value();
2868 template<
typename MT >
2869 template<
typename VT >
2874 const size_t jend( (~rhs).size() &
size_t(-2) );
2875 for(
size_t j=0UL; j<jend; j+=2UL ) {
2876 matrix_(row_,j ) -= (~rhs)[j ];
2877 matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
2879 if( jend < (~rhs).size() )
2880 matrix_(row_,jend) -= (~rhs)[jend];
2898 template<
typename MT >
2899 template<
typename VT >
2904 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2905 matrix_(row_,element->index()) -= element->value();
2923 template<
typename MT >
2924 template<
typename VT >
2929 const size_t jend( (~rhs).size() &
size_t(-2) );
2930 for(
size_t j=0UL; j<jend; j+=2UL ) {
2931 matrix_(row_,j ) *= (~rhs)[j ];
2932 matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
2934 if( jend < (~rhs).size() )
2935 matrix_(row_,jend) *= (~rhs)[jend];
2953 template<
typename MT >
2954 template<
typename VT >
2963 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2964 matrix_(row_,element->index()) = tmp[element->index()] * element->value();
2985 template<
typename MT,
bool SO >
2986 inline void reset( DenseRow<MT,SO>&
row );
2988 template<
typename MT,
bool SO >
2989 inline void clear( DenseRow<MT,SO>&
row );
2991 template<
typename MT,
bool SO >
3004 template<
typename MT
3022 template<
typename MT
3049 template<
typename MT
3053 for(
size_t i=0UL; i<row.
size(); ++i )
3054 if( !
isDefault( row[i] ) )
return false;
3070 template<
typename MT,
bool SO >
3071 struct SubvectorTrait< DenseRow<MT,SO> >
Constraint on the data type.
Constraint on the data type.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseRow.h:340
const size_t OPENMP_DVECASSIGN_THRESHOLD
OpenMP dense vector assignment threshold.This threshold specifies when an assignment of a plain dense...
Definition: Thresholds.h:200
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
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:4075
Header file for the row trait.
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
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
Header file for the row base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
void smpMultAssign(DenseVector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:178
Header file for the IsSame and IsStrictlySame type traits.
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
Iterator end()
Returns an iterator just past the last element of the row.
Definition: DenseRow.h:712
IT::Type IntrinsicType
Intrinsic type of the row elements.
Definition: DenseRow.h:339
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
Header file for the DenseVector base class.
bool canAlias(const Other *alias) const
Returns whether the dense row can alias with the given address alias.
Definition: DenseRow.h:1094
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4595
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseRow.h:337
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: DenseRow.h:347
Constraint on the data type.
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
bool isAligned() const
Returns whether the dense row is properly aligned in memory.
Definition: DenseRow.h:1132
Base template for the RowTrait class.
Definition: RowTrait.h:114
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the dense vector SMP implementation.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseRow.h:356
Header file for nested template disabiguation.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the dense row.
Definition: DenseRow.h:1172
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
Header file for the Or class template.
DenseRow & operator=(const ElementType &rhs)
Homogenous assignment to all row elements.
Definition: DenseRow.h:767
void storeu(size_t index, const IntrinsicType &value)
Unligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1237
Header file for the subvector trait.
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
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
RowTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseRow.h:336
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
Constraint on the data type.
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the row.
Definition: DenseRow.h:744
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: DenseRow.h:599
#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
ConstIterator cbegin() const
Returns an iterator to the first element of the row.
Definition: DenseRow.h:696
Constraints on the storage order of matrix types.
Constraint on the data type.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2382
MT::ElementType ElementType
Type of the row elements.
Definition: DenseRow.h:338
void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:269
Constraint on the data type.
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.
size_t nonZeros() const
Returns the number of non-zero elements in the row.
Definition: DenseRow.h:1033
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a constant row value.
Definition: DenseRow.h:353
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.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
size_t size() const
Returns the current size/dimension of the row.
Definition: DenseRow.h:1002
Operand matrix_
The dense matrix containing the row.
Definition: DenseRow.h:539
Header file for the IsSparseVector type trait.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2383
Header file for the IsConst type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
bool canSMPAssign() const
Returns whether the dense row can be used in SMP assignments.
Definition: DenseRow.h:1151
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: DenseRow.h:344
Base class for all rows.The Row class serves as a tag for all rows (i.e. dense and sparse rows)...
Definition: Row.h:63
Header file for run time assertion macros.
const size_t row_
The index of the row in the matrix.
Definition: DenseRow.h:540
Iterator begin()
Returns an iterator to the first element of the row.
Definition: DenseRow.h:664
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the dense row.
Definition: DenseRow.h:1259
Header file for the division trait.
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
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the dense row.
Definition: DenseRow.h:1193
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Header file for the reset shim.
Reference to a specific row of a dense matrix.The DenseRow template represents a reference to a speci...
Definition: DenseRow.h:310
Header file for the cache size of the target architecture.
SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: DenseRow.h:359
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
void reset()
Reset to the default initial values.
Definition: DenseRow.h:1047
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2387
Header file for the isDefault shim.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:118
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1215
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
Header file for all intrinsic functionality.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
const ElementType * ConstPointer
Pointer to a constant row value.
Definition: DenseRow.h:350
const DenseRow & CompositeType
Data type for composite expression templates.
Definition: DenseRow.h:341
Header file for the IsRowMajorMatrix type trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the row element type.
Definition: DenseRow.h:319
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:248
Header file for the sparse vector SMP implementation.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
DenseRow(MT &matrix, size_t index)
The constructor for DenseRow.
Definition: DenseRow.h:573
DenseRow< MT, SO > This
Type of this DenseRow instance.
Definition: DenseRow.h:335
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
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: TransposeFlag.h:81
size_t capacity() const
Returns the maximum capacity of the dense row.
Definition: DenseRow.h:1016
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2385
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
bool isAliased(const Other *alias) const
Returns whether the dense row is aliased with the given address alias.
Definition: DenseRow.h:1114
Pointer data()
Low-level data access to the row elements.
Definition: DenseRow.h:632
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: DenseRow.h:316