FIMS  v0.10.0
Loading...
Searching...
No Matches
size_products.hpp
Go to the documentation of this file.
1
9#ifndef FIMS_POPULATION_DYNAMICS_SIZE_PRODUCTS_HPP
10#define FIMS_POPULATION_DYNAMICS_SIZE_PRODUCTS_HPP
11
12#include <cstddef>
13#include <stdexcept>
14
15#include "../../common/fims_vector.hpp"
16
17namespace fims_popdy {
18
29template <typename Type>
31 std::size_t n_years = 0;
32 std::size_t n_ages = 0;
33 std::size_t n_size_bins =
34 0;
46
53 SizeProducts(std::size_t years, std::size_t ages, std::size_t size_bins) {
54 Resize(years, ages, size_bins);
55 }
56
63 void Resize(std::size_t years, std::size_t ages, std::size_t size_bins) {
64 n_years = years;
65 n_ages = ages;
67
68 const std::size_t n_age_year = n_years * n_ages;
69 const std::size_t n_prob = n_years * n_ages * n_size_bins;
70
71 mean_LAA.resize(n_age_year);
72 sd_LAA.resize(n_age_year);
73 prob_size.resize(n_prob);
74 }
75
85 void ResizeProbSizeOnly(std::size_t years, std::size_t ages,
86 std::size_t size_bins) {
87 n_years = years;
88 n_ages = ages;
90
91 mean_LAA.clear();
92 sd_LAA.clear();
93
94 const std::size_t n_prob = n_years * n_ages * n_size_bins;
95 prob_size.resize(n_prob);
96 }
97
104 inline std::size_t AgeYearIndex(std::size_t year_index,
105 std::size_t age_index) const {
106 if (year_index >= n_years || age_index >= n_ages) {
107 throw std::out_of_range("SizeProducts year-age index out of range");
108 }
109
110 return year_index * n_ages + age_index;
111 }
112
120 inline std::size_t AgeYearSizeIndex(std::size_t year_index,
121 std::size_t age_index,
122 std::size_t size_bin_index) const {
123 if (year_index >= n_years || age_index >= n_ages ||
125 throw std::out_of_range("SizeProducts year-age-size index out of range");
126 }
127
130 }
131
138 inline Type& MeanLAA(std::size_t year_index, std::size_t age_index) {
140 }
141
148 inline Type& SdLAA(std::size_t year_index, std::size_t age_index) {
150 }
151
159 inline Type& ProbSize(std::size_t year_index, std::size_t age_index,
160 std::size_t size_bin_index) {
162 }
163
170 inline const Type& MeanLAA(std::size_t year_index,
171 std::size_t age_index) const {
173 }
174
181 inline const Type& SdLAA(std::size_t year_index,
182 std::size_t age_index) const {
184 }
185
193 inline const Type& ProbSize(std::size_t year_index, std::size_t age_index,
194 std::size_t size_bin_index) const {
196 }
197};
198
199} // namespace fims_popdy
200
201#endif /* FIMS_POPULATION_DYNAMICS_SIZE_PRODUCTS_HPP */
Definition fims_vector.hpp:27
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
Cached population-level size outputs on a biological size grid.
Definition size_products.hpp:30
const Type & MeanLAA(std::size_t year_index, std::size_t age_index) const
Read mean length-at-age.
Definition size_products.hpp:170
Type & MeanLAA(std::size_t year_index, std::size_t age_index)
Access mean length-at-age.
Definition size_products.hpp:138
std::size_t AgeYearIndex(std::size_t year_index, std::size_t age_index) const
Return the flattened index for year-age products.
Definition size_products.hpp:104
fims::Vector< Type > mean_LAA
Definition size_products.hpp:36
std::size_t n_ages
Definition size_products.hpp:32
std::size_t AgeYearSizeIndex(std::size_t year_index, std::size_t age_index, std::size_t size_bin_index) const
Return the flattened index for year-age-size-bin probabilities.
Definition size_products.hpp:120
void Resize(std::size_t years, std::size_t ages, std::size_t size_bins)
Resize all cached product arrays.
Definition size_products.hpp:63
const Type & ProbSize(std::size_t year_index, std::size_t age_index, std::size_t size_bin_index) const
Read age-to-size probability.
Definition size_products.hpp:193
void ResizeProbSizeOnly(std::size_t years, std::size_t ages, std::size_t size_bins)
Resize only the cached age-to-size probability array.
Definition size_products.hpp:85
SizeProducts(std::size_t years, std::size_t ages, std::size_t size_bins)
Construct and size the size-product container.
Definition size_products.hpp:53
std::size_t n_years
Definition size_products.hpp:31
std::size_t n_size_bins
Definition size_products.hpp:33
fims::Vector< Type > sd_LAA
Definition size_products.hpp:38
SizeProducts()
Default constructor.
Definition size_products.hpp:45
Type & ProbSize(std::size_t year_index, std::size_t age_index, std::size_t size_bin_index)
Access age-to-size probability.
Definition size_products.hpp:159
Type & SdLAA(std::size_t year_index, std::size_t age_index)
Access spread of length-at-age.
Definition size_products.hpp:148
fims::Vector< Type > prob_size
Definition size_products.hpp:40
const Type & SdLAA(std::size_t year_index, std::size_t age_index) const
Read spread of length-at-age.
Definition size_products.hpp:181