## Inner Products

In general an inner product on a Real vector space**V**is a positive definite bilinear function

< · , · > :

**V**×

**V**→

*R*. The implementation presented below is for the case in which a basis for

**V**is chosen so that the matrix of the bilinear function is the identity matrix, i.e. if

**u**= (

*u*

_{0}, ...,

*u*

_{n-1}) and

**v**= (

*v*

_{0}, ...,

*v*

_{n-1}), then <

**u**,

**v**> =

*u*

_{0}

*v*

_{0}+ ··· +

*u*

_{n-1}

*v*

_{n-1}. The more general implementation is given by the function

*Bilinear_Form( )*described in Matrix Multiplication.

The function for evaluating the inner product of two vectors is Inner_Product. There are special versions of this routine for the cases of the ubiquitous

*2*-d and

*3*-d vectors.

In general an inner product on a Complex vector space

**V**is a positive definite sesquilinear function < · , · > :

**V**×

**V**→

*C*. The implementation presented below is for the case in which a basis for

**V**is chosen so that the matrix of the sesquilinear function is the identity matrix, i.e. if

**u**= (

*u*

_{0}, ...,

*u*

_{n-1}) and

**v**= (

*v*

_{0}, ...,

*v*

_{n-1}), then <

**u**,

**v**> =

*u*

^{*}_{0}

*v*

_{0}+ ··· +

*u*

^{*}_{n-1}

*v*

_{n-1}, where

***denotes the complex conjugate. The more general implementation is given by the function

*Sesquilinear_Form( )*described in Matrix Multiplication.

The function for evaluating the Hermitian inner product of two vectors is Hermitian_Inner_Product. There are special versions of this routine for the cases of the ubiquitous

*2*-d and

*3*-d vectors.

### Function List

- double Inner_Product( double u[ ], double v[ ], int n )

This routine calculates the inner product <**u**,**v**> =*u*_{0}*v*_{0}+ ··· +*u*_{n-1}*v*_{n-1}.

- double Inner_Product_2d( double u[ ], double v[ ])

This routine calculates the inner product <**u**,**v**> =*u*_{0}*v*_{0}+*u*_{1}*v*_{1}.

- double Inner_Product_3d( double u[ ], double v[ ])

This routine calculates the inner product <**u**,**v**> =*u*_{0}*v*_{0}+*u*_{1}*v*_{1}+*u*_{2}*v*_{2}.

- double complex Hermitian_Inner_Product( double complex u[ ], double complex v[ ], int n )

This routine calculates the Hermitian inner product <**u**,**v**> =*u*^{*}_{0}*v*_{0}+ ··· +*u*^{*}_{n-1}*v*_{n-1}, where***denotes the complex conjugate.

- double complex Hermitian_Inner_Product_2d( double complex u[ ], double complex v[ ])

This routine calculates the inner product <**u**,**v**> =*u*^{*}_{0}*v*_{0}+*u*^{*}_{1}*v*_{1}, where***denotes the complex conjugate..

- double complex Hermitian_Inner_Product_3d( double complex u[ ], double complex v[ ])

This routine calculates the inner product <**u**,**v**> =*u*^{*}_{0}*v*_{0}+*u*^{*}_{1}*v*_{1}+*u*^{*}_{2}*v*_{2}, where***denotes the complex conjugate..

*C* Source Code

- The file, inner_product.c, contains the version of Inner_Product() written in
*C*.

- The file, inner_product_2d.c, contains the version of Inner_Product_2d() written in
*C*.

- The file, inner_product_3d.c, contains the version of Inner_Product_3d() written in
*C*.

- The file, hermitian_inner_product.c, contains the version of Hermitian_Inner_Product() written in
*C*.

- The file, hermitian_inner_product_2d.c, contains the version of Hermitian_Inner_Product_2d() written in
*C*.

- The file, hermitian_inner_product_3d.c, contains the version of Hermitian_Inner_Product_3d() written in
*C*.

*NASM* Source Code

For Linux gcc Users

- The file, inner_product.asm, contains the version of Inner_Product() written in
*NASM*.

- The file, inner_product_2d.asm, contains the version of Inner_Product_2d() written in
*NASM*.

- The file, inner_product_3d.asm, contains the version of Inner_Product_3d() written in
*NASM*.

*C* Test Code, Test Results, and Build Shell Script

- The file, testinnerproduct.c, contains a test program of Inner_Product( ). This test program requires the file
*inner_product.c*listed above.

- The file, InnerProductTest.txt, contains the results of the test program testinnerproduct.c.

- The file, testinnerproduct.sh, contains the shell script used to compile, link, and execute the test program testinnerproduct.c.

- The file, testinnerproduct2d.c, contains a test program of Inner_Product_2d( ). This test program requires the file
*inner_product_2d.c*listed above.

- The file, InnerProduct2dTest.txt, contains the results of the test program testinnerproduct2d.c.

- The file, testinnerproduct2d.sh, contains the shell script used to compile, link, and execute the test program testinnerproduct2d.c.

- The file, testinnerproduct3d.c, contains a test program of Inner_Product_3d( ). This test program requires the file
*inner_product_3d.c*listed above.

- The file, InnerProduct3dTest.txt, contains the results of the test program testinnerproduct3d.c.

- The file, testinnerproduct3d.sh, contains the shell script used to compile, link, and execute the test program testinnerproduct3d.c.

- The file, testhermitianinnerproduct.c, contains a test program of Hermitian_Inner_Product( ). This test program requires the file
*hermitian_inner_product.c*listed above.

- The file, HermitianInnerProductTest.txt, contains the results of the test program testhermitianinnerproduct.c.

- The file, testhermitianinnerproduct.sh, contains the shell script used to compile, link, and execute the test program testhermitianinnerproduct.c.

- The file, testhermitianinnerproduct2d.c, contains a test program of Hermitian_Inner_Product_2d( ). This test program requires the file
*hermitian_inner_product_2d.c*listed above.

- The file, HermitianInnerProduct2dTest.txt, contains the results of the test program testhermitianinnerproduct2d.c.

- The file, testhermitianinnerproduct2d.sh, contains the shell script used to compile, link, and execute the test program testhermitianinnerproduct2d.c.

- The file, testhermitianinnerproduct3d.c, contains a test program of Hermitian_Inner_Product_3d( ). This test program requires the file
*hermitian_inner_product_3d.c*listed above.

- The file, HermitianInnerProduct3dTest.txt, contains the results of the test program testhermitianinnerproduct3d.c.

- The file, testhermitianinnerproduct3d.sh, contains the shell script used to compile, link, and execute the test program testhermitianinnerproduct3d.c.