本文整理汇总了C++中AMnDIndex::i方法的典型用法代码示例。如果您正苦于以下问题:C++ AMnDIndex::i方法的具体用法?C++ AMnDIndex::i怎么用?C++ AMnDIndex::i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMnDIndex
的用法示例。
在下文中一共展示了AMnDIndex::i方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AMNumber
AMNumber CLSQE65000Detector::reading(const AMnDIndex &indexes) const{
if( (!isConnected()) || (indexes.rank() != 1) || (indexes.i() > 1024) )
return AMNumber(AMNumber::DimensionError);
AMReadOnlyPVControl *tmpControl = qobject_cast<AMReadOnlyPVControl*>(spectrumControl_);
return tmpControl->readPV()->lastIntegerValues().at(indexes.i());
}
示例2: copyValues
void AMExternalScanDataSourceAB::copyValues(int dataSourceIndex)
{
AMDataSource* ds = scan_->dataSourceAt(dataSourceIndex);
const AMnDIndex size = ds->size();
switch(ds->rank()) {
case 0:
values_.clear();
values_ << ds->value(AMnDIndex());
break;
case 1: {
values_.resize(size.i());
for(int i=0; i<size.i(); i++)
values_[i] = ds->value(i);
break;
}
case 2: {
values_.resize(size.i()*size.j());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
values_[i*size.j() + j] = ds->value(AMnDIndex(i,j));
break;
}
case 3: {
values_.resize(size.i()*size.j()*size.k());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
for(int k=0; k<size.k(); k++)
values_[i*size.j()*size.k() + j*size.k() + k] = ds->value(AMnDIndex(i,j,k));
break;
}
case 4: {
values_.resize(size.i()*size.j()*size.k()*size.l());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
for(int k=0; k<size.k(); k++)
for(int l=0; l<size.l(); l++)
values_[i*size.j()*size.k()*size.l() + j*size.k()*size.l() + k*size.l() + l] = ds->value(AMnDIndex(i,j,k,l));
break;
}
case 5: {
values_.resize(size.i()*size.j()*size.k()*size.l()*size.m());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
for(int k=0; k<size.k(); k++)
for(int l=0; l<size.l(); l++)
for(int m=0; m<size.m(); m++)
values_[i*size.j()*size.k()*size.l()*size.m() + j*size.k()*size.l()*size.m() + k*size.l()*size.m() + l*size.m() + m] = ds->value(AMnDIndex(i,j,k,l,m));
/// \todo oh god, we really need a block copy or a multi-dimensional iterator for AMDataSource::value()...
break;
}
}
}
示例3: AMNumber
// Returns the dependent value at a (complete) set of axis indexes. Returns an invalid AMNumber if the indexes are insuffient or any are out of range, or if the data is not ready.
AMNumber AM1DExpressionAB::value(const AMnDIndex& indexes) const {
if(!isValid()) // will catch most invalid situations: non matching sizes, invalid inputs, invalid expressions.
return AMNumber(AMNumber::InvalidError);
if(indexes.rank() != 1)
return AMNumber(AMNumber::DimensionError);
#ifdef AM_ENABLE_BOUNDS_CHECKING
if(indexes.i() < 0 || indexes.i() >= size_)
return AMNumber(AMNumber::OutOfBoundsError);
#endif
// can we get it directly? Single-value expressions don't require the parser.
if(direct_) {
// info on which variable to use is contained in directVar_.
if(directVar_.useAxisValue)
return sources_.at(directVar_.sourceIndex)->axisValue(0, indexes.i());
else
return sources_.at(directVar_.sourceIndex)->value(indexes);
}
// otherwise we need the parser
else {
// copy the new input data values into parser storage
for(int i=0; i<usedVariables_.count(); i++) {
AMParserVariable* usedVar = usedVariables_.at(i);
if(usedVar->useAxisValue)
usedVar->value = sources_.at(usedVar->sourceIndex)->axisValue(0, indexes.i());
else
usedVar->value = sources_.at(usedVar->sourceIndex)->value(indexes);
}
// evaluate using the parser:
double rv;
try {
rv = parser_.Eval();
}
catch(mu::Parser::exception_type& e) {
QString explanation = QString("AM1DExpressionAB Analysis Block: error evaluating value: %1: '%2'. We found '%3' at position %4.").arg(QString::fromStdString(e.GetMsg()), QString::fromStdString(e.GetExpr()), QString::fromStdString(e.GetToken())).arg(e.GetPos());
AMErrorMon::report(AMErrorReport(this, AMErrorReport::Debug, e.GetCode(), explanation));
return AMNumber(AMNumber::InvalidError);
}
if (rv == std::numeric_limits<qreal>::infinity() || rv == -std::numeric_limits<qreal>::infinity() || rv == std::numeric_limits<qreal>::quiet_NaN())
return 0;
return rv;
}
}
示例4: value
AMNumber REIXSXESImageInterpolationAB::value(const AMnDIndex &indexes) const
{
if((indexes.rank() != 1))
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
if(((unsigned long)indexes.i() >= (unsigned long)axes_.at(0).size))
return AMNumber(AMNumber::OutOfBoundsError);
if(cacheUpdateRequired_)
computeCachedValues();
return AMNumber(cachedData_.at(indexes.i()));
}
示例5: AMNumber
AMNumber AM1DInterpolationAB::value(const AMnDIndex& indexes) const{
if(indexes.rank() != 1)
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
#ifdef AM_ENABLE_BOUNDS_CHECKING
if((unsigned)indexes.i() >= (unsigned)axes_.at(0).size)
return AMNumber(AMNumber::OutOfBoundsError);
#endif
int index = indexes.i();
return inputSource_->value(index);
}
示例6: value
AMNumber AMDeadTimeAB::value(const AMnDIndex &indexes) const
{
if(indexes.rank() != 1)
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
if (indexes.i() >= spectra_->size(0))
return AMNumber(AMNumber::OutOfBoundsError);
if ((int)spectra_->value(indexes.i()) == 0)
return 0;
else
return double(icr_->value(AMnDIndex()))/double(ocr_->value(AMnDIndex()))*(int)spectra_->value(indexes.i());
}
示例7:
bool AM1DInterpolationAB::values(const AMnDIndex &indexStart, const AMnDIndex &indexEnd, double *outputValues) const
{
if(indexStart.rank() != 1 || indexEnd.rank() != 1)
return false;
if(!isValid())
return false;
#ifdef AM_ENABLE_BOUNDS_CHECKING
if((unsigned)indexEnd.i() >= (unsigned)axes_.at(0).size || (unsigned)indexStart.i() > (unsigned)indexEnd.i())
return false;
#endif
inputSource_->values(indexStart, indexEnd, outputValues);
return true;
}
示例8: AMNumber
AMNumber AM3DAdditionAB::value(const AMnDIndex &indexes) const
{
if(indexes.rank() != 3)
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
for (int i = 0; i < sources_.size(); i++)
if (indexes.i() >= sources_.at(i)->size(0) || indexes.j() >= sources_.at(i)->size(1) || indexes.k() >= sources_.at(i)->size(2))
return AMNumber(AMNumber::OutOfBoundsError);
if (cacheUpdateRequired_)
computeCachedValues();
return cachedData_.at(indexes.i()*size(1)*size(2)+indexes.j()*size(2)+indexes.k());
}
示例9: setSize
bool AMBasicXRFDetectorInfo::setSize(const AMnDIndex &size)
{
if (size.rank() != 1)
return false;
channels_ = size.i();
setModified(true);
return true;
}
示例10: AMNumber
AMNumber AM2DDeadTimeAB::value(const AMnDIndex &indexes) const
{
if(indexes.rank() != 2)
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
#ifdef AM_ENABLE_BOUNDS_CHECKING
if (indexes.i() >= spectra_->size(0)
|| indexes.j() >= spectra_->size(1))
return AMNumber(AMNumber::OutOfBoundsError);
#endif
if ((int)spectra_->value(indexes) == 0 || double(ocr_->value(indexes.i())) == 0)
return 0;
else
return double(icr_->value(indexes.i()))/double(ocr_->value(indexes.i()))*(int)spectra_->value(indexes);
}
示例11: reading
bool AMDetector::reading1D(const AMnDIndex &startIndex, const AMnDIndex &endIndex, double *outputValues) const {
if(!checkValid(startIndex, endIndex))
return false;
if (endIndex.i() < startIndex.i())
return false;
for (int i = startIndex.i(); i <= endIndex.i(); i++) {
AMNumber retVal = reading(i);
if(!retVal.isValid())
return false;
outputValues[i] = double(retVal);
}
return true;
}
示例12: value
AMNumber AMnDDeadTimeAB::value(const AMnDIndex &indexes) const
{
if(indexes.rank() != rank())
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
#ifdef AM_ENABLE_BOUNDS_CHECKING
for (int i = 0, size = axes_.size(); i < size; i++)
if (indexes.at(i) >= axes_.at(i).size)
return AMNumber(AMNumber::OutOfBoundsError);
#endif
if ((int)spectrum_->value(indexes) == 0 || double(outputCounts_->value(indexes.i())) == 0)
return 0;
else
return double(inputCounts_->value(indexes.i()))/double(outputCounts_->value(indexes.i()))*(int)spectrum_->value(indexes);
}
示例13:
bool AM3DDeadTimeCorrectionAB::values(const AMnDIndex &indexStart, const AMnDIndex &indexEnd, double *outputValues) const
{
if(indexStart.rank() != 3 || indexEnd.rank() != 3)
return false;
if(!isValid())
return false;
if((unsigned)indexEnd.i() >= (unsigned)axes_.at(0).size || (unsigned)indexStart.i() > (unsigned)indexEnd.i()
|| (unsigned)indexEnd.j() >= (unsigned)axes_.at(1).size || (unsigned)indexStart.j() > (unsigned)indexEnd.j()
|| (unsigned)indexEnd.k() >= (unsigned)axes_.at(2).size || (unsigned)indexStart.k() > (unsigned)indexEnd.k())
return false;
int totalSize = indexStart.totalPointsTo(indexEnd);
QVector<double> data = QVector<double>(totalSize);
QVector<double> icr = QVector<double>(totalSize);
QVector<double> ocr = QVector<double>(totalSize);
spectra_->values(indexStart, indexEnd, data.data());
icr_->values(indexStart, indexEnd, icr.data());
ocr_->values(indexStart, indexEnd, ocr.data());
for (int i = 0, iSize = indexEnd.i()-indexStart.i()+1; i < iSize; i++){
for (int j = 0, jSize = indexEnd.j()-indexStart.j()+1; j < jSize; j++){
for (int k = 0, kSize = indexEnd.k()-indexStart.k()+1; k < kSize; k++){
int index = i + j*iSize + k*iSize*jSize;
// If ocr is equal to 0 then that will cause division by zero. Since these are both count rates, they should both be greater than zero.
if (icr.at(index) <= 0 || ocr.at(index) <= 0)
outputValues[index] = 0;
else
outputValues[index] = data.at(index)*icr.at(index)/ocr.at(index);
}
}
}
return true;
}
示例14: AMNumber
AMNumber AM1DSummingAB::value(const AMnDIndex &indexes) const
{
if(indexes.rank() != 1)
return AMNumber(AMNumber::DimensionError);
if(!isValid())
return AMNumber(AMNumber::InvalidError);
#ifdef AM_ENABLE_BOUNDS_CHECKING
for (int i = 0; i < sources_.size(); i++)
if (indexes.i() >= sources_.at(i)->size(0))
return AMNumber(AMNumber::OutOfBoundsError);
#endif
double val = 0;
for (int i = 0; i < sources_.size(); i++)
val += (double)sources_.at(i)->value(indexes.i());
return val;
}
示例15:
bool AM3DAdditionAB::values(const AMnDIndex &indexStart, const AMnDIndex &indexEnd, double *outputValues) const
{
if(indexStart.rank() != 3 || indexEnd.rank() != 3)
return false;
if(!isValid())
return false;
for (int i = 0; i < sources_.size(); i++)
if ((unsigned)indexEnd.i() >= (unsigned)axes_.at(0).size || (unsigned)indexEnd.j() >= (unsigned)axes_.at(1).size || (unsigned)indexEnd.k() >= (unsigned)axes_.at(2).size)
return false;
if ((unsigned)indexStart.i() > (unsigned)indexEnd.i() || (unsigned)indexStart.j() > (unsigned)indexEnd.j())
return false;
if (cacheUpdateRequired_)
computeCachedValues();
int totalSize = indexStart.totalPointsTo(indexEnd);
memcpy(outputValues, cachedData_.constData()+indexStart.flatIndexInArrayOfSize(size()), totalSize*sizeof(double));
return true;
}