Skip to content

Commit

Permalink
Doc fixes for propagate_grid() changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Dec 16, 2023
1 parent ee8d73a commit d5308e9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
12 changes: 10 additions & 2 deletions doc/tut_adaptive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,16 @@ contiguously in row-major order:
x(0.4) = 0.0232578
v(0.4) = -0.14078
There are no special requirements on the time values in the grid (apart from the
fact that they must be finite and ordered monotonically).
There are a few requirements on the time values in the grid:

- they must all be finite,
- they must be ordered monotonically,
- the first value in the grid must be equal to the current
time of the integrator.

.. versionchanged:: 4.0.0

The requirement on the first value of the time grid.

.. versionadded:: 0.7.0

Expand Down
2 changes: 1 addition & 1 deletion doc/tut_events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ execution of the callback:

.. literalinclude:: ../tutorial/event_basic.cpp
:language: c++
:lines: 136-145
:lines: 136-146

.. code-block:: console
Expand Down
3 changes: 1 addition & 2 deletions doc/tut_s11n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,11 @@ example, again based on the simple pendulum:

.. literalinclude:: ../tutorial/s11n_event.cpp
:language: c++
:lines: 35-71
:lines: 35-69

.. code-block:: console
Number of events (original) : 1
Number of events (after reset) : 0
Number of events (from archive): 1
The screen output indeed confirms that the event callback was correctly (de)serialised.
Expand Down
8 changes: 4 additions & 4 deletions tutorial/adaptive_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ int main()

// Propagate over a time grid from 0 to 1
// at regular intervals.
auto out = ta.propagate_grid({0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0});
auto out = ta.propagate_grid({0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0});

// Print the state at t = 0.4 (index 3 in the time grid).
std::cout << "x(0.4) = " << std::get<4>(out)[2 * 3] << '\n';
std::cout << "v(0.4) = " << std::get<4>(out)[2 * 3 + 1] << '\n';
// Print the state at t = 0.4 (index 4 in the time grid).
std::cout << "x(0.4) = " << std::get<4>(out)[2 * 4] << '\n';
std::cout << "v(0.4) = " << std::get<4>(out)[2 * 4 + 1] << '\n';
}
1 change: 1 addition & 0 deletions tutorial/event_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ int main()
std::cout << "Event index : " << static_cast<std::int64_t>(oc) << '\n';

// Integrate over a time grid.
ta.propagate_until(1.);
auto out = ta.propagate_grid({1., 2., 3., 4., 5., 6., 7., 8., 9., 10.});

// Let's print the values of the state vector
Expand Down
2 changes: 0 additions & 2 deletions tutorial/s11n_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ int main()
// Reset ta to an integrator without events.
ta = taylor_adaptive<double>{{prime(x) = v, prime(v) = -9.8 * sin(x)}, {0.05, 0.025}};

std::cout << "Number of events (after reset) : " << ta.get_nt_events().size() << '\n';

// Restore the serialised representation of ta.
{
boost::archive::binary_iarchive ia(ss);
Expand Down

0 comments on commit d5308e9

Please sign in to comment.