Tuesday, August 24, 2010

vector_write

Digital Signal Processing Library

Voice Lab

vector_write


void vector_write(double *vector, int vector_width, FILE *out_file, int options)
{
int i, offset;

/*
** The idea of the options flag is to make the program more flexible.
** The first bit is reserved for the offset.
** The offset can be 0 or 1. Under normal circumstances it will be 0.
** In the case of arrays being 1 more than the order,
** and needing to disregard the first element, set offset to 1.
** The fifth bit (0x10) is reserverd for the mode.
** If mode is 0, each value will be on a separate line.
** If mode is 1, each vector will occupy only one line.
*/

offset = options & 0x01;

if(options & 0x10) {
for(i = offset; i < (vector_width+offset); i++) {
if(vector[i] >= 0) {
fprintf(out_file, " %lf ", vector[i]);
} else {
/* compensate for the minus sign */
fprintf(out_file, "%lf ", vector[i]);
}
}
fprintf(out_file, "\n");
} else {
for(i = offset; i < (vector_width+offset); i++) {
fprintf(out_file, "%lf\n", vector[i]);
}
}
return;
}


No comments:

Post a Comment