35 #ifndef _BLAZE_MATH_VIEWS_COLUMNS_SPARSE_H_ 36 #define _BLAZE_MATH_VIEWS_COLUMNS_SPARSE_H_ 111 template<
typename MT
114 class Columns<MT,true,false,SF,CCAs...>
115 :
public View< SparseMatrix< Columns<MT,true,false,SF,CCAs...>, true > >
116 ,
private ColumnsData<CCAs...>
120 using DataType = ColumnsData<CCAs...>;
121 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
125 static constexpr
size_t N =
sizeof...( CCAs );
131 using This = Columns<MT,
true,
false,SF,CCAs...>;
133 using BaseType = SparseMatrix<This,true>;
134 using ViewedType = MT;
163 template<
typename... RCAs >
164 explicit inline Columns( MT& matrix, RCAs... args );
166 Columns(
const Columns& ) =
default;
167 Columns( Columns&& ) =
default;
174 ~Columns() =
default;
181 inline Reference operator()(
size_t i,
size_t j );
183 inline Reference at(
size_t i,
size_t j );
197 inline Columns& operator=( initializer_list< initializer_list<ElementType> > list );
198 inline Columns& operator=(
const Columns& rhs );
200 template<
typename MT2,
bool SO >
inline Columns& operator= (
const Matrix<MT2,SO>& rhs );
201 template<
typename MT2,
bool SO >
inline Columns&
operator+=(
const Matrix<MT2,SO>& rhs );
202 template<
typename MT2,
bool SO >
inline Columns&
operator-=(
const Matrix<MT2,SO>& rhs );
203 template<
typename MT2,
bool SO >
inline Columns& operator%=(
const Matrix<MT2,SO>& rhs );
211 using DataType::idces;
214 inline MT& operand() noexcept;
215 inline const MT& operand() const noexcept;
217 inline
size_t rows() const noexcept;
218 inline
size_t capacity() const noexcept;
219 inline
size_t capacity(
size_t j ) const noexcept;
221 inline
size_t nonZeros(
size_t j ) const;
223 inline
void reset(
size_t j );
224 inline
void reserve(
size_t nonzeros );
225 void reserve(
size_t j,
size_t nonzeros );
227 inline
void trim(
size_t j );
236 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
237 inline
void finalize(
size_t j );
244 inline
void erase(
size_t i,
size_t j );
248 template< typename Pred >
249 inline
void erase( Pred predicate );
251 template< typename Pred >
252 inline
void erase(
size_t j,
Iterator first,
Iterator last, Pred predicate );
259 inline
Iterator find (
size_t i,
size_t j );
261 inline
Iterator lowerBound(
size_t i,
size_t j );
263 inline
Iterator upperBound(
size_t i,
size_t j );
274 template< typename Other > inline Columns& scale( const Other& scalar );
281 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
282 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
284 inline
bool canSMPAssign() const noexcept;
286 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
287 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
288 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
289 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
290 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
291 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
299 inline
size_t extendCapacity(
size_t j ) const noexcept;
346 template< typename MT
349 template< typename... RCAs >
350 inline Columns<MT,true,false,SF,CCAs...>::Columns( MT& matrix, RCAs... args )
351 : DataType( args... )
355 for(
size_t j=0UL; j<
columns(); ++j ) {
356 if( matrix_.columns() <= idx(j) ) {
385 template<
typename MT
388 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Reference 389 Columns<MT,true,false,SF,CCAs...>::operator()(
size_t i,
size_t j )
394 return matrix_(i,idx(j));
411 template<
typename MT
415 Columns<MT,true,false,SF,CCAs...>::operator()(
size_t i,
size_t j )
const 420 return const_cast<const MT&
>( matrix_ )(i,idx(j));
438 template<
typename MT
441 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Reference 442 Columns<MT,true,false,SF,CCAs...>::at(
size_t i,
size_t j )
468 template<
typename MT
472 Columns<MT,true,false,SF,CCAs...>::at(
size_t i,
size_t j )
const 495 template<
typename MT
498 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 503 return matrix_.begin( idx(j) );
518 template<
typename MT
526 return matrix_.cbegin( idx(j) );
541 template<
typename MT
549 return matrix_.cbegin( idx(j) );
564 template<
typename MT
567 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 572 return matrix_.end( idx(j) );
587 template<
typename MT
595 return matrix_.cend( idx(j) );
610 template<
typename MT
618 return matrix_.cend( idx(j) );
648 template<
typename MT
651 inline Columns<MT,
true,
false,SF,CCAs...>&
652 Columns<MT,true,false,SF,CCAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
657 if( list.size() !=
rows() ) {
661 const InitializerMatrix<ElementType> tmp( list,
columns() );
663 if( IsRestricted_v<MT> ) {
664 for(
size_t j=0UL; j<
columns(); ++j ) {
671 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
697 template<
typename MT
700 inline Columns<MT,
true,
false,SF,CCAs...>&
701 Columns<MT,true,false,SF,CCAs...>::operator=(
const Columns& rhs )
709 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *
this, rhs ) ) )
712 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
716 if( IsRestricted_v<MT> ) {
717 for(
size_t j=0UL; j<
columns(); ++j ) {
718 if( !tryAssign( matrix_,
column( rhs, j,
unchecked ), 0UL, idx(j) ) ) {
724 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
726 if( rhs.canAlias( &matrix_ ) ) {
759 template<
typename MT
762 template<
typename MT2
764 inline Columns<MT,
true,
false,SF,CCAs...>&
765 Columns<MT,true,false,SF,CCAs...>::operator=(
const Matrix<MT2,SO>& rhs )
776 using Right = CompositeType_t<MT2>;
779 if( IsRestricted_v<MT> ) {
780 for(
size_t j=0UL; j<
columns(); ++j ) {
781 if( !tryAssign( matrix_,
column( right, j,
unchecked ), 0UL, idx(j) ) ) {
787 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
789 if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
790 const ResultType_t<MT2> tmp( right );
821 template<
typename MT
824 template<
typename MT2
826 inline Columns<MT,
true,
false,SF,CCAs...>&
836 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
844 const AddType tmp( *
this + (~rhs) );
846 if( IsRestricted_v<MT> ) {
847 for(
size_t j=0UL; j<
columns(); ++j ) {
848 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
854 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
881 template<
typename MT
884 template<
typename MT2
886 inline Columns<MT,
true,
false,SF,CCAs...>&
896 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
904 const SubType tmp( *
this - (~rhs) );
906 if( IsRestricted_v<MT> ) {
907 for(
size_t j=0UL; j<
columns(); ++j ) {
908 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
914 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
941 template<
typename MT
944 template<
typename MT2
946 inline Columns<MT,
true,
false,SF,CCAs...>&
947 Columns<MT,true,false,SF,CCAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
956 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
964 const SchurType tmp( *
this % (~rhs) );
966 if( IsRestricted_v<MT> ) {
967 for(
size_t j=0UL; j<
columns(); ++j ) {
968 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
974 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1001 template<
typename MT
1003 ,
typename... CCAs >
1004 inline MT& Columns<MT,true,false,SF,CCAs...>::operand() noexcept
1018 template<
typename MT
1020 ,
typename... CCAs >
1021 inline const MT& Columns<MT,true,false,SF,CCAs...>::operand() const noexcept
1035 template<
typename MT
1037 ,
typename... CCAs >
1040 return matrix_.rows();
1052 template<
typename MT
1054 ,
typename... CCAs >
1057 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
1072 template<
typename MT
1074 ,
typename... CCAs >
1079 return matrix_.capacity( idx(j) );
1091 template<
typename MT
1093 ,
typename... CCAs >
1096 size_t nonzeros( 0UL );
1098 for(
size_t j=0UL; j<
columns(); ++j )
1116 template<
typename MT
1118 ,
typename... CCAs >
1123 return matrix_.nonZeros( idx(j) );
1135 template<
typename MT
1137 ,
typename... CCAs >
1140 for(
size_t j=0UL; j<
columns(); ++j ) {
1141 matrix_.reset( idx(j) );
1158 template<
typename MT
1160 ,
typename... CCAs >
1163 matrix_.reset( idx(j) );
1180 template<
typename MT
1182 ,
typename... CCAs >
1183 inline void Columns<MT,true,false,SF,CCAs...>::reserve(
size_t nonzeros )
1185 const size_t current(
capacity() );
1187 if( nonzeros > current ) {
1188 matrix_.reserve( matrix_.capacity() + nonzeros - current );
1208 template<
typename MT
1210 ,
typename... CCAs >
1211 void Columns<MT,true,false,SF,CCAs...>::reserve(
size_t j,
size_t nonzeros )
1213 matrix_.reserve( idx(j), nonzeros );
1229 template<
typename MT
1231 ,
typename... CCAs >
1232 void Columns<MT,true,false,SF,CCAs...>::trim()
1234 for(
size_t j=0UL; j<
columns(); ++j ) {
1253 template<
typename MT
1255 ,
typename... CCAs >
1256 void Columns<MT,true,false,SF,CCAs...>::trim(
size_t j )
1260 matrix_.trim( idx(j) );
1276 template<
typename MT
1278 ,
typename... CCAs >
1279 inline size_t Columns<MT,true,false,SF,CCAs...>::extendCapacity(
size_t j )
const noexcept
1284 size_t nonzeros( 2UL*
capacity( j )+1UL );
1285 nonzeros =
max( nonzeros, 7UL );
1286 nonzeros =
min( nonzeros,
rows() );
1317 template<
typename MT
1319 ,
typename... CCAs >
1320 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1323 return matrix_.set( i, idx(j), value );
1343 template<
typename MT
1345 ,
typename... CCAs >
1346 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1347 Columns<MT,true,false,SF,CCAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
1349 return matrix_.insert( i, idx(j), value );
1399 template<
typename MT
1401 ,
typename... CCAs >
1402 inline void Columns<MT,true,false,SF,CCAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
1404 if( !check || !isDefault<strict>( value ) )
1405 matrix_.insert( i, idx(j), value );
1425 template<
typename MT
1427 ,
typename... CCAs >
1428 inline void Columns<MT,true,false,SF,CCAs...>::finalize(
size_t j )
1456 template<
typename MT
1458 ,
typename... CCAs >
1459 inline void Columns<MT,true,false,SF,CCAs...>::erase(
size_t i,
size_t j )
1464 matrix_.erase( i, idx(j) );
1480 template<
typename MT
1482 ,
typename... CCAs >
1483 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1484 Columns<MT,true,false,SF,CCAs...>::erase(
size_t j,
Iterator pos )
1488 return matrix_.erase( idx(j), pos );
1505 template<
typename MT
1507 ,
typename... CCAs >
1508 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1509 Columns<MT,true,false,SF,CCAs...>::erase(
size_t j,
Iterator first,
Iterator last )
1513 return matrix_.erase( idx(j), first, last );
1542 template<
typename MT
1544 ,
typename... CCAs >
1545 template<
typename Pred >
1546 inline void Columns<MT,true,false,SF,CCAs...>::erase( Pred predicate )
1548 for(
size_t j=0UL; j<
columns(); ++j ) {
1549 matrix_.erase( idx(j),
begin(j),
end(j), predicate );
1583 template<
typename MT
1585 ,
typename... CCAs >
1586 template<
typename Pred >
1587 inline void Columns<MT,true,false,SF,CCAs...>::erase(
size_t j,
Iterator first,
Iterator last, Pred predicate )
1591 matrix_.erase( idx(j), first, last, predicate );
1620 template<
typename MT
1622 ,
typename... CCAs >
1623 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1624 Columns<MT,true,false,SF,CCAs...>::find(
size_t i,
size_t j )
1626 return matrix_.find( i, idx(j) );
1647 template<
typename MT
1649 ,
typename... CCAs >
1651 Columns<MT,true,false,SF,CCAs...>::find(
size_t i,
size_t j )
const 1653 return matrix_.find( i, idx(j) );
1673 template<
typename MT
1675 ,
typename... CCAs >
1676 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1677 Columns<MT,true,false,SF,CCAs...>::lowerBound(
size_t i,
size_t j )
1679 return matrix_.lowerBound( i, idx(j) );
1699 template<
typename MT
1701 ,
typename... CCAs >
1703 Columns<MT,true,false,SF,CCAs...>::lowerBound(
size_t i,
size_t j )
const 1705 return matrix_.lowerBound( i, idx(j) );
1725 template<
typename MT
1727 ,
typename... CCAs >
1728 inline typename Columns<MT,
true,
false,SF,CCAs...>
::Iterator 1729 Columns<MT,true,false,SF,CCAs...>::upperBound(
size_t i,
size_t j )
1731 return matrix_.upperBound( i, idx(j) );
1751 template<
typename MT
1753 ,
typename... CCAs >
1755 Columns<MT,true,false,SF,CCAs...>::upperBound(
size_t i,
size_t j )
const 1757 return matrix_.upperBound( i, idx(j) );
1784 template<
typename MT
1786 ,
typename... CCAs >
1787 inline Columns<MT,
true,
false,SF,CCAs...>&
1796 if( IsRestricted_v<MT> ) {
1797 for(
size_t j=0UL; j<
columns(); ++j ) {
1798 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
1804 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1828 template<
typename MT
1830 ,
typename... CCAs >
1831 inline Columns<MT,
true,
false,SF,CCAs...>&
1840 if( IsRestricted_v<MT> ) {
1841 for(
size_t j=0UL; j<
columns(); ++j ) {
1842 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
1848 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
1872 template<
typename MT
1874 ,
typename... CCAs >
1875 template<
typename Other >
1876 inline Columns<MT,
true,
false,SF,CCAs...>&
1877 Columns<MT,true,false,SF,CCAs...>::scale(
const Other& scalar )
1881 for(
size_t j=0UL; j<
columns(); ++j ) {
1884 element->value() *= scalar;
1912 template<
typename MT
1914 ,
typename... CCAs >
1915 template<
typename Other >
1916 inline bool Columns<MT,true,false,SF,CCAs...>::canAlias(
const Other* alias )
const noexcept
1918 return matrix_.isAliased( alias );
1935 template<
typename MT
1937 ,
typename... CCAs >
1938 template<
typename Other >
1939 inline bool Columns<MT,true,false,SF,CCAs...>::isAliased(
const Other* alias )
const noexcept
1941 return matrix_.isAliased( alias );
1958 template<
typename MT
1960 ,
typename... CCAs >
1961 inline bool Columns<MT,true,false,SF,CCAs...>::canSMPAssign() const noexcept
1981 template<
typename MT
1983 ,
typename... CCAs >
1984 template<
typename MT2
1986 inline void Columns<MT,true,false,SF,CCAs...>::assign(
const DenseMatrix<MT2,SO>& rhs )
1995 for(
size_t j=0UL; j<
columns(); ++j )
1997 const size_t index( idx(j) );
1998 size_t remaining( matrix_.capacity( index ) );
2000 for(
size_t i=0UL; i<
rows(); ++i )
2002 if( remaining == 0UL ) {
2003 matrix_.reserve( index, extendCapacity( j ) );
2004 remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2007 matrix_.append( i, index, (~rhs)(i,j),
true );
2028 template<
typename MT
2030 ,
typename... CCAs >
2031 template<
typename MT2 >
2032 inline void Columns<MT,true,false,SF,CCAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
2041 for(
size_t j=0UL; j<
columns(); ++j )
2043 const size_t index( idx(j) );
2044 size_t remaining( matrix_.capacity( index ) );
2046 for( ConstIterator_t<MT2> element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
2048 if( remaining == 0UL ) {
2049 matrix_.reserve( index, extendCapacity( j ) );
2050 remaining = matrix_.capacity( index ) - matrix_.nonZeros( index );
2053 matrix_.append( element->index(), index, element->value(), true );
2074 template<
typename MT
2076 ,
typename... CCAs >
2077 template<
typename MT2 >
2078 inline void Columns<MT,true,false,SF,CCAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
2090 std::vector<size_t> columnLengths(
columns(), 0UL );
2091 for(
size_t i=0UL; i<
rows(); ++i ) {
2092 for(
auto element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2093 ++columnLengths[element->index()];
2097 for(
size_t j=0UL; j<
columns(); ++j ) {
2098 reserve( j, columnLengths[j] );
2102 for(
size_t i=0UL; i<
rows(); ++i ) {
2103 for(
auto element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
2104 append( i, element->index(), element->value(), true );
2123 template<
typename MT
2125 ,
typename... CCAs >
2126 template<
typename MT2
2128 inline void Columns<MT,true,false,SF,CCAs...>::addAssign(
const Matrix<MT2,SO>& rhs )
2133 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
2140 const AddType tmp(
serial( *
this + (~rhs) ) );
2160 template<
typename MT
2162 ,
typename... CCAs >
2163 template<
typename MT2
2165 inline void Columns<MT,true,false,SF,CCAs...>::subAssign(
const Matrix<MT2,SO>& rhs )
2170 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
2177 const SubType tmp(
serial( *
this - (~rhs) ) );
2197 template<
typename MT
2199 ,
typename... CCAs >
2200 template<
typename MT2
2202 inline void Columns<MT,true,false,SF,CCAs...>::schurAssign(
const Matrix<MT2,SO>& rhs )
2207 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
2215 const SchurType tmp(
serial( *
this % (~rhs) ) );
2243 template<
typename MT
2244 ,
typename... CCAs >
2245 class Columns<MT,false,false,false,CCAs...>
2246 :
public View< SparseMatrix< Columns<MT,false,false,false,CCAs...>, true > >
2247 ,
private ColumnsData<CCAs...>
2251 using DataType = ColumnsData<CCAs...>;
2252 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
2256 static constexpr
size_t N =
sizeof...( CCAs );
2262 using This = Columns<MT,
false,
false,
false,CCAs...>;
2264 using BaseType = SparseMatrix<This,true>;
2265 using ViewedType = MT;
2283 template<
typename MatrixType
2284 ,
typename IteratorType >
2285 class ColumnsElement
2286 :
private SparseElement
2295 inline ColumnsElement( IteratorType pos,
size_t row )
2307 template<
typename T >
inline ColumnsElement& operator=(
const T& v ) {
2319 template<
typename T >
inline ColumnsElement&
operator+=(
const T& v ) {
2331 template<
typename T >
inline ColumnsElement&
operator-=(
const T& v ) {
2343 template<
typename T >
inline ColumnsElement&
operator*=(
const T& v ) {
2355 template<
typename T >
inline ColumnsElement&
operator/=(
const T& v ) {
2366 inline const ColumnsElement* operator->()
const {
2376 inline decltype(
auto) value()
const {
2377 return pos_->value();
2386 inline size_t index()
const {
2402 template<
typename MatrixType
2403 ,
typename IteratorType >
2404 class ColumnsIterator
2408 using IteratorCategory = std::forward_iterator_tag;
2409 using ValueType = ColumnsElement<MatrixType,IteratorType>;
2410 using PointerType = ValueType;
2411 using ReferenceType = ValueType;
2412 using DifferenceType = ptrdiff_t;
2415 using iterator_category = IteratorCategory;
2416 using value_type = ValueType;
2417 using pointer = PointerType;
2418 using reference = ReferenceType;
2419 using difference_type = DifferenceType;
2425 inline ColumnsIterator()
2426 : matrix_( nullptr )
2440 inline ColumnsIterator( MatrixType& matrix,
size_t row,
size_t column )
2441 : matrix_( &matrix )
2446 for( ; row_<matrix_->rows(); ++row_ ) {
2447 pos_ = matrix_->find( row_, column_ );
2448 if( pos_ != matrix_->end( row_ ) )
break;
2461 inline ColumnsIterator( MatrixType& matrix,
size_t row,
size_t column, IteratorType pos )
2462 : matrix_( &matrix )
2476 template<
typename MatrixType2,
typename IteratorType2 >
2477 inline ColumnsIterator(
const ColumnsIterator<MatrixType2,IteratorType2>& it )
2478 : matrix_( it.matrix_ )
2480 , column_( it.column_ )
2490 inline ColumnsIterator& operator++() {
2492 for( ; row_<matrix_->rows(); ++row_ ) {
2493 pos_ = matrix_->find( row_, column_ );
2494 if( pos_ != matrix_->end( row_ ) )
break;
2506 inline const ColumnsIterator operator++(
int ) {
2507 const ColumnsIterator tmp( *
this );
2518 inline ReferenceType
operator*()
const {
2519 return ReferenceType( pos_, row_ );
2528 inline PointerType operator->()
const {
2529 return PointerType( pos_, row_ );
2539 template<
typename MatrixType2,
typename IteratorType2 >
2540 inline bool operator==(
const ColumnsIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2541 return row_ == rhs.row_;
2551 template<
typename MatrixType2,
typename IteratorType2 >
2552 inline bool operator!=(
const ColumnsIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2553 return !( *
this == rhs );
2563 inline DifferenceType
operator-(
const ColumnsIterator& rhs )
const {
2564 size_t counter( 0UL );
2565 for(
size_t i=rhs.row_; i<row_; ++i ) {
2566 if( matrix_->find( i, column_ ) != matrix_->end( i ) )
2575 MatrixType* matrix_;
2582 template<
typename MatrixType2,
typename IteratorType2 >
friend class ColumnsIterator;
2583 template<
typename MT2,
bool SO2,
bool DF2,
bool SF2,
typename... CCAs2 >
friend class Columns;
2590 using ConstIterator = ColumnsIterator< const MT, ConstIterator_t<MT> >;
2604 template<
typename... RCAs >
2605 explicit inline Columns( MT& matrix, RCAs... args );
2607 Columns(
const Columns& ) =
default;
2608 Columns( Columns&& ) =
default;
2615 ~Columns() =
default;
2622 inline Reference operator()(
size_t i,
size_t j );
2624 inline Reference at(
size_t i,
size_t j );
2638 inline Columns& operator=( initializer_list< initializer_list<ElementType> > list );
2639 inline Columns& operator=(
const Columns& rhs );
2641 template<
typename MT2,
bool SO >
inline Columns& operator= (
const Matrix<MT2,SO>& rhs );
2642 template<
typename MT2,
bool SO >
inline Columns&
operator+=(
const Matrix<MT2,SO>& rhs );
2643 template<
typename MT2,
bool SO >
inline Columns&
operator-=(
const Matrix<MT2,SO>& rhs );
2644 template<
typename MT2,
bool SO >
inline Columns& operator%=(
const Matrix<MT2,SO>& rhs );
2651 using DataType::idx;
2652 using DataType::idces;
2655 inline MT& operand() noexcept;
2656 inline const MT& operand() const noexcept;
2658 inline
size_t rows() const noexcept;
2659 inline
size_t capacity() const noexcept;
2660 inline
size_t capacity(
size_t j ) const noexcept;
2662 inline
size_t nonZeros(
size_t j ) const;
2663 inline
void reset();
2664 inline
void reset(
size_t j );
2665 inline
void reserve(
size_t nonzeros );
2666 void reserve(
size_t j,
size_t nonzeros );
2668 inline
void trim(
size_t j );
2677 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
2678 inline
void finalize(
size_t j );
2685 inline
void erase(
size_t i,
size_t j );
2689 template< typename Pred >
2690 inline
void erase( Pred predicate );
2692 template< typename Pred >
2693 inline
void erase(
size_t j,
Iterator first,
Iterator last, Pred predicate );
2700 inline
Iterator find (
size_t i,
size_t j );
2702 inline
Iterator lowerBound(
size_t i,
size_t j );
2703 inline
ConstIterator lowerBound(
size_t i,
size_t j ) const;
2704 inline
Iterator upperBound(
size_t i,
size_t j );
2705 inline
ConstIterator upperBound(
size_t i,
size_t j ) const;
2715 template< typename Other > inline Columns& scale( const Other& scalar );
2722 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2723 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2725 inline
bool canSMPAssign() const noexcept;
2727 template< typename MT2,
bool SO > inline
void assign ( const DenseMatrix<MT2,SO>& rhs );
2728 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,false>& rhs );
2729 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,true>& rhs );
2730 template< typename MT2,
bool SO > inline
void addAssign ( const Matrix<MT2,SO>& rhs );
2731 template< typename MT2,
bool SO > inline
void subAssign ( const Matrix<MT2,SO>& rhs );
2732 template< typename MT2,
bool SO > inline
void schurAssign( const Matrix<MT2,SO>& rhs );
2781 template< typename MT
2782 , typename... CCAs >
2783 template< typename... RCAs >
2784 inline Columns<MT,false,false,false,CCAs...>::Columns( MT& matrix, RCAs... args )
2785 : DataType( args... )
2786 , matrix_ ( matrix )
2789 for(
size_t j=0UL; j<
columns(); ++j ) {
2790 if( matrix_.columns() <= idx(j) ) {
2819 template<
typename MT
2820 ,
typename... CCAs >
2821 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Reference 2822 Columns<MT,false,false,false,CCAs...>::operator()(
size_t i,
size_t j )
2827 return matrix_(i,idx(j));
2844 template<
typename MT
2845 ,
typename... CCAs >
2847 Columns<MT,false,false,false,CCAs...>::operator()(
size_t i,
size_t j )
const 2852 return const_cast<const MT&
>( matrix_ )(i,idx(j));
2870 template<
typename MT
2871 ,
typename... CCAs >
2872 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Reference 2873 Columns<MT,false,false,false,CCAs...>::at(
size_t i,
size_t j )
2881 return (*
this)(i,j);
2899 template<
typename MT
2900 ,
typename... CCAs >
2902 Columns<MT,false,false,false,CCAs...>::at(
size_t i,
size_t j )
const 2910 return (*
this)(i,j);
2925 template<
typename MT
2926 ,
typename... CCAs >
2927 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 2932 return Iterator( matrix_, 0UL, idx(j) );
2947 template<
typename MT
2948 ,
typename... CCAs >
2969 template<
typename MT
2970 ,
typename... CCAs >
2991 template<
typename MT
2992 ,
typename... CCAs >
2993 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 3013 template<
typename MT
3014 ,
typename... CCAs >
3035 template<
typename MT
3036 ,
typename... CCAs >
3072 template<
typename MT
3073 ,
typename... CCAs >
3074 inline Columns<MT,
false,
false,
false,CCAs...>&
3075 Columns<MT,false,false,false,CCAs...>::operator=( initializer_list< initializer_list<ElementType> > list )
3080 if( list.size() !=
rows() ) {
3084 const InitializerMatrix<ElementType> tmp( list,
columns() );
3086 if( IsRestricted_v<MT> ) {
3087 for(
size_t j=0UL; j<
columns(); ++j ) {
3094 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3119 template<
typename MT
3120 ,
typename... CCAs >
3121 inline Columns<MT,
false,
false,
false,CCAs...>&
3122 Columns<MT,false,false,false,CCAs...>::operator=(
const Columns& rhs )
3130 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && compareIndices( *
this, rhs ) ) )
3133 if(
rows() != rhs.rows() ||
columns() != rhs.columns() ) {
3137 if( IsRestricted_v<MT> ) {
3138 for(
size_t j=0UL; j<
columns(); ++j ) {
3139 if( !tryAssign( matrix_,
column( rhs, j,
unchecked ), 0UL, idx(j) ) ) {
3145 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3147 if( rhs.canAlias( &matrix_ ) ) {
3180 template<
typename MT
3181 ,
typename... CCAs >
3182 template<
typename MT2
3184 inline Columns<MT,
false,
false,
false,CCAs...>&
3185 Columns<MT,false,false,false,CCAs...>::operator=(
const Matrix<MT2,SO>& rhs )
3196 using Right = CompositeType_t<MT2>;
3197 Right right( ~rhs );
3199 if( IsRestricted_v<MT> ) {
3200 for(
size_t j=0UL; j<
columns(); ++j ) {
3201 if( !tryAssign( matrix_,
column( right, j,
unchecked ), 0UL, idx(j) ) ) {
3207 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3209 if( IsReference_v<Right> && right.canAlias( &matrix_ ) ) {
3210 const ResultType_t<MT2> tmp( right );
3216 if( IsSparseMatrix_v<MT2> )
3243 template<
typename MT
3244 ,
typename... CCAs >
3245 template<
typename MT2
3247 inline Columns<MT,
false,
false,
false,CCAs...>&
3257 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
3265 const AddType tmp( *
this + (~rhs) );
3267 if( IsRestricted_v<MT> ) {
3268 for(
size_t j=0UL; j<
columns(); ++j ) {
3269 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
3275 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3277 if( IsSparseMatrix_v<AddType> ) {
3305 template<
typename MT
3306 ,
typename... CCAs >
3307 template<
typename MT2
3309 inline Columns<MT,
false,
false,
false,CCAs...>&
3319 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
3327 const SubType tmp( *
this - (~rhs) );
3329 if( IsRestricted_v<MT> ) {
3330 for(
size_t j=0UL; j<
columns(); ++j ) {
3331 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
3337 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3339 if( IsSparseMatrix_v<SubType> ) {
3367 template<
typename MT
3368 ,
typename... CCAs >
3369 template<
typename MT2
3371 inline Columns<MT,
false,
false,
false,CCAs...>&
3372 Columns<MT,false,false,false,CCAs...>::operator%=(
const Matrix<MT2,SO>& rhs )
3381 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
3389 const SchurType tmp( *
this % (~rhs) );
3391 if( IsRestricted_v<MT> ) {
3392 for(
size_t j=0UL; j<
columns(); ++j ) {
3393 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
3399 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
3401 if( IsSparseMatrix_v<SchurType> ) {
3429 template<
typename MT
3430 ,
typename... CCAs >
3431 inline MT& Columns<MT,false,false,false,CCAs...>::operand() noexcept
3445 template<
typename MT
3446 ,
typename... CCAs >
3447 inline const MT& Columns<MT,false,false,false,CCAs...>::operand() const noexcept
3461 template<
typename MT
3462 ,
typename... CCAs >
3465 return matrix_.rows();
3477 template<
typename MT
3478 ,
typename... CCAs >
3496 template<
typename MT
3497 ,
typename... CCAs >
3516 template<
typename MT
3517 ,
typename... CCAs >
3520 size_t nonzeros( 0UL );
3522 for(
size_t i=0UL; i<
rows(); ++i ) {
3523 const auto end( matrix_.end( i ) );
3524 for(
size_t j=0UL; j<
columns(); ++j ) {
3525 auto pos = matrix_.find( i, idx(j) );
3547 template<
typename MT
3548 ,
typename... CCAs >
3553 size_t counter( 0UL );
3572 template<
typename MT
3573 ,
typename... CCAs >
3576 for(
size_t j=0UL; j<
columns(); ++j ) {
3594 template<
typename MT
3595 ,
typename... CCAs >
3598 const size_t index( idx(j) );
3600 const size_t ibegin( ( IsLower_v<MT> )
3601 ?( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> )
3605 const size_t iend ( ( IsUpper_v<MT> )
3606 ?( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> )
3611 for(
size_t i=ibegin; i<iend; ++i ) {
3612 matrix_.erase( i, index );
3630 template<
typename MT
3631 ,
typename... CCAs >
3632 inline void Columns<MT,false,false,false,CCAs...>::reserve(
size_t nonzeros )
3655 template<
typename MT
3656 ,
typename... CCAs >
3657 void Columns<MT,false,false,false,CCAs...>::reserve(
size_t j,
size_t nonzeros )
3677 template<
typename MT
3678 ,
typename... CCAs >
3679 void Columns<MT,false,false,false,CCAs...>::trim()
3698 template<
typename MT
3699 ,
typename... CCAs >
3700 void Columns<MT,false,false,false,CCAs...>::trim(
size_t j )
3733 template<
typename MT
3734 ,
typename... CCAs >
3735 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 3738 return Iterator( matrix_, i, idx(j), matrix_.set( i, idx(j), value ) );
3758 template<
typename MT
3759 ,
typename... CCAs >
3760 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 3761 Columns<MT,false,false,false,CCAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
3763 return Iterator( matrix_, i, idx(j), matrix_.insert( i, idx(j), value ) );
3813 template<
typename MT
3814 ,
typename... CCAs >
3815 inline void Columns<MT,false,false,false,CCAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
3817 if( !check || !isDefault<strict>( value ) )
3818 matrix_.insert( i, idx(j), value );
3838 template<
typename MT
3839 ,
typename... CCAs >
3840 inline void Columns<MT,false,false,false,CCAs...>::finalize(
size_t j )
3868 template<
typename MT
3869 ,
typename... CCAs >
3870 inline void Columns<MT,false,false,false,CCAs...>::erase(
size_t i,
size_t j )
3875 matrix_.erase( i, idx(j) );
3891 template<
typename MT
3892 ,
typename... CCAs >
3893 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 3894 Columns<MT,false,false,false,CCAs...>::erase(
size_t j,
Iterator pos )
3896 const size_t row( pos.row_ );
3901 matrix_.erase(
row, pos.pos_ );
3919 template<
typename MT
3920 ,
typename... CCAs >
3921 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 3922 Columns<MT,false,false,false,CCAs...>::erase(
size_t j,
Iterator first,
Iterator last )
3928 for( ; first!=last; ++first ) {
3929 matrix_.erase( first.row_, first.pos_ );
3961 template<
typename MT
3962 ,
typename... CCAs >
3963 template<
typename Pred >
3964 inline void Columns<MT,false,false,false,CCAs...>::erase( Pred predicate )
3966 for(
size_t j=0UL; j<
columns(); ++j ) {
3968 if( predicate( element->value() ) )
3969 matrix_.erase( element.row_, element.pos_ );
4004 template<
typename MT
4005 ,
typename... CCAs >
4006 template<
typename Pred >
4007 inline void Columns<MT,false,false,false,CCAs...>::erase(
size_t j,
Iterator first,
Iterator last, Pred predicate )
4013 for( ; first!=last; ++first ) {
4014 if( predicate( first->value() ) )
4015 matrix_.erase( first.row_, first.pos_ );
4045 template<
typename MT
4046 ,
typename... CCAs >
4047 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 4048 Columns<MT,false,false,false,CCAs...>::find(
size_t i,
size_t j )
4050 const size_t index( idx(j) );
4051 const Iterator_t<MT> pos( matrix_.find( i, index ) );
4053 if( pos != matrix_.end( i ) )
4054 return Iterator( matrix_, i, index, pos );
4077 template<
typename MT
4078 ,
typename... CCAs >
4080 Columns<MT,false,false,false,CCAs...>::find(
size_t i,
size_t j )
const 4082 const size_t index( idx(j) );
4083 const ConstIterator_t<MT> pos( matrix_.find( i, index ) );
4085 if( pos != matrix_.end( i ) )
4108 template<
typename MT
4109 ,
typename... CCAs >
4110 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 4111 Columns<MT,false,false,false,CCAs...>::lowerBound(
size_t i,
size_t j )
4113 const size_t index( idx(j) );
4115 for( ; i<
rows(); ++i )
4117 const Iterator_t<MT> pos( matrix_.find( i, index ) );
4119 if( pos != matrix_.end( i ) )
4120 return Iterator( matrix_, i, index, pos );
4143 template<
typename MT
4144 ,
typename... CCAs >
4146 Columns<MT,false,false,false,CCAs...>::lowerBound(
size_t i,
size_t j )
const 4148 const size_t index( idx(j) );
4150 for( ; i<
rows(); ++i )
4152 const ConstIterator_t<MT> pos( matrix_.find( i, index ) );
4154 if( pos != matrix_.end( i ) )
4178 template<
typename MT
4179 ,
typename... CCAs >
4180 inline typename Columns<MT,
false,
false,
false,CCAs...>
::Iterator 4181 Columns<MT,false,false,false,CCAs...>::upperBound(
size_t i,
size_t j )
4183 return lowerBound( i+1UL, j );
4203 template<
typename MT
4204 ,
typename... CCAs >
4206 Columns<MT,false,false,false,CCAs...>::upperBound(
size_t i,
size_t j )
const 4208 return lowerBound( i+1UL, j );
4235 template<
typename MT
4236 ,
typename... CCAs >
4237 inline Columns<MT,
false,
false,
false,CCAs...>&
4249 if( IsRestricted_v<MT> ) {
4250 for(
size_t j=0UL; j<
columns(); ++j ) {
4251 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
4257 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
4281 template<
typename MT
4282 ,
typename... CCAs >
4283 inline Columns<MT,
false,
false,
false,CCAs...>&
4295 if( IsRestricted_v<MT> ) {
4296 for(
size_t j=0UL; j<
columns(); ++j ) {
4297 if( !tryAssign( matrix_,
column( tmp, j,
unchecked ), 0UL, idx(j) ) ) {
4303 BLAZE_DECLTYPE_AUTO( left, derestrict( *
this ) );
4327 template<
typename MT
4328 ,
typename... CCAs >
4329 template<
typename Other >
4330 inline Columns<MT,
false,
false,
false,CCAs...>&
4331 Columns<MT,false,false,false,CCAs...>::scale(
const Other& scalar )
4337 for(
size_t i=0UL; i<
rows(); ++i ) {
4338 const auto end( matrix_.end( i ) );
4339 for(
size_t j=0UL; j<
columns(); ++j ) {
4340 auto pos = matrix_.find( i, idx(j) );
4342 pos->value() *= scalar;
4372 template<
typename MT
4373 ,
typename... CCAs >
4374 template<
typename Other >
4375 inline bool Columns<MT,false,false,false,CCAs...>::canAlias(
const Other* alias )
const noexcept
4377 return matrix_.isAliased( alias );
4394 template<
typename MT
4395 ,
typename... CCAs >
4396 template<
typename Other >
4397 inline bool Columns<MT,false,false,false,CCAs...>::isAliased(
const Other* alias )
const noexcept
4399 return matrix_.isAliased( alias );
4416 template<
typename MT
4417 ,
typename... CCAs >
4418 inline bool Columns<MT,false,false,false,CCAs...>::canSMPAssign() const noexcept
4438 template<
typename MT
4439 ,
typename... CCAs >
4440 template<
typename MT2
4442 inline void Columns<MT,false,false,false,CCAs...>::assign(
const DenseMatrix<MT2,SO>& rhs )
4447 using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>,
const ElementType_t<MT2>& >;
4452 for(
size_t i=0UL; i<
rows(); ++i ) {
4453 for(
size_t j=0UL; j<
columns(); ++j ) {
4454 RT value( (~rhs)(i,j) );
4455 if( !isDefault<strict>( value ) )
4456 matrix_.set( i, idx(j), std::move( value ) );
4457 else matrix_.erase( i, idx(j) );
4477 template<
typename MT
4478 ,
typename... CCAs >
4479 template<
typename MT2 >
4480 inline void Columns<MT,false,false,false,CCAs...>::assign(
const SparseMatrix<MT2,false>& rhs )
4487 using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>,
const ElementType_t<MT2>& >;
4493 for(
size_t i=0UL; i<
rows(); ++i ) {
4494 for( ConstIterator_t<MT2> element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element ) {
4495 RT value( element->value() );
4496 if( !isDefault<strict>( value ) )
4497 matrix_.set( i, idx( element->index() ), std::move( value ) );
4498 else matrix_.erase( i, idx( element->index() ) );
4518 template<
typename MT
4519 ,
typename... CCAs >
4520 template<
typename MT2 >
4521 inline void Columns<MT,false,false,false,CCAs...>::assign(
const SparseMatrix<MT2,true>& rhs )
4526 using RT = If_t< IsComputation_v<MT2>, ElementType_t<MT>,
const ElementType_t<MT2>& >;
4532 for(
size_t j=0UL; j<
columns(); ++j ) {
4533 const size_t index( idx(j) );
4534 for( ConstIterator_t<MT2> element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
4535 RT value( element->value() );
4536 if( !isDefault<strict>( value ) )
4537 matrix_.set( element->index(), index, std::move( value ) );
4538 else matrix_.erase( element->index(), index );
4558 template<
typename MT
4559 ,
typename... CCAs >
4560 template<
typename MT2
4562 inline void Columns<MT,false,false,false,CCAs...>::addAssign(
const Matrix<MT2,SO>& rhs )
4567 using AddType = AddTrait_t< ResultType, ResultType_t<MT2> >;
4574 const AddType tmp(
serial( *
this + (~rhs) ) );
4594 template<
typename MT
4595 ,
typename... CCAs >
4596 template<
typename MT2
4598 inline void Columns<MT,false,false,false,CCAs...>::subAssign(
const Matrix<MT2,SO>& rhs )
4603 using SubType = SubTrait_t< ResultType, ResultType_t<MT2> >;
4610 const SubType tmp(
serial( *
this - (~rhs) ) );
4630 template<
typename MT
4631 ,
typename... CCAs >
4632 template<
typename MT2
4634 inline void Columns<MT,false,false,false,CCAs...>::schurAssign(
const Matrix<MT2,SO>& rhs )
4639 using SchurType = SchurTrait_t< ResultType, ResultType_t<MT2> >;
4647 const SchurType tmp(
serial( *
this % (~rhs) ) );
4675 template<
typename MT
4676 ,
typename... CCAs >
4677 class Columns<MT,false,false,true,CCAs...>
4678 :
public View< SparseMatrix< Columns<MT,false,false,true,CCAs...>, true > >
4679 ,
private ColumnsData<CCAs...>
4683 using DataType = ColumnsData<CCAs...>;
4684 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
4688 static constexpr
size_t N =
sizeof...( CCAs );
4694 using This = Columns<MT,
false,
false,
true,CCAs...>;
4696 using BaseType = SparseMatrix<This,true>;
4697 using ViewedType = MT;
4726 template<
typename... RCAs >
4727 explicit inline Columns( MT& matrix, RCAs... args );
4729 Columns(
const Columns& ) =
default;
4730 Columns( Columns&& ) =
default;
4737 ~Columns() =
default;
4744 inline Reference operator()(
size_t i,
size_t j );
4746 inline Reference at(
size_t i,
size_t j );
4760 Columns& operator=(
const Columns& ) =
delete;
4767 using DataType::idx;
4768 using DataType::idces;
4771 inline MT& operand() noexcept;
4772 inline const MT& operand() const noexcept;
4774 inline
size_t rows() const noexcept;
4775 inline
size_t capacity() const noexcept;
4776 inline
size_t capacity(
size_t j ) const noexcept;
4778 inline
size_t nonZeros(
size_t j ) const;
4779 inline
void reset();
4780 inline
void reset(
size_t j );
4781 inline
void reserve(
size_t nonzeros );
4782 void reserve(
size_t j,
size_t nonzeros );
4784 inline
void trim(
size_t j );
4793 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
4794 inline
void finalize(
size_t j );
4801 inline
void erase(
size_t i,
size_t j );
4805 template< typename Pred >
4806 inline
void erase( Pred predicate );
4808 template< typename Pred >
4809 inline
void erase(
size_t j,
Iterator first,
Iterator last, Pred predicate );
4816 inline
Iterator find (
size_t i,
size_t j );
4818 inline
Iterator lowerBound(
size_t i,
size_t j );
4819 inline
ConstIterator lowerBound(
size_t i,
size_t j ) const;
4820 inline
Iterator upperBound(
size_t i,
size_t j );
4821 inline
ConstIterator upperBound(
size_t i,
size_t j ) const;
4828 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
4829 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
4831 inline
bool canSMPAssign() const noexcept;
4880 template< typename MT
4881 , typename... CCAs >
4882 template< typename... RCAs >
4883 inline Columns<MT,false,false,true,CCAs...>::Columns( MT& matrix, RCAs... args )
4884 : DataType( args... )
4885 , matrix_ ( matrix )
4888 for(
size_t j=0UL; j<
columns(); ++j ) {
4889 if( matrix_.columns() <= idx(j) ) {
4918 template<
typename MT
4919 ,
typename... CCAs >
4920 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Reference 4921 Columns<MT,false,false,true,CCAs...>::operator()(
size_t i,
size_t j )
4926 return matrix_(idx(j),i);
4943 template<
typename MT
4944 ,
typename... CCAs >
4946 Columns<MT,false,false,true,CCAs...>::operator()(
size_t i,
size_t j )
const 4951 return const_cast<const MT&
>( matrix_ )(idx(j),i);
4969 template<
typename MT
4970 ,
typename... CCAs >
4971 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Reference 4972 Columns<MT,false,false,true,CCAs...>::at(
size_t i,
size_t j )
4980 return (*
this)(i,j);
4998 template<
typename MT
4999 ,
typename... CCAs >
5001 Columns<MT,false,false,true,CCAs...>::at(
size_t i,
size_t j )
const 5009 return (*
this)(i,j);
5024 template<
typename MT
5025 ,
typename... CCAs >
5026 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5031 return matrix_.begin( idx(j) );
5046 template<
typename MT
5047 ,
typename... CCAs >
5053 return matrix_.cbegin( idx(j) );
5068 template<
typename MT
5069 ,
typename... CCAs >
5075 return matrix_.cbegin( idx(j) );
5090 template<
typename MT
5091 ,
typename... CCAs >
5092 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5097 return matrix_.end( idx(j) );
5112 template<
typename MT
5113 ,
typename... CCAs >
5119 return matrix_.cend( idx(j) );
5134 template<
typename MT
5135 ,
typename... CCAs >
5141 return matrix_.cend( idx(j) );
5161 template<
typename MT
5162 ,
typename... CCAs >
5163 inline MT& Columns<MT,false,false,true,CCAs...>::operand() noexcept
5177 template<
typename MT
5178 ,
typename... CCAs >
5179 inline const MT& Columns<MT,false,false,true,CCAs...>::operand() const noexcept
5193 template<
typename MT
5194 ,
typename... CCAs >
5197 return matrix_.rows();
5209 template<
typename MT
5210 ,
typename... CCAs >
5213 return nonZeros() + matrix_.capacity() - matrix_.nonZeros();
5228 template<
typename MT
5229 ,
typename... CCAs >
5234 return matrix_.capacity( idx(j) );
5246 template<
typename MT
5247 ,
typename... CCAs >
5250 size_t nonzeros( 0UL );
5252 for(
size_t j=0UL; j<
columns(); ++j )
5270 template<
typename MT
5271 ,
typename... CCAs >
5276 return matrix_.nonZeros( idx(j) );
5288 template<
typename MT
5289 ,
typename... CCAs >
5292 for(
size_t j=0UL; j<
columns(); ++j ) {
5293 matrix_.reset( idx(j) );
5310 template<
typename MT
5311 ,
typename... CCAs >
5314 matrix_.reset( idx(j) );
5331 template<
typename MT
5332 ,
typename... CCAs >
5333 inline void Columns<MT,false,false,true,CCAs...>::reserve(
size_t nonzeros )
5335 const size_t current(
capacity() );
5337 if( nonzeros > current ) {
5338 matrix_.reserve( matrix_.capacity() + nonzeros - current );
5357 template<
typename MT
5358 ,
typename... CCAs >
5359 void Columns<MT,false,false,true,CCAs...>::reserve(
size_t j,
size_t nonzeros )
5361 matrix_.reserve( idx(j), nonzeros );
5377 template<
typename MT
5378 ,
typename... CCAs >
5379 void Columns<MT,false,false,true,CCAs...>::trim()
5381 for(
size_t j=0UL; j<
columns(); ++j ) {
5400 template<
typename MT
5401 ,
typename... CCAs >
5402 void Columns<MT,false,false,true,CCAs...>::trim(
size_t j )
5406 matrix_.trim( idx(j) );
5433 template<
typename MT
5434 ,
typename... CCAs >
5435 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5438 return matrix_.set( idx(j), i, value );
5458 template<
typename MT
5459 ,
typename... CCAs >
5460 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5461 Columns<MT,false,false,true,CCAs...>::insert(
size_t i,
size_t j,
const ElementType& value )
5463 return matrix_.insert( idx(j), i, value );
5513 template<
typename MT
5514 ,
typename... CCAs >
5515 inline void Columns<MT,false,false,true,CCAs...>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
5517 if( !check || !isDefault<strict>( value ) )
5518 matrix_.insert( idx(j), i, value );
5538 template<
typename MT
5539 ,
typename... CCAs >
5540 inline void Columns<MT,false,false,true,CCAs...>::finalize(
size_t j )
5568 template<
typename MT
5569 ,
typename... CCAs >
5570 inline void Columns<MT,false,false,true,CCAs...>::erase(
size_t i,
size_t j )
5575 matrix_.erase( idx(j), i );
5591 template<
typename MT
5592 ,
typename... CCAs >
5593 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5594 Columns<MT,false,false,true,CCAs...>::erase(
size_t j,
Iterator pos )
5598 return matrix_.erase( idx(j), pos );
5615 template<
typename MT
5616 ,
typename... CCAs >
5617 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5618 Columns<MT,false,false,true,CCAs...>::erase(
size_t j,
Iterator first,
Iterator last )
5622 return matrix_.erase( idx(j), first, last );
5651 template<
typename MT
5652 ,
typename... CCAs >
5653 template<
typename Pred >
5654 inline void Columns<MT,false,false,true,CCAs...>::erase( Pred predicate )
5656 for(
size_t j=0UL; j<
columns(); ++j ) {
5657 matrix_.erase( idx(j),
begin(j),
end(j), predicate );
5691 template<
typename MT
5692 ,
typename... CCAs >
5693 template<
typename Pred >
5694 inline void Columns<MT,false,false,true,CCAs...>::erase(
size_t j,
Iterator first,
Iterator last, Pred predicate )
5698 matrix_.erase( idx(j), first, last, predicate );
5727 template<
typename MT
5728 ,
typename... CCAs >
5729 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5730 Columns<MT,false,false,true,CCAs...>::find(
size_t i,
size_t j )
5732 return matrix_.find( idx(j), i );
5753 template<
typename MT
5754 ,
typename... CCAs >
5756 Columns<MT,false,false,true,CCAs...>::find(
size_t i,
size_t j )
const 5758 return matrix_.find( idx(j), i );
5778 template<
typename MT
5779 ,
typename... CCAs >
5780 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5781 Columns<MT,false,false,true,CCAs...>::lowerBound(
size_t i,
size_t j )
5783 return matrix_.lowerBound( idx(j), i );
5803 template<
typename MT
5804 ,
typename... CCAs >
5806 Columns<MT,false,false,true,CCAs...>::lowerBound(
size_t i,
size_t j )
const 5808 return matrix_.lowerBound( idx(j), i );
5828 template<
typename MT
5829 ,
typename... CCAs >
5830 inline typename Columns<MT,
false,
false,
true,CCAs...>
::Iterator 5831 Columns<MT,false,false,true,CCAs...>::upperBound(
size_t i,
size_t j )
5833 return matrix_.upperBound( idx(j), i );
5853 template<
typename MT
5854 ,
typename... CCAs >
5856 Columns<MT,false,false,true,CCAs...>::upperBound(
size_t i,
size_t j )
const 5858 return matrix_.upperBound( idx(j), i );
5883 template<
typename MT
5884 ,
typename... CCAs >
5885 template<
typename Other >
5886 inline bool Columns<MT,false,false,true,CCAs...>::canAlias(
const Other* alias )
const noexcept
5888 return matrix_.isAliased( alias );
5905 template<
typename MT
5906 ,
typename... CCAs >
5907 template<
typename Other >
5908 inline bool Columns<MT,false,false,true,CCAs...>::isAliased(
const Other* alias )
const noexcept
5910 return matrix_.isAliased( alias );
5927 template<
typename MT
5928 ,
typename... CCAs >
5929 inline bool Columns<MT,false,false,true,CCAs...>::canSMPAssign() const noexcept
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the implementation of the Columns base template.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
Header file for the Schur product trait.
#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
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
constexpr bool IsSparseMatrix_v
Auxiliary variable template for the IsSparseMatrix type trait.The IsSparseMatrix_v variable template ...
Definition: IsSparseMatrix.h:139
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:750
Header file for the View base class.
Header file for the IsSparseMatrix type trait.
#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:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:81
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
Header file for the decltype(auto) workaround.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
Constraints on the storage order of matrix types.
#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:81
Header file for the extended initializer_list functionality.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the IsUniLower type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Headerfile for the generic max algorithm.
Header file for the IsStrictlyUpper type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1364
Header file for the If class template.
#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: ColumnMajorMatrix.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#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:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.The Contains_v variable template provides a c...
Definition: Contains.h:139
Header file for the IsLower type trait.
Header file for the SparseElement base class.
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COLUMNS_TYPE(T)
Constraint on the data type.In case the given data type T is a column selection type (i...
Definition: Columns.h:81
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8908
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Constraint on the data type.
Header file for the IsStrictlyLower type trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#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: RowMajorMatrix.h:61
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Header file for the relaxation flag types.
Header file for the addition trait.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
Header file for the columns trait.
Constraint on the data type.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#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:79
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#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:81
Header file for the IsReference type trait.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Header file for the implementation of the ColumnsData class template.
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
#define BLAZE_THROW_LOGIC_ERROR(MESSAGE)
Macro for the emission of a std::logic_error exception.This macro encapsulates the default way of Bla...
Definition: Exception.h:187
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
Header file for the IsUpper type trait.
Header file for the IsRestricted type trait.
#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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the IsExpression type trait class.
Constraint on the data type.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825