Giter VIP home page Giter VIP logo

slhaea's Introduction

SLHAea - containers for SUSY Les Houches Accord input/output

test

Introduction

SLHAea is an easy to use C++ library for input, output, and manipulation of data in the SUSY Les Houches Accord (SLHA). It is based on the concept that a SLHA structure is a container of blocks, which are then again containers of lines, which are then again containers of strings.

Its main features are:

  • fast reading and writing of SLHA files
  • easy access to individual blocks, lines, and fields
  • three containers (Coll, Block, and Line) that mimic the containers of the C++ Standard Library and therefore offer great flexibility
  • the exact formatting of lines is preserved
  • everything is stored as strings, so data is not restricted to floats or integers
  • no precision is lost in read/write cycles of unmodified data
  • blocks and lines are not restricted to the ones specified in the SLHA, SLHA2, and FLHA or later accords that use the same syntax
  • easy to use since SLHAea is a header-only library consisting of only one file

Documentation

The API documentation is here. It includes some practical examples which can also be found in the doc/examples/ directory in SLHAea's source tree.

Dependencies

To use SLHAea only the C++ Standard Library and some headers from the Boost C++ Libraries are required.

Download

You can download SLHAea in either tar.gz or zip formats.

The version control system used for development of SLHAea is Git. The Git repository can be inspected and browsed online at GitHub and it can be cloned by running:

git clone git://github.com/fthomas/slhaea.git

Issues and feedback

For bug reports, feature requests, or general feedback either use the issue tracker or write me an email.

License

SLHAea is free software and licensed under the Boost Software License 1.0. The full text of the license can be found in the file LICENSE_1_0.txt in SLHAea's source tree.

Author

SLHAea was written by Frank S. Thomas <[email protected]>.

slhaea's People

Contributors

expander avatar fthomas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

expander

slhaea's Issues

warning from gcc 12.1

Newest g++ gives a warning about use of deprecated feature

In file included from src/slha_io.cpp:27:
slhaea/slhaea.h:1528:36: warning: ‘template<class _Arg, class _Result> struct std::unary_function’ is deprecated [-Wdeprecated-declarations]
 1528 |   struct key_matches : public std::unary_function<value_type, bool>
      |                                    ^~~~~~~~~~~~~~
In file included from /usr/include/c++/12/string:48,
                 from src/slha_format.hpp:22,
                 from src/slha_io.hpp:22,
                 from src/slha_io.cpp:19:
/usr/include/c++/12/bits/stl_function.h:117:12: note: declared here
  117 |     struct unary_function
      |            ^~~~~~~~~~~~~~
slhaea/slhaea.h:2354:36: warning: ‘template<class _Arg, class _Result> struct std::unary_function’ is deprecated [-Wdeprecated-declarations]
 2354 |   struct key_matches : public std::unary_function<value_type, bool>
      |                                    ^~~~~~~~~~~~~~
/usr/include/c++/12/bits/stl_function.h:117:12: note: declared here
  117 |     struct unary_function
      |            ^~~~~~~~~~~~~~
slhaea/slhaea.h:2375:46: warning: ‘template<class _Arg, class _Result> struct std::unary_function’ is deprecated [-Wdeprecated-declarations]
 2375 |   struct key_matches_block_def : public std::unary_function<value_type, bool>
      |                                              ^~~~~~~~~~~~~~
/usr/include/c++/12/bits/stl_function.h:117:12: note: declared here
  117 |     struct unary_function
      |            ^~~~~~~~~~~~~~

This is by no mean critical but I thought you might want to know about that.

Proposing push_front() functions

Dear Thomas,

for my personal use I implemented the following two push_front() functions with constant complexity:

  void
  push_front(const value_type& block)
  { impl_.push_front(block); }

  void
  push_front(const std::string& blockString)
  {
    value_type block;
    block.str(blockString);
    impl_.push_front(block);
  }

What do you think about adding these functions to your package? I find them quite useful, so maybe other users do so as well.

Best,
Alex

Performance deficite dute to map key type std::string

Dear Frank Thomas,

I'm planning to use your SLHAea package in my own spectrum generator because it looks very elegant and seems to be easy to use.

However, speed is a critical point for me, so I wonder how SLHAea performs compared to SLHALib (http://www.feynarts.de/slha/) or other hand-written SLHA libraries? My wish would be that reading and writing time together is much smaller than 0.1 ms. Have you done some speed comparisons with other libraries?

There is one problematic point which I have in mind: You are using std::string as map key in your examples:

  ifstream ifs("slha1.txt");
  Coll input(ifs);

  cout << "tan(beta) = "        << input["MINPAR"][3][1] << '\n';
  cout << "m_top(pole) line:\n" << input["SMINPUTS"][6]  << '\n';
  cout << "SMINPUTS block:\n"   << input["SMINPUTS"];

It could be that this is rather slow compared to an integer key (depending on the std::map implementation). So, using enums as an alternative would probably help here.

One possibility to achieve this would be to make the key type a template parameter which can be chosen by the user at compile time

  template <class key_type = std::string>
  class Coll { ... };

  namespace SLHAea {
     enum BlockNames : int { MINPAR, SMINPUTS, ... };
  }

  int main() {
    ifstream ifs("slha1.txt");
    Coll<SLHAea::BlockNames> input(ifs);

    cout << "tan(beta) = "        << input[SLHAea::MINPAR][3][1] << '\n';
    cout << "m_top(pole) line:\n" << input[SLHAea::SMINPUTS][6]  << '\n';
    cout << "SMINPUTS block:\n"   << input[SLHAea::SMINPUTS];
  }

What do you think about this option?

Best regards,
Alexander Voigt

Unary sign operator applied to unsigned type

MSVC gives a compiler warning for line 841 in slhaea.h, hinting to a possible bug.
The line for which the warning is given is in Block& read(std::istream& is):

is.seekg(-line_str.length()-1, std::ios_base::cur);

The warning from MSVC is:

warning C4146: unary minus operator applied to unsigned type, result still unsigned

If I understand correctly, the issue is the following: line_str.length() returns an unsigned value. Applying the unary minus operator to that value returns another unsigned value, which may be huge.

Example:

unsigned u = 1;
std::cout << -u; // prints 4294967295

I believe this is not the desired behavior.

A possible fix would be to perform a static_cast<std::ptrdiff_t>:

unsigned u = 1;
std::cout << -static_cast<std::ptrdiff_t>(u); // prints -1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.