Skip to content

Commit a43a7bf

Browse files
authored
Cleanup (#2907)
Fix const, fix mismatching parameter names in declaration/definition, ...
1 parent 34043c6 commit a43a7bf

26 files changed

+178
-195
lines changed

include/amici/event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Event {
5656
* @brief Get the initial value of the root function
5757
* @return The value of the root function at t_0.
5858
*/
59-
bool get_initial_value() { return initial_value_; }
59+
bool get_initial_value() const { return initial_value_; }
6060

6161
/**
6262
* @brief Get the priority of the event assignments

include/amici/model_dae.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class Model_DAE : public Model {
148148

149149
void
150150
fJv(realtype t, AmiVector const& x, AmiVector const& dx,
151-
AmiVector const& xdot, AmiVector const& v, AmiVector& nJv,
151+
AmiVector const& xdot, AmiVector const& v, AmiVector& Jv,
152152
realtype cj) override;
153153

154154
/**

include/amici/model_ode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class Model_ODE : public Model {
141141

142142
void
143143
fJv(realtype t, AmiVector const& x, AmiVector const& dx,
144-
AmiVector const& xdot, AmiVector const& v, AmiVector& nJv,
144+
AmiVector const& xdot, AmiVector const& v, AmiVector& Jv,
145145
realtype cj) override;
146146

147147
/**

include/amici/solver.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ class Solver;
2424
} // namespace amici
2525

2626
// for serialization friend in Solver
27-
namespace boost {
28-
namespace serialization {
27+
namespace boost::serialization {
2928
template <class Archive>
3029
void serialize(Archive& ar, amici::Solver& s, unsigned int version);
31-
}
32-
} // namespace boost
30+
} // namespace boost::serialization
3331

3432
namespace amici {
3533

include/amici/vector.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ class AmiVector;
1616
}
1717

1818
// for serialization friend
19-
namespace boost {
20-
namespace serialization {
19+
namespace boost::serialization {
2120
template <class Archive>
2221
void serialize(Archive& ar, amici::AmiVector& v, unsigned int version);
23-
}
24-
} // namespace boost
22+
} // namespace boost::serialization
2523

2624
namespace amici {
2725

@@ -51,7 +49,7 @@ class AmiVector {
5149
* @param length number of elements in vector
5250
* @param sunctx SUNDIALS context
5351
*/
54-
explicit AmiVector(long int const length, SUNContext sunctx)
52+
explicit AmiVector(long int const length, SUNContext const sunctx)
5553
: vec_(static_cast<decltype(vec_)::size_type>(length), 0.0)
5654
, nvec_(N_VMake_Serial(length, vec_.data(), sunctx)) {}
5755

@@ -63,7 +61,7 @@ class AmiVector {
6361
* @param rvec vector from which the data will be moved
6462
* @param sunctx SUNDIALS context
6563
*/
66-
explicit AmiVector(std::vector<realtype> rvec, SUNContext sunctx)
64+
explicit AmiVector(std::vector<realtype> rvec, SUNContext const sunctx)
6765
: vec_(std::move(rvec))
6866
, nvec_(N_VMake_Serial(
6967
gsl::narrow<long int>(vec_.size()), vec_.data(), sunctx
@@ -74,7 +72,7 @@ class AmiVector {
7472
* @param rvec vector from which the data will be copied
7573
* @param sunctx SUNDIALS context
7674
*/
77-
explicit AmiVector(gsl::span<realtype const> rvec, SUNContext sunctx)
75+
explicit AmiVector(gsl::span<realtype const> const rvec, SUNContext const sunctx)
7876
: AmiVector(std::vector(rvec.begin(), rvec.end()), sunctx) {}
7977

8078
/**

src/backwardproblem.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ BwdSimWorkspace::BwdSimWorkspace(
204204
, xQB_(model_->nJ * model_->nplist(), solver->getSunContext()) {}
205205

206206
void EventHandlingBwdSimulator::run(
207-
realtype t_start, realtype t_end, realtype it,
207+
realtype const t_start, realtype const t_end, realtype it,
208208
std::vector<realtype> const& timepoints, std::vector<realtype> const* dJydx,
209209
std::vector<realtype> const* dJzdx
210210
) {
@@ -311,15 +311,15 @@ SteadyStateBackwardProblem::SteadyStateBackwardProblem(
311311
, solver_(&solver)
312312
, ws_(ws) {}
313313

314-
void SteadyStateBackwardProblem::run(realtype t0) {
314+
void SteadyStateBackwardProblem::run(realtype const t0) {
315315
newton_solver_.reinitialize();
316316

317317
// initialize quadratures
318318
xQ_.zero();
319319
ws_->xQB_.zero();
320320

321321
// Compute quadratures, track computation time
322-
CpuTimer cpu_timer;
322+
CpuTimer const cpu_timer;
323323

324324
compute_steady_state_quadrature(t0);
325325
cpu_timeB_ = cpu_timer.elapsed_milliseconds();
@@ -333,7 +333,7 @@ AmiVector const& SteadyStateBackwardProblem::getAdjointQuadrature() const {
333333
return ws_->xQB_;
334334
}
335335

336-
void SteadyStateBackwardProblem::compute_steady_state_quadrature(realtype t0) {
336+
void SteadyStateBackwardProblem::compute_steady_state_quadrature(realtype const t0) {
337337
// This routine computes the quadratures:
338338
// xQB = Integral[ xB(x(t), t, p) * dxdot/dp(x(t), t, p) | dt ]
339339
// As we're in steady state, we have x(t) = x_ss (x_steadystate), hence
@@ -399,7 +399,7 @@ void SteadyStateBackwardProblem::compute_quadrature_by_lin_solve() {
399399
}
400400
}
401401

402-
void SteadyStateBackwardProblem::compute_quadrature_by_simulation(realtype t0) {
402+
void SteadyStateBackwardProblem::compute_quadrature_by_simulation(realtype const t0) {
403403
// If the Jacobian is singular, the integral over xB must be computed
404404
// by usual integration over time, but simplifications can be applied:
405405
// x is not time-dependent, no forward trajectory is needed.
@@ -409,7 +409,7 @@ void SteadyStateBackwardProblem::compute_quadrature_by_simulation(realtype t0) {
409409
// xQ was written in getQuadratureByLinSolve() -> set to zero
410410
xQ_.zero();
411411

412-
auto sim_solver = std::unique_ptr<Solver>(solver_->clone());
412+
auto const sim_solver = std::unique_ptr<Solver>(solver_->clone());
413413
sim_solver->logger = solver_->logger;
414414
sim_solver->setSensitivityMethod(SensitivityMethod::none);
415415
sim_solver->setSensitivityOrder(SensitivityOrder::none);
@@ -454,7 +454,7 @@ void SteadyStateBackwardProblem::run_simulation(Solver const& solver) {
454454
AmiVector xQBdot(model_->nplist(), solver.getSunContext());
455455

456456
int const convergence_check_frequency = newton_step_conv_ ? 25 : 1;
457-
auto max_steps = (solver.getMaxStepsBackwardProblem() > 0)
457+
auto const max_steps = (solver.getMaxStepsBackwardProblem() > 0)
458458
? solver.getMaxStepsBackwardProblem()
459459
: solver.getMaxSteps() * 100;
460460

src/cblas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void amici_dgemv(
5555
}
5656

5757
void amici_daxpy(
58-
int n, double alpha, double const* x, int const incx, double* y, int incy
58+
int const n, double const alpha, double const* x, int const incx, double* y, int const incy
5959
) {
6060
BLAS_FUNC(daxpy)(n, alpha, x, incx, y, incy);
6161
}

0 commit comments

Comments
 (0)