From 41cc11691aea5f642e17db187504be64728c2afe Mon Sep 17 00:00:00 2001 From: Carlos Mejuto Zaera Date: Fri, 22 Sep 2023 10:19:50 +0200 Subject: [PATCH] Added option to read in vectors of ints and bools from input file, to be used in GF calculation. --- tests/ini_input.cxx | 42 +++++++++++++++++++++++++++++++++++++ tests/standalone_driver.cxx | 10 ++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/tests/ini_input.cxx b/tests/ini_input.cxx index bee88cb1..58581a66 100644 --- a/tests/ini_input.cxx +++ b/tests/ini_input.cxx @@ -7,6 +7,7 @@ */ #include "ini_input.hpp" +#include // Misc string functions @@ -329,6 +330,25 @@ int INIFile::getData(std::string query) { } // INIFile::getData +/** + * \brief Specialization of getData to return vector of query + * data field + * + * \param [in] query Formatted query string to be parsed + * \return Value of query data field as a vector + */ +template <> +std::vector INIFile::getData(std::string query) { + std::string line = getData(query); + std::istringstream iss( line ); + std::vector res; + int tmp; + while( iss >> tmp ) + res.push_back(tmp); + return res; + +} // INIFile::getData> + /** * \brief Specialization of getData to return bool of query * data field @@ -344,6 +364,28 @@ bool INIFile::getData(std::string query) { } // INIFile::getData +/** + * \brief Specialization of getData to return std::vector of query + * data field + * + * \param [in] query Formatted query string to be parsed + * \return Value of query data field as a std::vector + */ +template <> +std::vector INIFile::getData(std::string query) { + std::string line = getData(query); + std::istringstream iss( line ); + std::vector res; + std::string tmp; + while( iss >> tmp ) + { + bool b = (not tmp.compare("TRUE") or not tmp.compare("ON")); + res.push_back(b); + } + return res; + +} // INIFile::getData> + /** * \brief Specialization of getData to return size_t of query * data field diff --git a/tests/standalone_driver.cxx b/tests/standalone_driver.cxx index 4c27bb7f..536929b9 100644 --- a/tests/standalone_driver.cxx +++ b/tests/standalone_driver.cxx @@ -345,12 +345,10 @@ int main(int argc, char** argv) { OPT_KEYWORD("GF.WRITE", gf_settings.writeGF, bool); OPT_KEYWORD("GF.PRINT", gf_settings.print, bool); OPT_KEYWORD("GF.SAVEGFMATS", gf_settings.saveGFmats, bool); - gf_settings.GF_orbs_basis = std::vector(n_active, 0); - for(int i = 0; i < n_active; i++) gf_settings.GF_orbs_basis[i] = i; - gf_settings.GF_orbs_comp = std::vector(n_active, 0); - for(int i = 0; i < n_active; i++) gf_settings.GF_orbs_comp[i] = i; - gf_settings.is_up_basis = std::vector(n_active, true); - gf_settings.is_up_comp = std::vector(n_active, true); + OPT_KEYWORD("GF.ORBS_BASIS", gf_settings.GF_orbs_basis, std::vector); + OPT_KEYWORD("GF.IS_UP_BASIS", gf_settings.is_up_basis, std::vector); + OPT_KEYWORD("GF.ORBS_COMP", gf_settings.GF_orbs_comp, std::vector); + OPT_KEYWORD("GF.IS_UP_COMP", gf_settings.is_up_comp, std::vector); // GF vector std::vector>> GF(