@@ -98,7 +98,7 @@ static realtype getValueById(
9898 std::vector<std::string> const & ids, std::vector<realtype> const & values,
9999 std::string const & id, char const * variable_name, char const * id_name
100100) {
101- auto it = std::find (ids. begin (), ids. end () , id);
101+ auto it = std::ranges:: find (ids, id);
102102 if (it != ids.end ())
103103 return values.at (it - ids.begin ());
104104
@@ -121,7 +121,7 @@ static void setValueById(
121121 realtype value, std::string const & id, char const * variable_name,
122122 char const * id_name
123123) {
124- auto it = std::find (ids. begin (), ids. end () , id);
124+ auto it = std::ranges:: find (ids, id);
125125 if (it != ids.end ())
126126 values.at (it - ids.begin ()) = value;
127127 else
@@ -338,8 +338,8 @@ void Model::initializeSplineSensitivities() {
338338 std::vector<realtype> tmp_dvalues (allnodes, 0.0 );
339339 std::vector<realtype> tmp_dslopes (allnodes, 0.0 );
340340 for (int ip = 0 ; ip < nplist (); ip++) {
341- std::fill (tmp_dvalues. begin (), tmp_dvalues. end () , 0.0 );
342- std::fill (tmp_dslopes. begin (), tmp_dslopes. end () , 0.0 );
341+ std::ranges:: fill (tmp_dvalues, 0.0 );
342+ std::ranges:: fill (tmp_dslopes, 0.0 );
343343 fdspline_valuesdp (
344344 tmp_dvalues.data (), state_.unscaledParameters .data (),
345345 state_.fixedParameters .data (), plist (ip)
@@ -405,7 +405,7 @@ void Model::initEvents(
405405) {
406406 std::vector<realtype> rootvals (ne, 0.0 );
407407 froot (simulation_parameters_.tstart_ , x, dx, rootvals);
408- std::fill (roots_found. begin (), roots_found. end () , 0 );
408+ std::ranges:: fill (roots_found, 0 );
409409 for (int ie = 0 ; ie < ne; ie++) {
410410 if (rootvals.at (ie) < 0 ) {
411411 state_.h .at (ie) = 0.0 ;
@@ -796,7 +796,7 @@ double Model::getTimepoint(int const it) const {
796796}
797797
798798void Model::setTimepoints (std::vector<realtype> const & ts) {
799- if (!std::is_sorted (ts. begin (), ts. end () ))
799+ if (!std::ranges:: is_sorted (ts))
800800 throw AmiException (" Encountered non-monotonic timepoints, please order"
801801 " timepoints such that they are monotonically"
802802 " increasing!" );
@@ -813,9 +813,7 @@ std::vector<bool> const& Model::getStateIsNonNegative() const {
813813
814814void Model::setStateIsNonNegative (std::vector<bool > const & nonNegative) {
815815 auto any_state_non_negative
816- = std::any_of (nonNegative.begin (), nonNegative.end (), [](bool x) {
817- return x;
818- });
816+ = std::ranges::any_of (nonNegative, [](bool x) { return x; });
819817 if (nx_solver != nx_rdata) {
820818 if (any_state_non_negative)
821819 throw AmiException (" Non-negative states are not supported with"
@@ -845,7 +843,7 @@ int Model::plist(int pos) const { return state_.plist.at(pos); }
845843
846844void Model::setParameterList (std::vector<int > const & plist) {
847845 int np = this ->np (); // cannot capture 'this' in lambda expression
848- if (std::any_of (plist. begin (), plist. end () , [&np](int idx) {
846+ if (std::ranges:: any_of (plist, [&np](int idx) {
849847 return idx < 0 || idx >= np;
850848 })) {
851849 throw AmiException (" Indices in plist must be in [0..np]" );
@@ -1112,7 +1110,7 @@ void Model::addObservableObjective(
11121110 std::vector<realtype> nllh (nJ, 0.0 );
11131111 for (int iyt = 0 ; iyt < nytrue; iyt++) {
11141112 if (edata.isSetObservedData (it, iyt)) {
1115- std::fill (nllh. begin (), nllh. end () , 0.0 );
1113+ std::ranges:: fill (nllh, 0.0 );
11161114 fJy (nllh.data (), iyt, state_.unscaledParameters .data (),
11171115 state_.fixedParameters .data (), derived_state_.y_ .data (),
11181116 derived_state_.sigmay_ .data (), edata.getObservedDataPtr (it));
@@ -1303,7 +1301,7 @@ void Model::addEventObjective(
13031301 std::vector<realtype> nllh (nJ, 0.0 );
13041302 for (int iztrue = 0 ; iztrue < nztrue; iztrue++) {
13051303 if (edata.isSetObservedEvents (nroots, iztrue)) {
1306- std::fill (nllh. begin (), nllh. end () , 0.0 );
1304+ std::ranges:: fill (nllh, 0.0 );
13071305 fJz (nllh.data (), iztrue, state_.unscaledParameters .data (),
13081306 state_.fixedParameters .data (), derived_state_.z_ .data (),
13091307 derived_state_.sigmaz_ .data (),
@@ -1323,7 +1321,7 @@ void Model::addEventObjectiveRegularization(
13231321 std::vector<realtype> nllh (nJ, 0.0 );
13241322 for (int iztrue = 0 ; iztrue < nztrue; iztrue++) {
13251323 if (edata.isSetObservedEvents (nroots, iztrue)) {
1326- std::fill (nllh. begin (), nllh. end () , 0.0 );
1324+ std::ranges:: fill (nllh, 0.0 );
13271325 fJrz (
13281326 nllh.data (), iztrue, state_.unscaledParameters .data (),
13291327 state_.fixedParameters .data (), derived_state_.rz_ .data (),
@@ -1395,7 +1393,7 @@ void Model::getEventTimeSensitivity(
13951393 AmiVector const & x, AmiVectorArray const & sx
13961394) {
13971395
1398- std::fill (stau. begin (), stau. end () , 0.0 );
1396+ std::ranges:: fill (stau, 0.0 );
13991397
14001398 for (int ip = 0 ; ip < nplist (); ip++) {
14011399 fstau (
@@ -1525,7 +1523,7 @@ void Model::updateHeavisideB(int const* rootsfound) {
15251523int Model::checkFinite (
15261524 gsl::span<realtype const > array, ModelQuantity model_quantity, realtype t
15271525) const {
1528- auto it = std::find_if (array. begin (), array. end () , [](realtype x) {
1526+ auto it = std::ranges:: find_if (array, [](realtype x) {
15291527 return !std::isfinite (x);
15301528 });
15311529 if (it == array.end ()) {
@@ -1624,7 +1622,7 @@ int Model::checkFinite(
16241622 gsl::span<realtype const > array, ModelQuantity model_quantity,
16251623 size_t num_cols, realtype t
16261624) const {
1627- auto it = std::find_if (array. begin (), array. end () , [](realtype x) {
1625+ auto it = std::ranges:: find_if (array, [](realtype x) {
16281626 return !std::isfinite (x);
16291627 });
16301628 if (it == array.end ()) {
@@ -1739,7 +1737,7 @@ int Model::checkFinite(SUNMatrix m, ModelQuantity model_quantity, realtype t)
17391737 // check flat array, to see if there are any issues
17401738 // (faster, in particular for sparse arrays)
17411739 auto m_flat = gsl::make_span (m);
1742- auto it = std::find_if (m_flat. begin (), m_flat. end () , [](realtype x) {
1740+ auto it = std::ranges:: find_if (m_flat, [](realtype x) {
17431741 return !std::isfinite (x);
17441742 });
17451743 if (it == m_flat.end ()) {
@@ -1831,9 +1829,7 @@ void Model::setAlwaysCheckFinite(bool alwaysCheck) {
18311829bool Model::getAlwaysCheckFinite () const { return always_check_finite_; }
18321830
18331831void Model::fx0 (AmiVector& x) {
1834- std::fill (
1835- derived_state_.x_rdata_ .begin (), derived_state_.x_rdata_ .end (), 0.0
1836- );
1832+ std::ranges::fill (derived_state_.x_rdata_ , 0.0 );
18371833 /* this function also computes initial total abundances */
18381834 fx0 (derived_state_.x_rdata_ .data (), simulation_parameters_.tstart_ ,
18391835 state_.unscaledParameters .data (), state_.fixedParameters .data ());
@@ -1877,10 +1873,7 @@ void Model::fsx0(AmiVectorArray& sx, AmiVector const& x) {
18771873 for (int ip = 0 ; ip < nplist (); ip++) {
18781874 if (ncl () > 0 )
18791875 stcl = &state_.stotal_cl .at (plist (ip) * ncl ());
1880- std::fill (
1881- derived_state_.sx_rdata_ .begin (), derived_state_.sx_rdata_ .end (),
1882- 0.0
1883- );
1876+ std::ranges::fill (derived_state_.sx_rdata_ , 0.0 );
18841877 fsx0 (
18851878 derived_state_.sx_rdata_ .data (), simulation_parameters_.tstart_ ,
18861879 computeX_pos (x), state_.unscaledParameters .data (),
@@ -2244,10 +2237,7 @@ void Model::fdJydy(int const it, AmiVector const& x, ExpData const& edata) {
22442237 }
22452238 }
22462239 } else {
2247- std::fill (
2248- derived_state_.dJydy_matlab_ .begin (),
2249- derived_state_.dJydy_matlab_ .end (), 0.0
2250- );
2240+ std::ranges::fill (derived_state_.dJydy_matlab_ , 0.0 );
22512241 for (int iyt = 0 ; iyt < nytrue; iyt++) {
22522242 if (!edata.isSetObservedData (it, iyt))
22532243 continue ;
@@ -2821,7 +2811,7 @@ void Model::fsspl(realtype const t) {
28212811
28222812void Model::fw (realtype const t, realtype const * x, bool include_static) {
28232813 if (include_static) {
2824- std::fill (derived_state_.w_ . begin (), derived_state_. w_ . end () , 0.0 );
2814+ std::ranges:: fill (derived_state_.w_ , 0.0 );
28252815 }
28262816 fspl (t);
28272817 fw (derived_state_.w_ .data (), t, x, state_.unscaledParameters .data (),
@@ -3076,7 +3066,7 @@ std::vector<double> Model::get_trigger_timepoints() const {
30763066 for (auto const & kv : state_independent_events_) {
30773067 *(it++) = kv.first ;
30783068 }
3079- std::sort (trigger_timepoints. begin (), trigger_timepoints. end () );
3069+ std::ranges:: sort (trigger_timepoints);
30803070 return trigger_timepoints;
30813071}
30823072
0 commit comments