A list of CompatFunction. More...
#include <CompatFunctionList.h>
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) |
| CompatFunctionList & | operator= (const CompatFunctionList &o) |
| void | sameSamplingForCurves (CompatFunction &xModel, bool interpole, double invalidValue) |
| ~CompatFunctionList () | |
Protected Attributes | |
| QList< QList< CompatFunction * > * > * | _selected |
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):
| 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 TRACE.
{
TRACE;
qDeleteAll(*this);
QList<CompatFunction *>::clear();
}
References QGpCompatibility::CompatFunction::deleteVectors(), and TRACE.
{
TRACE;
CompatFunction * it;
foreach(it, *this) it->deleteVectors();
}
| 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.
{
TRACE;
QList<CompatFunction *>::operator=(o);
_selected=0;
return *this;
}
| void QGpCompatibility::CompatFunctionList::sameSamplingForCurves | ( | CompatFunction & | xModel, |
| bool | interpole, | ||
| double | invalidValue | ||
| ) |
QList< QList<CompatFunction *> * >* QGpCompatibility::CompatFunctionList::_selected [protected] |
Referenced by addXSamples(), average(), cleanupAverage(), CompatFunctionList(), inverseX(), modesCount(), operator=(), sameSamplingForCurves(), and ~CompatFunctionList().