HODLROptions.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 HODLR_OPTIONS_HPP
33#define HODLR_OPTIONS_HPP
34
37
38namespace strumpack {
39
40 namespace HODLR {
41
49 template<typename real_t> inline real_t default_HODLR_rel_tol() {
50 return real_t(1e-4);
51 }
57 template<typename real_t> inline real_t default_HODLR_abs_tol() {
58 return real_t(1e-10);
59 }
60
68 template<> inline float default_HODLR_rel_tol() {
69 return 1e-2;
70 }
76 template<> inline float default_HODLR_abs_tol() {
77 return 1e-5;
78 }
79
88 };
89
96
104
105
106
116 template<typename scalar_t> class HODLROptions
117 : public structured::StructuredOptions<scalar_t> {
118
119 public:
124 using real_t = typename RealType<scalar_t>::value_type;
125
131 structured::StructuredOptions<scalar_t>(structured::Type::HODLR) {
132 set_defaults();
133 }
134
136 : structured::StructuredOptions<scalar_t>(sopts) {
137 this->type_ = structured::Type::HODLR;
138 }
139
144 assert(rank_guess > 0);
145 rank_guess_ = rank_guess;
146 }
147
153 assert(rank_rate > 0);
154 rank_rate_ = rank_rate;
155 }
156
162 clustering_algo_ = a;
163 }
164
169 compression_algo_ = a;
170 }
171
176 void set_butterfly_levels(int bfl) {
177 assert(bfl >= 0);
178 butterfly_levels_ = bfl;
179 }
180
184 void set_BACA_block_size(int BACA) {
185 assert(BACA > 0);
186 BACA_block_size_ = BACA;
187 }
188
193 void set_BF_sampling_parameter(double param) {
194 assert(param > 0);
195 BF_sampling_parameter_ = param;
196 }
197
204 void set_geo(int geo) {
205 assert(geo == 0 || geo == 1 || geo == 2 || geo == 3);
206 geo_ = geo;
207 }
208
215 assert(lr_leaf == 1 || lr_leaf == 2 || lr_leaf == 3 ||
216 lr_leaf == 4 || lr_leaf == 5);
217 lr_leaf_ = lr_leaf;
218 }
219
224 void set_knn_hodlrbf(int k) {
225 assert(k >= 0);
226 knn_hodlrbf_ = k;
227 }
228
233 void set_knn_lrbf(int k) {
234 assert(k >= 0);
235 knn_lrbf_ = k;
236 }
237
242 void set_less_adapt(bool l) { less_adapt_ = l; }
243
247 void set_BF_entry_n15(bool l) { BF_entry_n15_ = l; }
248
252 int rank_guess() const { return rank_guess_; }
253
258 double rank_rate() const { return rank_rate_; }
259
267 return clustering_algo_;
268 }
269
276 return compression_algo_;
277 }
278
283 int butterfly_levels() const { return butterfly_levels_; }
284
288 int BACA_block_size() const { return BACA_block_size_; }
289
293 double BF_sampling_parameter() const { return BF_sampling_parameter_; }
294
298 int geo() const { return geo_; }
299
303 int lr_leaf() const { return lr_leaf_; }
304
309 int knn_hodlrbf() const { return knn_hodlrbf_; }
310
315 int knn_lrbf() const { return knn_lrbf_; }
316
321 bool less_adapt() const { return less_adapt_; }
322
326 bool BF_entry_n15() const { return BF_entry_n15_; }
327
336 void set_from_command_line(int argc, const char* const* cargv) override;
337
342 void describe_options() const override;
343
344 private:
345 int rank_guess_ = 128;
346 double rank_rate_ = 2.;
348 int butterfly_levels_ = 0;
350 int BACA_block_size_ = 16;
351 double BF_sampling_parameter_ = 1.2;
352 int geo_ = 2;
353 int lr_leaf_ = 5;
354 int knn_hodlrbf_ = 64;
355 int knn_lrbf_ = 128;
356 bool less_adapt_ = true;
357 bool BF_entry_n15_ = false;
358
359 void set_defaults() {
360 this->type_ = structured::Type::HODLR;
361 this->rel_tol_ = default_HODLR_rel_tol<real_t>();
362 this->abs_tol_ = default_HODLR_abs_tol<real_t>();
363 this->leaf_size_ = 256;
364 this->max_rank_ = 50000;
365 }
366
367 };
368
369 } // end namespace HODLR
370} // end namespace strumpack
371
372
373#endif // HODLR_OPTIONS_HPP
Main include file for the different clustering/ordering codes. These ordering codes can be used to de...
Contains the class definition for StructuredOptions, as well as some routines to get default options,...
Class containing several options for the HODLR code and data-structures.
Definition: HODLROptions.hpp:117
ClusteringAlgorithm clustering_algorithm() const
Definition: HODLROptions.hpp:266
void set_knn_hodlrbf(int k)
Definition: HODLROptions.hpp:224
HODLROptions()
Definition: HODLROptions.hpp:130
bool less_adapt() const
Definition: HODLROptions.hpp:321
double rank_rate() const
Definition: HODLROptions.hpp:258
int butterfly_levels() const
Definition: HODLROptions.hpp:283
void set_BF_entry_n15(bool l)
Definition: HODLROptions.hpp:247
void set_rank_guess(int rank_guess)
Definition: HODLROptions.hpp:143
void set_rank_rate(double rank_rate)
Definition: HODLROptions.hpp:152
bool BF_entry_n15() const
Definition: HODLROptions.hpp:326
void set_BACA_block_size(int BACA)
Definition: HODLROptions.hpp:184
void set_butterfly_levels(int bfl)
Definition: HODLROptions.hpp:176
int BACA_block_size() const
Definition: HODLROptions.hpp:288
void set_lr_leaf(int lr_leaf)
Definition: HODLROptions.hpp:214
int geo() const
Definition: HODLROptions.hpp:298
void set_compression_algorithm(CompressionAlgorithm a)
Definition: HODLROptions.hpp:168
void set_less_adapt(bool l)
Definition: HODLROptions.hpp:242
void set_clustering_algorithm(ClusteringAlgorithm a)
Definition: HODLROptions.hpp:161
void set_knn_lrbf(int k)
Definition: HODLROptions.hpp:233
CompressionAlgorithm compression_algorithm() const
Definition: HODLROptions.hpp:275
int lr_leaf() const
Definition: HODLROptions.hpp:303
void set_geo(int geo)
Definition: HODLROptions.hpp:204
void set_from_command_line(int argc, const char *const *cargv) override
double BF_sampling_parameter() const
Definition: HODLROptions.hpp:293
int knn_lrbf() const
Definition: HODLROptions.hpp:315
int knn_hodlrbf() const
Definition: HODLROptions.hpp:309
void describe_options() const override
void set_BF_sampling_parameter(double param)
Definition: HODLROptions.hpp:193
int rank_guess() const
Definition: HODLROptions.hpp:252
Class containing several options for the StructuredMatrix code and data-structures.
Definition: StructuredOptions.hpp:106
CompressionAlgorithm
Definition: HODLROptions.hpp:85
std::string get_name(CompressionAlgorithm a)
real_t default_HODLR_abs_tol()
Definition: HODLROptions.hpp:57
CompressionAlgorithm get_compression_algorithm(const std::string &c)
real_t default_HODLR_rel_tol()
Definition: HODLROptions.hpp:49
Type
Definition: StructuredOptions.hpp:61
Definition: StrumpackOptions.hpp:43
ClusteringAlgorithm
Definition: Clustering.hpp:51