vector_add

Digital Signal Processing Library

Voice Lab

Program name: vector_add

Language: C

In file: vector_lib.c

Objective: Add a vector to another

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

Parameters:

  • vector1 - The pointer to the first input vector array
  • vector2 - The pointer to the second input vector array
  • vector_width - Number of elements in each vector
  • vector3 - The pointer to the output vector array address
Return value:
  • void

Mathematical Description: v1 + v2 ==> v3

Comments: Routine is used to add a vector to another

User Comments

Code:

void vector_add(double *vector1, double *vector2, int vector_width, double **vector3)
{
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++){
(*vector3)[i] = vector1[i] + vector2[i];
number_adds++;
}
return;
}