Go to the documentation of this file.
4 #ifndef DUNE_ISTL_BCRSMATRIX_HH
5 #define DUNE_ISTL_BCRSMATRIX_HH
19 #include <dune/common/stdstreams.hh>
20 #include <dune/common/iteratorfacades.hh>
21 #include <dune/common/typetraits.hh>
22 #include <dune/common/ftraits.hh>
23 #include <dune/common/scalarvectorview.hh>
24 #include <dune/common/scalarmatrixview.hh>
81 template<
typename size_type>
139 return _m.entry(_i,j);
168 if (m.buildMode() != Matrix::implicit)
169 DUNE_THROW(
BCRSMatrixError,
"You can only create an ImplicitBuilder for a matrix in implicit build mode");
170 if (m.buildStage() != Matrix::building)
171 DUNE_THROW(
BCRSMatrixError,
"You can only create an ImplicitBuilder for a matrix with set size that has not been compressed() yet");
192 if (m.buildStage() != Matrix::notAllocated)
193 DUNE_THROW(
BCRSMatrixError,
"You can only set up a matrix for this ImplicitBuilder if it has no memory allocated yet");
194 m.setBuildMode(Matrix::implicit);
195 m.setImplicitBuildModeParameters(avg_cols_per_row,overflow_fraction);
196 m.setSize(rows,cols);
423 template<
class B,
class A=std::allocator<B> >
456 typedef Imp::CompressedBlockVectorWindow<B,A>
row_type;
465 static constexpr
unsigned int blocklevel = Imp::BlockTraits<B>::blockLevel()+1;
509 #ifdef DUNE_ISTL_WITH_CHECKING
511 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
521 #ifdef DUNE_ISTL_WITH_CHECKING
523 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
536 :
public RandomAccessIteratorFacade<RealRowIterator<T>, T>
608 void advance(std::ptrdiff_t diff)
613 T& elementAt(std::ptrdiff_t diff)
const
748 DUNE_THROW(
BCRSMatrixError,
"Only call this constructor when using the implicit build mode");
753 if (_overflowsize < 0.0)
754 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative overflow fraction");
769 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copy-constructed when source matrix is completely empty (size not set) or fully built)");
801 DUNE_THROW(InvalidStateException,
"Matrix structure cannot be changed at this stage anymore (ready == "<<
ready<<
").");
827 DUNE_THROW(
Dune::BCRSMatrixError,
"number of non-zeroes may not be set in implicit mode, use setImplicitBuildModeParameters() instead");
835 allocate(rows, columns, nnz,
true,
false);
854 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative overflow fraction");
858 DUNE_THROW(InvalidStateException,
"You cannot modify build mode parameters at this stage anymore");
872 if (&Mat==
this)
return *
this;
875 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copied when both target and source are empty or fully built)");
882 if (
n>0 &&
n!=Mat.
n) {
884 for(
row_type *riter=
r+(
n-1), *rend=
r-1; riter!=rend; --riter)
905 DUNE_THROW(InvalidStateException,
"Scalar assignment only works on fully built BCRSMatrix)");
919 : Mat(_Mat), i(_i), nnz(0), current_row(nullptr, Mat.
j_.
get(), 0)
926 DUNE_THROW(
BCRSMatrixError,
"creation only allowed for uninitialized matrix");
928 DUNE_THROW(
BCRSMatrixError,
"creation only allowed if row wise allocation was requested in the constructor");
929 if(i==0 && _Mat.
N()==0)
962 Mat.
r[i].set(s,
nullptr,current_row.getindexptr());
963 current_row.setindexptr(current_row.getindexptr()+s);
976 Mat.
r[i].set(0,
nullptr,
nullptr);
979 std::copy(pattern.cbegin(), pattern.cend(), Mat.
r[i].getindexptr());
1006 return (i!=it.i) || (&Mat!=&it.Mat);
1012 return (i==it.i) && (&Mat==&it.Mat);
1030 return pattern.find(j) != pattern.end();
1039 return pattern.size();
1046 typedef std::set<size_type,std::less<size_type> > PatternType;
1047 PatternType pattern;
1088 #ifdef DUNE_ISTL_WITH_CHECKING
1092 return r[i].getsize();
1103 r[i].setsize(
r[i].getsize()+s);
1118 total +=
r[i].getsize();
1124 else if(
nnz_ < total)
1126 <<
"sufficient for calculated nonzeros ("<<total<<
"! ");
1158 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1164 size_type*
const first =
r[row].getindexptr();
1165 size_type*
const last = first +
r[row].getsize();
1171 if (pos!=last && *pos ==
col)
return;
1179 std::copy_backward(pos,
end,
end+1);
1191 template<
typename It>
1198 if ((col_end = std::copy(
begin,
end,
r[row].getindexptr())) != col_begin + row_size)
1201 <<
") does not match number of passed entries (" << (col_end - col_begin) <<
")");
1202 std::sort(col_begin,col_end);
1215 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1223 if (j.index() >=
m) {
1224 dwarn <<
"WARNING: size of row "<< i.index()<<
" is "<<j.offset()<<
". But was specified as being "<< (*i).end().offset()
1225 <<
". This means you are wasting valuable space and creating additional cache misses!"<<std::endl;
1226 nnz_ -= ((*i).end().offset() - j.offset());
1227 r[i.index()].setsize(j.offset());
1256 #ifdef DUNE_ISTL_WITH_CHECKING
1260 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, use operator[] for entry access now");
1262 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1264 DUNE_THROW(InvalidStateException,
"You may only use entry() during the 'building' stage");
1281 std::ptrdiff_t offset = pos -
r[row].getindexptr();
1282 B* aptr =
r[row].getptr() + offset;
1288 if (
r[row].getsize() ==
avg)
1296 std::ptrdiff_t offset =
end -
r[row].getindexptr();
1297 B* apos =
r[row].getptr() + offset;
1300 r[row].setsize(
r[row].getsize()+1);
1323 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, no more need for compression");
1325 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1327 DUNE_THROW(InvalidStateException,
"You may only call compress() at the end of the 'building' stage");
1339 typename OverflowType::iterator oit =
overflow.begin();
1342 std::vector<size_type*> perm;
1354 typename std::vector<size_type*>::iterator it = perm.begin();
1362 r[i].setindexptr(jiit);
1365 for (it = perm.begin(); it != perm.end(); ++it)
1368 while ((oit!=
overflow.end()) && (oit->first < std::make_pair(i,**it)))
1373 "Allocated memory for BCRSMatrix exhausted during compress()!"
1374 "Please increase either the average number of entries per row or the overflow fraction."
1377 *jiit = oit->first.second;
1379 *aiit = oit->second;
1382 r[i].setsize(
r[i].getsize()+1);
1388 "Allocated memory for BCRSMatrix exhausted during compress()!"
1389 "Please increase either the average number of entries per row or the overflow fraction."
1395 B* apos = *it -
j_.get() +
a;
1401 while ((oit!=
overflow.end()) && (oit->first.first == i))
1406 "Allocated memory for BCRSMatrix exhausted during compress()!"
1407 "Please increase either the average number of entries per row or the overflow fraction."
1411 *jiit = oit->first.second;
1413 *aiit = oit->second;
1416 r[i].setsize(
r[i].getsize()+1);
1428 std::ptrdiff_t diff = (
r[
n-1].getindexptr() +
r[
n-1].getsize() -
j_.get());
1430 stats.
avg = (double) (
nnz_) / (double)
n;
1444 #ifdef DUNE_ISTL_WITH_CHECKING
1446 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1472 #ifdef DUNE_ISTL_WITH_CHECKING
1474 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1505 #ifdef DUNE_ISTL_WITH_CHECKING
1507 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1508 if(
N()!=b.
N() ||
M() != b.
M())
1509 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1527 #ifdef DUNE_ISTL_WITH_CHECKING
1529 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1530 if(
N()!=b.
N() ||
M() != b.
M())
1531 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1552 #ifdef DUNE_ISTL_WITH_CHECKING
1554 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1555 if(
N()!=b.
N() ||
M() != b.
M())
1556 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1569 template<
class X,
class Y>
1570 void mv (
const X& x, Y& y)
const
1572 #ifdef DUNE_ISTL_WITH_CHECKING
1574 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1576 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" x: " << x.N());
1578 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" y: " << y.N());
1587 auto&& xj = Impl::asVector(x[j.index()]);
1588 auto&& yi = Impl::asVector(y[i.index()]);
1589 Impl::asMatrix(*j).umv(xj, yi);
1595 template<
class X,
class Y>
1596 void umv (
const X& x, Y& y)
const
1598 #ifdef DUNE_ISTL_WITH_CHECKING
1600 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1610 auto&& xj = Impl::asVector(x[j.index()]);
1611 auto&& yi = Impl::asVector(y[i.index()]);
1612 Impl::asMatrix(*j).umv(xj,yi);
1618 template<
class X,
class Y>
1619 void mmv (
const X& x, Y& y)
const
1621 #ifdef DUNE_ISTL_WITH_CHECKING
1623 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1633 auto&& xj = Impl::asVector(x[j.index()]);
1634 auto&& yi = Impl::asVector(y[i.index()]);
1635 Impl::asMatrix(*j).mmv(xj,yi);
1641 template<
class X,
class Y,
class F>
1642 void usmv (F&& alpha,
const X& x, Y& y)
const
1644 #ifdef DUNE_ISTL_WITH_CHECKING
1646 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1656 auto&& xj = Impl::asVector(x[j.index()]);
1657 auto&& yi = Impl::asVector(y[i.index()]);
1658 Impl::asMatrix(*j).usmv(alpha,xj,yi);
1664 template<
class X,
class Y>
1665 void mtv (
const X& x, Y& y)
const
1667 #ifdef DUNE_ISTL_WITH_CHECKING
1669 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1679 template<
class X,
class Y>
1682 #ifdef DUNE_ISTL_WITH_CHECKING
1684 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1694 auto&& xi = Impl::asVector(x[i.index()]);
1695 auto&& yj = Impl::asVector(y[j.index()]);
1696 Impl::asMatrix(*j).umtv(xi,yj);
1702 template<
class X,
class Y>
1705 #ifdef DUNE_ISTL_WITH_CHECKING
1715 auto&& xi = Impl::asVector(x[i.index()]);
1716 auto&& yj = Impl::asVector(y[j.index()]);
1717 Impl::asMatrix(*j).mmtv(xi,yj);
1723 template<
class X,
class Y>
1726 #ifdef DUNE_ISTL_WITH_CHECKING
1728 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1738 auto&& xi = Impl::asVector(x[i.index()]);
1739 auto&& yj = Impl::asVector(y[j.index()]);
1740 Impl::asMatrix(*j).usmtv(alpha,xi,yj);
1746 template<
class X,
class Y>
1749 #ifdef DUNE_ISTL_WITH_CHECKING
1751 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1761 auto&& xi = Impl::asVector(x[i.index()]);
1762 auto&& yj = Impl::asVector(y[j.index()]);
1763 Impl::asMatrix(*j).umhv(xi,yj);
1769 template<
class X,
class Y>
1772 #ifdef DUNE_ISTL_WITH_CHECKING
1774 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1784 auto&& xi = Impl::asVector(x[i.index()]);
1785 auto&& yj = Impl::asVector(y[j.index()]);
1786 Impl::asMatrix(*j).mmhv(xi,yj);
1792 template<
class X,
class Y>
1795 #ifdef DUNE_ISTL_WITH_CHECKING
1797 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1807 auto&& xi = Impl::asVector(x[i.index()]);
1808 auto&& yj = Impl::asVector(y[j.index()]);
1809 Impl::asMatrix(*j).usmhv(alpha,xi,yj);
1820 #ifdef DUNE_ISTL_WITH_CHECKING
1822 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1825 typename FieldTraits<field_type>::real_type sum=0;
1827 for (
auto&& row : (*
this))
1828 for (
auto&&
entry : row)
1829 sum += Impl::asMatrix(
entry).frobenius_norm2();
1842 typename std::enable_if<!HasNaN<ft>::value,
int>::type = 0>
1845 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1847 using real_type =
typename FieldTraits<ft>::real_type;
1851 for (
auto const &x : *
this) {
1853 for (
auto const &y : x)
1854 sum += Impl::asMatrix(y).infinity_norm();
1855 norm = max(sum, norm);
1862 typename std::enable_if<!HasNaN<ft>::value,
int>::type = 0>
1865 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1867 using real_type =
typename FieldTraits<ft>::real_type;
1871 for (
auto const &x : *
this) {
1873 for (
auto const &y : x)
1874 sum += Impl::asMatrix(y).infinity_norm_real();
1875 norm = max(sum, norm);
1882 typename std::enable_if<HasNaN<ft>::value,
int>::type = 0>
1885 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1887 using real_type =
typename FieldTraits<ft>::real_type;
1891 real_type isNaN = 1;
1892 for (
auto const &x : *
this) {
1894 for (
auto const &y : x)
1895 sum += Impl::asMatrix(y).infinity_norm();
1896 norm = max(sum, norm);
1900 return norm * (isNaN / isNaN);
1905 typename std::enable_if<HasNaN<ft>::value,
int>::type = 0>
1908 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1910 using real_type =
typename FieldTraits<ft>::real_type;
1914 real_type isNaN = 1;
1916 for (
auto const &x : *
this) {
1918 for (
auto const &y : x)
1919 sum += Impl::asMatrix(y).infinity_norm_real();
1920 norm = max(sum, norm);
1924 return norm * (isNaN / isNaN);
1967 #ifdef DUNE_ISTL_WITH_CHECKING
1971 return (
r[i].size() &&
r[i].find(j) !=
r[i].
end());
2001 std::shared_ptr<size_type>
j_;
2019 r[i].set(s,current_row.getptr(), current_row.getindexptr());
2021 current_row.setptr(current_row.getptr()+s);
2022 current_row.setindexptr(current_row.getindexptr()+s);
2025 r[i].set(0,
nullptr,
nullptr);
2045 r[i].setindexptr(jptr);
2048 r[i].set(0,
nullptr,
nullptr);
2066 if (
r[i].getsize() > 0) {
2071 r[i].set(0,
nullptr,
nullptr);
2075 aptr +=
r[i].getsize();
2119 if (
r[i].getsize()>0)
2121 for (B *
col=
r[i].getptr()+(
r[i].getsize()-1),
2122 *colend =
r[i].getptr()-1;
col!=colend; --
col) {
2129 r[i].set(0,
nullptr,
nullptr);
2134 if (
n>0 && deallocateRows &&
r) {
2135 for(
row_type *riter=
r+(
n-1), *rend=
r-1; riter!=rend; --riter)
2149 typename A::template rebind<size_type>::other& sizeAllocator_;
2152 Deallocator(
typename A::template rebind<size_type>::other& sizeAllocator)
2153 : sizeAllocator_(sizeAllocator)
2182 nnz_ = allocationSize;
2189 DUNE_THROW(InvalidStateException,
"Rows have already been allocated, cannot allocate a second time");
2217 DUNE_THROW(InvalidStateException,
"Cannot allocate data array (already allocated)");
2236 DUNE_THROW(InvalidStateException,
"implicit_allocate() may only be called in implicit build mode");
2238 DUNE_THROW(InvalidStateException,
"memory has already been allocated");
2242 DUNE_THROW(InvalidStateException,
"You have to set the implicit build mode parameters before starting to build the matrix");
2251 B* aptr =
a + osize;
2254 r[i].set(0,aptr,jptr);
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1206
RealRowIterator(const RealRowIterator< ValueType > &it)
Definition: bcrsmatrix.hh:558
void copyWindowStructure(const BCRSMatrix &Mat)
Copy the window structure from another matrix.
Definition: bcrsmatrix.hh:2080
RealRowIterator< const row_type > const_iterator
The const iterator over the matrix rows.
Definition: bcrsmatrix.hh:665
A::template rebind< row_type >::other rowAllocator_
Definition: bcrsmatrix.hh:1983
static constexpr unsigned int blocklevel
increment block level counter
Definition: bcrsmatrix.hh:465
A::template rebind< size_type >::other sizeAllocator_
Definition: bcrsmatrix.hh:1985
Deallocator(typename A::template rebind< size_type >::other &sizeAllocator)
Definition: bcrsmatrix.hh:2152
std::remove_const< T >::type ValueType
The unqualified value type.
Definition: bcrsmatrix.hh:541
Iterator beforeEnd()
Definition: bcrsmatrix.hh:646
ConstIterator begin() const
Get const iterator to first row.
Definition: bcrsmatrix.hh:670
CreateIterator(BCRSMatrix &_Mat, size_type _i)
constructor
Definition: bcrsmatrix.hh:918
CreateIterator createend()
get create iterator pointing to one after the last block
Definition: bcrsmatrix.hh:1061
B & entry(size_type row, size_type col)
Returns reference to entry (row,col) of the matrix.
Definition: bcrsmatrix.hh:1254
Col col
Definition: matrixmatrix.hh:349
void usmhv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: bcrsmatrix.hh:1793
std::ptrdiff_t distanceTo(const RealRowIterator< const ValueType > &other) const
Definition: bcrsmatrix.hh:575
Matrix::size_type size_type
The size_type of the underlying matrix.
Definition: bcrsmatrix.hh:123
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: bcrsmatrix.hh:1843
RealRowIterator< row_type > Iterator
Definition: bcrsmatrix.hh:630
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: bcrsmatrix.hh:1703
@ notAllocated
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition: bcrsmatrix.hh:432
size_type M() const
The number of columns in the matrix.
Definition: bcrsmatrix.hh:212
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:2233
RealRowIterator< const row_type > ConstIterator
Definition: bcrsmatrix.hh:666
void setDataPointers()
Set data pointers for all rows.
Definition: bcrsmatrix.hh:2061
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition: bcrsmatrix.hh:819
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:2177
void deallocate(bool deallocateRows=true)
deallocate memory of the matrix.
Definition: bcrsmatrix.hh:2097
size_type getrowsize(size_type i) const
get current number of indices in row i
Definition: bcrsmatrix.hh:1086
CreateIterator createbegin()
get initial create iterator
Definition: bcrsmatrix.hh:1055
bool equals(const RealRowIterator< ValueType > &other) const
equality
Definition: bcrsmatrix.hh:582
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: bcrsmatrix.hh:1770
Some handy generic functions for ISTL matrices.
BCRSMatrix & operator-=(const BCRSMatrix &b)
Subtract the entries of another matrix from this one.
Definition: bcrsmatrix.hh:1525
double overflowsize
Definition: bcrsmatrix.hh:2005
Class used by shared_ptr to deallocate memory using the proper allocator.
Definition: bcrsmatrix.hh:2147
bool contains(size_type j)
return true if column index is in row
Definition: bcrsmatrix.hh:1028
Iterator end()
Get iterator to one beyond last row.
Definition: bcrsmatrix.hh:639
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bcrsmatrix.hh:1863
std::shared_ptr< size_type > j_
Definition: bcrsmatrix.hh:2001
size_type m
Definition: bcrsmatrix.hh:1989
::Dune::CompressionStatistics< size_type > CompressionStatistics
The type for the statistics object returned by compress()
Definition: bcrsmatrix.hh:462
Iterator access to matrix rows
Definition: bcrsmatrix.hh:535
void usmtv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: bcrsmatrix.hh:1724
The overflow error used during implicit BCRSMatrix construction was exhausted.
Definition: istlexception.hh:32
size_type nonzeroes() const
number of blocks that are stored (the number of blocks that possibly are nonzero)
Definition: bcrsmatrix.hh:1942
BCRSMatrix & axpy(field_type alpha, const BCRSMatrix &b)
Add the scaled entries of another matrix to this one.
Definition: bcrsmatrix.hh:1550
A wrapper for uniform access to the BCRSMatrix during and after the build stage in implicit build mod...
Definition: bcrsmatrix.hh:111
Iterator beforeBegin()
Definition: bcrsmatrix.hh:653
void usmv(F &&alpha, const X &x, Y &y) const
y += alpha A x
Definition: bcrsmatrix.hh:1642
BCRSMatrix & operator/=(const field_type &k)
vector space division by scalar
Definition: bcrsmatrix.hh:1470
size_type nnz_
Definition: bcrsmatrix.hh:1990
BuildMode
we support two modes
Definition: bcrsmatrix.hh:468
BuildStage
Definition: bcrsmatrix.hh:428
@ implicit
Build entries randomly with an educated guess for the number of entries per row.
Definition: bcrsmatrix.hh:497
Iterator RowIterator
rename the iterators for easier access
Definition: bcrsmatrix.hh:659
std::ptrdiff_t distanceTo(const RealRowIterator< ValueType > &other) const
Definition: bcrsmatrix.hh:569
Imp::CompressedBlockVectorWindow< B, A > row_type
implement row_type with compressed vector
Definition: bcrsmatrix.hh:456
void setIndices(size_type row, It begin, It end)
Set all column indices for row from the given iterator range.
Definition: bcrsmatrix.hh:1192
A generic dynamic dense matrix.
Definition: matrix.hh:557
void mv(const X &x, Y &y) const
y = A x
Definition: bcrsmatrix.hh:1570
Definition: bcrsmatrix.hh:72
size_type allocationSize_
Definition: bcrsmatrix.hh:1991
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:189
ConstIterator beforeEnd() const
Definition: bcrsmatrix.hh:683
row_object operator[](size_type i) const
Returns a proxy for entries in row i.
Definition: bcrsmatrix.hh:200
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:742
size_type n
Definition: bcrsmatrix.hh:1988
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
@ unknown
Build mode not set!
Definition: bcrsmatrix.hh:501
CompressionStatistics compress()
Finishes the buildstage in implicit mode.
Definition: bcrsmatrix.hh:1318
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition: bcrsmatrix.hh:1149
bool operator!=(const CreateIterator &it) const
inequality
Definition: bcrsmatrix.hh:1004
BCRSMatrix(const BCRSMatrix &Mat)
copy constructor
Definition: bcrsmatrix.hh:763
row_type * r
Definition: bcrsmatrix.hh:1995
std::map< std::pair< size_type, size_type >, B > OverflowType
Definition: bcrsmatrix.hh:2007
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: bcrsmatrix.hh:1835
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition: bcrsmatrix.hh:869
A::size_type size_type
The type for the index access and the size.
Definition: bcrsmatrix.hh:459
bool operator==(const CreateIterator &it) const
equality
Definition: bcrsmatrix.hh:1010
size_type maximum
maximum number of non-zeroes per row.
Definition: bcrsmatrix.hh:87
BCRSMatrix(size_type _n, size_type _m, BuildMode bm)
matrix with unknown number of nonzeroes
Definition: bcrsmatrix.hh:723
friend class CreateIterator
allow CreateIterator to access internal data
Definition: bcrsmatrix.hh:1052
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: bcrsmatrix.hh:1818
void umv(const X &x, Y &y) const
y += A x
Definition: bcrsmatrix.hh:1596
void setrowsize(size_type i, size_type s)
Set number of indices in row i to s.
Definition: bcrsmatrix.hh:1075
void umhv(const X &x, Y &y) const
y += A^H x
Definition: bcrsmatrix.hh:1747
size_type avg
Definition: bcrsmatrix.hh:2004
void setWindowPointers(ConstRowIterator row)
Definition: bcrsmatrix.hh:2010
@ notbuilt
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition: bcrsmatrix.hh:430
size_type index() const
The number of the row that the iterator currently points to.
Definition: bcrsmatrix.hh:1016
A::template rebind< B >::other allocator_
Definition: bcrsmatrix.hh:1981
@ random
Build entries randomly.
Definition: bcrsmatrix.hh:488
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:424
bool exists(size_type i, size_type j) const
return true if (i,j) is in pattern
Definition: bcrsmatrix.hh:1965
size_type N() const
The number of rows in the matrix.
Definition: bcrsmatrix.hh:206
block_type & operator[](size_type j) const
Returns entry in column j.
Definition: bcrsmatrix.hh:137
void umtv(const X &x, Y &y) const
y += A^T x
Definition: bcrsmatrix.hh:1680
double mem_ratio
fraction of wasted memory resulting from non-used overflow area.
Definition: bcrsmatrix.hh:94
RealRowIterator(row_type *_p, size_type _i)
constructor
Definition: bcrsmatrix.hh:549
@ rowSizesBuilt
The row sizes of the matrix are known.
Definition: bcrsmatrix.hh:439
void insert(size_type j)
put column index in row
Definition: bcrsmatrix.hh:1022
BuildStage buildStage() const
The current build stage of the matrix.
Definition: bcrsmatrix.hh:1951
OverflowType overflow
Definition: bcrsmatrix.hh:2008
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1930
Definition: allocator.hh:7
void operator()(size_type *p)
Definition: bcrsmatrix.hh:2156
void incrementrowsize(size_type i, size_type s=1)
increment size of row i by s (1 by default)
Definition: bcrsmatrix.hh:1096
CreateIterator & operator++()
prefix increment
Definition: bcrsmatrix.hh:935
B * a
Definition: bcrsmatrix.hh:1998
A::size_type size_type
Type for indices and sizes.
Definition: matrix.hh:574
A allocator_type
export the allocator type
Definition: bcrsmatrix.hh:453
size_type M() const
number of columns (counted in blocks)
Definition: bcrsmatrix.hh:1936
@ built
The matrix structure is fully built.
Definition: bcrsmatrix.hh:441
ConstIterator ConstRowIterator
rename the const row iterator for easier access
Definition: bcrsmatrix.hh:696
size_type index() const
return index
Definition: bcrsmatrix.hh:564
Iterator class for sequential creation of blocks
Definition: bcrsmatrix.hh:914
ConstIterator beforeBegin() const
Definition: bcrsmatrix.hh:690
B block_type
export the type representing the components
Definition: bcrsmatrix.hh:450
BuildMode buildMode() const
The currently selected build mode of the matrix.
Definition: bcrsmatrix.hh:1957
BCRSMatrix & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bcrsmatrix.hh:1442
Proxy row object for entry access.
Definition: bcrsmatrix.hh:131
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1107
ImplicitMatrixBuilder(Matrix &m)
Creates an ImplicitMatrixBuilder for matrix m.
Definition: bcrsmatrix.hh:165
typename Imp::BlockTraits< B >::field_type field_type
export the type representing the field
Definition: bcrsmatrix.hh:447
Matrix::block_type block_type
The block_type of the underlying matrix.
Definition: bcrsmatrix.hh:120
BCRSMatrix & operator+=(const BCRSMatrix &b)
Add the entries of another matrix to this one.
Definition: bcrsmatrix.hh:1503
ConstIterator end() const
Get const iterator to one beyond last row.
Definition: bcrsmatrix.hh:676
void mmv(const X &x, Y &y) const
y -= A x
Definition: bcrsmatrix.hh:1619
size_type overflow_total
total number of elements written to the overflow area during construction.
Definition: bcrsmatrix.hh:89
Statistics about compression achieved in implicit mode.
Definition: bcrsmatrix.hh:82
row_type::ConstIterator ConstColIterator
Const iterator to the entries of a row.
Definition: bcrsmatrix.hh:699
BuildMode build_mode
Definition: bcrsmatrix.hh:1977
@ row_wise
Build in a row-wise manner.
Definition: bcrsmatrix.hh:479
RealRowIterator()
empty constructor, use with care!
Definition: bcrsmatrix.hh:554
size_type size() const
Get the current row size.
Definition: bcrsmatrix.hh:1037
void allocateData()
Definition: bcrsmatrix.hh:2214
RealRowIterator< row_type > iterator
The iterator over the (mutable matrix rows.
Definition: bcrsmatrix.hh:629
row_type::Iterator ColIterator
Iterator for the entries of each row.
Definition: bcrsmatrix.hh:662
Error specific to BCRSMatrix.
Definition: istlexception.hh:19
T block_type
Export the type representing the components.
Definition: matrix.hh:565
~BCRSMatrix()
destructor
Definition: bcrsmatrix.hh:782
@ building
Matrix is currently being built, some memory has been allocated, build mode and size are fixed.
Definition: bcrsmatrix.hh:434
BCRSMatrix(size_type _n, size_type _m, size_type _nnz, BuildMode bm)
matrix with known number of nonzeroes
Definition: bcrsmatrix.hh:714
void mtv(const X &x, Y &y) const
y = A^T x
Definition: bcrsmatrix.hh:1665
This file implements a vector space as a tensor product of a given vector space. The number of compon...
M_ Matrix
The underlying matrix.
Definition: bcrsmatrix.hh:117
Iterator begin()
Get iterator to first row.
Definition: bcrsmatrix.hh:633
void setColumnPointers(ConstRowIterator row)
Copy row sizes from iterator range starting at row and set column index pointers for all rows.
Definition: bcrsmatrix.hh:2035
void setBuildMode(BuildMode bm)
Sets the build mode of the matrix.
Definition: bcrsmatrix.hh:791
Definition: matrixutils.hh:535
BuildStage ready
Definition: bcrsmatrix.hh:1978
void setImplicitBuildModeParameters(size_type _avg, double _overflow)
Set parameters needed for creation in implicit build mode.
Definition: bcrsmatrix.hh:847
BCRSMatrix()
an empty matrix
Definition: bcrsmatrix.hh:707
bool equals(const RealRowIterator< const ValueType > &other) const
equality
Definition: bcrsmatrix.hh:589
row_type & operator[](size_type i)
random access to the rows
Definition: bcrsmatrix.hh:507
double avg
average number of non-zeroes per row.
Definition: bcrsmatrix.hh:85