00001 /* dsdot.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 dsdot_(integer *n, real *sx, integer *incx, real *sy, integer * 00017 incy) 00018 { 00019 /* System generated locals */ 00020 integer i__1, i__2; 00021 doublereal ret_val; 00022 00023 /* Local variables */ 00024 integer i__, ns, kx, ky; 00025 00026 /* .. Scalar Arguments .. */ 00027 /* .. */ 00028 /* .. Array Arguments .. */ 00029 /* .. */ 00030 00031 /* AUTHORS */ 00032 /* ======= */ 00033 /* Lawson, C. L., (JPL), Hanson, R. J., (SNLA), */ 00034 /* Kincaid, D. R., (U. of Texas), Krogh, F. T., (JPL) */ 00035 00036 /* Purpose */ 00037 /* ======= */ 00038 /* Compute the inner product of two vectors with extended */ 00039 /* precision accumulation and result. */ 00040 00041 /* Returns D.P. dot product accumulated in D.P., for S.P. SX and SY */ 00042 /* DSDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY), */ 00043 /* where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is */ 00044 /* defined in a similar way using INCY. */ 00045 00046 /* Arguments */ 00047 /* ========= */ 00048 00049 /* N (input) INTEGER */ 00050 /* number of elements in input vector(s) */ 00051 00052 /* SX (input) REAL array, dimension(N) */ 00053 /* single precision vector with N elements */ 00054 00055 /* INCX (input) INTEGER */ 00056 /* storage spacing between elements of SX */ 00057 00058 /* SY (input) REAL array, dimension(N) */ 00059 /* single precision vector with N elements */ 00060 00061 /* INCY (input) INTEGER */ 00062 /* storage spacing between elements of SY */ 00063 00064 /* DSDOT (output) DOUBLE PRECISION */ 00065 /* DSDOT double precision dot product (zero if N.LE.0) */ 00066 00067 /* REFERENCES */ 00068 /* ========== */ 00069 00070 /* C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T. */ 00071 /* Krogh, Basic linear algebra subprograms for Fortran */ 00072 /* usage, Algorithm No. 539, Transactions on Mathematical */ 00073 /* Software 5, 3 (September 1979), pp. 308-323. */ 00074 00075 /* REVISION HISTORY (YYMMDD) */ 00076 /* ========================== */ 00077 00078 /* 791001 DATE WRITTEN */ 00079 /* 890831 Modified array declarations. (WRB) */ 00080 /* 890831 REVISION DATE from Version 3.2 */ 00081 /* 891214 Prologue converted to Version 4.0 format. (BAB) */ 00082 /* 920310 Corrected definition of LX in DESCRIPTION. (WRB) */ 00083 /* 920501 Reformatted the REFERENCES section. (WRB) */ 00084 /* 070118 Reformat to LAPACK style (JL) */ 00085 00086 /* ===================================================================== */ 00087 00088 /* .. Local Scalars .. */ 00089 /* .. */ 00090 /* .. Intrinsic Functions .. */ 00091 /* .. */ 00092 /* Parameter adjustments */ 00093 --sy; 00094 --sx; 00095 00096 /* Function Body */ 00097 ret_val = 0.; 00098 if (*n <= 0) { 00099 return ret_val; 00100 } 00101 if (*incx == *incy && *incx > 0) { 00102 goto L20; 00103 } 00104 00105 /* Code for unequal or nonpositive increments. */ 00106 00107 kx = 1; 00108 ky = 1; 00109 if (*incx < 0) { 00110 kx = (1 - *n) * *incx + 1; 00111 } 00112 if (*incy < 0) { 00113 ky = (1 - *n) * *incy + 1; 00114 } 00115 i__1 = *n; 00116 for (i__ = 1; i__ <= i__1; ++i__) { 00117 ret_val += (doublereal) sx[kx] * (doublereal) sy[ky]; 00118 kx += *incx; 00119 ky += *incy; 00120 /* L10: */ 00121 } 00122 return ret_val; 00123 00124 /* Code for equal, positive, non-unit increments. */ 00125 00126 L20: 00127 ns = *n * *incx; 00128 i__1 = ns; 00129 i__2 = *incx; 00130 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { 00131 ret_val += (doublereal) sx[i__] * (doublereal) sy[i__]; 00132 /* L30: */ 00133 } 00134 return ret_val; 00135 } /* dsdot_ */