FIMS  v0.10.0
Loading...
Searching...
No Matches
size_grid.hpp
Go to the documentation of this file.
1
9#ifndef FIMS_POPULATION_DYNAMICS_SIZE_GRID_HPP
10#define FIMS_POPULATION_DYNAMICS_SIZE_GRID_HPP
11
12#include <cstddef>
13
14#include "../../common/fims_vector.hpp"
15
16namespace fims_popdy {
17
26struct SizeGrid {
27 std::size_t n_bins = 0;
36 if (n_bins == 0) {
37 return edges.size() == 0;
38 }
39
40 if (edges.size() != n_bins + 1) {
41 return false;
42 }
43
44 for (std::size_t i = 1; i < edges.size(); ++i) {
45 if (!(edges[i] > edges[i - 1])) {
46 return false;
47 }
48 }
49
50 return true;
51 }
52
57 bool CentersFallWithinBins() const {
58 if (n_bins == 0) {
59 return centers.size() == 0;
60 }
61
62 if (centers.size() != n_bins || edges.size() != n_bins + 1) {
63 return false;
64 }
65
66 for (std::size_t i = 0; i < n_bins; ++i) {
67 if (!(centers[i] > edges[i] && centers[i] < edges[i + 1])) {
68 return false;
69 }
70 }
71
72 return true;
73 }
74
80 bool IsConsistent() const {
81 if (n_bins == 0) {
82 return edges.size() == 0 && centers.size() == 0;
83 }
84
86 }
87};
88
89} // namespace fims_popdy
90#endif /* FIMS_POPULATION_DYNAMICS_SIZE_GRID_HPP */
Definition fims_vector.hpp:27
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:299
The population dynamics of FIMS.
Definition catch_at_age.hpp:45
std::shared_ptr< AgeToLengthConversionBase< Type > > BuildAgeToLengthConversionFleet(const std::shared_ptr< Population< Type > > &population, const std::shared_ptr< Fleet< Type > > &fleet)
Build the active age-to-length conversion for a fleet from the current population and fleet state.
Definition runtime.hpp:44
Population-level biological size grid.
Definition size_grid.hpp:26
bool HasStrictlyIncreasingEdges() const
Return whether the bin edges are strictly increasing.
Definition size_grid.hpp:35
bool CentersFallWithinBins() const
Return whether each center falls inside its matching bin.
Definition size_grid.hpp:57
bool IsConsistent() const
Return whether the grid dimensions and geometry are internally consistent.
Definition size_grid.hpp:80
fims::Vector< double > centers
Definition size_grid.hpp:29
fims::Vector< double > edges
Definition size_grid.hpp:28
std::size_t n_bins
Definition size_grid.hpp:27