- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
int const Nh = 4;
int const Nz = (2*Nx-1);
int iy0 = 0;
float h1[Nh];
float z1[Nz];
h1 = i;
}
// This is working
VSLConvTaskPtr task;
status = vslsConvNewTask1D(&task,VSL_CONV_MODE_AUTO,Nh,Nx,Nz);
std::cerr << "status= " << status << std::endl;
status = vslConvSetStart(task,&iy0);
std::cerr << "status= " << status << std::endl;
status = vslsConvExec1D(task,h1,1,a1,1,z1,1);
std::cerr << "status= " << status << std::endl;
status = vslConvDeleteTask(&task);
std::cerr << "status= " << status << std::endl;
}
// Cross Correlation
// Not working
VSLCorrTaskPtr task2;
status = vslsCorrNewTask1D(&task2,VSL_CORR_MODE_AUTO,Nh,Nx,Nz);
std::cerr << "status= " << status << std::endl;
status = vslCorrSetStart(task2,&iy0);
std::cerr << "status= " << status << std::endl;
status = vslsCorrExec1D(task2,h1,1,a1,1,z1,1);
std::cerr << "status= " << status << std::endl;
status = vslCorrDeleteTask(&task2);
std::cerr << "status= " << status << std::endl;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Message Edited by trosenqu on 10-13-2005 06:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the somewhat longer, but more helpful response from the developer.
Mathematically, the operations of convolution and correlation assume different enumerations for elements of the output array. For convolution, the output is enumerated as w0, , w(Nh-1)+(Nx-1); and for correlation, the enumeration is w-(Nh-1), , wNx-1.
If the parameter iy0 is assigned to 0, for convolution this implies that the output array z1[] is fulfilled starting from the 0th element of the mathematical enumeration, i.e.:
z1[0]=w0, , z1[Nz-1]=wNz-1
For correlation, the parameter iy0 is usually assigned to (Nh-1); this again implies that z1[] is fulfilled starting from the beginning of the mathematical sequence:
z1[0]=w-(Nh-1), , z1[Nz-1]=wNx-1
The user could just omit the calls to the SetStart() functions to let the software adjusting the iy0 parameter automatically. By default, iy0 would be assigned to 0 for convolution, and to (Nh-1) for correlation.
Anyway, if iy0 is explicitly assigned by user and iy0>-(Nh-1), for the case of correlation this implies that z1[] must start from the middle of the mathematical output:
z1[0]=w0, , z[Nx-1]=wNx-1,
Unfortunately, mathematical results are not defined for z1[Nx], , z1[Nz-1] in this case; and the software signals about this problem that it cannot calculate z1 for i>Nx-1.
To fix this issue, the code snippet could be changed as shown in the attached file. Here, the value of iy0 is reassigned to (Nh-1) before calculating correlation.
Or, if the user intentionally assumed to fulfill the correlation output as z1[0]=w0, ; then the value of Nz should be reduced to Nx or to some less value in order to ensure that mathematical results would be defined for all z1 up to i=Nz-1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page