Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Jul 10, 2024
1 parent 954fe8b commit 37ba89d
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 53 deletions.
8 changes: 4 additions & 4 deletions include/amici/model_dae.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class Model_DAE : public Model {
std::map<realtype, std::vector<int>> state_independent_events = {}
)
: Model(
model_dimensions, simulation_parameters, o2mode, idlist, z2event,
pythonGenerated, ndxdotdp_explicit, ndxdotdx_explicit,
w_recursion_depth, state_independent_events
) {
model_dimensions, simulation_parameters, o2mode, idlist, z2event,
pythonGenerated, ndxdotdp_explicit, ndxdotdx_explicit,
w_recursion_depth, state_independent_events
) {
derived_state_.M_ = SUNMatrixWrapper(nx_solver, nx_solver);
auto M_nnz = static_cast<sunindextype>(
std::reduce(idlist.begin(), idlist.end())
Expand Down
8 changes: 4 additions & 4 deletions include/amici/model_ode.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class Model_ODE : public Model {
std::map<realtype, std::vector<int>> state_independent_events = {}
)
: Model(
model_dimensions, simulation_parameters, o2mode, idlist, z2event,
pythonGenerated, ndxdotdp_explicit, ndxdotdx_explicit,
w_recursion_depth, state_independent_events
) {}
model_dimensions, simulation_parameters, o2mode, idlist, z2event,
pythonGenerated, ndxdotdp_explicit, ndxdotdx_explicit,
w_recursion_depth, state_independent_events
) {}

void
fJ(realtype t, realtype cj, AmiVector const& x, AmiVector const& dx,
Expand Down
12 changes: 6 additions & 6 deletions src/edata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ ExpData::ExpData(

ExpData::ExpData(Model const& model)
: ExpData(
model.nytrue, model.nztrue, model.nMaxEvent(), model.getTimepoints(),
model.getFixedParameters()
) {
model.nytrue, model.nztrue, model.nMaxEvent(), model.getTimepoints(),
model.getFixedParameters()
) {
reinitializeFixedParameterInitialStates
= model.getReinitializeFixedParameterInitialStates()
&& model.getReinitializationStateIdxs().empty();
Expand All @@ -70,9 +70,9 @@ ExpData::ExpData(Model const& model)

ExpData::ExpData(ReturnData const& rdata, realtype sigma_y, realtype sigma_z)
: ExpData(
rdata, std::vector<realtype>(rdata.nytrue * rdata.nt, sigma_y),
std::vector<realtype>(rdata.nztrue * rdata.nmaxevent, sigma_z)
) {}
rdata, std::vector<realtype>(rdata.nytrue * rdata.nt, sigma_y),
std::vector<realtype>(rdata.nztrue * rdata.nmaxevent, sigma_z)
) {}

ExpData::ExpData(
ReturnData const& rdata, std::vector<realtype> sigma_y,
Expand Down
16 changes: 8 additions & 8 deletions src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ CvodeException::CvodeException(
int const error_code, char const* function, char const* extra
)
: AmiException(
"CVODE routine %s failed with error code %i. %s", function, error_code,
extra ? extra : ""
) {}
"CVODE routine %s failed with error code %i. %s", function,
error_code, extra ? extra : ""
) {}

IDAException::IDAException(
int const error_code, char const* function, char const* extra
)
: AmiException(
"IDA routine %s failed with error code %i. %s", function, error_code,
extra ? extra : ""
) {}
"IDA routine %s failed with error code %i. %s", function, error_code,
extra ? extra : ""
) {}

IntegrationFailure::IntegrationFailure(int code, realtype t)
: AmiException("AMICI failed to integrate the forward problem")
Expand All @@ -61,8 +61,8 @@ IntegrationFailureB::IntegrationFailureB(int code, realtype t)

NewtonFailure::NewtonFailure(int code, char const* function)
: AmiException(
"NewtonSolver routine %s failed with error code %i", function, code
) {
"NewtonSolver routine %s failed with error code %i", function, code
) {
error_code = code;
}

Expand Down
10 changes: 7 additions & 3 deletions src/interface_matlab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,10 @@ void setModelData(mxArray const* prhs[], int nrhs, Model& model) {
model.setParameterScale(
static_cast<ParameterScaling>(dbl2int(mxGetScalar(a)))
);
} else if((mxGetM(a) == 1 && gsl::narrow<int>(mxGetN(a)) == model.np())
|| (mxGetN(a) == 1 && gsl::narrow<int>(mxGetM(a)) == model.np())) {
} else if ((mxGetM(a) == 1
&& gsl::narrow<int>(mxGetN(a)) == model.np())
|| (mxGetN(a) == 1
&& gsl::narrow<int>(mxGetM(a)) == model.np())) {
auto pscaleArray = static_cast<double*>(mxGetData(a));
std::vector<ParameterScaling> pscale(model.np());
for (int ip = 0; ip < model.np(); ++ip) {
Expand Down Expand Up @@ -597,7 +599,9 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, mxArray const* prhs[]) {
ex.what()
);
}
} else if (solver->getSensitivityOrder() >= amici::SensitivityOrder::first && solver->getSensitivityMethod() == amici::SensitivityMethod::adjoint) {
} else if (solver->getSensitivityOrder() >= amici::SensitivityOrder::first
&& solver->getSensitivityMethod()
== amici::SensitivityMethod::adjoint) {
mexErrMsgIdAndTxt("AMICI:mex:setup", "No data provided!");
}

Expand Down
2 changes: 1 addition & 1 deletion src/newton_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void NewtonSolverDense::solveLinearSystem(AmiVector& rhs) {
throw NewtonFailure(status, "SUNLinSolSolve_Dense");
}

void NewtonSolverDense::reinitialize(){
void NewtonSolverDense::reinitialize() {
/* dense solver does not need reinitialization */
};

Expand Down
16 changes: 8 additions & 8 deletions src/rdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace amici {

ReturnData::ReturnData(Solver const& solver, Model const& model)
: ReturnData(
model.getTimepoints(),
ModelDimensions(static_cast<ModelDimensions const&>(model)),
model.nplist(), model.nMaxEvent(), model.nt(),
solver.getNewtonMaxSteps(), model.getParameterScale(), model.o2mode,
solver.getSensitivityOrder(), solver.getSensitivityMethod(),
solver.getReturnDataReportingMode(), model.hasQuadraticLLH(),
model.getAddSigmaResiduals(), model.getMinimumSigmaResiduals()
) {}
model.getTimepoints(),
ModelDimensions(static_cast<ModelDimensions const&>(model)),
model.nplist(), model.nMaxEvent(), model.nt(),
solver.getNewtonMaxSteps(), model.getParameterScale(), model.o2mode,
solver.getSensitivityOrder(), solver.getSensitivityMethod(),
solver.getReturnDataReportingMode(), model.hasQuadraticLLH(),
model.getAddSigmaResiduals(), model.getMinimumSigmaResiduals()
) {}

ReturnData::ReturnData(
std::vector<realtype> ts, ModelDimensions const& model_dimensions,
Expand Down
4 changes: 2 additions & 2 deletions src/spline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ double seval(
j = k; /* move the upper bound */
if (u >= x[k])
i = k; /* move the lower bound */
} /* there are no more segments to search */
} /* there are no more segments to search */
while (j > i + 1);
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ double sinteg(
j = k; /* move the upper bound */
if (u >= x[k])
i = k; /* move the lower bound */
} /* there are no more segments to search */
} /* there are no more segments to search */
while (j > i + 1);
}

Expand Down
30 changes: 19 additions & 11 deletions src/splinefunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ HermiteSpline::HermiteSpline(
bool logarithmic_parametrization
)
: AbstractSpline(
std::move(nodes), std::move(node_values), equidistant_spacing,
logarithmic_parametrization
)
std::move(nodes), std::move(node_values), equidistant_spacing,
logarithmic_parametrization
)
, node_values_derivative_(std::move(node_values_derivative))
, first_node_bc_(firstNodeBC)
, last_node_bc_(lastNodeBC)
Expand Down Expand Up @@ -602,21 +602,25 @@ void HermiteSpline::compute_coefficients_extrapolation_sensi(
case SplineExtrapolation::linear:
if (first_node_bc_ == SplineBoundaryCondition::zeroDerivative) {
sm0 = 0;
} else if (get_node_derivative_by_fd() && first_node_bc_ == SplineBoundaryCondition::given) {
} else if (get_node_derivative_by_fd()
&& first_node_bc_ == SplineBoundaryCondition::given) {
sm0 = (dvaluesdp[spline_offset + ip + nplist] - sp0)
/ (nodes_[1] - nodes_[0]);

} else if (get_node_derivative_by_fd() && first_node_bc_ == SplineBoundaryCondition::natural) {
} else if (get_node_derivative_by_fd()
&& first_node_bc_ == SplineBoundaryCondition::natural) {
throw AmiException(
"Natural boundary condition for "
"Hermite splines with linear extrapolation is "
"not yet implemented."
);

} else if (!get_node_derivative_by_fd() && first_node_bc_ == SplineBoundaryCondition::given) {
} else if (!get_node_derivative_by_fd()
&& first_node_bc_ == SplineBoundaryCondition::given) {
sm0 = dslopesdp[spline_offset + ip];

} else if (!get_node_derivative_by_fd() && first_node_bc_ == SplineBoundaryCondition::natural) {
} else if (!get_node_derivative_by_fd()
&& first_node_bc_ == SplineBoundaryCondition::natural) {
throw AmiException(
"Natural boundary condition for "
"Hermite splines with linear extrapolation is "
Expand Down Expand Up @@ -662,24 +666,28 @@ void HermiteSpline::compute_coefficients_extrapolation_sensi(
case SplineExtrapolation::linear:
if (last_node_bc_ == SplineBoundaryCondition::zeroDerivative) {
sm_end = 0;
} else if (get_node_derivative_by_fd() && last_node_bc_ == SplineBoundaryCondition::given) {
} else if (get_node_derivative_by_fd()
&& last_node_bc_ == SplineBoundaryCondition::given) {
sm_end = (sp_end
- dvaluesdp
[spline_offset + ip + (n_nodes() - 2) * nplist])
/ (nodes_[n_nodes() - 1] - nodes_[n_nodes() - 2]);

} else if (get_node_derivative_by_fd() && last_node_bc_ == SplineBoundaryCondition::natural) {
} else if (get_node_derivative_by_fd()
&& last_node_bc_ == SplineBoundaryCondition::natural) {
throw AmiException(
"Natural boundary condition for "
"Hermite splines with linear extrapolation is "
"not yet implemented."
);

} else if (!get_node_derivative_by_fd() && last_node_bc_ == SplineBoundaryCondition::given) {
} else if (!get_node_derivative_by_fd()
&& last_node_bc_ == SplineBoundaryCondition::given) {
sm_end
= dslopesdp[spline_offset + ip + (n_nodes() - 1) * nplist];

} else if (!get_node_derivative_by_fd() && last_node_bc_ == SplineBoundaryCondition::natural) {
} else if (!get_node_derivative_by_fd()
&& last_node_bc_ == SplineBoundaryCondition::natural) {
throw AmiException(
"Natural boundary condition for "
"Hermite splines with linear extrapolation is "
Expand Down
12 changes: 6 additions & 6 deletions src/sundials_linsol_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ N_Vector SUNLinSolSPBCGS::getResid() const {

SUNLinSolSPFGMR::SUNLinSolSPFGMR(AmiVector const& x, int pretype, int maxl)
: SUNLinSolWrapper(
SUNLinSol_SPFGMR(const_cast<N_Vector>(x.getNVector()), pretype, maxl)
) {
SUNLinSol_SPFGMR(const_cast<N_Vector>(x.getNVector()), pretype, maxl)
) {
if (!solver_)
throw AmiException("Failed to create solver.");
}
Expand Down Expand Up @@ -311,8 +311,8 @@ N_Vector SUNLinSolSPFGMR::getResid() const {

SUNLinSolSPGMR::SUNLinSolSPGMR(AmiVector const& x, int pretype, int maxl)
: SUNLinSolWrapper(
SUNLinSol_SPGMR(const_cast<N_Vector>(x.getNVector()), pretype, maxl)
) {
SUNLinSol_SPGMR(const_cast<N_Vector>(x.getNVector()), pretype, maxl)
) {
if (!solver_)
throw AmiException("Failed to create solver.");
}
Expand Down Expand Up @@ -404,8 +404,8 @@ SUNNonLinSolFixedPoint::SUNNonLinSolFixedPoint(
int count, const_N_Vector x, int m
)
: SUNNonLinSolWrapper(
SUNNonlinSol_FixedPointSens(count, const_cast<N_Vector>(x), m)
) {}
SUNNonlinSol_FixedPointSens(count, const_cast<N_Vector>(x), m)
) {}

int SUNNonLinSolFixedPoint::getSysFn(SUNNonlinSolSysFn* SysFn) const {
return SUNNonlinSolGetSysFn_FixedPoint(solver, SysFn);
Expand Down

0 comments on commit 37ba89d

Please sign in to comment.