4 #ifndef DUNE_ISTL_BCRSMATRIX_HH
5 #define DUNE_ISTL_BCRSMATRIX_HH
20 #include <dune/common/stdstreams.hh>
21 #include <dune/common/iteratorfacades.hh>
22 #include <dune/common/typetraits.hh>
23 #include <dune/common/ftraits.hh>
24 #include <dune/common/scalarvectorview.hh>
25 #include <dune/common/scalarmatrixview.hh>
73 struct MatrixDimension;
82 template<
typename size_type>
140 return _m.entry(_i,j);
169 if (m.buildMode() != Matrix::implicit)
170 DUNE_THROW(
BCRSMatrixError,
"You can only create an ImplicitBuilder for a matrix in implicit build mode");
171 if (m.buildStage() != Matrix::building)
172 DUNE_THROW(
BCRSMatrixError,
"You can only create an ImplicitBuilder for a matrix with set size that has not been compressed() yet");
193 if (m.buildStage() != Matrix::notAllocated)
194 DUNE_THROW(
BCRSMatrixError,
"You can only set up a matrix for this ImplicitBuilder if it has no memory allocated yet");
195 m.setBuildMode(Matrix::implicit);
196 m.setImplicitBuildModeParameters(avg_cols_per_row,overflow_fraction);
197 m.setSize(rows,cols);
424 template<
class B,
class A=std::allocator<B> >
457 typedef Imp::CompressedBlockVectorWindow<B,A>
row_type;
466 static constexpr
unsigned int blocklevel = Imp::BlockTraits<B>::blockLevel()+1;
510 #ifdef DUNE_ISTL_WITH_CHECKING
512 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
522 #ifdef DUNE_ISTL_WITH_CHECKING
524 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
537 :
public RandomAccessIteratorFacade<RealRowIterator<T>, T>
609 void advance(std::ptrdiff_t diff)
614 T& elementAt(std::ptrdiff_t diff)
const
749 DUNE_THROW(
BCRSMatrixError,
"Only call this constructor when using the implicit build mode");
754 if (_overflowsize < 0.0)
755 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative overflow fraction");
770 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copy-constructed when source matrix is completely empty (size not set) or fully built)");
802 DUNE_THROW(InvalidStateException,
"Matrix structure cannot be changed at this stage anymore (ready == "<<
ready<<
").");
828 DUNE_THROW(
Dune::BCRSMatrixError,
"number of non-zeroes may not be set in implicit mode, use setImplicitBuildModeParameters() instead");
836 allocate(rows, columns, nnz,
true,
false);
855 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative overflow fraction");
859 DUNE_THROW(InvalidStateException,
"You cannot modify build mode parameters at this stage anymore");
873 if (&Mat==
this)
return *
this;
876 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copied when both target and source are empty or fully built)");
883 if (
n>0 &&
n!=Mat.
n) {
885 for(
row_type *riter=
r+(
n-1), *rend=
r-1; riter!=rend; --riter)
906 DUNE_THROW(InvalidStateException,
"Scalar assignment only works on fully built BCRSMatrix)");
920 : Mat(_Mat), i(_i), nnz(0), current_row(nullptr, Mat.
j_.
get(), 0)
927 DUNE_THROW(
BCRSMatrixError,
"creation only allowed for uninitialized matrix");
929 DUNE_THROW(
BCRSMatrixError,
"creation only allowed if row wise allocation was requested in the constructor");
930 if(i==0 && _Mat.
N()==0)
963 Mat.
r[i].set(s,
nullptr,current_row.getindexptr());
964 current_row.setindexptr(current_row.getindexptr()+s);
977 Mat.
r[i].set(0,
nullptr,
nullptr);
980 std::copy(pattern.cbegin(), pattern.cend(), Mat.
r[i].getindexptr());
1007 return (i!=it.i) || (&Mat!=&it.Mat);
1013 return (i==it.i) && (&Mat==&it.Mat);
1031 return pattern.find(j) != pattern.end();
1040 return pattern.size();
1047 typedef std::set<size_type,std::less<size_type> > PatternType;
1048 PatternType pattern;
1089 #ifdef DUNE_ISTL_WITH_CHECKING
1093 return r[i].getsize();
1104 r[i].setsize(
r[i].getsize()+s);
1119 total +=
r[i].getsize();
1125 else if(
nnz_ < total)
1127 <<
"sufficient for calculated nonzeros ("<<total<<
"! ");
1159 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1165 size_type*
const first =
r[row].getindexptr();
1166 size_type*
const last = first +
r[row].getsize();
1172 if (pos!=last && *pos ==
col)
return;
1180 std::copy_backward(pos,
end,
end+1);
1192 template<
typename It>
1199 if ((col_end = std::copy(
begin,
end,
r[row].getindexptr())) != col_begin + row_size)
1202 <<
") does not match number of passed entries (" << (col_end - col_begin) <<
")");
1203 std::sort(col_begin,col_end);
1216 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1224 if (j.index() >=
m) {
1225 dwarn <<
"WARNING: size of row "<< i.index()<<
" is "<<j.offset()<<
". But was specified as being "<< (*i).end().offset()
1226 <<
". This means you are wasting valuable space and creating additional cache misses!"<<std::endl;
1227 nnz_ -= ((*i).end().offset() - j.offset());
1228 r[i.index()].setsize(j.offset());
1257 #ifdef DUNE_ISTL_WITH_CHECKING
1261 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, use operator[] for entry access now");
1263 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1265 DUNE_THROW(InvalidStateException,
"You may only use entry() during the 'building' stage");
1282 std::ptrdiff_t offset = pos -
r[row].getindexptr();
1283 B* aptr =
r[row].getptr() + offset;
1289 if (
r[row].getsize() ==
avg)
1297 std::ptrdiff_t offset =
end -
r[row].getindexptr();
1298 B* apos =
r[row].getptr() + offset;
1301 r[row].setsize(
r[row].getsize()+1);
1324 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, no more need for compression");
1326 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1328 DUNE_THROW(InvalidStateException,
"You may only call compress() at the end of the 'building' stage");
1340 typename OverflowType::iterator oit =
overflow.begin();
1343 std::vector<size_type*> perm;
1355 typename std::vector<size_type*>::iterator it = perm.begin();
1363 r[i].setindexptr(jiit);
1366 for (it = perm.begin(); it != perm.end(); ++it)
1369 while ((oit!=
overflow.end()) && (oit->first < std::make_pair(i,**it)))
1374 "Allocated memory for BCRSMatrix exhausted during compress()!"
1375 "Please increase either the average number of entries per row or the overflow fraction."
1378 *jiit = oit->first.second;
1380 *aiit = oit->second;
1383 r[i].setsize(
r[i].getsize()+1);
1389 "Allocated memory for BCRSMatrix exhausted during compress()!"
1390 "Please increase either the average number of entries per row or the overflow fraction."
1396 B* apos = *it -
j_.get() +
a;
1402 while ((oit!=
overflow.end()) && (oit->first.first == i))
1407 "Allocated memory for BCRSMatrix exhausted during compress()!"
1408 "Please increase either the average number of entries per row or the overflow fraction."
1412 *jiit = oit->first.second;
1414 *aiit = oit->second;
1417 r[i].setsize(
r[i].getsize()+1);
1429 std::ptrdiff_t diff = (
r[
n-1].getindexptr() +
r[
n-1].getsize() -
j_.get());
1431 stats.
avg = (double) (
nnz_) / (double)
n;
1445 #ifdef DUNE_ISTL_WITH_CHECKING
1447 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1473 #ifdef DUNE_ISTL_WITH_CHECKING
1475 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1506 #ifdef DUNE_ISTL_WITH_CHECKING
1508 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1509 if(
N()!=b.
N() ||
M() != b.
M())
1510 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1528 #ifdef DUNE_ISTL_WITH_CHECKING
1530 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1531 if(
N()!=b.
N() ||
M() != b.
M())
1532 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1553 #ifdef DUNE_ISTL_WITH_CHECKING
1555 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1556 if(
N()!=b.
N() ||
M() != b.
M())
1557 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1570 template<
class X,
class Y>
1571 void mv (
const X& x, Y& y)
const
1573 #ifdef DUNE_ISTL_WITH_CHECKING
1575 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1577 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" x: " << x.N());
1579 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" y: " << y.N());
1588 auto&& xj = Impl::asVector(x[j.index()]);
1589 auto&& yi = Impl::asVector(y[i.index()]);
1590 Impl::asMatrix(*j).umv(xj, yi);
1596 template<
class X,
class Y>
1597 void umv (
const X& x, Y& y)
const
1599 #ifdef DUNE_ISTL_WITH_CHECKING
1601 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1611 auto&& xj = Impl::asVector(x[j.index()]);
1612 auto&& yi = Impl::asVector(y[i.index()]);
1613 Impl::asMatrix(*j).umv(xj,yi);
1619 template<
class X,
class Y>
1620 void mmv (
const X& x, Y& y)
const
1622 #ifdef DUNE_ISTL_WITH_CHECKING
1624 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1634 auto&& xj = Impl::asVector(x[j.index()]);
1635 auto&& yi = Impl::asVector(y[i.index()]);
1636 Impl::asMatrix(*j).mmv(xj,yi);
1642 template<
class X,
class Y,
class F>
1643 void usmv (F&& alpha,
const X& x, Y& y)
const
1645 #ifdef DUNE_ISTL_WITH_CHECKING
1647 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1657 auto&& xj = Impl::asVector(x[j.index()]);
1658 auto&& yi = Impl::asVector(y[i.index()]);
1659 Impl::asMatrix(*j).usmv(alpha,xj,yi);
1665 template<
class X,
class Y>
1666 void mtv (
const X& x, Y& y)
const
1668 #ifdef DUNE_ISTL_WITH_CHECKING
1670 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1680 template<
class X,
class Y>
1683 #ifdef DUNE_ISTL_WITH_CHECKING
1685 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1695 auto&& xi = Impl::asVector(x[i.index()]);
1696 auto&& yj = Impl::asVector(y[j.index()]);
1697 Impl::asMatrix(*j).umtv(xi,yj);
1703 template<
class X,
class Y>
1706 #ifdef DUNE_ISTL_WITH_CHECKING
1716 auto&& xi = Impl::asVector(x[i.index()]);
1717 auto&& yj = Impl::asVector(y[j.index()]);
1718 Impl::asMatrix(*j).mmtv(xi,yj);
1724 template<
class X,
class Y>
1727 #ifdef DUNE_ISTL_WITH_CHECKING
1729 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1739 auto&& xi = Impl::asVector(x[i.index()]);
1740 auto&& yj = Impl::asVector(y[j.index()]);
1741 Impl::asMatrix(*j).usmtv(alpha,xi,yj);
1747 template<
class X,
class Y>
1750 #ifdef DUNE_ISTL_WITH_CHECKING
1752 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1762 auto&& xi = Impl::asVector(x[i.index()]);
1763 auto&& yj = Impl::asVector(y[j.index()]);
1764 Impl::asMatrix(*j).umhv(xi,yj);
1770 template<
class X,
class Y>
1773 #ifdef DUNE_ISTL_WITH_CHECKING
1775 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1785 auto&& xi = Impl::asVector(x[i.index()]);
1786 auto&& yj = Impl::asVector(y[j.index()]);
1787 Impl::asMatrix(*j).mmhv(xi,yj);
1793 template<
class X,
class Y>
1796 #ifdef DUNE_ISTL_WITH_CHECKING
1798 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1808 auto&& xi = Impl::asVector(x[i.index()]);
1809 auto&& yj = Impl::asVector(y[j.index()]);
1810 Impl::asMatrix(*j).usmhv(alpha,xi,yj);
1821 #ifdef DUNE_ISTL_WITH_CHECKING
1823 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1826 typename FieldTraits<field_type>::real_type sum=0;
1828 for (
auto&& row : (*
this))
1829 for (
auto&&
entry : row)
1830 sum += Impl::asMatrix(
entry).frobenius_norm2();
1843 typename std::enable_if<!HasNaN<ft>::value,
int>::type = 0>
1846 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1848 using real_type =
typename FieldTraits<ft>::real_type;
1852 for (
auto const &x : *
this) {
1854 for (
auto const &y : x)
1855 sum += Impl::asMatrix(y).infinity_norm();
1856 norm = max(sum, norm);
1863 typename std::enable_if<!HasNaN<ft>::value,
int>::type = 0>
1866 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1868 using real_type =
typename FieldTraits<ft>::real_type;
1872 for (
auto const &x : *
this) {
1874 for (
auto const &y : x)
1875 sum += Impl::asMatrix(y).infinity_norm_real();
1876 norm = max(sum, norm);
1883 typename std::enable_if<HasNaN<ft>::value,
int>::type = 0>
1886 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1888 using real_type =
typename FieldTraits<ft>::real_type;
1892 real_type isNaN = 1;
1893 for (
auto const &x : *
this) {
1895 for (
auto const &y : x)
1896 sum += Impl::asMatrix(y).infinity_norm();
1897 norm = max(sum, norm);
1901 return norm * (isNaN / isNaN);
1906 typename std::enable_if<HasNaN<ft>::value,
int>::type = 0>
1909 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1911 using real_type =
typename FieldTraits<ft>::real_type;
1915 real_type isNaN = 1;
1917 for (
auto const &x : *
this) {
1919 for (
auto const &y : x)
1920 sum += Impl::asMatrix(y).infinity_norm_real();
1921 norm = max(sum, norm);
1925 return norm * (isNaN / isNaN);
1968 #ifdef DUNE_ISTL_WITH_CHECKING
1972 return (
r[i].size() &&
r[i].find(j) !=
r[i].
end());
1982 typename std::allocator_traits<A>::template rebind_alloc<B>
allocator_;
1984 typename std::allocator_traits<A>::template rebind_alloc<row_type>
rowAllocator_;
2002 std::shared_ptr<size_type>
j_;
2020 r[i].set(s,current_row.getptr(), current_row.getindexptr());
2022 current_row.setptr(current_row.getptr()+s);
2023 current_row.setindexptr(current_row.getindexptr()+s);
2026 r[i].set(0,
nullptr,
nullptr);
2046 r[i].setindexptr(jptr);
2049 r[i].set(0,
nullptr,
nullptr);
2067 if (
r[i].getsize() > 0) {
2072 r[i].set(0,
nullptr,
nullptr);
2076 aptr +=
r[i].getsize();
2120 if (
r[i].getsize()>0)
2122 for (B *
col=
r[i].getptr()+(
r[i].getsize()-1),
2123 *colend =
r[i].getptr()-1;
col!=colend; --
col) {
2130 r[i].set(0,
nullptr,
nullptr);
2135 if (
n>0 && deallocateRows &&
r) {
2136 for(
row_type *riter=
r+(
n-1), *rend=
r-1; riter!=rend; --riter)
2150 typename std::allocator_traits<A>::template rebind_alloc<size_type>& sizeAllocator_;
2153 Deallocator(
typename std::allocator_traits<A>::template rebind_alloc<size_type>& sizeAllocator)
2154 : sizeAllocator_(sizeAllocator)
2183 nnz_ = allocationSize;
2190 DUNE_THROW(InvalidStateException,
"Rows have already been allocated, cannot allocate a second time");
2218 DUNE_THROW(InvalidStateException,
"Cannot allocate data array (already allocated)");
2237 DUNE_THROW(InvalidStateException,
"implicit_allocate() may only be called in implicit build mode");
2239 DUNE_THROW(InvalidStateException,
"memory has already been allocated");
2243 DUNE_THROW(InvalidStateException,
"You have to set the implicit build mode parameters before starting to build the matrix");
2252 B* aptr =
a + osize;
2255 r[i].set(0,aptr,jptr);
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Some handy generic functions for ISTL matrices.
Col col
Definition: matrixmatrix.hh:349
Definition: allocator.hh:7
PropertyMapTypeSelector< Amg::VertexVisitedTag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > >::Type get(const Amg::VertexVisitedTag &tag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > &graph)
Definition: dependency.hh:292
Definition: matrixutils.hh:209
Statistics about compression achieved in implicit mode.
Definition: bcrsmatrix.hh:84
size_type overflow_total
total number of elements written to the overflow area during construction.
Definition: bcrsmatrix.hh:90
size_type maximum
maximum number of non-zeroes per row.
Definition: bcrsmatrix.hh:88
double avg
average number of non-zeroes per row.
Definition: bcrsmatrix.hh:86
double mem_ratio
fraction of wasted memory resulting from non-used overflow area.
Definition: bcrsmatrix.hh:95
A wrapper for uniform access to the BCRSMatrix during and after the build stage in implicit build mod...
Definition: bcrsmatrix.hh:113
Matrix::block_type block_type
The block_type of the underlying matrix.
Definition: bcrsmatrix.hh:121
ImplicitMatrixBuilder(Matrix &m)
Creates an ImplicitMatrixBuilder for matrix m.
Definition: bcrsmatrix.hh:166
M_ Matrix
The underlying matrix.
Definition: bcrsmatrix.hh:118
ImplicitMatrixBuilder(Matrix &m, size_type rows, size_type cols, size_type avg_cols_per_row, double overflow_fraction)
Sets up matrix m for implicit construction using the given parameters and creates an ImplicitBmatrixu...
Definition: bcrsmatrix.hh:190
size_type M() const
The number of columns in the matrix.
Definition: bcrsmatrix.hh:213
Matrix::size_type size_type
The size_type of the underlying matrix.
Definition: bcrsmatrix.hh:124
row_object operator[](size_type i) const
Returns a proxy for entries in row i.
Definition: bcrsmatrix.hh:201
size_type N() const
The number of rows in the matrix.
Definition: bcrsmatrix.hh:207
Proxy row object for entry access.
Definition: bcrsmatrix.hh:133
block_type & operator[](size_type j) const
Returns entry in column j.
Definition: bcrsmatrix.hh:138
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:426
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: bcrsmatrix.hh:1836
typename Imp::BlockTraits< B >::field_type field_type
export the type representing the field
Definition: bcrsmatrix.hh:448
std::allocator_traits< A >::template rebind_alloc< row_type > rowAllocator_
Definition: bcrsmatrix.hh:1984
bool exists(size_type i, size_type j) const
return true if (i,j) is in pattern
Definition: bcrsmatrix.hh:1966
BuildStage buildStage() const
The current build stage of the matrix.
Definition: bcrsmatrix.hh:1952
Iterator begin()
Get iterator to first row.
Definition: bcrsmatrix.hh:634
friend class CreateIterator
allow CreateIterator to access internal data
Definition: bcrsmatrix.hh:1053
void copyWindowStructure(const BCRSMatrix &Mat)
Copy the window structure from another matrix.
Definition: bcrsmatrix.hh:2081
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: bcrsmatrix.hh:1771
void usmhv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: bcrsmatrix.hh:1794
void umtv(const X &x, Y &y) const
y += A^T x
Definition: bcrsmatrix.hh:1681
size_type m
Definition: bcrsmatrix.hh:1990
RealRowIterator< const row_type > const_iterator
The const iterator over the matrix rows.
Definition: bcrsmatrix.hh:666
double overflowsize
Definition: bcrsmatrix.hh:2006
static constexpr unsigned int blocklevel
increment block level counter
Definition: bcrsmatrix.hh:466
BCRSMatrix(size_type _n, size_type _m, size_type _avg, double _overflowsize, BuildMode bm)
construct matrix with a known average number of entries per row
Definition: bcrsmatrix.hh:743
void allocate(size_type rows, size_type columns, size_type allocationSize, bool allocateRows, bool allocate_data)
Allocate memory for the matrix structure.
Definition: bcrsmatrix.hh:2178
~BCRSMatrix()
destructor
Definition: bcrsmatrix.hh:783
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition: bcrsmatrix.hh:870
void allocateData()
Definition: bcrsmatrix.hh:2215
void deallocate(bool deallocateRows=true)
deallocate memory of the matrix.
Definition: bcrsmatrix.hh:2098
Iterator RowIterator
rename the iterators for easier access
Definition: bcrsmatrix.hh:660
BCRSMatrix()
an empty matrix
Definition: bcrsmatrix.hh:708
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1108
void incrementrowsize(size_type i, size_type s=1)
increment size of row i by s (1 by default)
Definition: bcrsmatrix.hh:1097
void mtv(const X &x, Y &y) const
y = A^T x
Definition: bcrsmatrix.hh:1666
void umhv(const X &x, Y &y) const
y += A^H x
Definition: bcrsmatrix.hh:1748
size_type nonzeroes() const
number of blocks that are stored (the number of blocks that possibly are nonzero)
Definition: bcrsmatrix.hh:1943
size_type allocationSize_
Definition: bcrsmatrix.hh:1992
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bcrsmatrix.hh:1864
ConstIterator ConstRowIterator
rename the const row iterator for easier access
Definition: bcrsmatrix.hh:697
BuildStage ready
Definition: bcrsmatrix.hh:1979
BuildMode build_mode
Definition: bcrsmatrix.hh:1978
void setrowsize(size_type i, size_type s)
Set number of indices in row i to s.
Definition: bcrsmatrix.hh:1076
RealRowIterator< row_type > Iterator
Definition: bcrsmatrix.hh:631
size_type nnz_
Definition: bcrsmatrix.hh:1991
std::allocator_traits< A >::template rebind_alloc< size_type > sizeAllocator_
Definition: bcrsmatrix.hh:1986
RealRowIterator< row_type > iterator
The iterator over the (mutable matrix rows.
Definition: bcrsmatrix.hh:630
void usmtv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: bcrsmatrix.hh:1725
ConstIterator beforeBegin() const
Definition: bcrsmatrix.hh:691
RealRowIterator< const row_type > ConstIterator
Definition: bcrsmatrix.hh:667
Iterator beforeBegin()
Definition: bcrsmatrix.hh:654
B * a
Definition: bcrsmatrix.hh:1999
BuildMode
we support two modes
Definition: bcrsmatrix.hh:469
@ implicit
Build entries randomly with an educated guess for the number of entries per row.
Definition: bcrsmatrix.hh:498
@ unknown
Build mode not set!
Definition: bcrsmatrix.hh:502
@ random
Build entries randomly.
Definition: bcrsmatrix.hh:489
@ row_wise
Build in a row-wise manner.
Definition: bcrsmatrix.hh:480
BCRSMatrix & operator/=(const field_type &k)
vector space division by scalar
Definition: bcrsmatrix.hh:1471
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: bcrsmatrix.hh:1819
BCRSMatrix(size_type _n, size_type _m, size_type _nnz, BuildMode bm)
matrix with known number of nonzeroes
Definition: bcrsmatrix.hh:715
::Dune::CompressionStatistics< size_type > CompressionStatistics
The type for the statistics object returned by compress()
Definition: bcrsmatrix.hh:463
BCRSMatrix(const BCRSMatrix &Mat)
copy constructor
Definition: bcrsmatrix.hh:764
Iterator end()
Get iterator to one beyond last row.
Definition: bcrsmatrix.hh:640
row_type * r
Definition: bcrsmatrix.hh:1996
void setIndices(size_type row, It begin, It end)
Set all column indices for row from the given iterator range.
Definition: bcrsmatrix.hh:1193
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition: bcrsmatrix.hh:1150
std::map< std::pair< size_type, size_type >, B > OverflowType
Definition: bcrsmatrix.hh:2008
row_type::Iterator ColIterator
Iterator for the entries of each row.
Definition: bcrsmatrix.hh:663
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: bcrsmatrix.hh:1844
A::size_type size_type
The type for the index access and the size.
Definition: bcrsmatrix.hh:460
OverflowType overflow
Definition: bcrsmatrix.hh:2009
row_type & operator[](size_type i)
random access to the rows
Definition: bcrsmatrix.hh:508
CreateIterator createend()
get create iterator pointing to one after the last block
Definition: bcrsmatrix.hh:1062
BCRSMatrix & axpy(field_type alpha, const BCRSMatrix &b)
Add the scaled entries of another matrix to this one.
Definition: bcrsmatrix.hh:1551
BCRSMatrix & operator+=(const BCRSMatrix &b)
Add the entries of another matrix to this one.
Definition: bcrsmatrix.hh:1504
Iterator beforeEnd()
Definition: bcrsmatrix.hh:647
row_type::ConstIterator ConstColIterator
Const iterator to the entries of a row.
Definition: bcrsmatrix.hh:700
void usmv(F &&alpha, const X &x, Y &y) const
y += alpha A x
Definition: bcrsmatrix.hh:1643
size_type getrowsize(size_type i) const
get current number of indices in row i
Definition: bcrsmatrix.hh:1087
size_type M() const
number of columns (counted in blocks)
Definition: bcrsmatrix.hh:1937
size_type n
Definition: bcrsmatrix.hh:1989
Imp::CompressedBlockVectorWindow< B, A > row_type
implement row_type with compressed vector
Definition: bcrsmatrix.hh:457
CreateIterator createbegin()
get initial create iterator
Definition: bcrsmatrix.hh:1056
BuildStage
Definition: bcrsmatrix.hh:429
@ rowSizesBuilt
The row sizes of the matrix are known.
Definition: bcrsmatrix.hh:440
@ built
The matrix structure is fully built.
Definition: bcrsmatrix.hh:442
@ notbuilt
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition: bcrsmatrix.hh:431
@ notAllocated
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition: bcrsmatrix.hh:433
@ building
Matrix is currently being built, some memory has been allocated, build mode and size are fixed.
Definition: bcrsmatrix.hh:435
BuildMode buildMode() const
The currently selected build mode of the matrix.
Definition: bcrsmatrix.hh:1958
void mmv(const X &x, Y &y) const
y -= A x
Definition: bcrsmatrix.hh:1620
void mv(const X &x, Y &y) const
y = A x
Definition: bcrsmatrix.hh:1571
B block_type
export the type representing the components
Definition: bcrsmatrix.hh:451
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: bcrsmatrix.hh:1704
size_type avg
Definition: bcrsmatrix.hh:2005
void umv(const X &x, Y &y) const
y += A x
Definition: bcrsmatrix.hh:1597
void implicit_allocate(size_type _n, size_type _m)
organizes allocation implicit mode calculates correct array size to be allocated and sets the the win...
Definition: bcrsmatrix.hh:2234
BCRSMatrix(size_type _n, size_type _m, BuildMode bm)
matrix with unknown number of nonzeroes
Definition: bcrsmatrix.hh:724
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1207
BCRSMatrix & operator-=(const BCRSMatrix &b)
Subtract the entries of another matrix from this one.
Definition: bcrsmatrix.hh:1526
BCRSMatrix & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bcrsmatrix.hh:1443
CompressionStatistics compress()
Finishes the buildstage in implicit mode.
Definition: bcrsmatrix.hh:1319
B & entry(size_type row, size_type col)
Returns reference to entry (row,col) of the matrix.
Definition: bcrsmatrix.hh:1255
void setDataPointers()
Set data pointers for all rows.
Definition: bcrsmatrix.hh:2062
std::allocator_traits< A >::template rebind_alloc< B > allocator_
Definition: bcrsmatrix.hh:1982
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1931
void setBuildMode(BuildMode bm)
Sets the build mode of the matrix.
Definition: bcrsmatrix.hh:792
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition: bcrsmatrix.hh:820
std::shared_ptr< size_type > j_
Definition: bcrsmatrix.hh:2002
void setWindowPointers(ConstRowIterator row)
Definition: bcrsmatrix.hh:2011
void setColumnPointers(ConstRowIterator row)
Copy row sizes from iterator range starting at row and set column index pointers for all rows.
Definition: bcrsmatrix.hh:2036
ConstIterator end() const
Get const iterator to one beyond last row.
Definition: bcrsmatrix.hh:677
ConstIterator begin() const
Get const iterator to first row.
Definition: bcrsmatrix.hh:671
void setImplicitBuildModeParameters(size_type _avg, double _overflow)
Set parameters needed for creation in implicit build mode.
Definition: bcrsmatrix.hh:848
A allocator_type
export the allocator type
Definition: bcrsmatrix.hh:454
ConstIterator beforeEnd() const
Definition: bcrsmatrix.hh:684
Iterator access to matrix rows
Definition: bcrsmatrix.hh:538
RealRowIterator()
empty constructor, use with care!
Definition: bcrsmatrix.hh:555
bool equals(const RealRowIterator< ValueType > &other) const
equality
Definition: bcrsmatrix.hh:583
std::remove_const< T >::type ValueType
The unqualified value type.
Definition: bcrsmatrix.hh:542
RealRowIterator(const RealRowIterator< ValueType > &it)
Definition: bcrsmatrix.hh:559
friend class RealRowIterator< const ValueType >
Definition: bcrsmatrix.hh:546
bool equals(const RealRowIterator< const ValueType > &other) const
equality
Definition: bcrsmatrix.hh:590
RealRowIterator(row_type *_p, size_type _i)
constructor
Definition: bcrsmatrix.hh:550
std::ptrdiff_t distanceTo(const RealRowIterator< const ValueType > &other) const
Definition: bcrsmatrix.hh:576
friend class RealRowIterator< ValueType >
Definition: bcrsmatrix.hh:547
size_type index() const
return index
Definition: bcrsmatrix.hh:565
std::ptrdiff_t distanceTo(const RealRowIterator< ValueType > &other) const
Definition: bcrsmatrix.hh:570
Iterator class for sequential creation of blocks
Definition: bcrsmatrix.hh:916
bool operator==(const CreateIterator &it) const
equality
Definition: bcrsmatrix.hh:1011
size_type index() const
The number of the row that the iterator currently points to.
Definition: bcrsmatrix.hh:1017
bool operator!=(const CreateIterator &it) const
inequality
Definition: bcrsmatrix.hh:1005
CreateIterator(BCRSMatrix &_Mat, size_type _i)
constructor
Definition: bcrsmatrix.hh:919
CreateIterator & operator++()
prefix increment
Definition: bcrsmatrix.hh:936
void insert(size_type j)
put column index in row
Definition: bcrsmatrix.hh:1023
bool contains(size_type j)
return true if column index is in row
Definition: bcrsmatrix.hh:1029
size_type size() const
Get the current row size.
Definition: bcrsmatrix.hh:1038
Class used by shared_ptr to deallocate memory using the proper allocator.
Definition: bcrsmatrix.hh:2149
Deallocator(typename std::allocator_traits< A >::template rebind_alloc< size_type > &sizeAllocator)
Definition: bcrsmatrix.hh:2153
void operator()(size_type *p)
Definition: bcrsmatrix.hh:2157
Error specific to BCRSMatrix.
Definition: istlexception.hh:21
The overflow error used during implicit BCRSMatrix construction was exhausted.
Definition: istlexception.hh:34
A generic dynamic dense matrix.
Definition: matrix.hh:558
A::size_type size_type
Type for indices and sizes.
Definition: matrix.hh:574
T block_type
Export the type representing the components.
Definition: matrix.hh:565
Definition: matrixutils.hh:536