inner product

SYNOPSIS

#include "matrix.h"
double  in_prod(VEC *x, VEC *y)
#include "zmatrix.h"
complex zin_prod(ZVEC *x, ZVEC *y)

DESCRIPTION

The inner product $x^Ty = \sum_i x_i y_i$ of x and y is returned by in_prod(). The complex inner product $\bar x^T y = \sum_i\bar x_i y_i$ of x and y is returned by zin_prod(). This will fail if x or y is NULL. These are built on the ``raw'' inner product routines:

double  _in_prod (VEC *x,  VEC *y,  int i0)
complex _zin_prod(ZVEC *x, ZVEC *y, int i0, int conj)
which compute the inner products ignoring the first i0 entries. For the routine _zin_prod() if the flag conj is Z_CONJ (or TRUE) then the entries in the x vector are conjugated and $\sum_{i\ge i0}\bar x_i y_i$ is returned; otherwise if conj is Z_NOCONJ (or FALSE) then $\sum_{i\ge i0}x_i y_i$ is returned.

EXAMPLE

VEC  *x, *y;
ZVEC *zx, *zy;
Real x_dot_y;
complex zx_do_zy;
  ......
x_dot_y = in_prod(x,y);
zx_dot_zy = zin_prod(zx,zy);

SEE ALSO: __ip__(), __zip__() and the core routines.

BUGS

The accumulation is not guaranteed to be done in a higher precision than Real, although the return type is double. To guarantee more than this, we would either need an explicit extended precision long double type or force the accumulation to be done in a single register. While this is in principle possible on IEEE standard hardware, the routines to ensure this are not standard, even for IEEE arithmetic.

SOURCE FILE: vecop.c, zvecop.c