Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/popinfo.h
[mareframe] / trunk / gadget / popinfo.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/popinfo.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download)

1 : agomez 1 #ifndef popinfo_h
2 :     #define popinfo_h
3 :    
4 :     #include "gadget.h"
5 : ulcessvp 2 #include "mathfunc.h"
6 : agomez 1
7 :     /**
8 :     * \class PopInfo
9 :     * \brief This is the class used to store information about the number, and mean weight, of a population cell of a stock
10 :     */
11 :     class PopInfo {
12 :     public:
13 :     /**
14 :     * \brief This is the PopInfo constructor
15 :     */
16 :     PopInfo() { N = 0.0; W = 0.0; };
17 :     /**
18 :     * \brief This is the PopInfo destructor
19 :     */
20 :     ~PopInfo() {};
21 :     /**
22 :     * \brief This is the number of fish in the population cell
23 :     */
24 :     double N;
25 :     /**
26 :     * \brief This is the mean weight of the fish in the population cell
27 :     */
28 :     double W;
29 :     /**
30 :     * \brief This operator will subtract a number from the PopInfo
31 :     * \param a is the number to subtract
32 :     */
33 :     void operator -= (double a) { N -= a; };
34 :     /**
35 :     * \brief This operator will increase the PopInfo by a multiplicative constant
36 :     * \param a is the multiplicative constant
37 :     */
38 :     void operator *= (double a) { N *= a; };
39 :     /**
40 :     * \brief This function will set the PopInfo to zero
41 :     */
42 :     void setToZero() { N = 0.0; W = 0.0; };
43 :     /**
44 :     * \brief This operator will set the PopInfo equal to an existing PopInfo
45 :     * \param a is the PopInfo to copy
46 :     */
47 :     PopInfo& operator = (const PopInfo& a);
48 :     /**
49 :     * \brief This operator will add an existing PopInfo to the current PopInfo
50 :     * \param a is the PopInfo to add
51 :     */
52 : ulcessvp 2 PopInfo& operator += (const PopInfo& a){
53 :     if (isZero(N + a.N)) {
54 :     W = 0.0;
55 :     N = 0.0;
56 :     } else if (isZero(a.N)) {
57 :     //adding a zero popinfo, so don't do anything
58 :     } else if (isZero(N)) {
59 :     W = a.W;
60 :     N = a.N;
61 :     } else {
62 :     W = (N * W + a.N * a.W) / (N + a.N);
63 :     N = N + a.N;
64 :     }
65 :     return *this;
66 :     }
67 :    
68 :    
69 :     ;
70 : agomez 1 /**
71 :     * \brief This operator will multiply the PopInfo by a constant
72 :     * \param a is the constant
73 :     */
74 :     PopInfo operator * (double a);
75 :     };
76 :    
77 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge