本文整理汇总了C++中DoubleArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleArray::size方法的具体用法?C++ DoubleArray::size怎么用?C++ DoubleArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleArray
的用法示例。
在下文中一共展示了DoubleArray::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeNoise
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor::computeNoise(const DoubleArray &data, int i1, int i2, double *offset, double *amplitude) {
// compute offset and rms within the time window
if(i1<0) i1=0;
if(i2<0) return false;
if(i2>(int)data.size()) i2=(int)data.size();
// If noise window is zero return an amplitude and offset of zero as well.
if ( i2-i1 == 0 ) {
*amplitude = 0;
*offset = 0;
return true;
}
DoubleArrayPtr d = static_cast<DoubleArray*>(data.slice(i1, i2));
double ofs, amp;
// compute pre-arrival offset
ofs = d->median();
// compute rms after removing offset
amp = 2 * d->rms(ofs);
if ( offset ) *offset = ofs;
if ( amplitude ) *amplitude = amp;
return true;
}
示例2: deconvolveData
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor_Mjma::deconvolveData(Response *resp,
DoubleArray &data,
int numberOfIntegrations) {
Math::Restitution::FFT::TransferFunctionPtr tf =
resp->getTransferFunction(numberOfIntegrations);
if ( tf == NULL ) {
setStatus(DeconvolutionFailed, 0);
return false;
}
Math::SeismometerResponse::Seismometer5sec paz(Math::Velocity);
Math::Restitution::FFT::PolesAndZeros seis5sec(paz);
Math::Restitution::FFT::TransferFunctionPtr cascade =
*tf / seis5sec;
// Remove linear trend
double m,n;
Math::Statistics::computeLinearTrend(data.size(), data.typedData(), m, n);
Math::Statistics::detrend(data.size(), data.typedData(), m, n);
return Math::Restitution::transformFFT(data.size(), data.typedData(),
_stream.fsamp, cascade.get(),
_config.respTaper, _config.respMinFreq, _config.respMaxFreq);
}
示例3: UpdatePanel
/*!
Updates the ImageView and the ParameterSelector associated
with the given panel.
*/
void VideoParserWindow::UpdatePanel(VideoControlPanel* pPanel, int sel,
DoubleArray params, bool checkViewSync)
{
// Get the potentially new parameter range from the component
DoubleArray minVals, maxVals, steps;
m_videoProcessor.GetParameterInfo(sel, &minVals, &maxVals, &steps);
// Ensure that the current parameters are within the "new" ranges
if (params.size() == minVals.size())
{
for (unsigned i = 0; i < params.size(); i++)
{
if (params[i] > maxVals[i])
params[i] = maxVals[i];
if (params[i] < minVals[i])
params[i] = minVals[i];
}
}
else
{
params = minVals;
}
// Update the selected view with the new image
UpdateImageView(pPanel, sel, params, checkViewSync);
// Update the displayed parameter value and range
pPanel->GetParamSelector()->Update(params, minVals, maxVals, steps);
pPanel->GetCommandSelector()->UpdateCommands(
m_videoProcessor.GetUserCommands(sel));
}
示例4: deconvolveData
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor_Md::deconvolveData(Response* resp,
DoubleArray& data,
int numberOfIntegrations) {
if ( numberOfIntegrations < -1 )
return false;
SEISCOMP_DEBUG("Inside deconvolve function");
double m, n;
Math::Restitution::FFT::TransferFunctionPtr tf =
resp->getTransferFunction(numberOfIntegrations < 0 ? 0 : numberOfIntegrations);
if ( !tf )
return false;
Math::GroundMotion gm;
if ( numberOfIntegrations < 0 )
gm = Math::Displacement;
else
gm = Math::Velocity;
Math::Restitution::FFT::TransferFunctionPtr cascade;
Math::SeismometerResponse::WoodAnderson woodAndersonResp(gm, _config.woodAndersonResponse);
Math::SeismometerResponse::Seismometer5sec seis5sResp(gm);
Math::SeismometerResponse::L4C_1Hz l4c1hzResp(gm);
Math::Restitution::FFT::PolesAndZeros woodAnderson(woodAndersonResp);
Math::Restitution::FFT::PolesAndZeros seis5sec(seis5sResp);
Math::Restitution::FFT::PolesAndZeros l4c1hz(l4c1hzResp);
SEISCOMP_DEBUG("SEISMO = %d", aFile.SEISMO);
switch ( aFile.SEISMO ) {
case 1:
cascade = *tf / woodAnderson;
break;
case 2:
cascade = *tf / seis5sec;
break;
case 9:
SEISCOMP_INFO("%s Applying filter L4C 1Hz to data", AMPTAG);
cascade = *tf / l4c1hz;
break;
default:
cascade = tf;
SEISCOMP_INFO("%s No seismometer specified, no signal reconvolution performed", AMPTAG);
return false;
break;
}
// Remove linear trend
Math::Statistics::computeLinearTrend(data.size(), data.typedData(), m, n);
Math::Statistics::detrend(data.size(), data.typedData(), m, n);
return Math::Restitution::transformFFT(data.size(), data.typedData(),
_stream.fsamp, cascade.get(), _config.respTaper, _config.respMinFreq,
_config.respMaxFreq);
}
示例5: computeAmplitude
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor_msbb::computeAmplitude(const DoubleArray &data,
size_t i1, size_t i2,
size_t si1, size_t si2, double offset,
AmplitudeIndex *dt,
AmplitudeValue *amplitude,
double *period, double *snr) {
/*
* Low-level signal amplitude computation. This is magnitude specific.
*
* Input:
* f double array of length n
* i1,i2 indices defining the measurement window,
* 0 <= i1 < i2 <= n
* offset this is subtracted from the samples in f before
* computation
*
* Output:
* dt Point at which the measurement was mad/completed. May
* be the peak time or end of integration.
* amplitude amplitude. This may be a peak amplitude as well as a
* sum or integral.
* period dominant period of the signal. Optional. If the period
* is not computed, set it to -1.
*/
size_t imax = find_absmax(data.size(), (const double*)data.data(), si1, si2, offset);
double amax = fabs(data[imax] - offset);
double pmax = -1;
double pstd = 0; // standard error of period
if ( !measure_period(data.size(), static_cast<const double*>(data.data()), imax, offset, &pmax, &pstd) )
pmax = -1;
if ( amax < *_noiseAmplitude * _config.snrMin ) {
amplitude->value = amax / *_noiseAmplitude;
setStatus(LowSNR, amplitude->value);
return false;
}
dt->index = imax;
*period = pmax;
amplitude->value = amax;
if ( _usedComponent <= SecondHorizontal ) {
if ( _streamConfig[_usedComponent].gain != 0.0 )
amplitude->value /= _streamConfig[_usedComponent].gain;
else {
setStatus(MissingGain, 0.0);
return false;
}
}
else
return false;
return true;
}
示例6: deconvolveData
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor::deconvolveData(Response *resp, DoubleArray &data,
int numberOfIntegrations) {
// Remove linear trend
double m,n;
Math::Statistics::computeLinearTrend(data.size(), data.typedData(), m, n);
Math::Statistics::detrend(data.size(), data.typedData(), m, n);
return resp->deconvolveFFT(data, _stream.fsamp, _config.respTaper,
_config.respMinFreq, _config.respMaxFreq,
numberOfIntegrations);
}
示例7: ZAdd
int Ardb::ZAdd(const DBID& db, const Slice& key, DoubleArray& scores,
const SliceArray& svs)
{
KeyLockerGuard keyguard(m_key_locker, db, key);
ZSetMetaValue meta;
GetZSetMetaValue(db, key, meta);
BatchWriteGuard guard(GetEngine());
int count = 0;
bool metachange = false;
for (uint32 i = 0; i < scores.size(); i++)
{
int tryret = TryZAdd(db, key, meta, scores[i], svs[i]);
if (tryret == 2)
{
count++;
}
if (!metachange && tryret > 0)
{
metachange = true;
}
}
if (metachange)
{
SetZSetMetaValue(db, key, meta);
}
return count;
}
示例8:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(ArrayTest, CopyData)
{
DoubleArray a;
a.resize(6);
a[0] = 1.23;
a[1] = 4.56;
a[2] = 7.89;
double data[] = { 3.2, 1.0, 0.0 };
a.copyData(data, 3, 3);
ASSERT_DOUBLE_EQ(3.2, a[3]);
ASSERT_DOUBLE_EQ(1.0, a[4]);
ASSERT_DOUBLE_EQ(0.0, a[5]);
DoubleArray b;
b.resize(3);
b[0] = 10.0;
b[1] = 20.0;
b[2] = 30.0;
a.copyData(b, b.size(), 2, 0);
ASSERT_DOUBLE_EQ(1.23, a[0]);
ASSERT_DOUBLE_EQ(4.56, a[1]);
ASSERT_DOUBLE_EQ(10.0, a[2]);
ASSERT_DOUBLE_EQ(20.0, a[3]);
ASSERT_DOUBLE_EQ(30.0, a[4]);
ASSERT_DOUBLE_EQ(0.0, a[5]);
}
示例9: applyMask
/*
This has a funny way of dealing with edges. In case of a Gaussian blur, divides by the sum of all of the numbers in the mask by definition. Might prove harsh on edges. In all other cases, divides by 8 no matter what, so that can equalize at edges. Also, when one of the pixels needed in the mask calculation is off the bounds of the image, the center pixel value is substituted, so that there is less difference. This doesnt pick up as many stray lines on edges, but also proves to often not pick up enough lines.
*/
DoubleArray Mask::applyMask(DoubleArray array){
ICoord size = array.size();
DoubleArray newarray = DoubleArray(size);
width = (int)maskArray.size()(0)/2; /* in case the maskArray was edited */
for (DoubleArray::iterator i = array.begin();i !=array.end(); ++i){
ICoord curr = i.coord();
double num = 0;
double c = 0;
int d = 1;
for (int i = -width; i <= width; ++i){ // scans through the mask
for (int j = -width; j <= width; ++j){
ICoord a = ICoord(i,j);
if (pixelInBounds(curr + a, size)){
num = num + array[curr+a]*maskArray[ICoord(i + width, j + width)];
c = c + maskArray[ICoord(i + width, j + width)];
}
else{
num = num + array[curr]*maskArray[ICoord(i + width, j + width)]; /* if pixel needed for mask is out of the image, then substitute the center pixel */
d = d + 1; /* count number of pixels out of bounds */
}
}
}
if (type == GAUSSIAN_MASK)
newarray[curr] = num/159;
else if (type == SMALL_GAUSSIAN_MASK)
newarray[curr] = num/99;
else
newarray[curr] = num/8;
}
return newarray;
}
示例10: applyMasks
DoubleArray MASKS::applyMasks(const DoubleArray& image) {
//This applies the mask that is stored onto an array of doubles representing
//the image.
DoubleArray newImage(image.size(),0.0);
double tempSum=0;
int startI,endI,startK,endK;
int M=maskArrays.width(), N=maskArrays.height();
for(int x=0;x<image.width();x++) {
for(int y=0;y<image.height();y++) {
startI=-M/2; endI=M/2;
startK=-N/2; endK=N/2;
if(x-M/2<0)
startI=-x;
if(y-N/2<0)
startK=-y;
if(x+M/2>=image.width())
endI=image.width()-x-1;
if(y+N/2>=image.height())
endK=image.height()-y-1;
for(int i=startI;i<=endI;i++) {
for(int k=startK;k<=endK;k++) {
tempSum+=image[ICoord(x+i,y+k)]*maskArrays[ICoord(M/2+i,N/2+k)];
//If M and N aren't odd, will get segmentation fault
}
}
newImage[ICoord(x,y)]=tempSum;
// if(tempSum<0)
tempSum=0;
}
}
return newImage;
}
示例11: doClassifying
void doClassifying(DoubleArray & gray) {
ICoord size = gray.size();
DoubleArray newgray = DoubleArray(size);
ClassifyClass classif = ClassifyClass();
newgray = classif.classifyRegions(gray);
gray = newgray;
}
示例12: process
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Detector::process(const Record *record, const DoubleArray &filteredData) {
_amplProc.pickIndex = 0;
SimpleDetector::process(record, filteredData);
if ( _amplProc.isRunning() ) {
calculateMaxAmplitude(record, _amplProc.pickIndex, filteredData.size(), filteredData);
if ( _amplProc.isFinished() )
sendMaxAmplitude(record);
}
}
示例13: deconvolveData
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor::deconvolveData(Response *resp, DoubleArray &data,
int numberOfIntegrations) {
// Remove linear trend
double m,n;
Math::Statistics::computeLinearTrend(data.size(), data.typedData(), m, n);
Math::Statistics::detrend(data.size(), data.typedData(), m, n);
bool ret = resp->deconvolveFFT(data, _stream.fsamp, _config.respTaper,
_config.respMinFreq, _config.respMaxFreq,
numberOfIntegrations < 0 ? 0 : numberOfIntegrations);
if ( !ret )
return false;
// If number of integrations are negative, derive data
while ( numberOfIntegrations < 0 ) {
Math::Filtering::IIRDifferentiate<double> diff;
diff.setSamplingFrequency(_stream.fsamp);
diff.apply(data.size(), data.typedData());
++numberOfIntegrations;
}
return true;
}
示例14: ZAddLimit
int Ardb::ZAddLimit(const DBID& db, const Slice& key, DoubleArray& scores,
const SliceArray& svs, int setlimit, ValueArray& pops)
{
ZSetMetaValue meta;
GetZSetMetaValue(db, key, meta);
if (setlimit <= 0)
{
setlimit = meta.size + scores.size();
}
ZAdd(db, key, scores, svs);
GetZSetMetaValue(db, key, meta);
if (meta.size > (uint32) setlimit)
{
ZPop(db, key, false, meta.size - setlimit, pops);
}
return 0;
}
示例15: computeAmplitude
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor_Mjma::computeAmplitude(
const DoubleArray &data,
size_t i1, size_t i2,
size_t si1, size_t si2,
double offset,AmplitudeIndex *dt,
AmplitudeValue *amplitude,
double *period, double *snr)
{
double amax;
size_t imax = find_absmax(data.size(), data.typedData(), si1, si2, offset);
amax = fabs(data[imax] - offset);
dt->index = imax;
if ( *_noiseAmplitude == 0. )
*snr = 1000000.0;
else
*snr = amax / *_noiseAmplitude;
if ( *snr < _config.snrMin ) {
setStatus(LowSNR, *snr);
return false;
}
*period = -1;
amplitude->value = amax;
if ( _streamConfig[_usedComponent].gain != 0.0 )
amplitude->value /= _streamConfig[_usedComponent].gain;
else {
setStatus(MissingGain, 0.0);
return false;
}
// - convert to micrometer
amplitude->value *= 1E06;
// - estimate peak-to-peak from absmax amplitude
amplitude->value *= 2.0;
return true;
}