35 #ifndef _BLAZE_MATH_VIEWS_DENSEROW_H_
36 #define _BLAZE_MATH_VIEWS_DENSEROW_H_
306 template<
typename MT
307 ,
bool SO = IsRowMajorMatrix<MT>::value >
362 enum { vectorizable = MT::vectorizable };
365 enum { smpAssignable = MT::smpAssignable };
371 explicit inline DenseRow( MT& matrix,
size_t index );
401 template<
typename VT >
inline DenseRow&
operator= (
const Vector<VT,true>& rhs );
402 template<
typename VT >
inline DenseRow& operator+=(
const Vector<VT,true>& rhs );
403 template<
typename VT >
inline DenseRow& operator-=(
const Vector<VT,true>& rhs );
404 template<
typename VT >
inline DenseRow& operator*=(
const Vector<VT,true>& rhs );
406 template<
typename Other >
407 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
408 operator*=( Other rhs );
410 template<
typename Other >
411 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
412 operator/=( Other rhs );
419 inline size_t size()
const;
423 template<
typename Other >
inline DenseRow& scale(
const Other& scalar );
430 template<
typename VT >
432 struct VectorizedAssign {
433 enum { value = vectorizable && VT::vectorizable &&
434 IsSame<ElementType,typename VT::ElementType>::value };
441 template<
typename VT >
443 struct VectorizedAddAssign {
444 enum { value = vectorizable && VT::vectorizable &&
445 IsSame<ElementType,typename VT::ElementType>::value &&
446 IntrinsicTrait<ElementType>::addition };
453 template<
typename VT >
455 struct VectorizedSubAssign {
456 enum { value = vectorizable && VT::vectorizable &&
457 IsSame<ElementType,typename VT::ElementType>::value &&
458 IntrinsicTrait<ElementType>::subtraction };
465 template<
typename VT >
467 struct VectorizedMultAssign {
468 enum { value = vectorizable && VT::vectorizable &&
469 IsSame<ElementType,typename VT::ElementType>::value &&
470 IntrinsicTrait<ElementType>::multiplication };
479 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
480 template<
typename MT2,
bool SO2 >
inline bool canAlias (
const DenseRow<MT2,SO2>* alias )
const;
481 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
482 template<
typename MT2,
bool SO2 >
inline bool isAliased(
const DenseRow<MT2,SO2>* 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 );
546 template<
typename MT2,
bool SO2 >
friend class DenseRow;
548 template<
typename MT2,
bool SO2 >
580 template<
typename MT
587 throw std::invalid_argument(
"Invalid row access index" );
606 template<
typename MT
611 return matrix_(row_,index);
622 template<
typename MT
627 return matrix_(row_,index);
639 template<
typename MT
643 return matrix_.data( row_ );
655 template<
typename MT
659 return matrix_.data( row_ );
671 template<
typename MT
675 return matrix_.begin( row_ );
687 template<
typename MT
691 return matrix_.cbegin( row_ );
703 template<
typename MT
707 return matrix_.cbegin( row_ );
719 template<
typename MT
723 return matrix_.end( row_ );
735 template<
typename MT
739 return matrix_.cend( row_ );
751 template<
typename MT
755 return matrix_.cend( row_ );
774 template<
typename MT
778 const size_t columns( size() );
780 for(
size_t j=0UL; j<
columns; ++j )
781 matrix_(row_,j) = rhs;
798 template<
typename MT
802 if( &rhs ==
this )
return *
this;
804 if( size() != rhs.
size() )
805 throw std::invalid_argument(
"Row sizes do not match" );
807 const size_t columns( size() );
809 for(
size_t j=0UL; j<
columns; ++j )
810 matrix_(row_,j) = rhs[j];
827 template<
typename MT
829 template<
typename VT >
835 if( size() != (~rhs).size() )
836 throw std::invalid_argument(
"Vector sizes do not match" );
838 if( (~rhs).canAlias( &matrix_ ) ) {
863 template<
typename MT
865 template<
typename VT >
871 if( size() != (~rhs).size() )
872 throw std::invalid_argument(
"Vector sizes do not match" );
874 if( (~rhs).canAlias( &matrix_ ) ) {
897 template<
typename MT
899 template<
typename VT >
905 if( size() != (~rhs).size() )
906 throw std::invalid_argument(
"Vector sizes do not match" );
908 if( (~rhs).canAlias( &matrix_ ) ) {
932 template<
typename MT
934 template<
typename VT >
940 if( size() != (~rhs).size() )
941 throw std::invalid_argument(
"Vector sizes do not match" );
963 template<
typename MT
965 template<
typename Other >
969 return operator=( (*
this) * rhs );
983 template<
typename MT
985 template<
typename Other >
991 return operator=( (*
this) / rhs );
1009 template<
typename MT
1013 return matrix_.columns();
1023 template<
typename MT
1027 return matrix_.capacity( row_ );
1040 template<
typename MT
1044 return matrix_.nonZeros( row_ );
1054 template<
typename MT
1058 matrix_.reset( row_ );
1069 template<
typename MT
1071 template<
typename Other >
1074 for(
size_t j=0UL; j<size(); ++j ) {
1075 matrix_(row_,j) *= scalar;
1100 template<
typename MT
1102 template<
typename Other >
1105 return matrix_.isAliased( alias );
1120 template<
typename MT
1122 template<
typename MT2
1126 return matrix_.isAliased( &alias->
matrix_ ) && ( row_ == alias->
row_ );
1141 template<
typename MT
1143 template<
typename Other >
1146 return matrix_.isAliased( alias );
1161 template<
typename MT
1163 template<
typename MT2
1167 return matrix_.isAliased( &alias->
matrix_ ) && ( row_ == alias->
row_ );
1181 template<
typename MT
1185 return matrix_.isAligned();
1200 template<
typename MT
1221 template<
typename MT
1225 return matrix_.load( row_, index );
1242 template<
typename MT
1246 return matrix_.loadu( row_, index );
1264 template<
typename MT
1268 matrix_.store( row_, index, value );
1286 template<
typename MT
1290 matrix_.storeu( row_, index, value );
1308 template<
typename MT
1312 matrix_.stream( row_, index, value );
1328 template<
typename MT
1330 template<
typename VT >
1336 const size_t jend( (~rhs).size() &
size_t(-2) );
1337 for(
size_t j=0UL; j<jend; j+=2UL ) {
1338 matrix_(row_,j ) = (~rhs)[j ];
1339 matrix_(row_,j+1UL) = (~rhs)[j+1UL];
1341 if( jend < (~rhs).size() )
1342 matrix_(row_,jend) = (~rhs)[jend];
1358 template<
typename MT
1360 template<
typename VT >
1368 const size_t columns( size() );
1372 for(
size_t j=0UL; j<
columns; j+=IT::size ) {
1373 matrix_.stream( row_, j, (~rhs).
load(j) );
1378 const size_t jend( columns &
size_t(-IT::size*4) );
1379 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1382 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1383 matrix_.store( row_, j , it.load() ); it += IT::size;
1384 matrix_.store( row_, j+IT::size , it.load() ); it += IT::size;
1385 matrix_.store( row_, j+IT::size*2UL, it.load() ); it += IT::size;
1386 matrix_.store( row_, j+IT::size*3UL, it.load() ); it += IT::size;
1388 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1389 matrix_.store( row_, j, it.load() );
1407 template<
typename MT
1409 template<
typename VT >
1414 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1415 matrix_(row_,element->index()) = element->value();
1431 template<
typename MT
1433 template<
typename VT >
1439 const size_t jend( (~rhs).size() &
size_t(-2) );
1440 for(
size_t j=0UL; j<jend; j+=2UL ) {
1441 matrix_(row_,j ) += (~rhs)[j ];
1442 matrix_(row_,j+1UL) += (~rhs)[j+1UL];
1444 if( jend < (~rhs).size() )
1445 matrix_(row_,jend) += (~rhs)[jend];
1461 template<
typename MT
1463 template<
typename VT >
1471 const size_t columns( size() );
1473 const size_t jend( columns &
size_t(-IT::size*4) );
1474 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1477 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1478 matrix_.store( row_, j , matrix_.load(row_,j ) + it.load() ); it += IT::size;
1479 matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) + it.load() ); it += IT::size;
1480 matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) + it.load() ); it += IT::size;
1481 matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) + it.load() ); it += IT::size;
1483 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1484 matrix_.store( row_, j, matrix_.load(row_,j) + it.load() );
1501 template<
typename MT
1503 template<
typename VT >
1508 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1509 matrix_(row_,element->index()) += element->value();
1525 template<
typename MT
1527 template<
typename VT >
1533 const size_t jend( (~rhs).size() &
size_t(-2) );
1534 for(
size_t j=0UL; j<jend; j+=2UL ) {
1535 matrix_(row_,j ) -= (~rhs)[j ];
1536 matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
1538 if( jend < (~rhs).size() )
1539 matrix_(row_,jend) -= (~rhs)[jend];
1555 template<
typename MT
1557 template<
typename VT >
1565 const size_t columns( size() );
1567 const size_t jend( columns &
size_t(-IT::size*4) );
1568 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1571 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1572 matrix_.store( row_, j , matrix_.load(row_,j ) - it.load() ); it += IT::size;
1573 matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) - it.load() ); it += IT::size;
1574 matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) - it.load() ); it += IT::size;
1575 matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) - it.load() ); it += IT::size;
1577 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1578 matrix_.store( row_, j, matrix_.load(row_,j) - it.load() );
1595 template<
typename MT
1597 template<
typename VT >
1602 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1603 matrix_(row_,element->index()) -= element->value();
1619 template<
typename MT
1621 template<
typename VT >
1627 const size_t jend( (~rhs).size() &
size_t(-2) );
1628 for(
size_t j=0UL; j<jend; j+=2UL ) {
1629 matrix_(row_,j ) *= (~rhs)[j ];
1630 matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
1632 if( jend < (~rhs).size() )
1633 matrix_(row_,jend) *= (~rhs)[jend];
1649 template<
typename MT
1651 template<
typename VT >
1659 const size_t columns( size() );
1661 const size_t jend( columns &
size_t(-IT::size*4) );
1662 BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend,
"Invalid end calculation" );
1665 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1666 matrix_.store( row_, j , matrix_.load(row_,j ) * it.load() ); it += IT::size;
1667 matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) * it.load() ); it += IT::size;
1668 matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) * it.load() ); it += IT::size;
1669 matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) * it.load() ); it += IT::size;
1671 for(
size_t j=jend; j<
columns; j+=IT::size, it+=IT::size ) {
1672 matrix_.store( row_, j, matrix_.load(row_,j) * it.load() );
1689 template<
typename MT
1691 template<
typename VT >
1700 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1701 matrix_(row_,element->index()) = tmp[element->index()] * element->value();
1726 template<
typename MT >
1749 typedef DenseRow<MT,false>
This;
1750 typedef typename RowTrait<MT>::Type
ResultType;
1760 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
1766 template<
typename MatrixType >
1777 enum { returnConst = IsConst<MatrixType>::value };
1783 typedef typename SelectType< returnConst, typename MT::ConstReference, typename MT::Reference >::Type
Reference;
1785 typedef std::random_access_iterator_tag IteratorCategory;
1786 typedef RemoveReference<Reference> ValueType;
1787 typedef ValueType* PointerType;
1789 typedef ptrdiff_t DifferenceType;
1792 typedef IteratorCategory iterator_category;
1793 typedef ValueType value_type;
1794 typedef PointerType pointer;
1795 typedef ReferenceType reference;
1796 typedef DifferenceType difference_type;
1806 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column )
1818 template<
typename MatrixType2 >
1819 inline RowIterator(
const RowIterator<MatrixType2>& it )
1822 , column_( it.column_ )
1832 inline RowIterator& operator+=(
size_t inc ) {
1844 inline RowIterator& operator-=(
size_t dec ) {
1855 inline RowIterator& operator++() {
1866 inline const RowIterator operator++(
int ) {
1867 const RowIterator tmp( *
this );
1878 inline RowIterator& operator--() {
1889 inline const RowIterator operator--(
int ) {
1890 const RowIterator tmp( *
this );
1902 inline ReferenceType
operator[](
size_t index )
const {
1912 inline ReferenceType
operator*()
const {
1922 inline PointerType operator->()
const {
1923 return &(*matrix_)(
row_,column_);
1933 template<
typename MatrixType2 >
1934 inline bool operator==(
const RowIterator<MatrixType2>& rhs )
const {
1935 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1945 template<
typename MatrixType2 >
1946 inline bool operator!=(
const RowIterator<MatrixType2>& rhs )
const {
1947 return !( *
this == rhs );
1957 template<
typename MatrixType2 >
1958 inline bool operator<( const RowIterator<MatrixType2>& rhs )
const {
1959 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ < rhs.column_ );
1969 template<
typename MatrixType2 >
1970 inline bool operator>(
const RowIterator<MatrixType2>& rhs )
const {
1971 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ > rhs.column_ );
1981 template<
typename MatrixType2 >
1982 inline bool operator<=( const RowIterator<MatrixType2>& rhs )
const {
1983 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ <= rhs.column_ );
1993 template<
typename MatrixType2 >
1994 inline bool operator>=(
const RowIterator<MatrixType2>& rhs )
const {
1995 return (
matrix_ == rhs.matrix_ ) && (
row_ == rhs.row_ ) && ( column_ >= rhs.column_ );
2005 inline DifferenceType
operator-(
const RowIterator& rhs )
const {
2006 return column_ - rhs.column_;
2017 friend inline const RowIterator
operator+(
const RowIterator& it,
size_t inc ) {
2018 return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2029 friend inline const RowIterator
operator+(
size_t inc,
const RowIterator& it ) {
2030 return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2041 friend inline const RowIterator
operator-(
const RowIterator& it,
size_t dec ) {
2042 return RowIterator( *it.matrix_, it.row_, it.column_-dec );
2054 template<
typename MatrixType2 >
friend class RowIterator;
2064 typedef typename SelectType< useConst, ConstIterator, RowIterator<MT> >::Type
Iterator;
2069 enum { vectorizable = 0 };
2072 enum { smpAssignable = MT::smpAssignable };
2078 explicit inline DenseRow( MT& matrix,
size_t index );
2106 template<
typename VT >
inline DenseRow&
operator= (
const Vector<VT,true>& rhs );
2107 template<
typename VT >
inline DenseRow& operator+=(
const Vector<VT,true>& rhs );
2108 template<
typename VT >
inline DenseRow& operator-=(
const Vector<VT,true>& rhs );
2109 template<
typename VT >
inline DenseRow& operator*=(
const Vector<VT,true>& rhs );
2111 template<
typename Other >
2112 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
2113 operator*=( Other rhs );
2115 template<
typename Other >
2116 inline typename EnableIf< IsNumeric<Other>,
DenseRow >::Type&
2117 operator/=( Other rhs );
2124 inline size_t size()
const;
2127 inline void reset();
2128 template<
typename Other >
inline DenseRow& scale(
const Other& scalar );
2136 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2137 template<
typename MT2,
bool SO2 >
inline bool canAlias (
const DenseRow<MT2,SO2>* alias )
const;
2138 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2139 template<
typename MT2,
bool SO2 >
inline bool isAliased(
const DenseRow<MT2,SO2>* alias )
const;
2144 template<
typename VT >
inline void assign (
const DenseVector <VT,true>& rhs );
2145 template<
typename VT >
inline void assign (
const SparseVector<VT,true>& rhs );
2146 template<
typename VT >
inline void addAssign (
const DenseVector <VT,true>& rhs );
2147 template<
typename VT >
inline void addAssign (
const SparseVector<VT,true>& rhs );
2148 template<
typename VT >
inline void subAssign (
const DenseVector <VT,true>& rhs );
2149 template<
typename VT >
inline void subAssign (
const SparseVector<VT,true>& rhs );
2150 template<
typename VT >
inline void multAssign(
const DenseVector <VT,true>& rhs );
2151 template<
typename VT >
inline void multAssign(
const SparseVector<VT,true>& rhs );
2165 template<
typename MT2,
bool SO2 >
friend class DenseRow;
2167 template<
typename MT2,
bool SO2 >
2168 friend bool isSame(
const DenseRow<MT2,SO2>& a,
const DenseRow<MT2,SO2>& b );
2198 template<
typename MT >
2204 throw std::invalid_argument(
"Invalid row access index" );
2225 template<
typename MT >
2229 return matrix_(row_,index);
2242 template<
typename MT >
2246 return matrix_(row_,index);
2260 template<
typename MT >
2263 return Iterator( matrix_, row_, 0UL );
2277 template<
typename MT >
2294 template<
typename MT >
2311 template<
typename MT >
2314 return Iterator( matrix_, row_, size() );
2328 template<
typename MT >
2345 template<
typename MT >
2369 template<
typename MT >
2372 const size_t columns( size() );
2374 for(
size_t j=0UL; j<
columns; ++j )
2375 matrix_(row_,j) = rhs;
2394 template<
typename MT >
2397 if( &rhs ==
this )
return *
this;
2399 if( size() != rhs.size() )
2400 throw std::invalid_argument(
"Row sizes do not match" );
2402 const size_t columns( size() );
2404 for(
size_t j=0UL; j<
columns; ++j )
2405 matrix_(row_,j) = rhs[j];
2424 template<
typename MT >
2425 template<
typename VT >
2432 if( size() != (~rhs).size() )
2433 throw std::invalid_argument(
"Vector sizes do not match" );
2435 if( (~rhs).canAlias( &matrix_ ) ) {
2440 if( IsSparseVector<VT>::value )
2462 template<
typename MT >
2463 template<
typename VT >
2464 inline DenseRow<MT,false>& DenseRow<MT,false>::operator+=(
const Vector<VT,true>& rhs )
2469 if( size() != (~rhs).size() )
2470 throw std::invalid_argument(
"Vector sizes do not match" );
2472 if( (~rhs).canAlias( &matrix_ ) ) {
2497 template<
typename MT >
2498 template<
typename VT >
2499 inline DenseRow<MT,false>& DenseRow<MT,false>::operator-=(
const Vector<VT,true>& rhs )
2504 if( size() != (~rhs).size() )
2505 throw std::invalid_argument(
"Vector sizes do not match" );
2507 if( (~rhs).canAlias( &matrix_ ) ) {
2533 template<
typename MT >
2534 template<
typename VT >
2535 inline DenseRow<MT,false>& DenseRow<MT,false>::operator*=(
const Vector<VT,true>& rhs )
2540 if( size() != (~rhs).size() )
2541 throw std::invalid_argument(
"Vector sizes do not match" );
2543 if( (~rhs).canAlias( &matrix_ ) || IsSparseVector<VT>::value ) {
2565 template<
typename MT >
2566 template<
typename Other >
2567 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2568 DenseRow<MT,false>::operator*=( Other rhs )
2570 for(
size_t j=0UL; j<size(); ++j )
2571 matrix_(row_,j) *= rhs;
2588 template<
typename MT >
2589 template<
typename Other >
2590 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2591 DenseRow<MT,false>::operator/=( Other rhs )
2595 typedef typename DivTrait<ElementType,Other>::Type DT;
2596 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2600 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2601 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2602 for(
size_t j=0UL; j<size(); ++j )
2603 matrix_(row_,j) *= tmp;
2606 for(
size_t j=0UL; j<size(); ++j )
2607 matrix_(row_,j) /= rhs;
2630 template<
typename MT >
2633 return matrix_.columns();
2645 template<
typename MT >
2648 return matrix_.columns();
2663 template<
typename MT >
2666 const size_t columns( size() );
2667 size_t nonzeros( 0UL );
2669 for(
size_t j=0UL; j<
columns; ++j )
2685 template<
typename MT >
2689 const size_t columns( size() );
2690 for(
size_t j=0UL; j<
columns; ++j )
2691 reset( matrix_(row_,j) );
2704 template<
typename MT >
2705 template<
typename Other >
2706 inline DenseRow<MT,false>& DenseRow<MT,false>::scale(
const Other& scalar )
2708 for(
size_t j=0UL; j<size(); ++j ) {
2709 matrix_(row_,j) *= scalar;
2736 template<
typename MT >
2737 template<
typename Other >
2740 return matrix_.isAliased( alias );
2757 template<
typename MT >
2758 template<
typename MT2
2762 return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
2779 template<
typename MT >
2780 template<
typename Other >
2783 return matrix_.isAliased( alias );
2800 template<
typename MT >
2801 template<
typename MT2
2805 return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
2821 template<
typename MT >
2841 template<
typename MT >
2862 template<
typename MT >
2863 template<
typename VT >
2868 const size_t jend( (~rhs).size() &
size_t(-2) );
2869 for(
size_t j=0UL; j<jend; j+=2UL ) {
2870 matrix_(row_,j ) = (~rhs)[j ];
2871 matrix_(row_,j+1UL) = (~rhs)[j+1UL];
2873 if( jend < (~rhs).size() )
2874 matrix_(row_,jend) = (~rhs)[jend];
2892 template<
typename MT >
2893 template<
typename VT >
2898 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2899 matrix_(row_,element->index()) = element->value();
2917 template<
typename MT >
2918 template<
typename VT >
2923 const size_t jend( (~rhs).size() &
size_t(-2) );
2924 for(
size_t j=0UL; j<jend; j+=2UL ) {
2925 matrix_(row_,j ) += (~rhs)[j ];
2926 matrix_(row_,j+1UL) += (~rhs)[j+1UL];
2928 if( jend < (~rhs).size() )
2929 matrix_(row_,jend) += (~rhs)[jend];
2947 template<
typename MT >
2948 template<
typename VT >
2953 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2954 matrix_(row_,element->index()) += element->value();
2972 template<
typename MT >
2973 template<
typename VT >
2978 const size_t jend( (~rhs).size() &
size_t(-2) );
2979 for(
size_t j=0UL; j<jend; j+=2UL ) {
2980 matrix_(row_,j ) -= (~rhs)[j ];
2981 matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
2983 if( jend < (~rhs).size() )
2984 matrix_(row_,jend) -= (~rhs)[jend];
3002 template<
typename MT >
3003 template<
typename VT >
3008 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3009 matrix_(row_,element->index()) -= element->value();
3027 template<
typename MT >
3028 template<
typename VT >
3033 const size_t jend( (~rhs).size() &
size_t(-2) );
3034 for(
size_t j=0UL; j<jend; j+=2UL ) {
3035 matrix_(row_,j ) *= (~rhs)[j ];
3036 matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
3038 if( jend < (~rhs).size() )
3039 matrix_(row_,jend) *= (~rhs)[jend];
3057 template<
typename MT >
3058 template<
typename VT >
3067 for(
typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3068 matrix_(row_,element->index()) = tmp[element->index()] * element->value();
3089 template<
typename MT,
bool SO >
3090 inline void reset( DenseRow<MT,SO>&
row );
3092 template<
typename MT,
bool SO >
3093 inline void clear( DenseRow<MT,SO>&
row );
3095 template<
typename MT,
bool SO >
3098 template<
typename MT,
bool SO >
3099 inline bool isSame(
const DenseRow<MT,SO>& a,
const DenseRow<MT,SO>& b );
3111 template<
typename MT
3129 template<
typename MT
3156 template<
typename MT
3160 for(
size_t i=0UL; i<row.
size(); ++i )
3161 if( !
isDefault( row[i] ) )
return false;
3179 template<
typename MT,
bool SO >
3197 template<
typename MT,
bool SO >
3198 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:338
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
EnableIf< IsIntegral< T >, 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:4329
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:152
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
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:179
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:721
IT::Type IntrinsicType
Intrinsic type of the row elements.
Definition: DenseRow.h:337
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:1103
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
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:690
#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:4615
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:409
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseRow.h:335
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: DenseRow.h:345
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:122
bool isAligned() const
Returns whether the dense row is properly aligned in memory.
Definition: DenseRow.h:1183
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.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseRow.h:354
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:1223
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
Header file for the Or class template.
DenseRow & operator=(const ElementType &rhs)
Homogenous assignment to all row elements.
Definition: DenseRow.h:776
void storeu(size_t index, const IntrinsicType &value)
Unligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1288
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:271
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:334
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:753
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: DenseRow.h:608
#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:705
Constraints on the storage order of matrix types.
Constraint on the data type.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
MT::ElementType ElementType
Type of the row elements.
Definition: DenseRow.h:336
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:361
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
size_t nonZeros() const
Returns the number of non-zero elements in the row.
Definition: DenseRow.h:1042
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant row value.
Definition: DenseRow.h:351
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:92
Header file for the IsNumeric type trait.
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:1011
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:2407
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:1202
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: DenseRow.h:342
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:673
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the dense row.
Definition: DenseRow.h:1310
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:301
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:1244
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:308
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:357
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
void reset()
Reset to the default initial values.
Definition: DenseRow.h:1056
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
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:1266
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:348
const DenseRow & CompositeType
Data type for composite expression templates.
Definition: DenseRow.h:339
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:151
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the row element type.
Definition: DenseRow.h:317
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:250
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
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:582
DenseRow< MT, SO > This
Type of this DenseRow instance.
Definition: DenseRow.h:333
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
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:1025
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2409
const size_t SMP_DVECASSIGN_THRESHOLD
SMP dense vector assignment threshold.This threshold specifies when an assignment of a plain dense ve...
Definition: Thresholds.h:207
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:1144
Pointer data()
Low-level data access to the row elements.
Definition: DenseRow.h:641
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:314