vector_multiply

Digital Signal Processing Library

Voice Lab

Program name: vector_multiply

Language: C

In file: vector_lib.c

Objective: Multiply a vector by a constant value

Usage: void vector_multiply(double *vector1, double value, int vector_width, double **vector2);

Parameters:

  • vector1 - The pointer to the input vector array
  • value - The constant value by which to multiply the vector elements
  • vector_width - Number of elements in each vector
  • vector2 - The pointer to the output vector array address
Return value:
  • void

Mathematical Description: v1 * c ---> v2

Comments: Routine is used to multiply a vector by a constant

User Comments

Code:

void vector_multiply(double *vector1, double value, int vector_width, double **vector2)
{
int i;

if(vector_width > MAX_VECTOR_WIDTH) {
fprintf(stderr, "vector_width greater than MAX_VECTOR_WIDTH\n");
fprintf(stderr, "Please increase MAX_VECTOR_WIDTH in vector_lib.h and recompile.\n");
exit(-1);
}

for(i = 0; i < vector_width; i++){
(*vector2)[i] = vector1[i] * value;
number_muls++;
}
return;
}