<commit_before>#pragma once

#include <chrono>
#include "anyode/anyode.hpp"
#include "cvodes_cxx.hpp"

namespace cvodes_anyode {

    using cvodes_cxx::CVodeIntegrator;
    using cvodes_cxx::LMM;
    using cvodes_cxx::IterType;
    using cvodes_cxx::IterLinSolEnum;
    using cvodes_cxx::PrecType;
    using cvodes_cxx::GramSchmidtType;

    int handle_status_(AnyODE::Status status){
        switch (status){
        case AnyODE::Status::success:
            return 0;
        case AnyODE::Status::recoverable_error:
            return 1;
        case AnyODE::Status::unrecoverable_error:
            return -1;
        default:
            throw std::runtime_error("impossible (this is for silencing -Wreturn-type)");
        }
    }

    template<class OdeSys>
    int rhs_cb(realtype t, N_Vector y, N_Vector ydot, void *user_data){
        auto& odesys = *static_cast<OdeSys*>(user_data);
        AnyODE::Status status = odesys.rhs(t, NV_DATA_S(y), NV_DATA_S(ydot));
        return handle_status_(status);
    }

    template<class OdeSys>
    int roots_cb(realtype t, N_Vector y, realtype *gout, void *user_data){
        auto& odesys = *static_cast<OdeSys*>(user_data);
        AnyODE::Status status = odesys.roots(t, NV_DATA_S(y), gout);
        if (status == AnyODE::Status::recoverable_error)
            throw std::runtime_error("There are only unrecoverable errors for roots().");
        return handle_status_(status);
    }

    template <class OdeSys>
    int jac_dense_cb(long int N, realtype t,<commit_msg>Better error message<commit_after>#pragma once

#include <chrono>
#include "anyode/anyode.hpp"
#include "cvodes_cxx.hpp"

namespace cvodes_anyode {

    using cvodes_cxx::CVodeIntegrator;
    using cvodes_cxx::LMM;
    using cvodes_cxx::IterType;
    using cvodes_cxx::IterLinSolEnum;
    using cvodes_cxx::PrecType;
    using cvodes_cxx::GramSchmidtType;

    int handle_status_(AnyODE::Status status){
        switch (status){
        case AnyODE::Status::success:
            return 0;
        case AnyODE::Status::recoverable_error:
            return 1;
        case AnyODE::Status::unrecoverable_error:
            return -1;
        default:
            throw std::runtime_error(StreamFmt() << "Got an unhandle status: " << static_cast<int>(status));
        }
    }

    template<class OdeSys>
    int rhs_cb(realtype t, N_Vector y, N_Vector ydot, void *user_data){
        auto& odesys = *static_cast<OdeSys*>(user_data);
        AnyODE::Status status = odesys.rhs(t, NV_DATA_S(y), NV_DATA_S(ydot));
        return handle_status_(status);
    }

    template<class OdeSys>
    int roots_cb(realtype t, N_Vector y, realtype *gout, void *user_data){
        auto& odesys = *static_cast<OdeSys*>(user_data);
        AnyODE::Status status = odesys.roots(t, NV_DATA_S(y), gout);
        if (status == AnyODE::Status::recoverable_error)
            throw std::runtime_error("There are only unrecoverable errors for roots().");
        return handle_status_(status);
    }

    template <class OdeSys>
    int jac_dense_cb(long int N, realtype t,
{'fraction_non_alphanumeric': 0.11172638436482085, 'fraction_numerical': 0.001954397394136808, 'mean_word_length': 3.2184065934065935, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4368933', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1032, 'n_words': 219}