132 9. CODE OPTIMIZATION
*/
finish = clock();
double elapsedTime = (double)(finish---start)/CLOCKS_PER_SEC;
//elapsedTime contains time elapsed in seconds
e variables will show the total execution time of any code placed where the comment section
is indicated. More information on timing functionality may be found in the documentation for
the relevant C headers.
9.2 LINEAR CONVOLUTION
e linear convolution (FIR filtering) operation provides a good example of how a signal pro-
cessing C code should be written to be computationally efficient. For portability purposes, the
FIR filtering C code, which appears below, is implemented by setting up variable storage during
initialization and by generating output when the compute method is called.
typedef struct FIRFilter { // Data storage structure
int numCoefficients;
int frameSize;
float* coefficients;
float* window;
float* result;
} FIRFilter;
FIRFilter* //Data structure initialization
newFIR(int frameSize, int numCoefficients, float* coefficients) {
FIRFilter* newFIR = (FIRFilter*)malloc(sizeof(FIRFilter));
newFIR->numCoefficients = numCoefficients;
newFIR->frameSize = frameSize;
newFIR->coefficients = (float*)malloc(numCoefficients*
sizeof(float));
newFIR->window = (float*)calloc(numCoefficients +frameSize,
sizeof(float));
newFIR->result = (float*)malloc(frameSize*sizeof(float));
int i;
for(i=0;i<numCoefficients;i++) {
newFIR->coefficients[(numCoefficients - (1) - i] =
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.193.158