?dot
Compute the dot product of vectors, that is,
.
x and y are vectors containing n elements.
Interface Definition
C interface:
float cblas_sdot(const BLASINT n, const float *x, const BLASINT incx, const float *y, const BLASINT incy);
double cblas_ddot(const BLASINT n, const double *x, const BLASINT incx, const double *y, const BLASINT incy);
Fortran interface:
RES = SDOT(N, X, INCX, Y, INCY)
RES = DDOT(N, X, INCX, Y, INCY)
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
n |
Integer |
Number of elements in the x vector |
Input |
x |
|
Vector x. The vector size is at least (1+(n-1)*abs(incx)). |
Input |
incx |
Integer |
Increment for the elements of vector x |
Input |
y |
|
Vector y. The vector size is at least (1+(n-1)*abs(incy)). |
Input |
incy |
Integer |
Increment for the elements of vector y |
Input |
Return Value
Vector point product result. For sdot, it is of single-precision floating-point type. For ddot, it is of double-precision floating-point type.
Dependencies
#include "kblas.h"
Examples
C interface:
float res;
int n = 5, incx = 1, incy = 1;
/**
* X: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647
* Y: -0.302449, -0.164777, 0.268230, -0.222225, 0.053970
*/
float x[5] = {0.340188, -0.105617, 0.283099, 0.298440, 0.411647};
float y[5] = {-0.302449, -0.164777, 0.268230, -0.222225, 0.053970};
res = cblas_sdot(n, x, incx, y, incy);
/**
* Output:
* -0.053655
*/
Fortran interface:
REAL(4) :: RES
INTEGER :: N=5
INTEGER :: INCX=1
INTEGER :: INCY=1
REAL(4) :: X(5)
DATA X /0.340188, -0.105617, 0.283099, 0.298440, 0.411647/
REAL(4) :: Y(5)
DATA Y /-0.302449, -0.164777, 0.268230, -0.222225, 0.053970/
RES=SDOT(N, X, INCX, Y, INCY)
* Output : -0.053655