|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Records the Shannon entropy of the state distribution. More...
#include <ca-observer.H>
Public Member Functions | |
| Entropy_Observer ()=default | |
| Construct an empty entropy observer. | |
| Entropy_Observer (const Entropy_Observer &other)=default | |
| Copy another observer: the entropy of each step, and whether it has seen a frame. | |
| Entropy_Observer (Entropy_Observer &&other) noexcept | |
| Take the samples of another observer, which is left with none. | |
| Entropy_Observer & | operator= (const Entropy_Observer &other)=default |
| Copy another observer into this one: the entropy of each step, and whether it has seen a frame. | |
| Entropy_Observer & | operator= (Entropy_Observer &&other) noexcept |
| Exchange this observer with another, which is left with the previous samples of this one. | |
| void | swap (Entropy_Observer &other) noexcept |
| Exchange in O(1) the samples of this observer and another. | |
| const Array< double > & | entropy () const noexcept |
| Return the entropy time series. | |
| std::size_t | size () const noexcept |
| Return the number of entropy samples. | |
| void | reset () noexcept |
| Clear all entropy samples. | |
| template<typename Lattice > | |
| void | on_step_begin (const std::size_t step, const Lattice &frame) |
| Record entropy of the initial frame. | |
| template<typename Lattice > | |
| void | on_step_end (const std::size_t step, const Lattice &frame) |
| Record entropy after a completed step. | |
Private Attributes | |
| Array< double > | entropy_ |
| bool | seeded_ = false |
Records the Shannon entropy of the state distribution.
Computes the entropy in nats over the integer states in [0, MaxState). Pushes one sample per step (including the initial frame).
| MaxState | exclusive upper bound on the state values. |
Definition at line 601 of file ca-observer.H.
|
default |
Construct an empty entropy observer.
| This | function does not throw. |
|
default |
Copy another observer: the entropy of each step, and whether it has seen a frame.
| [in] | other | observer to copy. |
|
inlinenoexcept |
Take the samples of another observer, which is left with none.
The implicit move took the samples but copied the flag of the initial sample: the moved-from observer, reused, skipped the initial frame of its next run.
| [in,out] | other | observer to move from. |
Definition at line 626 of file ca-observer.H.
|
inlinenoexcept |
Return the entropy time series.
| This | function does not throw. |
Definition at line 661 of file ca-observer.H.
References Aleph::CA::Entropy_Observer< MaxState >::entropy_.
Referenced by main().
|
inline |
Record entropy of the initial frame.
| Lattice | lattice type. |
| [in] | step | step index about to run. |
| [in] | frame | frame before the step. |
| std::bad_alloc | if appending the sample allocates. |
Definition at line 694 of file ca-observer.H.
References Aleph::and, Aleph::Array< T >::append(), Aleph::CA::Entropy_Observer< MaxState >::entropy_, Aleph::CA::Entropy_Observer< MaxState >::seeded_, and Aleph::CA::shannon_entropy().
|
inline |
Record entropy after a completed step.
| Lattice | lattice type. |
| [in] | step | completed step index, ignored. |
| [in] | frame | frame after the step. |
| std::bad_alloc | if appending the sample allocates. |
Definition at line 710 of file ca-observer.H.
References Aleph::Array< T >::append(), Aleph::CA::Entropy_Observer< MaxState >::entropy_, and Aleph::CA::shannon_entropy().
|
default |
Copy another observer into this one: the entropy of each step, and whether it has seen a frame.
| [in] | other | observer to copy. |
|
inlinenoexcept |
Exchange this observer with another, which is left with the previous samples of this one.
| [in,out] | other | observer to move from. |
Definition at line 642 of file ca-observer.H.
References Aleph::CA::Entropy_Observer< MaxState >::swap().
|
inlinenoexcept |
Clear all entropy samples.
| This | function does not throw. |
Definition at line 681 of file ca-observer.H.
References Aleph::Array< T >::clear(), Aleph::CA::Entropy_Observer< MaxState >::entropy_, and Aleph::CA::Entropy_Observer< MaxState >::seeded_.
|
inlinenoexcept |
Return the number of entropy samples.
| This | function does not throw. |
Definition at line 670 of file ca-observer.H.
References Aleph::CA::Entropy_Observer< MaxState >::entropy_, and Aleph::Array< T >::size().
Referenced by main().
|
inlinenoexcept |
Exchange in O(1) the samples of this observer and another.
| [in,out] | other | observer to exchange with. |
Definition at line 651 of file ca-observer.H.
References Aleph::CA::Entropy_Observer< MaxState >::entropy_, Aleph::CA::Entropy_Observer< MaxState >::seeded_, and Aleph::Array< T >::swap().
Referenced by Aleph::CA::Entropy_Observer< MaxState >::operator=().
|
private |
Definition at line 603 of file ca-observer.H.
Referenced by Aleph::CA::Entropy_Observer< MaxState >::entropy(), Aleph::CA::Entropy_Observer< MaxState >::on_step_begin(), Aleph::CA::Entropy_Observer< MaxState >::on_step_end(), Aleph::CA::Entropy_Observer< MaxState >::reset(), Aleph::CA::Entropy_Observer< MaxState >::size(), and Aleph::CA::Entropy_Observer< MaxState >::swap().
|
private |
Definition at line 604 of file ca-observer.H.
Referenced by Aleph::CA::Entropy_Observer< MaxState >::on_step_begin(), Aleph::CA::Entropy_Observer< MaxState >::reset(), and Aleph::CA::Entropy_Observer< MaxState >::swap().