int2double

Signal Processing Library

Program name: int2double

Language: C

In file: window_lib.c

Objective: Convert INT window to double window with normalize.

Usage: void int2double(int *window, int window_size, double **d_window, int normalize) );

Parameters:

  • window - The input INT window
  • window_size - The size of the window
  • d_window - The output double window
  • normalize - if 1, divide by max value; if not, do not divide;
Return
  • void

Mathematical Description:

Comments: Routine to convert INT window to double window with normalize

User Comments

Code:

void int2double(int *window, int window_size, double **d_window, int normalize)
{
        int i;
        double  max;

        max = 0.0;

        /* for each element, copy and check if greater than maximum */
        for(i = 0; i < window_size; i++) {
                ((*d_window)[i]) = (double)window[i];
                if(((*d_window)[i]) >= 0) {
                        /* value positive or zero */
                        if(max < ((*d_window)[i])) {
                                max = (*d_window)[i];
                        }
                } else {
                        /* value negative, invert sign before comparison */
                        if(max < (-((*d_window)[i]))) {
                                max = -(*d_window)[i];
                        }
                }
        }

        /* section to normalize vector */
        if(normalize == 1) for(i = 0; i < window_size; i++) ((*d_window)[i]) /= max;

        return;
}