6#ifndef DUNE_ISTL_BCRSMATRIX_HH
7#define DUNE_ISTL_BCRSMATRIX_HH
22#include <dune/common/stdstreams.hh>
23#include <dune/common/iteratorfacades.hh>
24#include <dune/common/typetraits.hh>
25#include <dune/common/ftraits.hh>
26#include <dune/common/scalarvectorview.hh>
27#include <dune/common/scalarmatrixview.hh>
77 struct MatrixDimension;
86 template<
typename size_type>
144 return _m.entry(_i,j);
173 if (m.buildMode() != Matrix::implicit)
174 DUNE_THROW(
BCRSMatrixError,
"You can only create an ImplicitBuilder for a matrix in implicit build mode");
175 if (m.buildStage() != Matrix::building)
176 DUNE_THROW(
BCRSMatrixError,
"You can only create an ImplicitBuilder for a matrix with set size that has not been compressed() yet");
197 if (m.buildStage() != Matrix::notAllocated)
198 DUNE_THROW(
BCRSMatrixError,
"You can only set up a matrix for this ImplicitBuilder if it has no memory allocated yet");
199 m.setBuildMode(Matrix::implicit);
200 m.setImplicitBuildModeParameters(avg_cols_per_row,overflow_fraction);
201 m.setSize(rows,cols);
464 template<
class B,
class A=std::allocator<B> >
497 typedef Imp::CompressedBlockVectorWindow<B,A>
row_type;
506 [[deprecated(
"Use free function blockLevel(). Will be removed after 2.8.")]]
507 static constexpr unsigned int blocklevel = blockLevel<B>()+1;
551#ifdef DUNE_ISTL_WITH_CHECKING
553 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
563#ifdef DUNE_ISTL_WITH_CHECKING
565 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
578 :
public RandomAccessIteratorFacade<RealRowIterator<T>, T>
650 void advance(std::ptrdiff_t diff)
655 T& elementAt(std::ptrdiff_t diff)
const
790 DUNE_THROW(
BCRSMatrixError,
"Only call this constructor when using the implicit build mode");
796 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative overflow fraction");
811 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copy-constructed when source matrix is completely empty (size not set) or fully built)");
843 DUNE_THROW(InvalidStateException,
"Matrix structure cannot be changed at this stage anymore (ready == "<<
ready<<
").");
869 DUNE_THROW(
Dune::BCRSMatrixError,
"number of non-zeroes may not be set in implicit mode, use setImplicitBuildModeParameters() instead");
877 allocate(rows, columns, nnz,
true,
false);
895 if (compressionBufferSize < 0.0)
896 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative compressionBufferSize value");
900 DUNE_THROW(InvalidStateException,
"You cannot modify build mode parameters at this stage anymore");
914 if (&Mat==
this)
return *
this;
917 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copied when both target and source are empty or fully built)");
924 if (
n>0 &&
n!=Mat.
n) {
926 for(
row_type *riter=
r+(
n-1), *rend=
r-1; riter!=rend; --riter)
947 DUNE_THROW(InvalidStateException,
"Scalar assignment only works on fully built BCRSMatrix)");
961 : Mat(_Mat), i(_i), nnz(0), current_row(nullptr, Mat.
j_.
get(), 0)
968 DUNE_THROW(
BCRSMatrixError,
"creation only allowed for uninitialized matrix");
970 DUNE_THROW(
BCRSMatrixError,
"creation only allowed if row wise allocation was requested in the constructor");
971 if(i==0 && _Mat.
N()==0)
1004 Mat.
r[i].set(s,
nullptr,current_row.getindexptr());
1005 current_row.setindexptr(current_row.getindexptr()+s);
1014 Mat.
r[i].set(s,b,j);
1018 Mat.
r[i].set(0,
nullptr,
nullptr);
1021 std::copy(pattern.cbegin(), pattern.cend(), Mat.
r[i].getindexptr());
1048 return (i!=it.i) || (&Mat!=&it.Mat);
1054 return (i==it.i) && (&Mat==&it.Mat);
1072 return pattern.find(j) != pattern.end();
1081 return pattern.size();
1088 typedef std::set<size_type,std::less<size_type> > PatternType;
1089 PatternType pattern;
1130#ifdef DUNE_ISTL_WITH_CHECKING
1134 return r[i].getsize();
1145 r[i].setsize(
r[i].getsize()+s);
1160 total +=
r[i].getsize();
1166 else if(
nnz_ < total)
1168 <<
"sufficient for calculated nonzeros ("<<total<<
"! ");
1200 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1206 size_type*
const first =
r[row].getindexptr();
1207 size_type*
const last = first +
r[row].getsize();
1213 if (pos!=last && *pos ==
col)
return;
1221 std::copy_backward(pos,
end,
end+1);
1233 template<
typename It>
1240 if ((col_end = std::copy(
begin,
end,
r[row].getindexptr())) != col_begin + row_size)
1243 <<
") does not match number of passed entries (" << (col_end - col_begin) <<
")");
1244 std::sort(col_begin,col_end);
1257 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1265 if (j.index() >=
m) {
1266 dwarn <<
"WARNING: size of row "<< i.index()<<
" is "<<j.offset()<<
". But was specified as being "<< (*i).end().offset()
1267 <<
". This means you are wasting valuable space and creating additional cache misses!"<<std::endl;
1268 nnz_ -= ((*i).end().offset() - j.offset());
1269 r[i.index()].setsize(j.offset());
1298#ifdef DUNE_ISTL_WITH_CHECKING
1302 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, use operator[] for entry access now");
1304 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1306 DUNE_THROW(InvalidStateException,
"You may only use entry() during the 'building' stage");
1323 std::ptrdiff_t offset = pos -
r[row].getindexptr();
1324 B* aptr =
r[row].getptr() + offset;
1330 if (
r[row].getsize() ==
avg)
1338 std::ptrdiff_t offset =
end -
r[row].getindexptr();
1339 B* apos =
r[row].getptr() + offset;
1342 r[row].setsize(
r[row].getsize()+1);
1365 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, no more need for compression");
1367 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1369 DUNE_THROW(InvalidStateException,
"You may only call compress() at the end of the 'building' stage");
1381 typename OverflowType::iterator oit =
overflow.begin();
1384 std::vector<size_type*> perm;
1396 typename std::vector<size_type*>::iterator it = perm.begin();
1404 r[i].setindexptr(jiit);
1407 for (it = perm.begin(); it != perm.end(); ++it)
1410 while ((oit!=
overflow.end()) && (oit->first < std::make_pair(i,**it)))
1415 "Allocated memory for BCRSMatrix exhausted during compress()!"
1416 "Please increase either the average number of entries per row or the compressionBufferSize value."
1419 *jiit = oit->first.second;
1421 *aiit = oit->second;
1424 r[i].setsize(
r[i].getsize()+1);
1430 "Allocated memory for BCRSMatrix exhausted during compress()!"
1431 "Please increase either the average number of entries per row or the compressionBufferSize value."
1437 B* apos = *it -
j_.get() +
a;
1443 while ((oit!=
overflow.end()) && (oit->first.first == i))
1448 "Allocated memory for BCRSMatrix exhausted during compress()!"
1449 "Please increase either the average number of entries per row or the compressionBufferSize value."
1453 *jiit = oit->first.second;
1455 *aiit = oit->second;
1458 r[i].setsize(
r[i].getsize()+1);
1470 std::ptrdiff_t diff = (
r[
n-1].getindexptr() +
r[
n-1].getsize() -
j_.get());
1472 stats.
avg = (double) (
nnz_) / (double)
n;
1486#ifdef DUNE_ISTL_WITH_CHECKING
1488 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1514#ifdef DUNE_ISTL_WITH_CHECKING
1516 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1547#ifdef DUNE_ISTL_WITH_CHECKING
1549 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1550 if(
N()!=b.
N() ||
M() != b.
M())
1551 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1569#ifdef DUNE_ISTL_WITH_CHECKING
1571 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1572 if(
N()!=b.
N() ||
M() != b.
M())
1573 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1594#ifdef DUNE_ISTL_WITH_CHECKING
1596 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1597 if(
N()!=b.
N() ||
M() != b.
M())
1598 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1611 template<
class X,
class Y>
1612 void mv (
const X& x, Y& y)
const
1614#ifdef DUNE_ISTL_WITH_CHECKING
1616 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1618 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" x: " << x.N());
1620 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" y: " << y.N());
1629 auto&& xj = Impl::asVector(x[j.index()]);
1630 auto&& yi = Impl::asVector(y[i.index()]);
1631 Impl::asMatrix(*j).umv(xj, yi);
1637 template<
class X,
class Y>
1638 void umv (
const X& x, Y& y)
const
1640#ifdef DUNE_ISTL_WITH_CHECKING
1642 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1652 auto&& xj = Impl::asVector(x[j.index()]);
1653 auto&& yi = Impl::asVector(y[i.index()]);
1654 Impl::asMatrix(*j).umv(xj,yi);
1660 template<
class X,
class Y>
1661 void mmv (
const X& x, Y& y)
const
1663#ifdef DUNE_ISTL_WITH_CHECKING
1665 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1675 auto&& xj = Impl::asVector(x[j.index()]);
1676 auto&& yi = Impl::asVector(y[i.index()]);
1677 Impl::asMatrix(*j).mmv(xj,yi);
1683 template<
class X,
class Y,
class F>
1684 void usmv (F&& alpha,
const X& x, Y& y)
const
1686#ifdef DUNE_ISTL_WITH_CHECKING
1688 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1698 auto&& xj = Impl::asVector(x[j.index()]);
1699 auto&& yi = Impl::asVector(y[i.index()]);
1700 Impl::asMatrix(*j).usmv(alpha,xj,yi);
1706 template<
class X,
class Y>
1707 void mtv (
const X& x, Y& y)
const
1709#ifdef DUNE_ISTL_WITH_CHECKING
1711 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1721 template<
class X,
class Y>
1724#ifdef DUNE_ISTL_WITH_CHECKING
1726 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1736 auto&& xi = Impl::asVector(x[i.index()]);
1737 auto&& yj = Impl::asVector(y[j.index()]);
1738 Impl::asMatrix(*j).umtv(xi,yj);
1744 template<
class X,
class Y>
1747#ifdef DUNE_ISTL_WITH_CHECKING
1757 auto&& xi = Impl::asVector(x[i.index()]);
1758 auto&& yj = Impl::asVector(y[j.index()]);
1759 Impl::asMatrix(*j).mmtv(xi,yj);
1765 template<
class X,
class Y>
1768#ifdef DUNE_ISTL_WITH_CHECKING
1770 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1780 auto&& xi = Impl::asVector(x[i.index()]);
1781 auto&& yj = Impl::asVector(y[j.index()]);
1782 Impl::asMatrix(*j).usmtv(alpha,xi,yj);
1788 template<
class X,
class Y>
1791#ifdef DUNE_ISTL_WITH_CHECKING
1793 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1803 auto&& xi = Impl::asVector(x[i.index()]);
1804 auto&& yj = Impl::asVector(y[j.index()]);
1805 Impl::asMatrix(*j).umhv(xi,yj);
1811 template<
class X,
class Y>
1814#ifdef DUNE_ISTL_WITH_CHECKING
1816 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1826 auto&& xi = Impl::asVector(x[i.index()]);
1827 auto&& yj = Impl::asVector(y[j.index()]);
1828 Impl::asMatrix(*j).mmhv(xi,yj);
1834 template<
class X,
class Y>
1837#ifdef DUNE_ISTL_WITH_CHECKING
1839 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1849 auto&& xi = Impl::asVector(x[i.index()]);
1850 auto&& yj = Impl::asVector(y[j.index()]);
1851 Impl::asMatrix(*j).usmhv(alpha,xi,yj);
1862#ifdef DUNE_ISTL_WITH_CHECKING
1864 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1867 typename FieldTraits<field_type>::real_type sum=0;
1869 for (
auto&& row : (*this))
1870 for (
auto&&
entry : row)
1871 sum += Impl::asMatrix(
entry).frobenius_norm2();
1884 typename std::enable_if<!HasNaN<ft>::value,
int>::type = 0>
1887 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1889 using real_type =
typename FieldTraits<ft>::real_type;
1893 for (
auto const &x : *
this) {
1895 for (
auto const &y : x)
1896 sum += Impl::asMatrix(y).infinity_norm();
1897 norm = max(sum, norm);
1904 typename std::enable_if<!HasNaN<ft>::value,
int>::type = 0>
1907 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1909 using real_type =
typename FieldTraits<ft>::real_type;
1913 for (
auto const &x : *
this) {
1915 for (
auto const &y : x)
1916 sum += Impl::asMatrix(y).infinity_norm_real();
1917 norm = max(sum, norm);
1924 typename std::enable_if<HasNaN<ft>::value,
int>::type = 0>
1927 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1929 using real_type =
typename FieldTraits<ft>::real_type;
1933 real_type isNaN = 1;
1934 for (
auto const &x : *
this) {
1936 for (
auto const &y : x)
1937 sum += Impl::asMatrix(y).infinity_norm();
1938 norm = max(sum, norm);
1942 return norm * (isNaN / isNaN);
1947 typename std::enable_if<HasNaN<ft>::value,
int>::type = 0>
1950 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1952 using real_type =
typename FieldTraits<ft>::real_type;
1956 real_type isNaN = 1;
1958 for (
auto const &x : *
this) {
1960 for (
auto const &y : x)
1961 sum += Impl::asMatrix(y).infinity_norm_real();
1962 norm = max(sum, norm);
1966 return norm * (isNaN / isNaN);
2009#ifdef DUNE_ISTL_WITH_CHECKING
2013 return (
r[i].size() &&
r[i].find(j) !=
r[i].
end());
2023 typename std::allocator_traits<A>::template rebind_alloc<B>
allocator_;
2025 typename std::allocator_traits<A>::template rebind_alloc<row_type>
rowAllocator_;
2043 std::shared_ptr<size_type>
j_;
2061 r[i].set(s,current_row.getptr(), current_row.getindexptr());
2063 current_row.setptr(current_row.getptr()+s);
2064 current_row.setindexptr(current_row.getindexptr()+s);
2067 r[i].set(0,
nullptr,
nullptr);
2087 r[i].setindexptr(jptr);
2090 r[i].set(0,
nullptr,
nullptr);
2108 if (
r[i].getsize() > 0) {
2113 r[i].set(0,
nullptr,
nullptr);
2117 aptr +=
r[i].getsize();
2161 if (
r[i].getsize()>0)
2163 for (B *
col=
r[i].getptr()+(
r[i].getsize()-1),
2164 *colend =
r[i].getptr()-1;
col!=colend; --
col) {
2171 r[i].set(0,
nullptr,
nullptr);
2176 if (
n>0 && deallocateRows &&
r) {
2177 for(
row_type *riter=
r+(
n-1), *rend=
r-1; riter!=rend; --riter)
2210 nnz_ = allocationSize;
2217 DUNE_THROW(InvalidStateException,
"Rows have already been allocated, cannot allocate a second time");
2236 alloc.deallocate(ptr, size);
2249 DUNE_THROW(InvalidStateException,
"Cannot allocate data array (already allocated)");
2268 DUNE_THROW(InvalidStateException,
"implicit_allocate() may only be called in implicit build mode");
2270 DUNE_THROW(InvalidStateException,
"memory has already been allocated");
2274 DUNE_THROW(InvalidStateException,
"You have to set the implicit build mode parameters before starting to build the matrix");
2283 B* aptr =
a + osize;
2286 r[i].set(0,aptr,jptr);
2296 template<
class B,
class A>
2300 using real_type =
typename FieldTraits<field_type>::real_type;
Helper functions for determining the vector/matrix block level.
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:351
Definition allocator.hh:11
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:293
Definition matrixutils.hh:211
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:88
size_type overflow_total
total number of elements written to the overflow area during construction.
Definition bcrsmatrix.hh:94
size_type maximum
maximum number of non-zeroes per row.
Definition bcrsmatrix.hh:92
double avg
average number of non-zeroes per row.
Definition bcrsmatrix.hh:90
double mem_ratio
fraction of wasted memory resulting from non-used overflow area.
Definition bcrsmatrix.hh:99
A wrapper for uniform access to the BCRSMatrix during and after the build stage in implicit build mod...
Definition bcrsmatrix.hh:117
Matrix::block_type block_type
The block_type of the underlying matrix.
Definition bcrsmatrix.hh:125
ImplicitMatrixBuilder(Matrix &m)
Creates an ImplicitMatrixBuilder for matrix m.
Definition bcrsmatrix.hh:170
M_ Matrix
The underlying matrix.
Definition bcrsmatrix.hh:122
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:194
size_type M() const
The number of columns in the matrix.
Definition bcrsmatrix.hh:217
Matrix::size_type size_type
The size_type of the underlying matrix.
Definition bcrsmatrix.hh:128
row_object operator[](size_type i) const
Returns a proxy for entries in row i.
Definition bcrsmatrix.hh:205
size_type N() const
The number of rows in the matrix.
Definition bcrsmatrix.hh:211
Proxy row object for entry access.
Definition bcrsmatrix.hh:137
block_type & operator[](size_type j) const
Returns entry in column j.
Definition bcrsmatrix.hh:142
A sparse block matrix with compressed row storage.
Definition bcrsmatrix.hh:466
typename Imp::BlockTraits< B >::field_type field_type
export the type representing the field
Definition bcrsmatrix.hh:488
std::allocator_traits< A >::template rebind_alloc< row_type > rowAllocator_
Definition bcrsmatrix.hh:2025
bool exists(size_type i, size_type j) const
return true if (i,j) is in pattern
Definition bcrsmatrix.hh:2007
BuildStage buildStage() const
The current build stage of the matrix.
Definition bcrsmatrix.hh:1993
Iterator begin()
Get iterator to first row.
Definition bcrsmatrix.hh:675
friend class CreateIterator
allow CreateIterator to access internal data
Definition bcrsmatrix.hh:1094
void copyWindowStructure(const BCRSMatrix &Mat)
Copy the window structure from another matrix.
Definition bcrsmatrix.hh:2122
B & entry(size_type row, size_type col)
Returns reference to entry (row,col) of the matrix.
Definition bcrsmatrix.hh:1296
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition bcrsmatrix.hh:1812
void usmhv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition bcrsmatrix.hh:1835
void umtv(const X &x, Y &y) const
y += A^T x
Definition bcrsmatrix.hh:1722
double compressionBufferSize_
Definition bcrsmatrix.hh:2047
size_type m
Definition bcrsmatrix.hh:2031
RealRowIterator< const row_type > const_iterator
The const iterator over the matrix rows.
Definition bcrsmatrix.hh:707
static constexpr unsigned int blocklevel
increment block level counter
Definition bcrsmatrix.hh:507
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:2205
BCRSMatrix & axpy(field_type alpha, const BCRSMatrix &b)
Add the scaled entries of another matrix to this one.
Definition bcrsmatrix.hh:1592
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition bcrsmatrix.hh:1905
~BCRSMatrix()
destructor
Definition bcrsmatrix.hh:824
void allocateData()
Definition bcrsmatrix.hh:2246
void deallocate(bool deallocateRows=true)
deallocate memory of the matrix.
Definition bcrsmatrix.hh:2139
Iterator RowIterator
rename the iterators for easier access
Definition bcrsmatrix.hh:701
row_type & operator[](size_type i)
random access to the rows
Definition bcrsmatrix.hh:549
BCRSMatrix()
an empty matrix
Definition bcrsmatrix.hh:749
void endrowsizes()
indicate that size of all rows is defined
Definition bcrsmatrix.hh:1149
void incrementrowsize(size_type i, size_type s=1)
increment size of row i by s (1 by default)
Definition bcrsmatrix.hh:1138
void mtv(const X &x, Y &y) const
y = A^T x
Definition bcrsmatrix.hh:1707
void umhv(const X &x, Y &y) const
y += A^H x
Definition bcrsmatrix.hh:1789
size_type nonzeroes() const
number of blocks that are stored (the number of blocks that possibly are nonzero)
Definition bcrsmatrix.hh:1984
size_type allocationSize_
Definition bcrsmatrix.hh:2033
ConstIterator ConstRowIterator
rename the const row iterator for easier access
Definition bcrsmatrix.hh:738
BuildStage ready
Definition bcrsmatrix.hh:2020
BuildMode build_mode
Definition bcrsmatrix.hh:2019
void setrowsize(size_type i, size_type s)
Set number of indices in row i to s.
Definition bcrsmatrix.hh:1117
RealRowIterator< row_type > Iterator
Definition bcrsmatrix.hh:672
size_type nnz_
Definition bcrsmatrix.hh:2032
BCRSMatrix & operator*=(const field_type &k)
vector space multiplication with scalar
Definition bcrsmatrix.hh:1484
std::allocator_traits< A >::template rebind_alloc< size_type > sizeAllocator_
Definition bcrsmatrix.hh:2027
RealRowIterator< row_type > iterator
The iterator over the (mutable matrix rows.
Definition bcrsmatrix.hh:671
void usmtv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition bcrsmatrix.hh:1766
ConstIterator beforeBegin() const
Definition bcrsmatrix.hh:732
RealRowIterator< const row_type > ConstIterator
Definition bcrsmatrix.hh:708
Iterator beforeBegin()
Definition bcrsmatrix.hh:695
B * a
Definition bcrsmatrix.hh:2040
BuildMode
we support two modes
Definition bcrsmatrix.hh:510
@ implicit
Build entries randomly with an educated guess for the number of entries per row.
Definition bcrsmatrix.hh:539
@ unknown
Build mode not set!
Definition bcrsmatrix.hh:543
@ random
Build entries randomly.
Definition bcrsmatrix.hh:530
@ row_wise
Build in a row-wise manner.
Definition bcrsmatrix.hh:521
BCRSMatrix(size_type _n, size_type _m, size_type _nnz, BuildMode bm)
matrix with known number of nonzeroes
Definition bcrsmatrix.hh:756
::Dune::CompressionStatistics< size_type > CompressionStatistics
The type for the statistics object returned by compress()
Definition bcrsmatrix.hh:503
BCRSMatrix & operator-=(const BCRSMatrix &b)
Subtract the entries of another matrix from this one.
Definition bcrsmatrix.hh:1567
BCRSMatrix(const BCRSMatrix &Mat)
copy constructor
Definition bcrsmatrix.hh:805
Iterator end()
Get iterator to one beyond last row.
Definition bcrsmatrix.hh:681
row_type * r
Definition bcrsmatrix.hh:2037
void setIndices(size_type row, It begin, It end)
Set all column indices for row from the given iterator range.
Definition bcrsmatrix.hh:1234
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition bcrsmatrix.hh:1191
std::map< std::pair< size_type, size_type >, B > OverflowType
Definition bcrsmatrix.hh:2049
row_type::Iterator ColIterator
Iterator for the entries of each row.
Definition bcrsmatrix.hh:704
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition bcrsmatrix.hh:1877
A::size_type size_type
The type for the index access and the size.
Definition bcrsmatrix.hh:500
BCRSMatrix & operator/=(const field_type &k)
vector space division by scalar
Definition bcrsmatrix.hh:1512
OverflowType overflow
Definition bcrsmatrix.hh:2050
BCRSMatrix & operator+=(const BCRSMatrix &b)
Add the entries of another matrix to this one.
Definition bcrsmatrix.hh:1545
BCRSMatrix(size_type _n, size_type _m, size_type _avg, double compressionBufferSize, BuildMode bm)
construct matrix with a known average number of entries per row
Definition bcrsmatrix.hh:784
CreateIterator createend()
get create iterator pointing to one after the last block
Definition bcrsmatrix.hh:1103
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition bcrsmatrix.hh:1860
Iterator beforeEnd()
Definition bcrsmatrix.hh:688
row_type::ConstIterator ConstColIterator
Const iterator to the entries of a row.
Definition bcrsmatrix.hh:741
void usmv(F &&alpha, const X &x, Y &y) const
y += alpha A x
Definition bcrsmatrix.hh:1684
size_type getrowsize(size_type i) const
get current number of indices in row i
Definition bcrsmatrix.hh:1128
size_type M() const
number of columns (counted in blocks)
Definition bcrsmatrix.hh:1978
size_type n
Definition bcrsmatrix.hh:2030
Imp::CompressedBlockVectorWindow< B, A > row_type
implement row_type with compressed vector
Definition bcrsmatrix.hh:497
CreateIterator createbegin()
get initial create iterator
Definition bcrsmatrix.hh:1097
BuildStage
Definition bcrsmatrix.hh:469
@ rowSizesBuilt
The row sizes of the matrix are known.
Definition bcrsmatrix.hh:480
@ built
The matrix structure is fully built.
Definition bcrsmatrix.hh:482
@ notbuilt
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition bcrsmatrix.hh:471
@ notAllocated
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition bcrsmatrix.hh:473
@ building
Matrix is currently being built, some memory has been allocated, build mode and size are fixed.
Definition bcrsmatrix.hh:475
BuildMode buildMode() const
The currently selected build mode of the matrix.
Definition bcrsmatrix.hh:1999
void mmv(const X &x, Y &y) const
y -= A x
Definition bcrsmatrix.hh:1661
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition bcrsmatrix.hh:1885
void mv(const X &x, Y &y) const
y = A x
Definition bcrsmatrix.hh:1612
B block_type
export the type representing the components
Definition bcrsmatrix.hh:491
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition bcrsmatrix.hh:1745
size_type avg
Definition bcrsmatrix.hh:2046
void umv(const X &x, Y &y) const
y += A x
Definition bcrsmatrix.hh:1638
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:2265
void setImplicitBuildModeParameters(size_type _avg, double compressionBufferSize)
Set parameters needed for creation in implicit build mode.
Definition bcrsmatrix.hh:889
BCRSMatrix(size_type _n, size_type _m, BuildMode bm)
matrix with unknown number of nonzeroes
Definition bcrsmatrix.hh:765
void endindices()
indicate that all indices are defined, check consistency
Definition bcrsmatrix.hh:1248
CompressionStatistics compress()
Finishes the buildstage in implicit mode.
Definition bcrsmatrix.hh:1360
void setDataPointers()
Set data pointers for all rows.
Definition bcrsmatrix.hh:2103
std::allocator_traits< A >::template rebind_alloc< B > allocator_
Definition bcrsmatrix.hh:2023
size_type N() const
number of rows (counted in blocks)
Definition bcrsmatrix.hh:1972
void setBuildMode(BuildMode bm)
Sets the build mode of the matrix.
Definition bcrsmatrix.hh:833
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition bcrsmatrix.hh:861
std::shared_ptr< size_type > j_
Definition bcrsmatrix.hh:2043
void setWindowPointers(ConstRowIterator row)
Definition bcrsmatrix.hh:2052
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition bcrsmatrix.hh:911
void setColumnPointers(ConstRowIterator row)
Copy row sizes from iterator range starting at row and set column index pointers for all rows.
Definition bcrsmatrix.hh:2077
ConstIterator end() const
Get const iterator to one beyond last row.
Definition bcrsmatrix.hh:718
ConstIterator begin() const
Get const iterator to first row.
Definition bcrsmatrix.hh:712
A allocator_type
export the allocator type
Definition bcrsmatrix.hh:494
ConstIterator beforeEnd() const
Definition bcrsmatrix.hh:725
Iterator access to matrix rows
Definition bcrsmatrix.hh:579
RealRowIterator()
empty constructor, use with care!
Definition bcrsmatrix.hh:596
bool equals(const RealRowIterator< ValueType > &other) const
equality
Definition bcrsmatrix.hh:624
std::remove_const< T >::type ValueType
The unqualified value type.
Definition bcrsmatrix.hh:583
RealRowIterator(const RealRowIterator< ValueType > &it)
Definition bcrsmatrix.hh:600
bool equals(const RealRowIterator< const ValueType > &other) const
equality
Definition bcrsmatrix.hh:631
RealRowIterator(row_type *_p, size_type _i)
constructor
Definition bcrsmatrix.hh:591
std::ptrdiff_t distanceTo(const RealRowIterator< const ValueType > &other) const
Definition bcrsmatrix.hh:617
size_type index() const
return index
Definition bcrsmatrix.hh:606
std::ptrdiff_t distanceTo(const RealRowIterator< ValueType > &other) const
Definition bcrsmatrix.hh:611
Iterator class for sequential creation of blocks
Definition bcrsmatrix.hh:957
bool operator==(const CreateIterator &it) const
equality
Definition bcrsmatrix.hh:1052
CreateIterator & operator++()
prefix increment
Definition bcrsmatrix.hh:977
size_type index() const
The number of the row that the iterator currently points to.
Definition bcrsmatrix.hh:1058
bool operator!=(const CreateIterator &it) const
inequality
Definition bcrsmatrix.hh:1046
CreateIterator(BCRSMatrix &_Mat, size_type _i)
constructor
Definition bcrsmatrix.hh:960
void insert(size_type j)
put column index in row
Definition bcrsmatrix.hh:1064
bool contains(size_type j)
return true if column index is in row
Definition bcrsmatrix.hh:1070
size_type size() const
Get the current row size.
Definition bcrsmatrix.hh:1079
typename BCRSMatrix< B, A >::field_type field_type
Definition bcrsmatrix.hh:2299
typename FieldTraits< field_type >::real_type real_type
Definition bcrsmatrix.hh:2300
Error specific to BCRSMatrix.
Definition istlexception.hh:24
Thrown when the compression buffer used by the implicit BCRSMatrix construction is exhausted.
Definition istlexception.hh:37
A generic dynamic dense matrix.
Definition matrix.hh:561
A::size_type size_type
Type for indices and sizes.
Definition matrix.hh:577
T block_type
Export the type representing the components.
Definition matrix.hh:568
Definition matrixutils.hh:538