26 #include "function.hpp"
32 int eval_dump(
const std::string& name) {
40 ss << std::setfill(
'0') << std::setw(6);
42 std::vector<DM> inputs;
44 for (
int i=0;i<1000000;++i) {
47 inputs = f.
generate_in(name+
"."+ss.str()+
".in.txt");
50 casadi_warning(ex.
what());
51 casadi_assert(i>0,
"Could not find a single input file "
52 "with file name " + name +
".<dddddd>.in.txt");
58 std::vector<DM> res = f(inputs);
66 int eval_dump_parse(
const std::vector<std::string>& args) {
67 casadi_assert(args.size()>0,
"Name is missing in $ casadi-cli eval_dump name.");
68 std::string name = args[0];
69 return eval_dump(name);
72 int main(
int argc,
char* argv[]) {
75 std::vector<std::string> args(argv + 1, argv + argc);
78 std::set<std::string> commands = {
"eval_dump"};
79 casadi_assert(args.size()>0,
"Must provide a command. Use one of: " +
str(commands) +
".");
80 std::string cmd = args[0];
81 if (cmd==
"eval_dump") {
82 return eval_dump_parse(std::vector<std::string>(args.begin()+1, args.end()));
84 casadi_assert(commands.find(cmd)!=commands.end(),
85 "Unrecognised command '" + cmd +
"'. Use one of: " +
str(commands) +
".");
87 }
catch (
const std::exception& e) {
88 std::cerr << e.what() << std::endl;
91 std::cerr <<
"Unknown error" << std::endl;
const char * what() const override
Display error.
void generate_in(const std::string &fname, const std::vector< DM > &arg)
Export an input file that can be passed to generate C code with a main.
void generate_out(const std::string &fname, const std::vector< DM > &arg)
Export an output file that can be checked with generated C code output.
static Function load(const std::string &filename)
Build function from serialization.
void change_option(const std::string &option_name, const GenericType &option_value)
Change option after object creation for debugging.
std::string str(const T &v)
String representation, any type.