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
40namespace 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 { COLWISE, RL, LL, COMB, STAR };
66 std::string get_name(BLRFactorAlgorithm a);
67
68 enum class CompressionKernel { HALF, FULL };
69 std::string get_name(CompressionKernel a);
70
71
81 template<typename scalar_t> class BLROptions
82 : public structured::StructuredOptions<scalar_t> {
83
84 public:
85
90 using real_t = typename RealType<scalar_t>::value_type;
91
92 BLROptions() :
93 structured::StructuredOptions<scalar_t>(structured::Type::BLR) {
94 set_defaults();
95 }
96
98 : structured::StructuredOptions<scalar_t>(sopts) {
99 this->type_ = structured::Type::BLR;
100 }
101
102 void set_low_rank_algorithm(LowRankAlgorithm a) {
103 lr_algo_ = a;
104 }
105 void set_admissibility(Admissibility adm) { adm_ = adm; }
106 void set_BACA_blocksize(int B) {
107 assert(B > 0);
108 BACA_blocksize_ = B;
109 }
110 void set_BLR_factor_algorithm(BLRFactorAlgorithm a) {
111 blr_algo_ = a;
112 }
113 void set_compression_kernel(CompressionKernel a) {
114 crn_krnl_ = a;
115 }
116
117 LowRankAlgorithm low_rank_algorithm() const { return lr_algo_; }
118 Admissibility admissibility() const { return adm_; }
119 int BACA_blocksize() const { return BACA_blocksize_; }
120 BLRFactorAlgorithm BLR_factor_algorithm() const { return blr_algo_; }
121 CompressionKernel compression_kernel() const { return crn_krnl_; }
122
123 void set_from_command_line(int argc, const char* const* cargv) override;
124
125 void describe_options() const override;
126
127 private:
128 bool verbose_ = true;
129 LowRankAlgorithm lr_algo_ = LowRankAlgorithm::RRQR;
130 int BACA_blocksize_ = 4;
131 Admissibility adm_ = Admissibility::WEAK;
132 BLRFactorAlgorithm blr_algo_ = BLRFactorAlgorithm::RL;
133 CompressionKernel crn_krnl_ = CompressionKernel::HALF;
134
135 void set_defaults() {
136 this->rel_tol_ = default_BLR_rel_tol<real_t>();
137 this->abs_tol_ = default_BLR_abs_tol<real_t>();
138 this->leaf_size_ = 256;
139 this->max_rank_ = 5000;
140 }
141
142 };
143
144 } // end namespace BLR
145} // end namespace strumpack
146
147
148#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:82
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)