#include "config.h"#include <cassert>#include <cmath>#include <cstddef>#include <limits>Go to the source code of this file.
Namespaces | |
| namespace | numerics |
Functions | |
| double | numerics::expm1 (double x) |
| template<typename T > | |
| bool | numerics::is_nan (T f) |
| long | ld_round (double) |
| Round to nearest int, rounding midpoints upwards. | |
| double | dround (double) |
| Round to nearest int, rounding midpoints upwards. | |
| double | dtruncate (double) |
| Return integer part of argument. | |
| bool | is_integer (double) |
| Returns true if n is integer up to rounding error. | |
| long | mod_inverse (long a, long m) |
| Returns inverse of integer a modulo m. | |
| size_t | first_index (long period, long phase0, long step, long phase) |
| Return first matching index for entry in container with double periodicity. | |
Variables | |
| const double | numerics::e = std::numbers::e |
| const double | numerics::pi = std::numbers::pi |
| const double | numerics::nan = std::nan( "" ) |
| const double | numerics::sqrt_log_two = std::sqrt( std::numbers::ln2 ) |
| double dround | ( | double | x | ) |
Round to nearest int, rounding midpoints upwards.
Referenced by nest::Time::set_resolution().
| double dtruncate | ( | double | x | ) |
Return integer part of argument.
| size_t first_index | ( | long | period, |
| long | phase0, | ||
| long | step, | ||
| long | phase | ||
| ) |
Return first matching index for entry in container with double periodicity.
Consider
If such an index x exists, it is given by
x = phase0 + k' mod lcm(period, step) k' = min_k ( phase0 + k step = phase mod period )
As an example, consider
idx 0 1 2 3 4 5 6 7 8 9 10 11 | 12 13 14 15 16 17 18 gid 1 2 3 4 5 6 7 8 9 10 11 12 | 13 14 15 16 17 18 19 vp 1 2 3 0 1 2 3 0 1 2 3 0 | 1 2 3 0 1 2 3
Here, idx is a linear index into the container, gid neuron ids which map to the given vp numbers. The container is sliced with step=3, i.e., starting with the first element we take every third, as marked by the asterisks. The question is then at which index we find the first entry belonging to vp 0, 1, 2, or 3. The numbers in the bottom row show for clarity on which VP we find the respective asterisks. The | symbol marks where the pattern repeats itself.
phase0 in this example is 1, i.e., the VP of the first element in the container.
See comments in the function definition for implementation details.
References mod_inverse().
Referenced by nest::NodeCollectionComposite::specific_local_begin_().
| bool is_integer | ( | double | n | ) |
Returns true if n is integer up to rounding error.
Referenced by nest::SimulationManager::set_status().
| long ld_round | ( | double | x | ) |
Round to nearest int, rounding midpoints upwards.
Referenced by nest::Time::delay_ms_to_steps().
| long mod_inverse | ( | long | a, |
| long | m | ||
| ) |
Returns inverse of integer a modulo m.
For integer a > 0, m ≥ 2, find x so that ( a * x ) mod m = 1.
Referenced by first_index().