Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions include/amici/abstract_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
#define AMICI_ABSTRACT_MODEL_H

#include "amici/defines.h"
#include "amici/splinefunctions.h"
#include "amici/sundials_matrix_wrapper.h"
#include "amici/vector.h"

#include <gsl/gsl-lite.hpp>
#include <sundials/sundials_matrix.h>

#include <memory>
#include <vector>

namespace amici {
class Solver;
class HermiteSpline;
class SUNMatrixWrapper;
class AmiVector;

/**
* @brief Abstract base class of amici::Model defining functions that need to
Expand Down
5 changes: 3 additions & 2 deletions include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
#include "amici/abstract_model.h"
#include "amici/defines.h"
#include "amici/event.h"
#include "amici/logging.h"
#include "amici/model_dimensions.h"
#include "amici/model_state.h"
#include "amici/simulation_parameters.h"
#include "amici/splinefunctions.h"
#include "amici/sundials_matrix_wrapper.h"
#include "amici/vector.h"

#include <map>
#include <vector>
Expand All @@ -20,6 +18,9 @@ namespace amici {
class ExpData;
class Model;
class Solver;
class Logger;
class AmiVector;
class AmiVectorArray;

} // namespace amici

Expand Down
16 changes: 16 additions & 0 deletions python/sdist/amici/_codegen/cxx_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ class _FunctionInfo:
default_return_value: str = ""
header: list[str] = field(default_factory=list)

def __post_init__(self):
common_header = [
'#include "amici/symbolic_functions.h"',
'#include "amici/defines.h"',
"",
# std::{min,find}
"#include <algorithm>",
]
if self.sparse:
common_header.append("#include <sundials/sundials_types.h>")
common_header.append("#include <gsl/gsl-lite.hpp>")

self.header = common_header + self.header

def arguments(self, ode: bool = True) -> str:
"""Get the arguments for the ODE or DAE function"""
if ode or not self.dae_arguments:
Expand Down Expand Up @@ -324,6 +338,7 @@ def var_in_signature(self, varname: str, ode: bool = True) -> bool:
"realtype *x0_fixedParameters, const realtype t, "
"const realtype *p, const realtype *k, "
"gsl::span<const int> reinitialization_state_idxs",
header=["#include <gsl/gsl-lite.hpp>"],
),
"sx0": _FunctionInfo(
"realtype *sx0, const realtype t, const realtype *x, "
Expand All @@ -333,6 +348,7 @@ def var_in_signature(self, varname: str, ode: bool = True) -> bool:
"realtype *sx0_fixedParameters, const realtype t, "
"const realtype *x0, const realtype *p, const realtype *k, "
"const int ip, gsl::span<const int> reinitialization_state_idxs",
header=["#include <gsl/gsl-lite.hpp>"],
),
"xdot": _FunctionInfo(
"realtype *xdot, const realtype t, const realtype *x, "
Expand Down
13 changes: 1 addition & 12 deletions python/sdist/amici/de_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,7 @@ def _write_function_file(self, function: str) -> None:
func_info = self.functions[function]

# function header
lines.extend(
[
'#include "amici/symbolic_functions.h"',
'#include "amici/defines.h"',
'#include "sundials/sundials_types.h"',
"",
"#include <gsl/gsl-lite.hpp>",
"#include <algorithm>",
"",
*func_info.header,
]
)
lines.extend(func_info.header)

# extract symbols that need definitions from signature
# don't add includes for files that won't be generated.
Expand Down
2 changes: 2 additions & 0 deletions src/abstract_model.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "amici/abstract_model.h"
#include "amici/exception.h"
#include "amici/splinefunctions.h"

namespace amici {

Expand Down
Loading