本文整理汇总了C++中VectorPtr::length方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorPtr::length方法的具体用法?C++ VectorPtr::length怎么用?C++ VectorPtr::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorPtr
的用法示例。
在下文中一共展示了VectorPtr::length方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internalUpdate
void PSD::internalUpdate() {
writeLockInputsAndOutputs();
VectorPtr iv = _inputVectors[INVECTOR];
const int v_len = iv->length();
_last_n_new += iv->numNew();
assert(_last_n_new >= 0);
int n_subsets = (v_len)/_PSDLength;
// determine if the PSD needs to be updated.
// if not using averaging, then we need at least _PSDLength/16 new data points.
// if averaging, then we want enough new data for a complete subset.
// ... unless we are counting from end at fixed length (scrolling data).
bool scrolling_data = (_last_n == iv->length());
if ( (!_changed) && ((_last_n_new < _PSDLength/16) ||
(_Average && scrolling_data && (_last_n_new < _PSDLength/16)) ||
(_Average && !scrolling_data && (n_subsets - _last_n_subsets < 1))) &&
iv->length() != iv->numNew()) {
unlockInputsAndOutputs();
return;
}
_changed = false;
_adjustLengths();
double *psd = _sVector->value();
double *f = _fVector->value();
int i_samp;
for (i_samp = 0; i_samp < _PSDLength; ++i_samp) {
f[i_samp] = i_samp * 0.5 * _Frequency / (_PSDLength - 1);
}
//f[0] = -1E-280; // really 0 (this shouldn't be needed...)
_psdCalculator.calculatePowerSpectrum(iv->value(), v_len, psd, _PSDLength, _RemoveMean, _interpolateHoles, _Average, _averageLength, _Apodize, _apodizeFxn, _gaussianSigma, _Output, _Frequency);
_last_n_subsets = n_subsets;
_last_n_new = 0;
_last_n = iv->length();
updateVectorLabels();
// should be updated by the update manager
//_sVector->update();
//_fVector->update();
unlockInputsAndOutputs();
return;
}
示例2: internalUpdate
void CSD::internalUpdate() {
VectorPtr inVector = _inputVectors[CSD_INVECTOR];
writeLockInputsAndOutputs();
double *tempOutput, *input;
int tempOutputLen = PSDCalculator::calculateOutputVectorLength(_windowSize, _average, _averageLength);
_length = tempOutputLen;
tempOutput = new double[tempOutputLen];
input = inVector->value();
int xSize = 0;
for (int i=0; i < inVector->length(); i+= _windowSize) {
//ensure there is enough data left.
if (i + _windowSize >= inVector->length()) {
break; //If there isn't enough left for a complete window.
}
_psdCalculator.calculatePowerSpectrum(input + i, _windowSize, tempOutput, tempOutputLen, _removeMean, false, _average, _averageLength, _apodize, _apodizeFxn, _gaussianSigma, _outputType, _frequency);
// resize output matrix
_outMatrix->resize(xSize+1, tempOutputLen);
if (_outMatrix->sampleCount() == (xSize+1)*tempOutputLen) { // all is well.
// copy elements to output matrix
for (int j=0; j < tempOutputLen; j++) {
_outMatrix->setValueRaw(xSize, j, tempOutput[j]);
}
} else {
Debug::self()->log(i18n("Could not allocate sufficient memory for CSD."), Debug::Error);
break;
}
xSize++;
}
delete[] tempOutput;
double frequencyStep = .5*_frequency/(double)(tempOutputLen-1);
_outMatrix->change(xSize, tempOutputLen, 0, 0, _windowSize/_frequency, frequencyStep);
unlockInputsAndOutputs();
return;
}
示例3: AutoBin
void Histogram::AutoBin(VectorPtr V, int *n, double *max, double *min) {
double m;
*max = V->max();
*min = V->min();
*n = V->length();
if (*max < *min) {
m = *max;
*max = *min;
*min = m;
}
if (*max == *min) {
*max += 1.0;
*min -= 1.0;
}
// we can do a better job auto-ranging using the tick rules from plot...
// this has not been done yet, you will notice...
*n /= 50;
if (*n < 6) {
*n = 6;
}
if (*n > 60) {
*n = 60;
}
m = (*max - *min)/(100.0*double(*n));
*max += m;
*min -= m;
}
示例4: createScalars
// If a plugin provides a Parameters Vector, then scalars will be created, as well as a label.
void BasicPlugin::createScalars() {
// Assumes that this is called with a write lock in place on this object
Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
if (hasParameterVector()) {
VectorPtr vectorParam = _outputVectors["Parameters Vector"];
if (vectorParam) {
QString paramName;
int i = 0;
int length = vectorParam->length();
Q_ASSERT(store());
for (paramName = parameterName(i);
!paramName.isEmpty() && i < length;
paramName = parameterName(++i)) {
double scalarValue = vectorParam->value(i);
if (!_outputScalars.contains(paramName)) {
ScalarPtr s = store()->createObject<Scalar>();
s->setProvider(this);
s->setSlaveName(paramName);
s->setValue(scalarValue);
s->writeLock();
_outputScalars.insert(paramName, s);
} else {
_outputScalars[paramName]->setValue(scalarValue);
}
}
}
}
}
示例5: internalUpdate
void Curve::internalUpdate() {
Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
VectorPtr cxV = *_inputVectors.find(XVECTOR);
VectorPtr cyV = *_inputVectors.find(YVECTOR);
if (!cxV || !cyV) {
return;
}
writeLockInputsAndOutputs();
MaxX = cxV->max();
MinX = cxV->min();
MeanX = cxV->mean();
MinPosX = cxV->minPos();
_ns_maxx = cxV->ns_max();
_ns_minx = cxV->ns_min();
if (MinPosX > MaxX) {
MinPosX = 0;
}
MaxY = cyV->max();
MinY = cyV->min();
MeanY = cyV->mean();
MinPosY = cyV->minPos();
_ns_maxy = cyV->ns_max();
_ns_miny = cyV->ns_min();
if (MinPosY > MaxY) {
MinPosY = 0;
}
NS = qMax(cxV->length(), cyV->length());
unlockInputsAndOutputs();
_redrawRequired = true;
return;
}
示例6: label
QString BasicPlugin::label(int precision) const {
Q_UNUSED(precision)
QString label;
QString paramName;
label = Name();
if (hasParameterVector()) {
VectorPtr vectorParam = _outputVectors["Parameters Vector"];
int length = vectorParam->length();
int i=0;
for (paramName = parameterName(i);
!paramName.isEmpty() && i < length;
paramName = parameterName(++i)) {
if (_outputScalars.contains(paramName)) {
label += QString("\n%1: [%2]").arg(paramName).arg(_outputScalars[paramName]->Name());
}
}
}
return label;
}