Coder Social home page Coder Social logo

Comments (1)

dweindl avatar dweindl commented on June 16, 2024

One alternative could be generating, for example, a class Parameters that wraps the plain parameter array and has as members the names of all parameters that map to the respective array location. So what is currently written as p1 + p2 would become p.p1 + p.p2. The main advantage would be, that we have everything inside the class namespace, so it's safe if somebody wants to use a parameter named p. Slightly more verbose, but on the positive side, it would be obvious that those are parameters. It still wouldn't work for c++ reserved names, so no parameter named int etc. would be supported. If we want that, then I guess there is no way around using a string-indexed map.
Seems to be possible to resolve some string-based mapping at compile time (e.g. https://github.com/serge-sans-paille/frozen/). However, that would make the code less readable, e.g. p["p1"] + p["p2"] (or probably worse, p[_p["p1"]] + p[_p["p2"]], because we need to look up indices, not values, as the parameter values aren't known at compile time).

EDIT: Okay, a simple consteval function for resolving string to index mapping would work without additional run-time cost, but it would require writing something like p[_p("p1")] + p[_p("p2")], or with a bit of macros (and code printing adaptations) PAR("p1") + PAR("p2"), which is actually not that bad. At least we wouldn't have to bother with any reserved names in amici/c++/... . Happy about better solutions.

from amici.

Related Issues (20)

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.