File: options.h

package info (click to toggle)
normaliz 3.11.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 41,376 kB
  • sloc: cpp: 48,779; makefile: 2,266; sh: 1
file content (363 lines) | stat: -rw-r--r-- 9,365 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/*
 * Normaliz
 * Copyright (C) 2007-2025  W. Bruns, B. Ichim, Ch. Soeger, U. v. d. Ohe
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * As an exception, when this program is distributed through (i) the App Store
 * by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play
 * by Google Inc., then that store may impose any digital rights management,
 * device limits and/or redistribution restrictions that are required by its
 * terms of service.
 */

#ifndef NORMALIZ_OPTIONS_H
#define NORMALIZ_OPTIONS_H

#include "libnormaliz/general.h"
#include "libnormaliz/input_type.h"
#include "libnormaliz/output.h"

#include <vector>
#include <string>

#ifndef STRINGIFY
#define STRINGIFYx(Token) #Token
#define STRINGIFY(Token) STRINGIFYx(Token)
#endif

namespace libnormaliz {
using namespace std;

//---------------------------------------------------------------------------

class OptionsHandler {
   public:
    OptionsHandler();

    // returns true if a help should be printed, false otherwise
    // bool handle_commandline(int argc, char* argv[]);
    bool handle_commandline(vector<string> argv);

    // returns true if default mode was activated, false otherwise
    bool activateDefaultMode();

    template <typename Integer>
    void applyOutputOptions(Output<Integer>& Out);

    inline bool isFilenameSet() const {
        return project_name_set;
    }

    inline bool isIgnoreInFileOpt() const {
        return ignoreInFileOpt;
    }

    inline int getNrThreads() const {
        return nr_threads;
    }

    inline void activateConeProperty(ConeProperty::Enum cp) {
        to_compute.set(cp, true);
    }

    inline void activateInputFileConeProperty(ConeProperty::Enum cp) {
        if (!ignoreInFileOpt)
            to_compute.set(cp, true);
    }
    /* void activateInputFileBigInt() {
        if (!ignoreInFileOpt) use_Big_Integer = true;
    }*/
    inline void activateInputFileLongLong() {
        if (!ignoreInFileOpt)
            use_long_long = true;
    }

    inline void activateNoExtRaysOutput() {
        if (!ignoreInFileOpt)
            no_ext_rays_output = true;
    }

    inline void activateBinomialsPacked() {
        if (!ignoreInFileOpt)
            binomials_packed = true;
    }

    inline void activateNoMatricesOutput() {
        if (!ignoreInFileOpt)
            no_matrices_output = true;
    }
    inline void activateOutputOnInterrupt() {
        if (!ignoreInFileOpt)
            output_on_interrupt = true;
    }


    inline void activateNoSuppHypsOutput() {
        if (!ignoreInFileOpt)
            no_supp_hyps_output = true;
    }

    inline void activateNoHilbertBasisOutput() {
        if (!ignoreInFileOpt)
            no_hilbert_basis_output = true;
    }

    inline const ConeProperties& getToCompute() const {
        return to_compute;
    }

    /* bool isUseBigInteger() const {
        return use_Big_Integer;
    }*/
    inline bool isUseLongLong() const {
        return use_long_long;
    }

    inline bool isUseChunk() const {
        return use_chunk;
    }

    inline bool isUseCollectLat() const {
        return use_collect_lat;
    }
    inline bool isUseSaveLocalSolutions() const {
        return use_save_local_solutions;
    }

    inline bool isUseMakeFullInput() const {
        return use_make_full_input;
    }

    inline bool isUseAddChunks() const {
        return use_add_chunks;
    }

    inline bool isUseSplit() const {
        return use_split;
    }

    inline bool isNoExtRaysOutput() const {
        return no_ext_rays_output;
    }

    inline bool isBinomialsPacked() const {
        return binomials_packed;
    }
    inline bool isOutputOnInterrupt() const {
        return output_on_interrupt;
    }
    inline bool isNoMatricesOutput() const {
        return no_matrices_output;
    }


    inline bool isNoSuppHypsOutput() const {
        return no_supp_hyps_output;
    }

    inline bool isNoHilbertBasisOutput() const {
        return no_hilbert_basis_output;
    }

    inline const string& getProjectName() const {
        return project_name;
    }

    inline void setProjectName_from_list(const string& name){
        project_name = name;
        project_name_set = true;
    }

    inline const string& getOutputDir() const {
        return output_dir;
    }

    inline bool get_given_name_contains_in() const {
        return given_name_contains_in;
    }

    //---------------------------------------------------------------------------

   private:
    bool project_name_set;
    bool output_dir_set;
    string project_name;
    string output_dir;
    string output_file;

    // bool use_Big_Integer; now in ConeProperty
    bool use_long_long;
    bool use_chunk;
    bool use_collect_lat;
    bool use_save_local_solutions;
    bool use_make_full_input;
    bool use_add_chunks;
    bool no_ext_rays_output;
    bool no_supp_hyps_output;
    bool no_matrices_output;
    bool no_hilbert_basis_output;
    bool binomials_packed;
    bool use_split;
    bool given_name_contains_in;

    bool ignoreInFileOpt;

    int nr_threads;

    ConeProperties to_compute;

    bool write_extra_files, write_all_files;

    vector<string> OutFiles;

    // return true if help should be printed, false otherwise
    bool handle_options(vector<string>& LongOptions, string& ShortOptions);

    void setProjectName(const string& s);
    void setOutputDirName(const string& s);
};

//---------------------------------------------------------------------------

inline OptionsHandler::OptionsHandler() {
    project_name_set = false;
    output_dir_set = false;
    write_extra_files = false, write_all_files = false;
    // use_Big_Integer = false;
    use_long_long = false;
    use_chunk = false;
    use_collect_lat = false;
    use_save_local_solutions = false;
    use_add_chunks = false;
    ignoreInFileOpt = false;
    nr_threads = 0;
    no_ext_rays_output = false;
    no_supp_hyps_output = false;
    no_matrices_output = false;
    no_hilbert_basis_output = false;
    binomials_packed = false;
    use_split = false;
    use_make_full_input = false;
    given_name_contains_in = false;
}

template <typename Integer>
void OptionsHandler::applyOutputOptions(Output<Integer>& Out) {
    if (no_ext_rays_output)
        Out.set_no_ext_rays_output();
    if (no_supp_hyps_output)
        Out.set_no_supp_hyps_output();
    if (no_matrices_output)
        Out.set_no_matrices_output();
    if (no_hilbert_basis_output)
        Out.set_no_hilbert_basis_output();
    if (binomials_packed)
        Out.set_binomials_packed();
    if (write_all_files) {
        Out.set_write_all_files();
    }
    else if (write_extra_files) {
        Out.set_write_extra_files();
    }

    if (to_compute.test(ConeProperty::WritePreComp)) {
        Out.set_write_precomp(true);
    }

    for (const auto& OutFile : OutFiles) {
        if (OutFile == "gen") {
            Out.set_write_gen(true);
            continue;
        }
        if (OutFile == "cst") {
            Out.set_write_cst(true);
            continue;
        }
        if (OutFile == "inv") {
            Out.set_write_inv(true);
            continue;
        }
        if (OutFile == "ht1") {
            Out.set_write_ht1(true);
            continue;
        }
        if (OutFile == "ext") {
            Out.set_write_ext(true);
            continue;
        }
        if (OutFile == "egn") {
            Out.set_write_egn(true);
            continue;
        }
        if (OutFile == "esp") {
            Out.set_write_esp(true);
            continue;
        }
        if (OutFile == "typ") {
            Out.set_write_typ(true);
            continue;
        }
        if (OutFile == "lat") {
            Out.set_write_lat(true);
            continue;
        }
        if (OutFile == "msp") {
            Out.set_write_msp(true);
            continue;
        }
        if (OutFile == "precomp") {
            Out.set_write_precomp(true);
            continue;
        }
        if (OutFile == "mod") {
            Out.set_write_mod(true);
            continue;
        }
    }

    if (!project_name_set) {
        cerr << "ERROR: No project name set!" << endl;
        exit(1);
    }
    Out.set_name(output_file);
}

string pureName(const string& fullName);

inline string package_string() {
    string optional_packages;

#ifdef NMZ_COCOA
    optional_packages += " CoCoALib";
#endif
#ifdef NMZ_FLINT
#ifndef ENFNORMALIZ
    optional_packages += " Flint";
#endif
#endif
#ifdef ENFNORMALIZ
    optional_packages += " Flint e-antic";
#endif
#ifdef NMZ_NAUTY
    optional_packages += " nauty";
#endif
#ifdef NMZ_HASHLIBRARY
    optional_packages += " hash-library";
#endif
    return optional_packages;
}

}  // namespace libnormaliz

#endif  // NMZ_OPTIONS_H