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] Diff of /trunk/gadget/popinfo.h
[mareframe] / trunk / gadget / popinfo.h Repository:
ViewVC logotype

Diff of /trunk/gadget/popinfo.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1, Mon Feb 10 17:09:07 2014 UTC revision 3, Thu Apr 30 12:52:16 2015 UTC
# Line 2  Line 2 
2  #define popinfo_h  #define popinfo_h
3    
4  #include "gadget.h"  #include "gadget.h"
5    #include "mathfunc.h"
6    
7  /**  /**
8   * \class PopInfo   * \class PopInfo
# Line 12  Line 13 
13    /**    /**
14     * \brief This is the PopInfo constructor     * \brief This is the PopInfo constructor
15     */     */
16    PopInfo() { N = 0.0; W = 0.0; };    PopInfo(double Ni = 0.0, double Wi = 0.0)
17      : N(Ni), W(Wi)
18      {};
19    /**    /**
20     * \brief This is the PopInfo destructor     * \brief This is the PopInfo destructor
21     */     */
# Line 43  Line 46 
46     * \brief This operator will set the PopInfo equal to an existing PopInfo     * \brief This operator will set the PopInfo equal to an existing PopInfo
47     * \param a is the PopInfo to copy     * \param a is the PopInfo to copy
48     */     */
49    PopInfo& operator = (const PopInfo& a);    PopInfo& operator = (const PopInfo& a) {
50        N = a.N;
51        W = a.W;
52        return *this;
53      }
54    
55    /**    /**
56     * \brief This operator will add an existing PopInfo to the current PopInfo     * \brief This operator will add an existing PopInfo to the current PopInfo
57     * \param a is the PopInfo to add     * \param a is the PopInfo to add
58     */     */
59    PopInfo& operator += (const PopInfo& a);    PopInfo& operator += (const PopInfo& a) {
60              if (isZero(N + a.N)) {
61                W = 0.0;
62                N = 0.0;
63              } else if (isZero(a.N)) {
64                //adding a zero popinfo, so don't do anything
65              } else if (isZero(N)) {
66                W = a.W;
67                N = a.N;
68              } else {
69                W = (N * W + a.N * a.W) / (N + a.N);
70                N = N + a.N;
71              }
72              return *this;
73            }
74    
75    
76                                                      ;
77    /**    /**
78     * \brief This operator will multiply the PopInfo by a constant     * \brief This operator will multiply the PopInfo by a constant
79     * \param a is the constant     * \param a is the constant
80     */     */
81    PopInfo operator * (double a);    PopInfo operator * (double a) const {
82        return PopInfo(N * a, W);
83      }
84  };  };
85    
86  #endif  #endif

Legend:
Removed from v.1  
changed lines
  Added in v.3

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

Powered By FusionForge