ddot.c
Go to the documentation of this file.
00001 /* ddot.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 doublereal ddot_(integer *n, doublereal *dx, integer *incx, doublereal *dy, 
00017         integer *incy)
00018 {
00019     /* System generated locals */
00020     integer i__1;
00021     doublereal ret_val;
00022 
00023     /* Local variables */
00024     integer i__, m, ix, iy, mp1;
00025     doublereal dtemp;
00026 
00027 /*     .. Scalar Arguments .. */
00028 /*     .. */
00029 /*     .. Array Arguments .. */
00030 /*     .. */
00031 
00032 /*  Purpose */
00033 /*  ======= */
00034 
00035 /*     forms the dot product of two vectors. */
00036 /*     uses unrolled loops for increments equal to one. */
00037 /*     jack dongarra, linpack, 3/11/78. */
00038 /*     modified 12/3/93, array(1) declarations changed to array(*) */
00039 
00040 
00041 /*     .. Local Scalars .. */
00042 /*     .. */
00043 /*     .. Intrinsic Functions .. */
00044 /*     .. */
00045     /* Parameter adjustments */
00046     --dy;
00047     --dx;
00048 
00049     /* Function Body */
00050     ret_val = 0.;
00051     dtemp = 0.;
00052     if (*n <= 0) {
00053         return ret_val;
00054     }
00055     if (*incx == 1 && *incy == 1) {
00056         goto L20;
00057     }
00058 
00059 /*        code for unequal increments or equal increments */
00060 /*          not equal to 1 */
00061 
00062     ix = 1;
00063     iy = 1;
00064     if (*incx < 0) {
00065         ix = (-(*n) + 1) * *incx + 1;
00066     }
00067     if (*incy < 0) {
00068         iy = (-(*n) + 1) * *incy + 1;
00069     }
00070     i__1 = *n;
00071     for (i__ = 1; i__ <= i__1; ++i__) {
00072         dtemp += dx[ix] * dy[iy];
00073         ix += *incx;
00074         iy += *incy;
00075 /* L10: */
00076     }
00077     ret_val = dtemp;
00078     return ret_val;
00079 
00080 /*        code for both increments equal to 1 */
00081 
00082 
00083 /*        clean-up loop */
00084 
00085 L20:
00086     m = *n % 5;
00087     if (m == 0) {
00088         goto L40;
00089     }
00090     i__1 = m;
00091     for (i__ = 1; i__ <= i__1; ++i__) {
00092         dtemp += dx[i__] * dy[i__];
00093 /* L30: */
00094     }
00095     if (*n < 5) {
00096         goto L60;
00097     }
00098 L40:
00099     mp1 = m + 1;
00100     i__1 = *n;
00101     for (i__ = mp1; i__ <= i__1; i__ += 5) {
00102         dtemp = dtemp + dx[i__] * dy[i__] + dx[i__ + 1] * dy[i__ + 1] + dx[
00103                 i__ + 2] * dy[i__ + 2] + dx[i__ + 3] * dy[i__ + 3] + dx[i__ + 
00104                 4] * dy[i__ + 4];
00105 /* L50: */
00106     }
00107 L60:
00108     ret_val = dtemp;
00109     return ret_val;
00110 } /* ddot_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:39