genVectorDotProd
in genMath.lib

Vector Functions            Function List by Category            Alphabetical Function List

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 explicit routines VectorDotProd2d and VectorDotProd3d are faster due to code
optimizations in explicit algorithms..

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"

////////////////////////////// MAIN //////////////////////////////////
void main()
{

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

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

	//character strings
	char  ch;		// input string to exit

	//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");
	
	//display closing message and wait for <enter> before exiting
	printf("Press <Enter> to end");
	scanf("%c", &ch);

} // End Main

/////////////////////////////// End splgenDP.c ///////////////////////
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