Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsTraceRefcntImpl.cpp File Reference
#include "nsTraceRefcntImpl.h"
#include "nscore.h"
#include "nsISupports.h"
#include "nsVoidArray.h"
#include "prprf.h"
#include "prlog.h"
#include "plstr.h"
#include <stdlib.h>
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include <math.h>

Go to the source code of this file.

Functions

NS_COM void NS_MeanAndStdDev (double n, double sumOfValues, double sumOfSquaredValues, double *meanResult, double *stdDevResult)
 NS_IMETHODIMP_ (nsrefcnt) nsTraceRefcntImpl

Function Documentation

Definition at line 936 of file nsTraceRefcntImpl.cpp.

{
  NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
  ++mRefCnt;
  return mRefCnt;
}
NS_COM void NS_MeanAndStdDev ( double  n,
double  sumOfValues,
double  sumOfSquaredValues,
double *  meanResult,
double *  stdDevResult 
)

Definition at line 62 of file nsTraceRefcntImpl.cpp.

{
  double mean = 0.0, var = 0.0, stdDev = 0.0;
  if (n > 0.0 && sumOfValues >= 0) {
    mean = sumOfValues / n;
    double temp = (n * sumOfSquaredValues) - (sumOfValues * sumOfValues);
    if (temp < 0.0 || n <= 1)
      var = 0.0;
    else
      var = temp / (n * (n - 1));
    // for some reason, Windows says sqrt(0.0) is "-1.#J" (?!) so do this:
    stdDev = var != 0.0 ? sqrt(var) : 0.0;
  }
  *meanResult = mean;
  *stdDevResult = stdDev;
}