BLROptions.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  */
31 #ifndef BLR_OPTIONS_HPP
32 #define BLR_OPTIONS_HPP
33 
34 #include <string>
35 #include <cassert>
36 
37 #include "dense/BLASLAPACKWrapper.hpp"
39 
40 namespace strumpack {
41 
42 
44  namespace BLR {
45 
46  template<typename real_t> inline real_t default_BLR_rel_tol() {
47  return real_t(1e-4);
48  }
49  template<typename real_t> inline real_t default_BLR_abs_tol() {
50  return real_t(1e-10);
51  }
52  template<> inline float default_BLR_rel_tol() {
53  return 1e-2;
54  }
55  template<> inline float default_BLR_abs_tol() {
56  return 1e-5;
57  }
58 
59  enum class LowRankAlgorithm { RRQR, ACA, BACA };
60  std::string get_name(LowRankAlgorithm a);
61 
62  enum class Admissibility { STRONG, WEAK };
63  std::string get_name(Admissibility a);
64 
65  enum class BLRFactorAlgorithm { RL, LL, COMB, STAR };
66  std::string get_name(BLRFactorAlgorithm a);
67 
68  enum class CBConstruction { COLWISE, DENSE };
69  std::string get_name(CBConstruction a);
70 
71  enum class CompressionKernel { HALF, FULL };
72  std::string get_name(CompressionKernel a);
73 
74 
84  template<typename scalar_t> class BLROptions
85  : public structured::StructuredOptions<scalar_t> {
86 
87  public:
88 
93  using real_t = typename RealType<scalar_t>::value_type;
94 
95  BLROptions() :
96  structured::StructuredOptions<scalar_t>(structured::Type::BLR) {
97  set_defaults();
98  }
99 
101  : structured::StructuredOptions<scalar_t>(sopts) {
102  this->type_ = structured::Type::BLR;
103  }
104 
105  void set_low_rank_algorithm(LowRankAlgorithm a) {
106  lr_algo_ = a;
107  }
108  void set_admissibility(Admissibility adm) { adm_ = adm; }
109  void set_BACA_blocksize(int B) {
110  assert(B > 0);
111  BACA_blocksize_ = B;
112  }
113  void set_BLR_factor_algorithm(BLRFactorAlgorithm a) {
114  blr_algo_ = a;
115  }
116  void set_CB_construction(CBConstruction a) {
117  cb_construction_ = a;
118  }
119  void set_compression_kernel(CompressionKernel a) {
120  crn_krnl_ = a;
121  }
122 
123  LowRankAlgorithm low_rank_algorithm() const { return lr_algo_; }
124  Admissibility admissibility() const { return adm_; }
125  int BACA_blocksize() const { return BACA_blocksize_; }
126  BLRFactorAlgorithm BLR_factor_algorithm() const { return blr_algo_; }
127  CBConstruction CB_construction() const { return cb_construction_; }
128  CompressionKernel compression_kernel() const { return crn_krnl_; }
129 
130  void set_from_command_line(int argc, const char* const* cargv) override;
131 
132  void describe_options() const override;
133 
134  private:
135  bool verbose_ = true;
136  LowRankAlgorithm lr_algo_ = LowRankAlgorithm::RRQR;
137  int BACA_blocksize_ = 4;
138  Admissibility adm_ = Admissibility::WEAK;
139  BLRFactorAlgorithm blr_algo_ = BLRFactorAlgorithm::RL;
140  CompressionKernel crn_krnl_ = CompressionKernel::HALF;
141  CBConstruction cb_construction_ = CBConstruction::DENSE;
142 
143  void set_defaults() {
144  this->rel_tol_ = default_BLR_rel_tol<real_t>();
145  this->abs_tol_ = default_BLR_abs_tol<real_t>();
146  this->leaf_size_ = 256;
147  this->max_rank_ = 5000;
148  }
149 
150  };
151 
152  } // end namespace BLR
153 } // end namespace strumpack
154 
155 
156 #endif // BLR_OPTIONS_HPP
Contains the class definition for StructuredOptions, as well as some routines to get default options,...
Class containing several options for the BLR code and data-structures.
Definition: BLROptions.hpp:85
Class containing several options for the StructuredMatrix code and data-structures.
Definition: StructuredOptions.hpp:106
Type
Definition: StructuredOptions.hpp:61
Definition: StrumpackOptions.hpp:42
std::string get_name(ReorderingStrategy method)