All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Attributes
QGpCompatibility::CompatFunctionList Class Reference

A list of CompatFunction. More...

#include <CompatFunctionList.h>

List of all members.

Public Member Functions

void addXSamples (CompatFunction &xModel, bool addInvalidY, double invalidValue)
void average (int iMode, int i, double &average, double &averageStddev, int &hitsCount, double invalidValue, bool logStat)
int cleanupAverage ()
void clear ()
 CompatFunctionList ()
 CompatFunctionList (const CompatFunctionList &o)
void deleteVectors ()
void inverseX ()
int modesCount (bool multiMode, QString baseName, const QStringList &curveNames, int startAt)
CompatFunctionListoperator= (const CompatFunctionList &o)
void sameSamplingForCurves (CompatFunction &xModel, bool interpole, double invalidValue)
 ~CompatFunctionList ()

Protected Attributes

QList< QList< CompatFunction * > * > * _selected

Detailed Description

A list of CompatFunction.

A list of function specifically dedicated to the computation of the average multi modal curves.

To get one averaged curve per mode, you must call (in this order):


Constructor & Destructor Documentation

References _selected, and TRACE.

{
  TRACE;
  _selected=0;
}

References _selected, and TRACE.

                                                                   :
    QList<CompatFunction *>(o)
{
  TRACE;
  _selected=0;
}

In usual situations, when the functions have been called without error, this destructor does nothing

References _selected, and TRACE.

{
  TRACE;
  if(_selected) {
    qDeleteAll(*_selected);
    _selected->clear();
    delete _selected;
  }
}

Member Function Documentation

void QGpCompatibility::CompatFunctionList::addXSamples ( CompatFunction xModel,
bool  addInvalidY,
double  invalidValue 
)

References _selected, TRACE, QGpCompatibility::CompatFunction::x(), and QGpCompatibility::CompatFunction::y().

{
  TRACE;
  ASSERT(_selected);
  QVector<double>& xList=*xModel.x();
  QVector<double>& yList=*xModel.y();
  foreach(QList<CompatFunction *> * modePtr, *_selected) {
    foreach(CompatFunction * fPtr, *modePtr) {
      QVector<double>& x=*fPtr->x();
      QVector<double>& y=*fPtr->y();
      for(int ix=x.count()-1;ix>=0;ix--) {
        if(addInvalidY || y[ix]!=invalidValue) {
          xList.append(x[ix]);
          yList.append(0);
        }
      }
    }
  }
}
void QGpCompatibility::CompatFunctionList::average ( int  iMode,
int  i,
double &  average,
double &  averageStddev,
int &  hitsCount,
double  invalidValue,
bool  logStat 
)

References _selected, QGpCoreTools::sqrt(), TRACE, w, QGpCompatibility::CompatFunction::weight(), QGpCompatibility::CompatFunction::y(), and QGpCompatibility::CompatFunction::yErr().

{
  TRACE;
  ASSERT(_selected);
  if(iMode>=(int)_selected->count()) {
    average=invalidValue;
    averageStddev=0;
    hitsCount=1;
    return;
  }
  average=0;
  averageStddev=0;
  hitsCount=0;
  double mui, sigma2i, w;
  foreach(CompatFunction * fPtr, *_selected->at(iMode)) {
    CompatFunction& curve=*fPtr;
    mui=curve.y()->at(i);
    if(mui!=invalidValue) {
      if(logStat) mui=log10(mui);
      if(curve.yErr())
        sigma2i=curve.yErr()->at(i);
      else
        sigma2i=0;
      if(logStat && sigma2i>0) sigma2i=log10(sigma2i);
      sigma2i=sigma2i*sigma2i;
      if(curve.weight()) {
        w=floor(curve.weight()->at(i)+0.5);
        average+=w*mui;
        if(w>1) {
          averageStddev+=(w-1)*sigma2i+w*mui*mui;
          hitsCount+=(int)w;
        } else {
          averageStddev+=sigma2i+mui*mui;
          hitsCount++;
        }
      } else {
        average+=mui;
        averageStddev+=mui*mui;
        hitsCount++;
      }
    }
  }
  if(hitsCount>0) {
    average/=hitsCount;
    averageStddev-=average*average*hitsCount;
    if(hitsCount>1)
      averageStddev/=hitsCount-1;
    else
      averageStddev/=hitsCount;

    if(averageStddev<1e-10) {
      averageStddev=0;
      hitsCount=1;
    } else averageStddev=sqrt(averageStddev);
    if(logStat) {
      average=pow(10.0,average);
      averageStddev=pow(10.0,averageStddev);
    }
  } else {
    average=invalidValue;
    if(logStat) averageStddev=1; else averageStddev=0;
    hitsCount=1;
  }
}

Delete the _selected vectors and return the total number of curves

References _selected, and TRACE.

{
  TRACE;
  ASSERT(_selected);
  int curveCount=0;
  foreach(QList<CompatFunction *> * modePtr, *_selected)
    curveCount+=modePtr->count();
  qDeleteAll(*_selected);
  _selected->clear();
  delete _selected;
  _selected=0;
  return curveCount;
}

References TRACE.

{
  TRACE;
  qDeleteAll(*this);
  QList<CompatFunction *>::clear();
}

References QGpCompatibility::CompatFunction::deleteVectors(), and TRACE.

{
  TRACE;
  CompatFunction * it;
  foreach(it, *this) it->deleteVectors();
}

References _selected, QGpCompatibility::CompatFunction::inverseX(), and TRACE.

{
  TRACE;
  ASSERT(_selected);
  foreach(QList<CompatFunction *> * modePtr, *_selected) {
    foreach(CompatFunction * fPtr, *modePtr) {
      fPtr->inverseX();
    }
  }
}
int QGpCompatibility::CompatFunctionList::modesCount ( bool  multiMode,
QString  baseName,
const QStringList &  curveNames,
int  startAt 
)

References _selected, str, and TRACE.

{
  TRACE;
  if(!_selected) {
    _selected=new QList< QList<CompatFunction *> *>;
  }
  for(int i=count()-1;i>=0;i--) {
    const QString& str=curveNames[i];
    if(str.contains(baseName)) {
      if(multiMode) {
        int num=str.section(" ",-1,-1).toUInt()+startAt;
        while(_selected->count()<num)
          _selected->append(new QList<CompatFunction *>);
        _selected->at(num-1)->append(at(i));
      } else {
        if(_selected->count()==startAt)
          _selected->append(new QList<CompatFunction *>);
        _selected->at(startAt)->append(at(i));
      }
    }
  }
  if(_selected->count()>startAt)
    return _selected->count()-startAt;
  else return 0;
}
CompatFunctionList & QGpCompatibility::CompatFunctionList::operator= ( const CompatFunctionList o)

References _selected, and TRACE.

void QGpCompatibility::CompatFunctionList::sameSamplingForCurves ( CompatFunction xModel,
bool  interpole,
double  invalidValue 
)

References _selected, QGpCompatibility::CompatFunction::resample(), TRACE, and QGpCompatibility::CompatFunction::x().

{
  TRACE;
  ASSERT(_selected);
  foreach(QList<CompatFunction *> * modePtr, *_selected) {
    foreach(CompatFunction * fPtr, *modePtr) {
      fPtr->resample(xModel.x(),invalidValue,interpole);
    }
  }
}

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines