genVectorCPL
in genMath.lib

Sample Code

int genVectorDotProd(
                                        float *VectorA,       // pointer to array holding vector A
                                        float *VectorB,       // pointer to array holding vector B
                                        int dimen,                // dimension of vectors A and B
                                        float *Result)         // pointer to store result

This function computes the Dot Product of two vectors of dimension n:

Dot Product = sum{ a(i) * b(i) }

 

The return code is errno, defined in the C standard library (math.h).  This is an integer value
for math errors.

 
Sample Application:
/////////// splgenDP.c for genVectorDotProd Library Function /////////
//								    //																//
//	For this sample, 3-d vectors are used.  Vectors are stored  //
//	in arrays a and b, and the dot product is returned into	    //
//	a scalar, c.						    //
//								    //
//////////////////////////////////////////////////////////////////////

//////////////////////////// INCLUDES ////////////////////////////////

#include "stdio.h"
#include "genMath.h"

// entry point
void main()
{

	//local declarations
	//integers
	int retcode;		// return code for call to genVectorDotProd

	float a[3];		// vector A
	float b[3];		// vector B
	float c;		// dot product result

	//intialize the A and B vectors
	a[0] = (float)1.234;
	a[1] = (float)-.678;
	a[2] = (float)10.3;

	b[0] = (float)4.559;
	b[1] = (float)3.24;
	b[2] = (float)0.3422;

	//compute the dot product
	retcode = genVectorDotProd(a,b,3,&c);
	
	//display the result
	printf("%s%f%s", "Dot Product = ", c,"\n\n");
	

}
The reader may compute the dot product of A and B and compare
to the output of the sample program.
Output from the test program splgenDP.c: 
Dot Product = 6.953746