本文整理汇总了C++中DataStorage::numberOfElements方法的典型用法代码示例。如果您正苦于以下问题:C++ DataStorage::numberOfElements方法的具体用法?C++ DataStorage::numberOfElements怎么用?C++ DataStorage::numberOfElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStorage
的用法示例。
在下文中一共展示了DataStorage::numberOfElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute
void FftClFft::
compute(DataStorage<float>::Ptr input, Tfr::ChunkData::Ptr output, DataStorageSize n )
{
unsigned denseWidth = n.width/2+1;
EXCEPTION_ASSERT( output->numberOfElements()/denseWidth == n.height );
EXCEPTION_ASSERT( input->numberOfElements()/n.width == n.height );
// interleave input to complex data
Tfr::ChunkData::Ptr complexinput( new Tfr::ChunkData( input->size()));
::stftToComplex( input, complexinput );
// make room for full output
Tfr::ChunkData::Ptr redundantOutput( new Tfr::ChunkData( n.width*n.height ));
// compute
computeWithClFft(complexinput, redundantOutput, n, FftDirection_Forward);
// discard redundant output
Tfr::ChunkElement* in = CpuMemoryStorage::ReadOnly<1>( redundantOutput ).ptr();
Tfr::ChunkElement* out = CpuMemoryStorage::WriteAll<1>( output ).ptr();
#pragma omp parallel for
for (int i=0; i < (int)n.height; ++i)
{
unsigned x;
for (x=0; x<denseWidth; ++x)
out[i*denseWidth + x] = in[i*n.width + x];
}
}
示例2: ComputationSynchronize
void FftClFft::
inverse(Tfr::ChunkData::Ptr input, DataStorage<float>::Ptr output, DataStorageSize n )
{
unsigned denseWidth = n.width/2+1;
unsigned redundantWidth = n.width;
unsigned batchcount1 = output->numberOfElements()/redundantWidth,
batchcount2 = input->numberOfElements()/denseWidth;
EXCEPTION_ASSERT( batchcount1 == batchcount2 );
EXCEPTION_ASSERT( (denseWidth-1)*2 == redundantWidth );
EXCEPTION_ASSERT( redundantWidth*n.height == output->numberOfElements() );
Tfr::ChunkData::Ptr redundantInput( new Tfr::ChunkData( n.height*redundantWidth ));
{
Tfr::ChunkElement* in = CpuMemoryStorage::ReadOnly<1>( input ).ptr();
Tfr::ChunkElement* out = CpuMemoryStorage::WriteAll<1>( redundantInput ).ptr();
#pragma omp parallel for
for (int i=0; i < (int)n.height; ++i)
{
unsigned x;
for (x=0; x<denseWidth; ++x)
out[i*redundantWidth + x] = in[i*denseWidth + x];
for (; x<redundantWidth; ++x)
out[i*redundantWidth + x] = conj(in[i*denseWidth + redundantWidth - x]);
}
}
Tfr::ChunkData::Ptr complexoutput( new Tfr::ChunkData( output->size()));
computeWithClFft(redundantInput, complexoutput, DataStorageSize( redundantWidth, n.height), FftDirection_Inverse);
::stftDiscardImag( complexoutput, output );
TIME_STFT ComputationSynchronize();
}