1 : |
agomez |
1 |
#ifndef agebandmatrix_h
|
2 : |
|
|
#define agebandmatrix_h
|
3 : |
|
|
|
4 : |
|
|
#include "conversionindex.h" |
5 : |
|
|
#include "doublematrix.h" |
6 : |
|
|
#include "popinfomatrix.h" |
7 : |
|
|
#include "popinfoindexvector.h" |
8 : |
ulcessvp |
2 |
#include "matrix.h" |
9 : |
agomez |
1 |
|
10 : |
|
|
class Maturity;
|
11 : |
|
|
|
12 : |
|
|
/**
|
13 : |
|
|
* \class AgeBandMatrix
|
14 : |
|
|
* \brief This class implements a vector of PopInfoIndexVector values, indexed from minage not 0
|
15 : |
|
|
*/
|
16 : |
|
|
class AgeBandMatrix {
|
17 : |
|
|
public:
|
18 : |
|
|
/**
|
19 : |
|
|
* \brief This is the default AgeBandMatrix constructor
|
20 : |
|
|
*/
|
21 : |
|
|
AgeBandMatrix() { minage = 0; nrow = 0; v = 0; };
|
22 : |
|
|
/**
|
23 : |
|
|
* \brief This is the AgeBandMatrix constructor for a specified minimum age and size
|
24 : |
|
|
* \param age is the minimum index of the vector to be created
|
25 : |
|
|
* \param minl is the IntVector of minimum lengths used when constructing the entries of the vector
|
26 : |
|
|
* \param size is the IntVector of sizes used when constructing the entries of the vector
|
27 : |
|
|
*/
|
28 : |
|
|
AgeBandMatrix(int age, const IntVector& minl, const IntVector& size);
|
29 : |
|
|
/**
|
30 : |
|
|
* \brief This is the AgeBandMatrix constructor for a specified minimum age and initial value
|
31 : |
|
|
* \param age is the minimum index of the vector to be created
|
32 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
33 : |
|
|
* \param minl is the minimum length used when constructing the entries of the vector
|
34 : |
|
|
*/
|
35 : |
|
|
AgeBandMatrix(int age, const PopInfoMatrix& initial, int minl);
|
36 : |
|
|
/**
|
37 : |
|
|
* \brief This is the AgeBandMatrix constructor for a specified minimum age and initial value
|
38 : |
|
|
* \param age is the minimum index of the vector to be created
|
39 : |
|
|
* \param initial is the initial value for the entry of the vector
|
40 : |
|
|
* \note There will only be one entry on the vector created with this constructor
|
41 : |
|
|
*/
|
42 : |
|
|
AgeBandMatrix(int age, const PopInfoIndexVector& initial);
|
43 : |
|
|
/**
|
44 : |
|
|
* \brief This is the AgeBandMatrix constructor that creates a copy of an existing AgeBandMatrix
|
45 : |
|
|
* \param initial is the AgeBandMatrix to copy
|
46 : |
|
|
*/
|
47 : |
|
|
AgeBandMatrix(const AgeBandMatrix& initial);
|
48 : |
|
|
/**
|
49 : |
|
|
* \brief This is the AgeBandMatrix destructor
|
50 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
51 : |
|
|
*/
|
52 : |
|
|
~AgeBandMatrix();
|
53 : |
|
|
/**
|
54 : |
|
|
* \brief This will return the minimum age of the population stored in the vector
|
55 : |
|
|
* \return minimum age
|
56 : |
|
|
*/
|
57 : |
|
|
int minAge() const { return minage; };
|
58 : |
|
|
/**
|
59 : |
|
|
* \brief This will return the maximum age of the population stored in the vector
|
60 : |
|
|
* \return maximum age
|
61 : |
|
|
*/
|
62 : |
|
|
int maxAge() const { return minage + nrow - 1; };
|
63 : |
|
|
/**
|
64 : |
|
|
* \brief This will return the number of rows of the vector
|
65 : |
|
|
* \return the number of rows of the vector
|
66 : |
|
|
*/
|
67 : |
|
|
int Nrow() const { return nrow; };
|
68 : |
|
|
/**
|
69 : |
|
|
* \brief This will return the value of an element of the vector
|
70 : |
|
|
* \param age is the element of the vector to be returned
|
71 : |
|
|
* \return the value of the specified element
|
72 : |
|
|
*/
|
73 : |
|
|
PopInfoIndexVector& operator [] (int age) { return *(v[age - minage]); };
|
74 : |
|
|
/**
|
75 : |
|
|
* \brief This will return the value of an element of the vector
|
76 : |
|
|
* \param age is the element of the vector to be returned
|
77 : |
|
|
* \return the value of the specified element
|
78 : |
|
|
*/
|
79 : |
|
|
const PopInfoIndexVector& operator [] (int age) const { return *(v[age - minage]); };
|
80 : |
|
|
/**
|
81 : |
|
|
* \brief This will return the minimum length of an age group stored in the vector
|
82 : |
|
|
* \param age is identifier for the age group
|
83 : |
|
|
* \return minimum length
|
84 : |
|
|
*/
|
85 : |
|
|
int minLength(int age) const { return v[age - minage]->minCol(); };
|
86 : |
|
|
/**
|
87 : |
|
|
* \brief This will return the maximum length of an age group stored in the vector
|
88 : |
|
|
* \param age is identifier for the age group
|
89 : |
|
|
* \return maximum length
|
90 : |
|
|
*/
|
91 : |
|
|
int maxLength(int age) const { return v[age - minage]->maxCol(); };
|
92 : |
|
|
/**
|
93 : |
|
|
* \brief This function will sum the columns of each element stored in the vector (ie sum over all ages for each length group of the population)
|
94 : |
|
|
* \param Result is the PopInfoVector containing the sum over all ages for each length
|
95 : |
|
|
*/
|
96 : |
|
|
void sumColumns(PopInfoVector& Result) const;
|
97 : |
|
|
/**
|
98 : |
|
|
* \brief This function will subtract a multiplicative ratio from each element stored in the vector
|
99 : |
|
|
* \param Ratio is the DoubleVector of multiplicative constants
|
100 : |
|
|
* \param CI is the ConversionIndex that will convert between the length groups of the 2 vectors
|
101 : |
|
|
*/
|
102 : |
|
|
void Subtract(const DoubleVector& Ratio, const ConversionIndex& CI);
|
103 : |
|
|
/**
|
104 : |
|
|
* \brief This function will multiply each element stored in the vector by a constant
|
105 : |
|
|
* \param Ratio is the DoubleVector of multiplicative constants
|
106 : |
|
|
*/
|
107 : |
|
|
void Multiply(const DoubleVector& Ratio);
|
108 : |
|
|
/**
|
109 : |
|
|
* \brief This function will set the population stored in the vector to zero
|
110 : |
|
|
*/
|
111 : |
|
|
void setToZero();
|
112 : |
|
|
/**
|
113 : |
|
|
* \brief This function will increase the age of the population stored in the vector to zero
|
114 : |
|
|
*/
|
115 : |
|
|
void IncrementAge();
|
116 : |
|
|
/**
|
117 : |
|
|
* \brief This function will print the numbers of the population stored in the vector
|
118 : |
|
|
* \param outfile is the ofstream that all the model information gets sent to
|
119 : |
|
|
*/
|
120 : |
|
|
void printNumbers(ofstream& outfile) const;
|
121 : |
|
|
/**
|
122 : |
|
|
* \brief This function will print the mean weights of the population stored in the vector
|
123 : |
|
|
* \param outfile is the ofstream that all the model information gets sent to
|
124 : |
|
|
*/
|
125 : |
|
|
void printWeights(ofstream& outfile) const;
|
126 : |
|
|
/**
|
127 : |
|
|
* \brief This function will increase the length and mean weight of the population stored in the vector, according to values calculated by the GrowthCalc calculations for the population
|
128 : |
ulcessvp |
12 |
* \param Lgrowth is the Matrix of doubles of the calculated change in length due to the growth
|
129 : |
|
|
* \param Wgrowth is the Matrix of doubles of the calculated change in mean weight due to the growth
|
130 : |
agomez |
1 |
*/
|
131 : |
ulcessvp |
2 |
void Grow(const Matrix& Lgrowth, const Matrix& Wgrowth);
|
132 : |
ulcessvp |
4 |
// void Grow(const DoubleMatrix& Lgrowth, const DoubleMatrix& Wgrowth);
|
133 : |
agomez |
1 |
/**
|
134 : |
|
|
* \brief This function will increase the length and mean weight of the population stored in the vector, according to values calculated by the GrowthCalc and Maturity calculations for the population
|
135 : |
|
|
* \param Lgrowth is the DoubleMatrix of the calculated change in length due to the growth
|
136 : |
|
|
* \param Wgrowth is the DoubleMatrix of the calculated change in mean weight due to the growth
|
137 : |
|
|
* \param Mat is the Maturity used to calculate (and store) the proportion that population that will mature
|
138 : |
|
|
* \param area is the identifier for the are used for the maturation process
|
139 : |
|
|
*/
|
140 : |
ulcessvp |
4 |
void Grow(const Matrix& Lgrowth, const Matrix& Wgrowth, Maturity* const Mat, int area);
|
141 : |
agomez |
1 |
/**
|
142 : |
|
|
* \brief This function will increase the length of the population stored in the vector, according to values calculated by the GrowthCalc calculations for the population
|
143 : |
|
|
* \param Lgrowth is the DoubleMatrix of the calculated change in length due to the growth
|
144 : |
|
|
* \param Weight is the DoubleVector of the specified mean weight of the population
|
145 : |
|
|
* \note The mean weight of the population is fixed to values specified in the input file for the population
|
146 : |
|
|
*/
|
147 : |
ulcessvp |
4 |
void Grow(const Matrix& Lgrowth, const DoubleVector& Weight);
|
148 : |
agomez |
1 |
/**
|
149 : |
|
|
* \brief This function will increase the length and mean weight of the population stored in the vector, according to values calculated by the GrowthCalc and Maturity calculations for the population
|
150 : |
|
|
* \param Lgrowth is the DoubleMatrix of the calculated change in length due to the growth
|
151 : |
|
|
* \param Weight is the DoubleVector of the specified mean weight of the population
|
152 : |
|
|
* \param Mat is the Maturity used to calculate (and store) the proportion that population that will mature
|
153 : |
|
|
* \param area is the identifier for the are used for the maturation process
|
154 : |
|
|
* \note The mean weight of the population is fixed to values specified in the input file for the population
|
155 : |
|
|
*/
|
156 : |
ulcessvp |
4 |
void Grow(const Matrix& Lgrowth, const DoubleVector& Weight, Maturity* const Mat, int area);
|
157 : |
agomez |
1 |
/**
|
158 : |
|
|
* \brief This function will add a AgeBandMatrix to the current vector
|
159 : |
|
|
* \param Addition is the AgeBandMatrix that will be added to the current vector
|
160 : |
|
|
* \param CI is the ConversionIndex that will convert between the length groups of the 2 vectors
|
161 : |
|
|
* \param ratio is a multiplicative constant applied to each entry (default value 1.0)
|
162 : |
|
|
*/
|
163 : |
|
|
void Add(const AgeBandMatrix& Addition, const ConversionIndex& CI, double ratio = 1.0);
|
164 : |
|
|
protected:
|
165 : |
|
|
/**
|
166 : |
|
|
* \brief This is the index for the vector
|
167 : |
|
|
*/
|
168 : |
|
|
int minage;
|
169 : |
|
|
/**
|
170 : |
|
|
* \brief This is number of rows of the vector
|
171 : |
|
|
*/
|
172 : |
|
|
int nrow;
|
173 : |
|
|
/**
|
174 : |
|
|
* \brief This is the indexed vector of PopInfoIndexVector values
|
175 : |
|
|
*/
|
176 : |
|
|
PopInfoIndexVector** v;
|
177 : |
|
|
};
|
178 : |
|
|
|
179 : |
|
|
#endif
|