4 #ifndef DUNE_BCRSMATRIX_HH
5 #define DUNE_BCRSMATRIX_HH
19 #include <dune/common/shared_ptr.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/static_assert.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);
412 template<
class B,
class A=std::allocator<B> >
501 #ifdef DUNE_ISTL_WITH_CHECKING
503 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
506 if (r[i].getptr()==0) DUNE_THROW(
BCRSMatrixError,
"row not initialized yet");
514 #ifdef DUNE_ISTL_WITH_CHECKING
516 DUNE_THROW(
BCRSMatrixError,
"You cannot use operator[] in implicit build mode before calling compress()");
529 :
public RandomAccessIteratorFacade<RealRowIterator<T>, T>
601 void advance(std::ptrdiff_t diff)
606 T& elementAt(std::ptrdiff_t diff)
const
702 allocationSize(0), r(0), a(0),
703 avg(0), overflowsize(-1.0)
708 : build_mode(bm), ready(
notAllocated), n(0), m(0), nnz(0),
709 allocationSize(0), r(0), a(0),
710 avg(0), overflowsize(-1.0)
712 allocate(_n, _m, _nnz,
true,
false);
717 : build_mode(bm), ready(
notAllocated), n(0), m(0), nnz(0),
718 allocationSize(0), r(0), a(0),
719 avg(0), overflowsize(-1.0)
721 allocate(_n, _m,0,
true,
false);
736 : build_mode(bm), ready(
notAllocated), n(0), m(0), nnz(0),
737 allocationSize(0), r(0), a(0),
738 avg(_avg), overflowsize(_overflowsize)
741 DUNE_THROW(
BCRSMatrixError,
"Only call this constructor when using the implicit build mode");
746 if (_overflowsize < 0.0)
747 DUNE_THROW(
BCRSMatrixError,
"You cannot set a negative overflow fraction");
748 implicit_allocate(_n,_m);
757 : build_mode(Mat.build_mode), ready(
notAllocated), n(0), m(0), nnz(0),
758 allocationSize(0), r(0), a(0),
759 avg(Mat.avg), overflowsize(Mat.overflowsize)
762 DUNE_THROW(InvalidStateException,
"BCRSMatrix can only be copy-constructed when source matrix is completely empty (size not set) or fully built)");
776 allocate(Mat.n, Mat.m, _nnz,
true,
true);
779 copyWindowStructure(Mat);
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");
831 implicit_allocate(rows,columns);
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");
861 overflowsize = _overflow;
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)");
882 if (n>0 && n!=Mat.n) {
884 for(
row_type *riter=r+(n-1), *rend=r-1; riter!=rend; --riter)
885 rowAllocator_.destroy(riter);
886 rowAllocator_.deallocate(r,n);
898 allocate(Mat.n, Mat.m, nnz, n!=Mat.n,
true);
901 copyWindowStructure(Mat);
910 DUNE_THROW(InvalidStateException,
"Scalar assignment only works on fully built BCRSMatrix)");
924 : Mat(_Mat), i(_i), nnz(0), current_row(nullptr, Mat.j.
get(), 0)
931 DUNE_THROW(
BCRSMatrixError,
"creation only allowed for uninitialized matrix");
933 DUNE_THROW(
BCRSMatrixError,
"creation only allowed if row wise allocation was requested in the constructor");
969 B* a = Mat.allocator_.allocate(s);
973 size_type* j = Mat.sizeAllocator_.allocate(s);
983 for (
typename PatternType::const_iterator it=pattern.begin(); it!=pattern.end(); ++it)
1001 Mat.setDataPointers();
1011 return (i!=it.i) || (&Mat!=&it.Mat);
1017 return (i==it.i) && (&Mat==&it.Mat);
1035 if (pattern.find(j)!=pattern.end())
1047 return pattern.size();
1054 typedef std::set<size_type,std::less<size_type> > PatternType;
1055 PatternType pattern;
1091 #ifdef DUNE_ISTL_WITH_CHECKING
1106 r[i].
setsize(r[i].getsize()+s);
1126 allocate(n,m,total,
false,
false);
1128 DUNE_THROW(
BCRSMatrixError,
"Specified number of nonzeros ("<<nnz<<
") not "
1129 <<
"sufficient for calculated nonzeros ("<<total<<
"! ");
1132 setColumnPointers(
begin());
1161 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1171 size_type* pos = std::lower_bound(first,last,col);
1174 if (pos!=last && *pos == col)
return;
1182 std::copy_backward(pos,end,end+1);
1194 template<
typename It>
1201 if ((col_end = std::copy(begin,end,r[row].getindexptr())) != col_begin + row_size)
1204 <<
") does not match number of passed entries (" << (col_end - col_begin) <<
")");
1205 std::sort(col_begin,col_end);
1218 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1227 dwarn <<
"WARNING: size of row "<< i.
index()<<
" is "<<j.offset()<<
". But was specified as being "<< (*i).end().offset()
1228 <<
". This means you are wasting valuable space and creating additional cache misses!"<<std::endl;
1229 r[i.index()].
setsize(j.offset());
1258 #ifdef DUNE_ISTL_WITH_CHECKING
1262 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, use operator[] for entry access now");
1264 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1266 DUNE_THROW(InvalidStateException,
"You may only use entry() during the 'building' stage");
1277 size_type* pos = std::find(begin, end, col);
1290 if (r[row].getsize() == avg)
1291 return overflow[std::make_pair(row,col)];
1325 DUNE_THROW(
BCRSMatrixError,
"matrix already built up, no more need for compression");
1327 DUNE_THROW(
BCRSMatrixError,
"matrix size not set and no memory allocated yet");
1329 DUNE_THROW(InvalidStateException,
"You may only call compress() at the end of the 'building' stage");
1341 typename OverflowType::iterator oit = overflow.begin();
1344 std::vector<size_type*> perm;
1356 typename std::vector<size_type*>::iterator it = perm.begin();
1357 for (
size_type* iit = begin; iit < begin + size; ++iit, ++it)
1367 for (it = perm.begin(); it != perm.end(); ++it)
1370 while ((oit!=overflow.end()) && (oit->first < std::make_pair(i,**it)))
1375 "Allocated memory for BCRSMatrix exhausted during compress()!"
1376 "Please increase either the average number of entries per row or the overflow fraction."
1379 *jiit = oit->first.second;
1381 *aiit = oit->second;
1384 r[i].
setsize(r[i].getsize()+1);
1390 "Allocated memory for BCRSMatrix exhausted during compress()!"
1391 "Please increase either the average number of entries per row or the overflow fraction."
1397 B* apos = *it-j.get()+a;
1403 while ((oit!=overflow.end()) && (oit->first.first == i))
1408 "Allocated memory for BCRSMatrix exhausted during compress()!"
1409 "Please increase either the average number of entries per row or the overflow fraction."
1413 *jiit = oit->first.second;
1415 *aiit = oit->second;
1418 r[i].
setsize(r[i].getsize()+1);
1422 if (r[i].getsize()>stats.
maximum)
1432 stats.
avg = (double) (nnz) / (double) n;
1433 stats.
mem_ratio = (double) (nnz)/(double) allocationSize;
1446 #ifdef DUNE_ISTL_WITH_CHECKING
1448 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1474 #ifdef DUNE_ISTL_WITH_CHECKING
1476 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1507 #ifdef DUNE_ISTL_WITH_CHECKING
1509 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1510 if(
N()!=b.
N() ||
M() != b.
M())
1511 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1529 #ifdef DUNE_ISTL_WITH_CHECKING
1531 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1532 if(
N()!=b.
N() ||
M() != b.
M())
1533 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1554 #ifdef DUNE_ISTL_WITH_CHECKING
1556 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1557 if(
N()!=b.
N() ||
M() != b.
M())
1558 DUNE_THROW(RangeError,
"Matrix sizes do not match!");
1571 template<
class X,
class Y>
1572 void mv (
const X& x, Y& y)
const
1574 #ifdef DUNE_ISTL_WITH_CHECKING
1576 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1578 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" x: " << x.N());
1580 "Size mismatch: M: " <<
N() <<
"x" <<
M() <<
" y: " << y.N());
1588 (*j).umv(x[j.index()],y[i.index()]);
1593 template<
class X,
class Y>
1594 void umv (
const X& x, Y& y)
const
1596 #ifdef DUNE_ISTL_WITH_CHECKING
1598 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1607 (*j).umv(x[j.index()],y[i.index()]);
1612 template<
class X,
class Y>
1613 void mmv (
const X& x, Y& y)
const
1615 #ifdef DUNE_ISTL_WITH_CHECKING
1617 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1626 (*j).mmv(x[j.index()],y[i.index()]);
1631 template<
class X,
class Y>
1634 #ifdef DUNE_ISTL_WITH_CHECKING
1636 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1645 (*j).usmv(alpha,x[j.index()],y[i.index()]);
1650 template<
class X,
class Y>
1651 void mtv (
const X& x, Y& y)
const
1653 #ifdef DUNE_ISTL_WITH_CHECKING
1655 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1665 template<
class X,
class Y>
1668 #ifdef DUNE_ISTL_WITH_CHECKING
1670 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1679 (*j).umtv(x[i.index()],y[j.index()]);
1684 template<
class X,
class Y>
1687 #ifdef DUNE_ISTL_WITH_CHECKING
1696 (*j).mmtv(x[i.index()],y[j.index()]);
1701 template<
class X,
class Y>
1704 #ifdef DUNE_ISTL_WITH_CHECKING
1706 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1715 (*j).usmtv(alpha,x[i.index()],y[j.index()]);
1720 template<
class X,
class Y>
1723 #ifdef DUNE_ISTL_WITH_CHECKING
1725 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1734 (*j).umhv(x[i.index()],y[j.index()]);
1739 template<
class X,
class Y>
1742 #ifdef DUNE_ISTL_WITH_CHECKING
1744 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1753 (*j).mmhv(x[i.index()],y[j.index()]);
1758 template<
class X,
class Y>
1761 #ifdef DUNE_ISTL_WITH_CHECKING
1763 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1772 (*j).usmhv(alpha,x[i.index()],y[j.index()]);
1782 #ifdef DUNE_ISTL_WITH_CHECKING
1784 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1794 sum += (*j).frobenius_norm2();
1810 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1819 sum += (*j).infinity_norm();
1820 max = std::max(max,sum);
1828 #ifdef DUNE_ISTL_WITH_CHECKING
1830 DUNE_THROW(
BCRSMatrixError,
"You can only call arithmetic operations on fully built BCRSMatrix instances");
1840 sum += (*j).infinity_norm_real();
1841 max = std::max(max,sum);
1884 #ifdef DUNE_ISTL_WITH_CHECKING
1885 if (i<0 || i>=n) DUNE_THROW(
BCRSMatrixError,
"row index out of range");
1886 if (j<0 || j>=m) DUNE_THROW(
BCRSMatrixError,
"column index out of range");
1888 if (r[i].size() && r[i].find(j)!=r[i].
end())
1901 typename A::template rebind<B>::other allocator_;
1903 typename A::template rebind<row_type>::other rowAllocator_;
1905 typename A::template rebind<size_type>::other sizeAllocator_;
1921 Dune::shared_ptr<size_type> j;
1925 double overflowsize;
1927 typedef std::map<std::pair<size_type,size_type>, B> OverflowType;
1928 OverflowType overflow;
1939 r[i].
set(s,current_row.getptr(), current_row.getindexptr());
1941 current_row.setptr(current_row.getptr()+s);
1942 current_row.setindexptr(current_row.getindexptr()+s);
1981 void setDataPointers()
1986 if (r[i].getsize() > 0) {
2000 void copyWindowStructure(
const BCRSMatrix& Mat)
2002 setWindowPointers(Mat.begin());
2005 for (
size_type i=0; i<n; i++) r[i] = Mat.r[i];
2017 void deallocate(
bool deallocateRows=
true)
2023 if (allocationSize>0)
2029 for(B *aiter=a+(allocationSize-1), *aend=a-1; aiter!=aend; --aiter)
2030 allocator_.destroy(aiter);
2031 allocator_.deallocate(a,allocationSize);
2039 if (r[i].getsize()>0)
2041 for (B *
col=r[i].getptr()+(r[i].getsize()-1),
2042 *colend = r[i].getptr()-1;
col!=colend; --
col) {
2043 allocator_.destroy(
col);
2045 sizeAllocator_.deallocate(r[i].getindexptr(),1);
2046 allocator_.deallocate(r[i].getptr(),1);
2049 r[i].
set(0,
nullptr,
nullptr);
2054 if (n>0 && deallocateRows && r) {
2055 for(
row_type *riter=r+(n-1), *rend=r-1; riter!=rend; --riter)
2056 rowAllocator_.destroy(riter);
2057 rowAllocator_.deallocate(r,n);
2069 typename A::template rebind<size_type>::other& sizeAllocator_;
2072 Deallocator(
typename A::template rebind<size_type>::other& sizeAllocator)
2073 : sizeAllocator_(sizeAllocator)
2076 void operator()(
size_type* p) { sizeAllocator_.deallocate(p,1); }
2102 nnz = allocationSize_;
2103 allocationSize = allocationSize_;
2109 DUNE_THROW(InvalidStateException,
"Rows have already been allocated, cannot allocate a second time");
2110 r = rowAllocator_.allocate(rows);
2119 if (allocationSize>0) {
2122 j.reset(sizeAllocator_.allocate(allocationSize),Deallocator(sizeAllocator_));
2125 for(
row_type* ri=r; ri!=r+rows; ++ri)
2126 rowAllocator_.construct(ri,
row_type());
2136 DUNE_THROW(InvalidStateException,
"Cannot allocate data array (already allocated)");
2137 if (allocationSize>0) {
2138 a = allocator_.allocate(allocationSize);
2141 new (a) B[allocationSize];
2155 DUNE_THROW(InvalidStateException,
"implicit_allocate() may only be called in implicit build mode");
2157 DUNE_THROW(InvalidStateException,
"memory has already been allocated");
2160 if (overflowsize < 0)
2161 DUNE_THROW(InvalidStateException,
"You have to set the implicit build mode parameters before starting to build the matrix");
2164 allocationSize = _n*avg + osize;
2166 allocate(_n, _m, allocationSize,
true,
true);
2170 B* aptr = a + osize;
2173 r[i].
set(0,aptr,jptr);
B::field_type field_type
export the type representing the field
Definition: bcrsmatrix.hh:436
BCRSMatrix & axpy(field_type alpha, const BCRSMatrix &b)
Add the scaled entries of another matrix to this one.
Definition: bcrsmatrix.hh:1552
std::ptrdiff_t distanceTo(const RealRowIterator< const ValueType > &other) const
Definition: bcrsmatrix.hh:568
A::size_type size_type
Type for indices and sizes.
Definition: matrix.hh:41
size_type index() const
return index
Definition: bcrsmatrix.hh:557
A allocator_type
export the allocator type
Definition: bcrsmatrix.hh:442
row_object operator[](size_type i) const
Returns a proxy for entries in row i.
Definition: bcrsmatrix.hh:200
Error specific to BCRSMatrix.
Definition: istlexception.hh:19
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition: bcrsmatrix.hh:870
size_type M() const
number of columns (counted in blocks)
Definition: bcrsmatrix.hh:1856
BCRSMatrix(size_type _n, size_type _m, size_type _nnz, BuildMode bm)
matrix with known number of nonzeroes
Definition: bcrsmatrix.hh:707
~BCRSMatrix()
destructor
Definition: bcrsmatrix.hh:783
BuildStage buildStage() const
The current build stage of the matrix.
Definition: bcrsmatrix.hh:1868
friend class CreateIterator
allow CreateIterator to access internal data
Definition: bcrsmatrix.hh:1060
Proxy row object for entry access.
Definition: bcrsmatrix.hh:131
The overflow error used during implicit BCRSMatrix construction was exhausted.
Definition: istlexception.hh:32
BuildMode buildMode() const
The currently selected build mode of the matrix.
Definition: bcrsmatrix.hh:1874
ConstIterator end() const
Get const iterator to one beyond last row.
Definition: bcrsmatrix.hh:669
Iterator class for sequential creation of blocks
Definition: bcrsmatrix.hh:919
A::size_type size_type
The type for the index access and the size.
Definition: bcrsmatrix.hh:448
Build mode not set!
Definition: bcrsmatrix.hh:493
Build in a row-wise manner.
Definition: bcrsmatrix.hh:471
void set(size_type _n, B *_p, size_type *_j)
set size and pointer
Definition: bvector.hh:1025
size_type nonzeroes() const
number of blocks that are stored (the number of blocks that possibly are nonzero) ...
Definition: bcrsmatrix.hh:1862
FieldTraits< field_type >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bcrsmatrix.hh:1826
Matrix::block_type block_type
The block_type of the underlying matrix.
Definition: bcrsmatrix.hh:120
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition: bcrsmatrix.hh:1152
void usmhv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition: bcrsmatrix.hh:1759
This file implements a vector space as a tensor product of a given vector space. The number of compon...
CreateIterator createbegin()
get initial create iterator
Definition: bcrsmatrix.hh:1063
BCRSMatrix(size_type _n, size_type _m, BuildMode bm)
matrix with unknown number of nonzeroes
Definition: bcrsmatrix.hh:716
void setImplicitBuildModeParameters(size_type _avg, double _overflow)
Set parameters needed for creation in implicit build mode.
Definition: bcrsmatrix.hh:848
Some handy generic functions for ISTL matrices.
void mmhv(const X &x, Y &y) const
y -= A^H x
Definition: bcrsmatrix.hh:1740
CreateIterator & operator++()
prefix increment
Definition: bcrsmatrix.hh:937
Build entries randomly.
Definition: bcrsmatrix.hh:480
Definition: matrixutils.hh:486
void setindexptr(size_type *_j)
set pointer only
Definition: bvector.hh:1045
RealRowIterator< row_type > iterator
The iterator over the (mutable matrix rows.
Definition: bcrsmatrix.hh:622
std::ptrdiff_t distanceTo(const RealRowIterator< ValueType > &other) const
Definition: bcrsmatrix.hh:562
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
ConstIterator beforeEnd() const
Definition: bcrsmatrix.hh:676
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition: bcrsmatrix.hh:1780
B * getptr()
get pointer
Definition: bvector.hh:1051
void setIndices(size_type row, It begin, It end)
Set all column indices for row from the given iterator range.
Definition: bcrsmatrix.hh:1195
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:413
row_type & operator[](size_type i)
random access to the rows
Definition: bcrsmatrix.hh:499
Iterator end()
Get iterator to one beyond last row.
Definition: bcrsmatrix.hh:632
A generic dynamic dense matrix.
Definition: matrix.hh:24
CreateIterator(BCRSMatrix &_Mat, size_type _i)
constructor
Definition: bcrsmatrix.hh:923
size_type index() const
return index corresponding to pointer
Definition: basearray.hh:640
A wrapper for uniform access to the BCRSMatrix during and after the build stage in implicit build mod...
Definition: bcrsmatrix.hh:111
BCRSMatrix & operator+=(const BCRSMatrix &b)
Add the entries of another matrix to this one.
Definition: bcrsmatrix.hh:1505
The matrix structure is fully built.
Definition: bcrsmatrix.hh:430
Iterator beforeEnd()
Definition: bcrsmatrix.hh:639
row_type::ConstIterator ConstColIterator
Const iterator to the entries of a row.
Definition: bcrsmatrix.hh:692
RealRowIterator(row_type *_p, size_type _i)
constructor
Definition: bcrsmatrix.hh:542
RealRowIterator(const RealRowIterator< ValueType > &it)
Definition: bcrsmatrix.hh:551
size_type overflow_total
total number of elements written to the overflow area during construction.
Definition: bcrsmatrix.hh:89
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition: bcrsmatrix.hh:820
CompressionStatistics compress()
Finishes the buildstage in implicit mode.
Definition: bcrsmatrix.hh:1320
void setrowsize(size_type i, size_type s)
set number of indices in row i to s
Definition: bcrsmatrix.hh:1078
Definition: bcrsmatrix.hh:72
size_type N() const
number of rows (counted in blocks)
Definition: bcrsmatrix.hh:1850
bool exists(size_type i, size_type j) const
return true if (i,j) is in pattern
Definition: bcrsmatrix.hh:1882
Col col
Definition: matrixmatrix.hh:347
The row sizes of the matrix are known.
Definition: bcrsmatrix.hh:428
void umtv(const X &x, Y &y) const
y += A^T x
Definition: bcrsmatrix.hh:1666
size_type M() const
The number of columns in the matrix.
Definition: bcrsmatrix.hh:212
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition: bcrsmatrix.hh:1801
BCRSMatrix & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bcrsmatrix.hh:1444
void mv(const X &x, Y &y) const
y = A x
Definition: bcrsmatrix.hh:1572
size_type size() const
Get the current row size.
Definition: bcrsmatrix.hh:1045
remove_const< T >::type ValueType
The unqualified value type.
Definition: bcrsmatrix.hh:534
void endindices()
indicate that all indices are defined, check consistency
Definition: bcrsmatrix.hh:1209
block_type & operator[](size_type j) const
Returns entry in column j.
Definition: bcrsmatrix.hh:137
FieldTraits< field_type >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition: bcrsmatrix.hh:1807
Matrix & A
Definition: matrixmatrix.hh:216
size_type getrowsize(size_type i) const
get current number of indices in row i
Definition: bcrsmatrix.hh:1089
void setBuildMode(BuildMode bm)
Sets the build mode of the matrix.
Definition: bcrsmatrix.hh:792
bool operator==(const CreateIterator &it) const
equality
Definition: bcrsmatrix.hh:1015
double mem_ratio
fraction of wasted memory resulting from non-used overflow area.
Definition: bcrsmatrix.hh:94
iterator class for sequential access
Definition: basearray.hh:594
::Dune::CompressionStatistics< size_type > CompressionStatistics
The type for the statistics object returned by compress()
Definition: bcrsmatrix.hh:451
void incrementrowsize(size_type i, size_type s=1)
increment size of row i by s (1 by default)
Definition: bcrsmatrix.hh:1099
The number of blocklevels the matrix contains.
Definition: bcrsmatrix.hh:456
ConstIterator begin() const
Get const iterator to first row.
Definition: bcrsmatrix.hh:663
size_type * getindexptr()
get pointer
Definition: bvector.hh:1057
void usmtv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition: bcrsmatrix.hh:1702
MM_TYPE type
Definition: matrixmarket.hh:267
RealRowIterator< const row_type > const_iterator
The const iterator over the matrix rows.
Definition: bcrsmatrix.hh:658
RealRowIterator()
empty constructor, use with care!
Definition: bcrsmatrix.hh:547
void umhv(const X &x, Y &y) const
y += A^H x
Definition: bcrsmatrix.hh:1721
Build entries randomly with an educated guess on entries per row.
Definition: bcrsmatrix.hh:489
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:735
BCRSMatrix & operator-=(const BCRSMatrix &b)
Substract the entries of another matrix to this one.
Definition: bcrsmatrix.hh:1527
Row row
Definition: matrixmatrix.hh:345
void setsize(size_type _n)
set size only
Definition: bvector.hh:1033
ConstIterator beforeBegin() const
Definition: bcrsmatrix.hh:683
CreateIterator createend()
get create iterator pointing to one after the last block
Definition: bcrsmatrix.hh:1069
T block_type
Export the type representing the components.
Definition: matrix.hh:32
Iterator begin()
Get iterator to first row.
Definition: bcrsmatrix.hh:626
Matrix::size_type size_type
The size_type of the underlying matrix.
Definition: bcrsmatrix.hh:123
BCRSMatrix & operator/=(const field_type &k)
vector space division by scalar
Definition: bcrsmatrix.hh:1472
M_ Matrix
The underlying matrix.
Definition: bcrsmatrix.hh:117
B block_type
export the type representing the components
Definition: bcrsmatrix.hh:439
RealRowIterator< row_type > Iterator
Definition: bcrsmatrix.hh:623
void setptr(B *_p)
set pointer only
Definition: bvector.hh:1039
bool operator!=(const CreateIterator &it) const
inequality
Definition: bcrsmatrix.hh:1009
Statistics about compression achieved in implicit mode.
Definition: bcrsmatrix.hh:82
void umv(const X &x, Y &y) const
y += A x
Definition: bcrsmatrix.hh:1594
bool contains(size_type j)
return true if column index is in row
Definition: bcrsmatrix.hh:1033
bool equals(const RealRowIterator< ValueType > &other) const
equality
Definition: bcrsmatrix.hh:575
size_type maximum
maximum number of non-zeroes per row.
Definition: bcrsmatrix.hh:87
void mmtv(const X &x, Y &y) const
y -= A^T x
Definition: bcrsmatrix.hh:1685
ConstIterator ConstRowIterator
rename the const row iterator for easier access
Definition: bcrsmatrix.hh:689
B & entry(size_type row, size_type col)
Returns reference to entry (row,col) of the matrix.
Definition: bcrsmatrix.hh:1256
void usmv(const field_type &alpha, const X &x, Y &y) const
y += alpha A x
Definition: bcrsmatrix.hh:1632
row_type::Iterator ColIterator
Iterator for the entries of each row.
Definition: bcrsmatrix.hh:655
Iterator RowIterator
rename the iterators for easier access
Definition: bcrsmatrix.hh:652
bool equals(const RealRowIterator< const ValueType > &other) const
equality
Definition: bcrsmatrix.hh:582
Iterator beforeBegin()
Definition: bcrsmatrix.hh:646
BCRSMatrix(const BCRSMatrix &Mat)
copy constructor
Definition: bcrsmatrix.hh:756
void insert(size_type j)
put column index in row
Definition: bcrsmatrix.hh:1027
BCRSMatrix()
an empty matrix
Definition: bcrsmatrix.hh:700
BuildMode
we support two modes
Definition: bcrsmatrix.hh:460
ImplicitMatrixBuilder(Matrix &m)
Creates an ImplicitMatrixBuilder for matrix m.
Definition: bcrsmatrix.hh:165
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:766
CompressedBlockVectorWindow< B, A > row_type
implement row_type with compressed vector
Definition: bcrsmatrix.hh:445
BuildStage
Definition: bcrsmatrix.hh:417
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
size_type N() const
The number of rows in the matrix.
Definition: bcrsmatrix.hh:206
Matrix is not built at all, no memory has been allocated, build mode and size can still be set...
Definition: bcrsmatrix.hh:421
Matrix is currently being built, some memory has been allocated, build mode and size are fixed...
Definition: bcrsmatrix.hh:423
size_type getsize() const
get size
Definition: bvector.hh:1074
void endrowsizes()
indicate that size of all rows is defined
Definition: bcrsmatrix.hh:1110
size_type index() const
dereferencing
Definition: bcrsmatrix.hh:1021
double avg
average number of non-zeroes per row.
Definition: bcrsmatrix.hh:85
Definition: bvector.hh:925
RealRowIterator< const row_type > ConstIterator
Definition: bcrsmatrix.hh:659
void mmv(const X &x, Y &y) const
y -= A x
Definition: bcrsmatrix.hh:1613
Matrix is not built at all, no memory has been allocated, build mode and size can still be set...
Definition: bcrsmatrix.hh:419
void mtv(const X &x, Y &y) const
y = A^T x
Definition: bcrsmatrix.hh:1651
Iterator access to matrix rows
Definition: bcrsmatrix.hh:528