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

View of /trunk/gadget/popinfo.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Mon Feb 10 17:09:07 2014 UTC (10 years, 4 months ago) by agomez
File size: 553 byte(s)
Initial version based on Gadget 2.2.00
#include "popinfo.h"
#include "mathfunc.h"

PopInfo& PopInfo::operator = (const PopInfo& a) {
  N = a.N;
  W = a.W;
  return *this;
}

PopInfo& PopInfo::operator += (const PopInfo& a) {
  if (isZero(N + a.N)) {
    W = 0.0;
    N = 0.0;
  } else if (isZero(a.N)) {
    //adding a zero popinfo, so don't do anything
  } else if (isZero(N)) {
    W = a.W;
    N = a.N;
  } else {
    W = (N * W + a.N * a.W) / (N + a.N);
    N = N + a.N;
  }
  return *this;
}

PopInfo PopInfo::operator * (double a) {
  PopInfo c;
  c.N = N * a;
  c.W = W;
  return c;
}

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

Powered By FusionForge