iterative-solver 0.0
Statistics.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_STATISTICS_H_
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_STATISTICS_H_
3#include <molpro/linalg/itsolv/ArrayHandlers.h>
4#include <ostream>
5
10struct Statistics {
11 int iterations = 0;
12 int r_creations = 0;
13 int q_creations = 0;
14 int p_creations = 0;
15 int q_deletions = 0;
16 int d_creations = 0;
21 std::string rq_ops = "";
22 std::string qr_ops = "";
23 std::string rr_ops = "";
24 std::string qq_ops = "";
25 std::string rp_ops = "";
26 std::string qp_ops = "";
27};
28
29template <typename R, typename Q, typename P>
30void read_handler_counts(std::shared_ptr<Statistics> stats, std::shared_ptr<ArrayHandlers<R, Q, P>> handlers) {
31 stats->rr_ops = handlers->rr().counter_to_string("R", "R");
32 stats->qr_ops = handlers->qr().counter_to_string("Q", "R");
33 stats->rq_ops = handlers->rq().counter_to_string("R", "Q");
34 stats->qq_ops = handlers->qq().counter_to_string("Q", "Q");
35 stats->rp_ops = handlers->rp().counter_to_string("R", "P");
36 stats->qp_ops = handlers->qp().counter_to_string("Q", "P");
37}
38
39inline std::ostream& operator<<(std::ostream& o, const Statistics& statistics) {
40 if (statistics.iterations > 0)
41 o << statistics.iterations << " iterations, ";
42 if (statistics.r_creations > 0)
43 o << statistics.r_creations << " R vectors, ";
44 if (statistics.q_creations != statistics.r_creations)
45 o << statistics.q_creations << " Q creations, ";
46 if (statistics.q_deletions > 0)
47 o << statistics.q_deletions << " Q deletions, ";
48 if (statistics.p_creations > 0)
49 o << statistics.p_creations << " P vectors, ";
50 if (statistics.d_creations > 0)
51 o << statistics.d_creations << " D vectors, ";
52 if (statistics.best_r_creations > 0)
53 o << statistics.best_r_creations << " best R vectors, ";
54 if (statistics.current_r_creations > 0)
55 o << statistics.current_r_creations << " current R vectors, ";
56 if (statistics.line_searches > 0)
57 o << statistics.line_searches << " line searches, ";
58 if (statistics.line_search_steps > 0)
59 o << statistics.line_search_steps << " line search steps, ";
60 o << statistics.rr_ops << " ";
61 o << statistics.qr_ops << " ";
62 o << statistics.rq_ops << " ";
63 o << statistics.qq_ops << " ";
64 o << statistics.rp_ops << " ";
65 o << statistics.qp_ops;
66
67 return o;
68}
69} // namespace molpro::linalg::itsolv
70
71#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ITERATIVESOLVER_STATISTICS_H_
Class, containing a collection of array handlers used in IterativeSolver Provides a Builder sub-class...
Definition: ArrayHandlers.h:25
4-parameter interpolation of a 1-dimensional function given two points for which function values and ...
Definition: helper.h:10
std::ostream & operator<<(std::ostream &o, const Statistics &statistics)
Definition: Statistics.h:39
void read_handler_counts(std::shared_ptr< Statistics > stats, std::shared_ptr< ArrayHandlers< R, Q, P > > handlers)
Definition: Statistics.h:30
Information about performance of IterativeSolver instance.
Definition: Statistics.h:10
int p_creations
Definition: Statistics.h:14
int d_creations
Definition: Statistics.h:16
int best_r_creations
Definition: Statistics.h:17
int line_searches
Definition: Statistics.h:19
std::string rr_ops
Definition: Statistics.h:23
std::string qp_ops
Definition: Statistics.h:26
int iterations
Definition: Statistics.h:11
int line_search_steps
Definition: Statistics.h:20
std::string rp_ops
Definition: Statistics.h:25
std::string rq_ops
Definition: Statistics.h:21
int q_creations
Definition: Statistics.h:13
int r_creations
Definition: Statistics.h:12
std::string qr_ops
Definition: Statistics.h:22
int current_r_creations
Definition: Statistics.h:18
int q_deletions
Definition: Statistics.h:15
std::string qq_ops
Definition: Statistics.h:24