Skip to content

Commit

Permalink
Merge branch 'development' into feature-2.0
Browse files Browse the repository at this point in the history
Conflicts:
	meta/EWSB.m
	src/standard_model.cpp
	test/test_CMSSM_model.cpp
	test/test_ewsb_solver.cpp
	test/test_fixed_point_iterator.cpp
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Oct 14, 2016
2 parents 4761550 + ad4284b commit 9385252
Show file tree
Hide file tree
Showing 35 changed files with 461 additions and 292 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Expand Up @@ -56,6 +56,16 @@ FlexibleSUSY-1.7.1 [not released yet]
FlexibleEFTHiggs[13] is set automatically to FlexibleEFTHiggs[20] -
1 when yt(BSM) is calculated in FlexibleEFTHiggs.

* Change (commit b533d67): Faster calculation of effective vertices h
-> photon photon and h -> gluon gluon.

* Bugfix (commit 8b04191): Improve numerical stability of low-scale
iteration which determines the SM(5) parameters by using a higher
RG running precision than the precision goal for the convergence.

* Bugfix (commit 44d2f01): Print SLHA output even if QedQcd class
throws an exception.

FlexibleSUSY-1.7.0 [September, 19 2016]

* Feature: FlexibleSUSY is now able to generate custom spectrum
Expand Down
171 changes: 83 additions & 88 deletions config/depgen.cpp
Expand Up @@ -24,22 +24,9 @@
#include <iostream>
#include <set>
#include <string>
#include <utility>
#include <vector>

namespace depgen {
template<class InputIt, class OutputIt, class UnaryPredicate>
OutputIt copy_if(InputIt first, InputIt last, OutputIt d_first,
UnaryPredicate pred)
{
while (first != last) {
if (pred(*first))
*d_first++ = *first;
first++;
}
return d_first;
}
} // namespace depgen

/// returns directory from file name
std::string directory(const std::string& file_name)
{
Expand Down Expand Up @@ -91,14 +78,15 @@ struct Is_not_duplicate_ignore_path {
};

/// deletes duplicate elements from a vector (preseves order)
template <typename Predicate>
std::vector<std::string> delete_duplicates(const std::vector<std::string>& vec,
Predicate& pred)
template <typename Predicate = decltype(Is_not_duplicate())>
std::vector<std::string> delete_duplicates(
const std::vector<std::string>& vec,
Predicate pred = Is_not_duplicate())
{
std::vector<std::string> unique_vector;

depgen::copy_if(vec.begin(), vec.end(), std::back_inserter(unique_vector),
pred);
std::copy_if(vec.begin(), vec.end(), std::back_inserter(unique_vector),
std::ref(pred));

return unique_vector;
}
Expand All @@ -123,7 +111,7 @@ std::string trim_left(const std::string& s)

str.erase(str.begin(),
std::find_if(str.begin(), str.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
[] (std::string::value_type c) { return !std::isspace(c); }));

return str;
}
Expand Down Expand Up @@ -153,56 +141,66 @@ void print_usage(const std::string& program_name)
/// print dependency list
void print_dependencies(const std::string& target_name,
const std::vector<std::string>& dependencies,
std::ostream& ostr = std::cout)
std::ostream& ostr)
{
ostr << target_name << ':';

for (std::vector<std::string>::const_iterator it = dependencies.begin(),
end = dependencies.end(); it != end; ++it) {
ostr << ' ' << *it;
}
for (const auto& d: dependencies)
ostr << ' ' << d;

ostr << '\n';
}

/// print empty phony targets for each dependency
void print_empty_phony_targets(const std::vector<std::string>& dependencies,
std::ostream& ostr = std::cout)
std::ostream& ostr)
{
for (std::vector<std::string>::const_iterator it = dependencies.begin(),
end = dependencies.end(); it != end; ++it) {
ostr << '\n' << *it << ":\n";
}
for (const auto& d: dependencies)
ostr << '\n' << d << ":\n";
}

/// returns file name from #include "..." statement
std::string get_filename_from_include(std::string line)
{
line = trim_left(line);

if (line.empty() || line[0] != '#')
return "";

// skip `#' and following whitespace
line = trim_left(line.substr(1));

if (!starts_with(line, "include"))
return "";

// skip `include'
line = trim_left(line.substr(7));

// extract file name from "file-name"
std::size_t pos1 = line.find_first_of('"');
if (pos1 == std::string::npos)
return "";
pos1++;

std::size_t pos2 = line.find_first_of('"', pos1);
if (pos2 == std::string::npos)
return "";
pos2--;

return line.substr(pos1, pos2);
}

/// extract include statements from file (ignoring system headers)
std::vector<std::string> get_includes(const std::string& file_name)
std::vector<std::string> get_included_files(const std::string& file_name)
{
std::ifstream istr(file_name.c_str());
std::ifstream istr(file_name);
std::vector<std::string> includes;
std::string line;

while (std::getline(istr, line)) {
const std::string tline(trim_left(line));
if (!tline.empty() && tline[0] == '#') {
const std::string ttline(trim_left(tline.substr(1)));
if (starts_with(ttline, "include")) {
// throw away `include'
const std::string header(trim_left(ttline.substr(7)));
// extract file name
std::size_t pos1 = header.find_first_of('"');
if (pos1 == std::string::npos)
continue;
pos1++;
std::size_t pos2 = header.find_first_of('"', pos1);
if (pos2 == std::string::npos)
continue;
pos2--;
const std::string file = header.substr(pos1, pos2);
if (!file.empty())
includes.push_back(file);
}
}
std::string file(get_filename_from_include(line));
if (!file.empty())
includes.push_back(std::move(file));
}

return includes;
Expand All @@ -214,10 +212,8 @@ std::vector<std::string> prepend(const std::string& str,
{
std::vector<std::string> result(strings);

for (std::vector<std::string>::iterator it = result.begin(),
end = result.end(); it != end; ++it) {
*it = str + *it;
}
for (auto& s: result)
s = str + s;

return result;
}
Expand All @@ -233,8 +229,8 @@ std::vector<std::string> filter(const std::string& dir,

std::vector<std::string> existing_files;

depgen::copy_if(files_in_dir.begin(), files_in_dir.end(),
std::back_inserter(existing_files), pred);
std::copy_if(files_in_dir.begin(), files_in_dir.end(),
std::back_inserter(existing_files), pred);

return existing_files;
}
Expand All @@ -250,22 +246,20 @@ std::vector<std::string> search_includes(const std::string& file_name,
return std::vector<std::string>();

// find included files from #include statements
const std::vector<std::string> includes(get_includes(file_name));
const std::vector<std::string> includes(get_included_files(file_name));

// select only files that exist in paths
std::vector<std::string> existing;
for (std::vector<std::string>::const_iterator it = paths.begin(),
end = paths.end(); it != end; ++it) {
const std::vector<std::string> existing_in_path(filter(*it, includes, file_exists));
for (const auto& p: paths) {
const std::vector<std::string> existing_in_path(filter(p, includes, file_exists));
existing.insert(existing.end(), existing_in_path.begin(), existing_in_path.end());
}

// search recursively for included files in existing headers
const std::vector<std::string> tmp_existing(existing);
for (std::vector<std::string>::const_iterator it = tmp_existing.begin(),
end = tmp_existing.end(); it != end; ++it) {
for (const auto& f: tmp_existing) {
const std::vector<std::string> sub_existing(
search_includes(*it, paths, ignore_non_existing, max_depth - 1));
search_includes(f, paths, ignore_non_existing, max_depth - 1));
existing.insert(existing.end(), sub_existing.begin(), sub_existing.end());
}

Expand All @@ -288,7 +282,7 @@ std::vector<std::string> search_includes(const std::string& file_name,
return existing;
}

int main(int argc, const char* argv[])
int main(int argc, char* argv[])
{
if (argc < 2) {
std::cerr << "Error: no file given\n";
Expand Down Expand Up @@ -356,40 +350,41 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE;
}

// select output stream
std::ofstream fstr(output_file);
std::ostream* ostr = &std::cout;

if (!output_file.empty()) {
if (!fstr.good()) {
std::cerr << "Error: cannot write to file " << output_file << '\n';
return EXIT_FAILURE;
}
ostr = &fstr;
}

// include paths
paths.insert(paths.begin(), directory(file_name));
paths.push_back(".");
Is_not_duplicate is_not_dup;
paths = delete_duplicates(paths, is_not_dup);
paths = delete_duplicates(paths);

// search for header inclusions (remove duplicate headers)
Is_not_duplicate_ignore_path is_not_dup_ign_path;
std::vector<std::string> dependencies
// search for header inclusions in file
const std::vector<std::string> dependencies
= delete_duplicates(
search_includes(file_name, paths, ignore_non_existing),
is_not_dup_ign_path);
Is_not_duplicate_ignore_path());

// add file name to dependency list
// prepend file itself to dependency list
std::vector<std::string> dependencies_and_main(dependencies);
dependencies_and_main.insert(dependencies_and_main.begin(), file_name);

if (target_name.empty())
target_name = replace_extension(filename(file_name), "o");

if (output_file.empty()) {
print_dependencies(target_name, dependencies_and_main);
if (add_empty_phony_targets)
print_empty_phony_targets(dependencies);
} else {
std::ofstream ostr(output_file.c_str());
if (ostr.good()) {
print_dependencies(target_name, dependencies_and_main, ostr);
if (add_empty_phony_targets)
print_empty_phony_targets(dependencies, ostr);
} else {
std::cerr << "Error: cannot write to file " << output_file << '\n';
return EXIT_FAILURE;
}
}
// output
print_dependencies(target_name, dependencies_and_main, *ostr);

if (add_empty_phony_targets)
print_empty_phony_targets(dependencies, *ostr);

return EXIT_SUCCESS;
}

0 comments on commit 9385252

Please sign in to comment.