|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Records the number of cells that changed across each step. More...
#include <ca-observer.H>
Public Member Functions | |
| Activity_Observer ()=default | |
| Construct an empty activity observer. | |
| const Array< ca_size_t > & | activity () const noexcept |
| Return the activity time series. | |
| std::size_t | size () const noexcept |
| Return the number of recorded steps. | |
| void | reset () noexcept |
| Clear the previous frame and activity samples. | |
| void | on_step_begin (std::size_t step, const Lattice &frame) |
| Capture the frame before a step. | |
| void | on_step_end (const std::size_t step, const Lattice &frame) |
| Record changed cells after a step. | |
Private Attributes | |
| std::optional< Lattice > | prev_ |
| Array< ca_size_t > | activity_ |
Records the number of cells that changed across each step.
Implementation note: the observer maintains a copy of the previous frame between on_step_begin and on_step_end. This costs O(N) memory but avoids depending on the engine to expose the previous frame, and keeps the observer self-contained.
| Lattice | lattice type the observer is wired to. Stored as a member so the previous frame can be retained. |
on_step_begin copies one frame in O(N); on_step_end compares frames in O(N).Definition at line 458 of file ca-observer.H.
|
default |
Construct an empty activity observer.
| This | function does not throw. |
|
inlinenoexcept |
Return the activity time series.
| This | function does not throw. |
Definition at line 473 of file ca-observer.H.
References Aleph::CA::Activity_Observer< Lattice >::activity_.
|
inline |
Capture the frame before a step.
| [in] | step | step index about to run, ignored. |
| [in] | frame | frame before the step. |
| Any | exception thrown while copying frame. |
Definition at line 504 of file ca-observer.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Activity_Observer< Lattice >::prev_.
|
inline |
Record changed cells after a step.
| [in] | step | completed step index, ignored. |
| [in] | frame | frame after the step. |
| std::bad_alloc | if appending the sample allocates. |
Definition at line 515 of file ca-observer.H.
References Aleph::CA::Activity_Observer< Lattice >::activity_, Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::cell_diff_count(), and Aleph::CA::Activity_Observer< Lattice >::prev_.
|
inlinenoexcept |
Clear the previous frame and activity samples.
| This | function does not throw. |
Definition at line 493 of file ca-observer.H.
References Aleph::CA::Activity_Observer< Lattice >::activity_, Aleph::Array< T >::clear(), and Aleph::CA::Activity_Observer< Lattice >::prev_.
|
inlinenoexcept |
Return the number of recorded steps.
| This | function does not throw. |
Definition at line 482 of file ca-observer.H.
References Aleph::CA::Activity_Observer< Lattice >::activity_, and Aleph::Array< T >::size().
|
private |
Definition at line 461 of file ca-observer.H.
Referenced by Aleph::CA::Activity_Observer< Lattice >::activity(), Aleph::CA::Activity_Observer< Lattice >::on_step_end(), Aleph::CA::Activity_Observer< Lattice >::reset(), and Aleph::CA::Activity_Observer< Lattice >::size().
|
private |
Definition at line 460 of file ca-observer.H.
Referenced by Aleph::CA::Activity_Observer< Lattice >::on_step_begin(), Aleph::CA::Activity_Observer< Lattice >::on_step_end(), and Aleph::CA::Activity_Observer< Lattice >::reset().