1 : |
agomez |
1 |
#ifndef popratiomatrix_h
|
2 : |
|
|
#define popratiomatrix_h
|
3 : |
|
|
|
4 : |
|
|
#include "intvector.h" |
5 : |
|
|
#include "popratiovector.h" |
6 : |
|
|
|
7 : |
|
|
/**
|
8 : |
|
|
* \class PopRatioMatrix
|
9 : |
|
|
* \brief This class implements a dynamic vector of PopRatioVector values
|
10 : |
|
|
*/
|
11 : |
|
|
class PopRatioMatrix {
|
12 : |
|
|
public:
|
13 : |
|
|
/**
|
14 : |
|
|
* \brief This is the default PopRatioMatrix constructor
|
15 : |
|
|
*/
|
16 : |
|
|
PopRatioMatrix() { nrow = 0; v = 0; };
|
17 : |
|
|
/**
|
18 : |
|
|
* \brief This is the PopRatioMatrix constructor for a specified size
|
19 : |
|
|
* \param nr is the size of the vector to be created
|
20 : |
|
|
* \param nc is the length of each row to be created (ie. the size of the PopRatioVector to be created for each row)
|
21 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
22 : |
|
|
*/
|
23 : |
|
|
PopRatioMatrix(int nr, int nc, PopRatio initial);
|
24 : |
|
|
/**
|
25 : |
|
|
* \brief This is the PopRatioMatrix constructor that creates a copy of an existing PopRatioMatrix
|
26 : |
|
|
* \param initial is the PopRatioMatrix to copy
|
27 : |
|
|
*/
|
28 : |
|
|
PopRatioMatrix(const PopRatioMatrix& initial);
|
29 : |
|
|
/**
|
30 : |
|
|
* \brief This is the PopRatioMatrix destructor
|
31 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
32 : |
|
|
*/
|
33 : |
|
|
~PopRatioMatrix();
|
34 : |
|
|
/**
|
35 : |
|
|
* \brief This will return the number of columns in row i of the vector
|
36 : |
|
|
* \param i is the row of the vector to have the number of columns counted
|
37 : |
|
|
* \return the number of columns in row i of the vector
|
38 : |
|
|
* \note This is the number of entries in the PopRatioVector that is entry i of the PopRatioMatrix
|
39 : |
|
|
*/
|
40 : |
|
|
int Ncol(int i = 0) const { return v[i]->Size(); };
|
41 : |
|
|
/**
|
42 : |
|
|
* \brief This will return the number of rows of the vector
|
43 : |
|
|
* \return the number of rows of the vector
|
44 : |
|
|
*/
|
45 : |
|
|
int Nrow() const { return nrow; };
|
46 : |
|
|
/**
|
47 : |
|
|
* \brief This will return the value of an element of the vector
|
48 : |
|
|
* \param pos is the element of the vector to be returned
|
49 : |
|
|
* \return the value of the specified element
|
50 : |
|
|
*/
|
51 : |
|
|
PopRatioVector& operator [] (int pos) { return *v[pos]; };
|
52 : |
|
|
/**
|
53 : |
|
|
* \brief This will return the value of an element of the vector
|
54 : |
|
|
* \param pos is the element of the vector to be returned
|
55 : |
|
|
* \return the value of the specified element
|
56 : |
|
|
*/
|
57 : |
|
|
const PopRatioVector& operator [] (int pos) const { return *v[pos]; };
|
58 : |
|
|
/**
|
59 : |
|
|
* \brief This will add new entries to the vector
|
60 : |
|
|
* \param add is the number of new entries to the vector
|
61 : |
|
|
* \param length is the number of entries to the PopRatioVector that is created
|
62 : |
|
|
* \param value is the value that will be entered for the new entries
|
63 : |
|
|
*/
|
64 : |
|
|
void AddRows(int add, int length, PopRatio value);
|
65 : |
|
|
/**
|
66 : |
|
|
* \brief This will delete an entry from the vector
|
67 : |
|
|
* \param pos is the element of the vector to be deleted
|
68 : |
|
|
* \note This will free the memory allocated to the deleted element of the vector
|
69 : |
|
|
*/
|
70 : |
|
|
void Delete(int pos);
|
71 : |
|
|
protected:
|
72 : |
|
|
/**
|
73 : |
|
|
* \brief This is number of rows of the vector
|
74 : |
|
|
*/
|
75 : |
|
|
int nrow;
|
76 : |
|
|
/**
|
77 : |
|
|
* \brief This is the vector of PopRatioVector values
|
78 : |
|
|
*/
|
79 : |
|
|
PopRatioVector** v;
|
80 : |
|
|
};
|
81 : |
|
|
|
82 : |
|
|
#endif
|