StructuredOptions.hpp
Go to the documentation of this file.
1 /*
2  * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3  * Regents of the University of California, through Lawrence Berkeley
4  * National Laboratory (subject to receipt of any required approvals
5  * from the U.S. Dept. of Energy). All rights reserved.
6  *
7  * If you have questions about your rights to use or distribute this
8  * software, please contact Berkeley Lab's Technology Transfer
9  * Department at TTD@lbl.gov.
10  *
11  * NOTICE. This software is owned by the U.S. Department of Energy. As
12  * such, the U.S. Government has been granted for itself and others
13  * acting on its behalf a paid-up, nonexclusive, irrevocable,
14  * worldwide license in the Software to reproduce, prepare derivative
15  * works, and perform publicly and display publicly. Beginning five
16  * (5) years after the date permission to assert copyright is obtained
17  * from the U.S. Department of Energy, and subject to any subsequent
18  * five (5) year renewals, the U.S. Government is granted for itself
19  * and others acting on its behalf a paid-up, nonexclusive,
20  * irrevocable, worldwide license in the Software to reproduce,
21  * prepare derivative works, distribute copies to the public, perform
22  * publicly and display publicly, and to permit others to do so.
23  *
24  * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25  * (Lawrence Berkeley National Lab, Computational Research
26  * Division).
27  */
32 #ifndef STRUCTURED_OPTIONS_HPP
33 #define STRUCTURED_OPTIONS_HPP
34 
35 #include <string>
36 #include <cassert>
37 
38 #include "dense/BLASLAPACKWrapper.hpp"
39 
40 namespace strumpack {
41  namespace structured {
42 
43  template<typename real_t> inline real_t default_structured_rel_tol() {
44  return real_t(1e-4);
45  }
46  template<typename real_t> inline real_t default_structured_abs_tol() {
47  return real_t(1e-10);
48  }
49  template<> inline float default_structured_rel_tol() {
50  return 1e-2;
51  }
52  template<> inline float default_structured_abs_tol() {
53  return 1e-5;
54  }
55 
60  enum class Type : int
61  {
62  HSS = 0,
64  BLR,
66  HODLR,
69  HODBF,
73  BUTTERFLY,
76  LR,
79  LOSSY,
80  LOSSLESS
81  };
82 
83  inline std::string get_name(Type a) {
84  switch (a) {
85  case Type::HSS: return "HSS";
86  case Type::BLR: return "BLR";
87  case Type::HODLR: return "HODLR";
88  case Type::HODBF: return "HODBF";
89  case Type::BUTTERFLY: return "BUTTERFLY";
90  case Type::LR: return "LR";
91  case Type::LOSSY: return "LOSSY";
92  case Type::LOSSLESS: return "LOSSLESS";
93  default: return "unknown";
94  }
95  }
96 
106  template<typename scalar_t> class StructuredOptions {
107  using real_t = typename RealType<scalar_t>::value_type;
108 
109  public:
110  StructuredOptions() {}
111  StructuredOptions(Type type) : type_(type) {}
112 
113  virtual ~StructuredOptions() {}
114 
115  void set_rel_tol(real_t rel_tol) {
116  assert(rel_tol <= real_t(1.) && rel_tol >= real_t(0.));
117  rel_tol_ = rel_tol;
118  }
119  void set_abs_tol(real_t abs_tol) {
120  assert(abs_tol >= real_t(0.));
121  abs_tol_ = abs_tol;
122  }
123  void set_leaf_size(int leaf_size) {
124  assert(leaf_size_ > 0);
125  leaf_size_ = leaf_size;
126  }
127  void set_max_rank(int max_rank) {
128  assert(max_rank > 0);
129  max_rank_ = max_rank;
130  }
131  void set_type(Type a) {
132  type_ = a;
133  }
134  void set_verbose(bool verbose) { verbose_ = verbose; }
135 
136  real_t rel_tol() const { return rel_tol_; }
137  real_t abs_tol() const { return abs_tol_; }
138  int leaf_size() const { return leaf_size_; }
139  int max_rank() const { return max_rank_; }
140  Type type() const { return type_; }
141  bool verbose() const { return verbose_; }
142 
143  virtual void set_from_command_line(int argc, const char* const* cargv);
144 
145  virtual void describe_options() const;
146 
147  protected:
148  Type type_ = Type::BLR;
149  real_t rel_tol_ = default_structured_rel_tol<real_t>();
150  real_t abs_tol_ = default_structured_abs_tol<real_t>();
151  int leaf_size_ = 128;
152  int max_rank_ = 5000;
153  bool verbose_ = true;
154  };
155 
156  } // end namespace structured
157 } // end namespace strumpack
158 
159 
160 #endif // STRUCTURED_OPTIONS_HPP
Class containing several options for the StructuredMatrix code and data-structures.
Definition: StructuredOptions.hpp:106
Type
Definition: StructuredOptions.hpp:61
Definition: StrumpackOptions.hpp:43
std::string get_name(ReorderingStrategy method)