/*1 */ // inner_product_C.c 
/*2 */ // Calculates the inner product of two vectors 
/*3 */ 
/*4 */ int inprod_C_func(short *a, short *b, int ncount);  // function prototype
/*5 */ #include <stdio.h>                                  // for printf
/*6 */ #define N 4                                         // # of data in each nx1 vector
/*7 */ short x[N] = {1,2,3,4};                             // define elements in 1st vector
/*8 */ short y[N] = {0,2,4,6};                             // define elements in 2nd vector
/*9 */ short inner_product;                                // to store inner product
/*10*/ 
/*11*/ int inprod_C_func(short *a, short *b, int ncount)   // inner product function
/*12*/ {                                        
/*13*/   int sum = 0;                                      // init sum
/*14*/   int i;                                            // local var used in for loop
/*15*/   
/*16*/   for (i = 0; i < ncount; i++)
/*17*/   {
/*18*/      sum += a[i] * b[i];                            // sum of products
/*19*/   }
/*20*/   return(sum);                                      // return sum as result
/*21*/ }
/*22*/ 
/*23*/ main()
/*24*/ {
/*25*/   inner_product = inprod_C_func(x,y,N);             // call inner_prod function
/*26*/   printf("<x,y> = %d (decimal) \n", inner_product); // print result
/*27*/ }


