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 #include <iostream>
6 
7 namespace Dune {
8  namespace PDELab {
9  namespace ISTL {
10 
12  template<typename T>
14  {
15 
16  public:
17 
19  typedef T size_type;
20 
21 #ifndef DOXYGEN
22 
24  size_type longest_row,
25  size_type overflow_count,
26  size_type estimate,
28  : _nnz(nnz)
29  , _longest_row(longest_row)
30  , _overflow_count(overflow_count)
31  , _estimate(estimate)
32  , _rows(rows)
33  {}
34 
35 #endif
36 
39  {
40  return _nnz;
41  }
42 
45  {
46  return _longest_row;
47  }
48 
51  {
52  return _overflow_count;
53  }
54 
57  {
58  return _estimate;
59  }
60 
62  size_type rows() const
63  {
64  return _rows;
65  }
66 
68  double averageEntriesPerRow() const
69  {
70  return static_cast<double>(_nnz) / _rows;
71  }
72 
73  friend std::ostream& operator<<(std::ostream& os, const PatternStatistics& s)
74  {
75  std::cout << "==== Pattern statistics ====" << std::endl
76  << "matrix rows: " << s.rows() << std::endl
77  << "nonzero entries: " << s.nonZeros() << std::endl
78  << "maximum number of nonzeros per row: " << s.longestRow() << std::endl
79  << "user-provided estimate of nonzeros per row: " << s.estimatedEntriesPerRow() << std::endl
80  << "average nonzeros per row: " << s.averageEntriesPerRow() << std::endl
81  << "number of entries in overflow area during setup: " << s.overflowCount() << std::endl;
82  return os;
83  }
84 
85  private:
86 
87  size_type _nnz;
88  size_type _longest_row;
89  size_type _overflow_count;
90  size_type _estimate;
91  size_type _rows;
92 
93  };
94 
95  } // namespace ISTL
96  } // namespace PDELab
97 } // namespace Dune
98 
99 #endif // DUNE_PDELAB_BACKEND_ISTL_PATTERNSTATISTICS_HH
Dune::PDELab::ISTL::PatternStatistics::operator<<
friend std::ostream & operator<<(std::ostream &os, const PatternStatistics &s)
Definition: patternstatistics.hh:73
Dune::PDELab::ISTL::PatternStatistics::overflowCount
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:50
Dune::PDELab::ISTL::PatternStatistics::estimatedEntriesPerRow
size_type estimatedEntriesPerRow() const
The estimated number of nonzeros per row as provided by the user before pattern construction.
Definition: patternstatistics.hh:56
Dune
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::PDELab::ISTL::PatternStatistics::nonZeros
size_type nonZeros() const
The total number of nonzero entries in the matrix.
Definition: patternstatistics.hh:38
Dune::PDELab::ISTL::PatternStatistics::rows
size_type rows() const
The number of matrix rows.
Definition: patternstatistics.hh:62
Dune::PDELab::ISTL::PatternStatistics::size_type
T size_type
size_type of the associated BCRSMatrix.
Definition: patternstatistics.hh:19
Dune::PDELab::ISTL::PatternStatistics
Statistics about the pattern of a BCRSMatrix.
Definition: patternstatistics.hh:13
Dune::PDELab::ISTL::PatternStatistics::longestRow
size_type longestRow() const
The maximum number of nonzero entries in any row of the matrix.
Definition: patternstatistics.hh:44
Dune::PDELab::ISTL::PatternStatistics::averageEntriesPerRow
double averageEntriesPerRow() const
The average number of nonzero entries per row, after matrix construction was completed.
Definition: patternstatistics.hh:68
s
const std::string s
Definition: function.hh:830