Normed and Inner Product Spaces



Inner Products

Inner Products

In general an inner product on a Real vector space V is a positive definite bilinear function
< · , · > : V × VR. 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 = ( u0, ..., un-1 ) and v = ( v0, ..., vn-1 ), then < u , v > = u0 v0 + ··· + un-1 vn-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 × VC. 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 = ( u0, ..., un-1 ) and v = ( v0, ..., vn-1 ), then < u , v > = u*0 v0 + ··· + u*n-1 vn-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 > = u0 v0 + ··· + un-1 vn-1.

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

    This routine calculates the inner product < u , v > = u0 v0 + u1 v1.

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

    This routine calculates the inner product < u , v > = u0 v0 + u1 v1 + u2 v2.

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

    This routine calculates the Hermitian inner product < u , v > = u*0 v0 + ··· + u*n-1 vn-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 v0 + u*1 v1, 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 v0 + u*1 v1 + u*2 v2, where * denotes the complex conjugate..

C Source Code

NASM Source Code
For Linux gcc Users

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.