MolSSI Integral Reference Project
All Classes Namespaces Files Functions Variables Typedefs Macros Pages
test_boys.hpp
Go to the documentation of this file.
1 /*! \file
2  *
3  * \brief Functions related to testing the Boys function
4  */
5 
6 #pragma once
7 
8 #include <arb.h>
9 #include <vector>
10 #include <string>
11 
12 namespace mirp {
13 
14 /*! \brief An single entry for a Boys function test */
16 {
17  int m; //!< The order of the Boys function
18  std::string t; //!< The value at which the function is evaluated
19  std::string value; //!< The expected (reference) value
20 };
21 
22 /*! \brief A collection of data for testing the Boys function */
23 struct boys_data
24 {
25  long ndigits; //!< The number of digits of accuracy in the file
26  long working_prec; //!< Working precision used for the integrals
27  std::string header; //!< Header or comments about the test
28  std::vector<boys_data_entry> entries; //!< Actual data for the tests
29 };
30 
31 
32 /*! \brief Finds the maximum value of `m` in a Boys test data structure */
33 int boys_max_m(const boys_data & data);
34 
35 
36 /*! \brief Read a file with reference data for the Boys function
37  *
38  * This reads in `m` and `t` entries for the Boys function, as
39  * well as a descriptive header.
40  *
41  * If \p is_input is true, then then `ndigits` and the reference
42  * entries are also read.
43  *
44  * \throw std::runtime_error if the file does not exist or there
45  * there is a problem reading/parsing the file
46  *
47  * \param [in] filepath Path to the file to read
48  * \param [in] is_input Set to true when reading an input file
49  * \return The data in the file
50  */
51 boys_data boys_read_file(const std::string & filepath, bool is_input);
52 
53 
54 /*! \brief Write a file with reference data for the Boys function
55  *
56  * This writes reference data files only. It can not be used to write
57  * input files.
58  *
59  * Any existing file will be overrwitten
60  *
61  * \throw std::runtime_error if there is a problem opening the file or there
62  * there is a problem writing the data
63  *
64  * \param [in] filepath Path to the file to write to
65  * \param [in] data The data to write to the file
66  */
67 void boys_write_file(const std::string & filepath, const boys_data & data);
68 
69 
70 /*! \brief Run a test of the Boys function
71  *
72  * \param [in] filepath Path to the file to test
73  * \param [in] floattype Type of floating point to test ("double", for example)
74  * \param [in] extra_m Additional `m` entries (used to test recurrence relations)
75  * \param [in] working_prec Internal working precision to use
76  * \return The number of tests that have failed
77  */
78 long boys_verify_test_main(const std::string & filepath,
79  const std::string & floattype,
80  int extra_m, slong working_prec);
81 
82 
83 /*! \brief Create a test file for the Boys function from a given input file
84  *
85  * Any existing output file (given by \p output_filepath) will be overwritten.
86  *
87  * \throw std::runtime_error if there is a problem opening the file or there
88  * there is a problem reading or writing the data
89  *
90  * \throw std::runtime_error if the working precision is not sufficient for
91  * the specified number of digits
92  *
93  * \param [in] input_filepath Path to the input file
94  * \param [in] output_filepath File to write the computed data to
95  * \param [in] working_prec Internal working precision to use
96  * \param [in] ndigits Number of decimal digits to compute
97  * \param [in] header Any descriptive header data
98  * (will be appended to the existing header in the input file)
99  */
100 void boys_create_test(const std::string & input_filepath,
101  const std::string & output_filepath,
102  slong working_prec, long ndigits,
103  const std::string & header);
104 
105 } // close namespace mirp
106 
void boys_create_test(const std::string &input_filepath, const std::string &output_filepath, slong working_prec, long ndigits, const std::string &header)
Create a test file for the Boys function from a given input file.
Definition: test_boys.cpp:276
std::vector< boys_data_entry > entries
Actual data for the tests.
Definition: test_boys.hpp:28
A collection of data for testing the Boys function.
Definition: test_boys.hpp:23
std::string header
Header or comments about the test.
Definition: test_boys.hpp:27
long boys_verify_test_main(const std::string &filepath, const std::string &floattype, int extra_m, slong working_prec)
Run a test of the Boys function.
Definition: test_boys.cpp:249
An single entry for a Boys function test.
Definition: test_boys.hpp:15
long ndigits
The number of digits of accuracy in the file.
Definition: test_boys.hpp:25
int m
The order of the Boys function.
Definition: test_boys.hpp:17
std::string value
The expected (reference) value.
Definition: test_boys.hpp:19
boys_data boys_read_file(const std::string &filepath, bool is_input)
Read a file with reference data for the Boys function.
Definition: test_boys.cpp:146
int boys_max_m(const boys_data &data)
Finds the maximum value of m in a Boys test data structure.
Definition: test_boys.cpp:137
void boys_write_file(const std::string &filepath, const boys_data &data)
Write a file with reference data for the Boys function.
Definition: test_boys.cpp:227
long working_prec
Working precision used for the integrals.
Definition: test_boys.hpp:26
std::string t
The value at which the function is evaluated.
Definition: test_boys.hpp:18