|
dune-istl 2.12-git
|
Loading...
Searching...
No Matches
bcrsmatrix.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
176 DUNE_THROW(BCRSMatrixError,"You can only create an ImplicitBuilder for a matrix in implicit build mode");
178 DUNE_THROW(BCRSMatrixError,"You can only create an ImplicitBuilder for a matrix with set size that has not been compressed() yet");
196 ImplicitMatrixBuilder(Matrix& m, size_type rows, size_type cols, size_type avg_cols_per_row, double overflow_fraction)
200 DUNE_THROW(BCRSMatrixError,"You can only set up a matrix for this ImplicitBuilder if it has no memory allocated yet");
485 };
551 DUNE_THROW(BCRSMatrixError,"You cannot use operator[] in implicit build mode before calling compress()");
563 DUNE_THROW(BCRSMatrixError,"You cannot use operator[] in implicit build mode before calling compress()");
810 DUNE_THROW(InvalidStateException,"BCRSMatrix can only be copy-constructed when source matrix is completely empty (size not set) or fully built)");
839 if (ready == building && (build_mode == unknown || build_mode == random || build_mode == row_wise) && (bm == row_wise || bm == random))
842 DUNE_THROW(InvalidStateException, "Matrix structure cannot be changed at this stage anymore (ready == "<<ready<<").");
868 DUNE_THROW(Dune::BCRSMatrixError,"number of non-zeroes may not be set in implicit mode, use setImplicitBuildModeParameters() instead");
899 DUNE_THROW(InvalidStateException,"You cannot modify build mode parameters at this stage anymore");
915 if (!((ready == notAllocated || ready == built) && (Mat.ready == notAllocated || Mat.ready == built)))
916 DUNE_THROW(InvalidStateException,"BCRSMatrix can only be copied when both target and source are empty or fully built)");
970 DUNE_THROW(BCRSMatrixError,"creation only allowed if row wise allocation was requested in the constructor");
1294 dwarn << "WARNING: size of row "<< i.index()<<" is "<<j.offset()<<". But was specified as being "<< (*i).end().offset()
1295 <<". This means you are wasting valuable space and creating additional cache misses!"<<std::endl;
1397 DUNE_THROW(InvalidStateException,"You may only call compress() at the end of the 'building' stage");
1429 std::sort(perm.begin(),perm.end(), [](const size_type* l, const size_type* r){ return *l < *r; });
1444 "Please increase either the average number of entries per row or the compressionBufferSize value."
1459 "Please increase either the average number of entries per row or the compressionBufferSize value."
1524 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1552 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1585 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1607 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1632 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1652 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1678 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1701 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1724 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1747 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1762 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1806 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1829 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1852 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1875 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1900 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1923 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1943 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1963 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
1986 DUNE_THROW(BCRSMatrixError,"You can only call arithmetic operations on fully built BCRSMatrix instances");
2062 size_type allocationSize_; //allocated size of a and j arrays, except in implicit mode: nnz_==allocationsSize_
2085 // NOTE: If the original allocator A is stateful, the rebound allocators will share the same state as A, as they are rebound from A.
2086 using block_allocator_t = typename std::allocator_traits<A>::template rebind_alloc<block_type>;
2248 void allocate(size_type rows, size_type columns, size_type allocationSize, bool allocateRows, bool allocate_data)
2261 DUNE_THROW(InvalidStateException,"Rows have already been allocated, cannot allocate a second time");
2315 DUNE_THROW(InvalidStateException,"implicit_allocate() may only be called in implicit build mode");
2321 DUNE_THROW(InvalidStateException,"You have to set the implicit build mode parameters before starting to build the matrix");
Some handy generic functions for ISTL matrices.
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...
#define DUNE_NO_UNIQUE_ADDRESS
T & dereference() const
void decrement()
int size() const
reference elementAt(size_type i) const
void increment()
void advance(difference_type n)
void * allocate()
#define DUNE_THROW(E,...)
const_iterator find(int proc) const
DWarnType dwarn
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
T real_type
Definition matrixutils.hh:211
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:90
size_type overflow_total
total number of elements written to the overflow area during construction.
Definition bcrsmatrix.hh:96
size_type maximum
maximum number of non-zeroes per row.
Definition bcrsmatrix.hh:94
double avg
average number of non-zeroes per row.
Definition bcrsmatrix.hh:92
double mem_ratio
fraction of wasted memory resulting from non-used overflow area.
Definition bcrsmatrix.hh:101
A wrapper for uniform access to the BCRSMatrix during and after the build stage in implicit build mod...
Definition bcrsmatrix.hh:119
Matrix::block_type block_type
The block_type of the underlying matrix.
Definition bcrsmatrix.hh:127
ImplicitMatrixBuilder(Matrix &m)
Creates an ImplicitMatrixBuilder for matrix m.
Definition bcrsmatrix.hh:172
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:196
size_type M() const
The number of columns in the matrix.
Definition bcrsmatrix.hh:219
Matrix::size_type size_type
The size_type of the underlying matrix.
Definition bcrsmatrix.hh:130
row_object operator[](size_type i) const
Returns a proxy for entries in row i.
Definition bcrsmatrix.hh:207
size_type N() const
The number of rows in the matrix.
Definition bcrsmatrix.hh:213
Proxy row object for entry access.
Definition bcrsmatrix.hh:139
block_type & operator[](size_type j) const
Returns entry in column j.
Definition bcrsmatrix.hh:144
typename Imp::BlockTraits< B >::field_type field_type
export the type representing the field
Definition bcrsmatrix.hh:490
bool exists(size_type i, size_type j) const
return true if (i,j) is in pattern
Definition bcrsmatrix.hh:2043
BuildStage buildStage() const
The current build stage of the matrix.
Definition bcrsmatrix.hh:2029
void copyWindowStructure(const BCRSMatrix &Mat)
Copy the window structure from another matrix.
Definition bcrsmatrix.hh:2160
B & entry(size_type row, size_type col)
Returns reference to entry (row,col) of the matrix.
Definition bcrsmatrix.hh:1324
void usmhv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^H x
Definition bcrsmatrix.hh:1871
typename std::allocator_traits< A >::template rebind_alloc< size_type > size_allocator_t
Definition bcrsmatrix.hh:2088
RealRowIterator< const row_type > const_iterator
The const iterator over the matrix rows.
Definition bcrsmatrix.hh:705
std::allocator_traits< A >::size_type size_type
The type for the index access and the size.
Definition bcrsmatrix.hh:496
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:2248
BCRSMatrix & axpy(field_type alpha, const BCRSMatrix &b)
Add the scaled entries of another matrix to this one.
Definition bcrsmatrix.hh:1628
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition bcrsmatrix.hh:1941
void deallocate(bool deallocateRows=true)
deallocate memory of the matrix.
Definition bcrsmatrix.hh:2177
Iterator RowIterator
rename the iterators for easier access
Definition bcrsmatrix.hh:699
typename std::allocator_traits< A >::template rebind_alloc< row_type > row_allocator_t
Definition bcrsmatrix.hh:2087
row_type & operator[](size_type i)
random access to the rows
Definition bcrsmatrix.hh:547
void endrowsizes()
indicate that size of all rows is defined
Definition bcrsmatrix.hh:1153
typename std::allocator_traits< A >::template rebind_alloc< block_type > block_allocator_t
Definition bcrsmatrix.hh:2086
void incrementrowsize(size_type i, size_type s=1)
increment size of row i by s (1 by default)
Definition bcrsmatrix.hh:1142
size_type nonzeroes() const
number of blocks that are stored (the number of blocks that possibly are nonzero)
Definition bcrsmatrix.hh:2020
ConstIterator ConstRowIterator
rename the const row iterator for easier access
Definition bcrsmatrix.hh:736
void setIndicesNoSort(size_type row, It begin, It end)
Set all column indices for row from the given iterator range.
Definition bcrsmatrix.hh:1239
void setrowsize(size_type i, size_type s)
Set number of indices in row i to s.
Definition bcrsmatrix.hh:1121
BCRSMatrix & operator*=(const field_type &k)
vector space multiplication with scalar
Definition bcrsmatrix.hh:1520
RealRowIterator< row_type > iterator
The iterator over the (mutable matrix rows.
Definition bcrsmatrix.hh:669
void usmtv(const field_type &alpha, const X &x, Y &y) const
y += alpha A^T x
Definition bcrsmatrix.hh:1802
RealRowIterator< const row_type > ConstIterator
Definition bcrsmatrix.hh:706
@ implicit
Build entries randomly with an educated guess for the number of entries per row.
Definition bcrsmatrix.hh:537
BCRSMatrix(size_type _n, size_type _m, size_type _nnz, BuildMode bm)
matrix with known number of nonzeroes
Definition bcrsmatrix.hh:754
Imp::CompressedBlockVectorWindow< B, size_type > row_type
implement row_type with compressed vector
Definition bcrsmatrix.hh:499
::Dune::CompressionStatistics< size_type > CompressionStatistics
The type for the statistics object returned by compress()
Definition bcrsmatrix.hh:505
BCRSMatrix & operator-=(const BCRSMatrix &b)
Subtract the entries of another matrix from this one.
Definition bcrsmatrix.hh:1603
BCRSMatrix(const BCRSMatrix &Mat)
copy constructor
Definition bcrsmatrix.hh:804
void setIndices(size_type row, It begin, It end)
Set all column indices for row from the given iterator range.
Definition bcrsmatrix.hh:1262
void addindex(size_type row, size_type col)
add index (row,col) to the matrix
Definition bcrsmatrix.hh:1195
std::map< std::pair< size_type, size_type >, B > OverflowType
Definition bcrsmatrix.hh:2078
row_type::Iterator ColIterator
Iterator for the entries of each row.
Definition bcrsmatrix.hh:702
FieldTraits< field_type >::real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared values of entries)
Definition bcrsmatrix.hh:1913
BCRSMatrix & operator/=(const field_type &k)
vector space division by scalar
Definition bcrsmatrix.hh:1548
BCRSMatrix & operator+=(const BCRSMatrix &b)
Add the entries of another matrix to this one.
Definition bcrsmatrix.hh:1581
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:783
CreateIterator createend()
get create iterator pointing to one after the last block
Definition bcrsmatrix.hh:1107
FieldTraits< field_type >::real_type frobenius_norm2() const
square of frobenius norm, need for block recursion
Definition bcrsmatrix.hh:1896
row_type::ConstIterator ConstColIterator
Const iterator to the entries of a row.
Definition bcrsmatrix.hh:739
void usmv(F &&alpha, const X &x, Y &y) const
y += alpha A x
Definition bcrsmatrix.hh:1720
size_type getrowsize(size_type i) const
get current number of indices in row i
Definition bcrsmatrix.hh:1132
size_type M() const
number of columns (counted in blocks)
Definition bcrsmatrix.hh:2014
CreateIterator createbegin()
get initial create iterator
Definition bcrsmatrix.hh:1101
@ rowSizesBuilt
The row sizes of the matrix are known.
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:473
@ notAllocated
Matrix is not built at all, no memory has been allocated, build mode and size can still be set.
Definition bcrsmatrix.hh:475
@ building
Matrix is currently being built, some memory has been allocated, build mode and size are fixed.
Definition bcrsmatrix.hh:477
BuildMode buildMode() const
The currently selected build mode of the matrix.
Definition bcrsmatrix.hh:2035
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (row sum norm, how to generalize for blocks?)
Definition bcrsmatrix.hh:1921
B block_type
export the type representing the components
Definition bcrsmatrix.hh:493
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:2312
void setImplicitBuildModeParameters(size_type _avg, double compressionBufferSize)
Set parameters needed for creation in implicit build mode.
Definition bcrsmatrix.hh:888
BCRSMatrix(size_type _n, size_type _m, BuildMode bm)
matrix with unknown number of nonzeroes
Definition bcrsmatrix.hh:763
void endindices()
indicate that all indices are defined, check consistency
Definition bcrsmatrix.hh:1276
DUNE_NO_UNIQUE_ADDRESS allocator_type allocator_
Definition bcrsmatrix.hh:2082
CompressionStatistics compress()
Finishes the buildstage in implicit mode.
Definition bcrsmatrix.hh:1388
void setDataPointers()
Set data pointers for all rows.
Definition bcrsmatrix.hh:2141
size_type N() const
number of rows (counted in blocks)
Definition bcrsmatrix.hh:2008
void setBuildMode(BuildMode bm)
Sets the build mode of the matrix.
Definition bcrsmatrix.hh:832
void setSize(size_type rows, size_type columns, size_type nnz=0)
Set the size of the matrix.
Definition bcrsmatrix.hh:860
void setWindowPointers(ConstRowIterator row)
Definition bcrsmatrix.hh:2090
BCRSMatrix & operator=(const BCRSMatrix &Mat)
assignment
Definition bcrsmatrix.hh:910
void setColumnPointers(ConstRowIterator row)
Copy row sizes from iterator range starting at row and set column index pointers for all rows.
Definition bcrsmatrix.hh:2115
ConstIterator end() const
Get const iterator to one beyond last row.
Definition bcrsmatrix.hh:716
ConstIterator begin() const
Get const iterator to first row.
Definition bcrsmatrix.hh:710
RealRowIterator()
empty constructor, use with care!
Definition bcrsmatrix.hh:594
bool equals(const RealRowIterator< ValueType > &other) const
equality
Definition bcrsmatrix.hh:622
std::remove_const< T >::type ValueType
The unqualified value type.
Definition bcrsmatrix.hh:581
RealRowIterator(const RealRowIterator< ValueType > &it)
Definition bcrsmatrix.hh:598
bool equals(const RealRowIterator< const ValueType > &other) const
equality
Definition bcrsmatrix.hh:629
RealRowIterator(row_type *_p, size_type _i)
constructor
Definition bcrsmatrix.hh:589
std::ptrdiff_t distanceTo(const RealRowIterator< const ValueType > &other) const
Definition bcrsmatrix.hh:615
size_type index() const
return index
Definition bcrsmatrix.hh:604
std::ptrdiff_t distanceTo(const RealRowIterator< ValueType > &other) const
Definition bcrsmatrix.hh:609
Iterator class for sequential creation of blocks
Definition bcrsmatrix.hh:957
bool operator==(const CreateIterator &it) const
equality
Definition bcrsmatrix.hh:1056
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:1062
bool operator!=(const CreateIterator &it) const
inequality
Definition bcrsmatrix.hh:1050
CreateIterator(BCRSMatrix &_Mat, size_type _i)
constructor
Definition bcrsmatrix.hh:960
void insert(size_type j)
put column index in row
Definition bcrsmatrix.hh:1068
size_type size() const
Get the current row size.
Definition bcrsmatrix.hh:1083
bool contains(size_type j) const
return true if column index is in row
Definition bcrsmatrix.hh:1074
typename BCRSMatrix< B, A >::field_type field_type
Definition bcrsmatrix.hh:2346
typename FieldTraits< field_type >::real_type real_type
Definition bcrsmatrix.hh:2347
Thrown when the compression buffer used by the implicit BCRSMatrix construction is exhausted.
Definition istlexception.hh:37
T block_type
Export the type representing the components.
Definition matrix.hh:568
T accumulate(T... args)
T begin(T... args)
T clear(T... args)
T copy_backward(T... args)
T copy(T... args)
T deallocate(T... args)
T destroy(T... args)
T end(T... args)
T endl(T... args)
T find(T... args)
T get(T... args)
T lower_bound(T... args)
T make_pair(T... args)
T max(T... args)
T reset(T... args)
T resize(T... args)
T size(T... args)
T sort(T... args)
T visit(T... args)
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8