Sunday, July 04, 2010

energy

Digital Signal Processing Library

Voice Lab

energy


double energy(double *vector, int vector_width, int option)
{
int i;
double d_energy;

/* start with zero energy */
d_energy = 0.0;

for(i = 0; i < vector_width; i++){
/* add the square of each element of the vector */
d_energy += (vector[i] * vector[i]);
}

if(option & 0x02) return(sqrt(d_energy));
if(option & 0x08) return(d_energy/vector_width);
return(d_energy);
}


No comments:

Post a Comment