dune-pdelab  2.5-dev
patternstatistics.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil -*-
2 #ifndef DUNE_PDELAB_BACKEND_ISTL_PATTERNSTATISTICS_HH
3 #define DUNE_PDELAB_BACKEND_ISTL_PATTERNSTATISTICS_HH
4 
5 // this is here for backwards compatibility and deprecation warnings, remove after 2.5.0
6 #include "ensureistlinclude.hh"
7 
8 #include <iostream>
9 
10 namespace Dune {
11  namespace PDELab {
12  namespace ISTL {
13 
15  template<typename T>
17  {
18 
19  public:
20 
22  typedef T size_type;
23 
24 #ifndef DOXYGEN
25 
26  PatternStatistics(size_type nnz,
27  size_type longest_row,
28  size_type overflow_count,
29  size_type estimate,
30  size_type rows)
31  : _nnz(nnz)
32  , _longest_row(longest_row)
33  , _overflow_count(overflow_count)
34  , _estimate(estimate)
35  , _rows(rows)
36  {}
37 
38 #endif
39 
41  size_type nonZeros() const
42  {
43  return _nnz;
44  }
45 
47  size_type longestRow() const
48  {
49  return _longest_row;
50  }
51 
53  size_type overflowCount() const
54  {
55  return _overflow_count;
56  }
57 
59  size_type estimatedEntriesPerRow() const
60  {
61  return _estimate;
62  }
63 
65  size_type rows() const
66  {
67  return _rows;
68  }
69 
71  double averageEntriesPerRow() const
72  {
73  return static_cast<double>(_nnz) / _rows;
74  }
75 
76  friend std::ostream& operator<<(std::ostream& os, const PatternStatistics& s)
77  {
78  std::cout << "==== Pattern statistics ====" << std::endl
79  << "matrix rows: " << s.rows() << std::endl
80  << "nonzero entries: " << s.nonZeros() << std::endl
81  << "maximum number of nonzeros per row: " << s.longestRow() << std::endl
82  << "user-provided estimate of nonzeros per row: " << s.estimatedEntriesPerRow() << std::endl
83  << "average nonzeros per row: " << s.averageEntriesPerRow() << std::endl
84  << "number of entries in overflow area during setup: " << s.overflowCount() << std::endl;
85  return os;
86  }
87 
88  private:
89 
90  size_type _nnz;
91  size_type _longest_row;
92  size_type _overflow_count;
93  size_type _estimate;
94  size_type _rows;
95 
96  };
97 
98  } // namespace ISTL
99  } // namespace PDELab
100 } // namespace Dune
101 
102 #endif // DUNE_PDELAB_BACKEND_ISTL_PATTERNSTATISTICS_HH
double averageEntriesPerRow() const
The average number of nonzero entries per row, after matrix construction was completed.
Definition: patternstatistics.hh:71
size_type estimatedEntriesPerRow() const
The estimated number of nonzeros per row as provided by the user before pattern construction.
Definition: patternstatistics.hh:59
const std::string s
Definition: function.hh:1101
size_type overflowCount() const
The number of nonzero entries that had to be temporarily stored in the overflow area during pattern c...
Definition: patternstatistics.hh:53
size_type rows() const
The number of matrix rows.
Definition: patternstatistics.hh:65
size_type nonZeros() const
The total number of nonzero entries in the matrix.
Definition: patternstatistics.hh:41
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
T size_type
size_type of the associated BCRSMatrix.
Definition: patternstatistics.hh:22
friend std::ostream & operator<<(std::ostream &os, const PatternStatistics &s)
Definition: patternstatistics.hh:76
size_type longestRow() const
The maximum number of nonzero entries in any row of the matrix.
Definition: patternstatistics.hh:47
Statistics about the pattern of a BCRSMatrix.
Definition: patternstatistics.hh:16