sdot.c
Go to the documentation of this file.
00001 /* sdot.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 sdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy)
00017 {
00018     /* System generated locals */
00019     integer i__1;
00020     real ret_val;
00021 
00022     /* Local variables */
00023     integer i__, m, ix, iy, mp1;
00024     real stemp;
00025 
00026 /*     .. Scalar Arguments .. */
00027 /*     .. */
00028 /*     .. Array Arguments .. */
00029 /*     .. */
00030 
00031 /*  Purpose */
00032 /*  ======= */
00033 
00034 /*     forms the dot product of two vectors. */
00035 /*     uses unrolled loops for increments equal to one. */
00036 /*     jack dongarra, linpack, 3/11/78. */
00037 /*     modified 12/3/93, array(1) declarations changed to array(*) */
00038 
00039 
00040 /*     .. Local Scalars .. */
00041 /*     .. */
00042 /*     .. Intrinsic Functions .. */
00043 /*     .. */
00044     /* Parameter adjustments */
00045     --sy;
00046     --sx;
00047 
00048     /* Function Body */
00049     stemp = 0.f;
00050     ret_val = 0.f;
00051     if (*n <= 0) {
00052         return ret_val;
00053     }
00054     if (*incx == 1 && *incy == 1) {
00055         goto L20;
00056     }
00057 
00058 /*        code for unequal increments or equal increments */
00059 /*          not equal to 1 */
00060 
00061     ix = 1;
00062     iy = 1;
00063     if (*incx < 0) {
00064         ix = (-(*n) + 1) * *incx + 1;
00065     }
00066     if (*incy < 0) {
00067         iy = (-(*n) + 1) * *incy + 1;
00068     }
00069     i__1 = *n;
00070     for (i__ = 1; i__ <= i__1; ++i__) {
00071         stemp += sx[ix] * sy[iy];
00072         ix += *incx;
00073         iy += *incy;
00074 /* L10: */
00075     }
00076     ret_val = stemp;
00077     return ret_val;
00078 
00079 /*        code for both increments equal to 1 */
00080 
00081 
00082 /*        clean-up loop */
00083 
00084 L20:
00085     m = *n % 5;
00086     if (m == 0) {
00087         goto L40;
00088     }
00089     i__1 = m;
00090     for (i__ = 1; i__ <= i__1; ++i__) {
00091         stemp += sx[i__] * sy[i__];
00092 /* L30: */
00093     }
00094     if (*n < 5) {
00095         goto L60;
00096     }
00097 L40:
00098     mp1 = m + 1;
00099     i__1 = *n;
00100     for (i__ = mp1; i__ <= i__1; i__ += 5) {
00101         stemp = stemp + sx[i__] * sy[i__] + sx[i__ + 1] * sy[i__ + 1] + sx[
00102                 i__ + 2] * sy[i__ + 2] + sx[i__ + 3] * sy[i__ + 3] + sx[i__ + 
00103                 4] * sy[i__ + 4];
00104 /* L50: */
00105     }
00106 L60:
00107     ret_val = stemp;
00108     return ret_val;
00109 } /* sdot_ */


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