1: #region Translated by Jose Antonio De Santiago-Castillo.
2:
3: //Translated by Jose Antonio De Santiago-Castillo.
4: //E-mail:JAntonioDeSantiago@gmail.com
5: //Web: www.DotNumerics.com
6: //
7: //Fortran to C# Translation.
8: //Translated by:
9: //F2CSharp Version 0.71 (November 10, 2009)
10: //Code Optimizations: None
11: //
12: #endregion
13:
14: using System;
15: using DotNumerics.FortranLibrary;
16:
17: namespace DotNumerics.CSLapack
18: {
19: public class DDOT
20: {
21:
22:
23: #region Fields
24:
25: double DTEMP = 0; int I = 0; int IX = 0; int IY = 0; int M = 0; int MP1 = 0;
26:
27: #endregion
28:
29: public DDOT()
30: {
31:
32: }
33:
34: public double Run(int N, double[] DX, int offset_dx, int INCX, double[] DY, int offset_dy, int INCY)
35: {
36: double ddot = 0;
37:
38: #region Array Index Correction
39:
40: int o_dx = -1 + offset_dx; int o_dy = -1 + offset_dy;
41:
42: #endregion
43:
44: // c
45: // c forms the dot product of two vectors.
46: // c uses unrolled loops for increments equal to one.
47: // c jack dongarra, linpack, 3/11/78.
48: // c modified 12/3/93, array(1) declarations changed to array(*)
49: // c
50: // c
51:
52: #region Body
53:
54: ddot = 0.0E0;
55: DTEMP = 0.0E0;
56: if (N <= 0) return ddot;
57: if (INCX == 1 && INCY == 1) goto LABEL20;
58: // c
59: // c code for unequal increments or equal increments
60: // c not equal to 1
61: // c
62: IX = 1;
63: IY = 1;
64: if (INCX < 0) IX = ( - N + 1) * INCX + 1;
65: if (INCY < 0) IY = ( - N + 1) * INCY + 1;
66: for (I = 1; I <= N; I++)
67: {
68: DTEMP = DTEMP + DX[IX + o_dx] * DY[IY + o_dy];
69: IX = IX + INCX;
70: IY = IY + INCY;
71: }
72: ddot = DTEMP;
73: return ddot;
74: // c
75: // c code for both increments equal to 1
76: // c
77: // c
78: // c clean-up loop
79: // c
80: LABEL20: M = FortranLib.Mod(N,5);
81: if (M == 0) goto LABEL40;
82: for (I = 1; I <= M; I++)
83: {
84: DTEMP = DTEMP + DX[I + o_dx] * DY[I + o_dy];
85: }
86: if (N < 5) goto LABEL60;
87: LABEL40: MP1 = M + 1;
88: for (I = MP1; I <= N; I += 5)
89: {
90: DTEMP = DTEMP + DX[I + o_dx] * DY[I + o_dy] + DX[I + 1 + o_dx] * DY[I + 1 + o_dy] + DX[I + 2 + o_dx] * DY[I + 2 + o_dy] + DX[I + 3 + o_dx] * DY[I + 3 + o_dy] + DX[I + 4 + o_dx] * DY[I + 4 + o_dy];
91: }
92: LABEL60: ddot = DTEMP;
93: return ddot;
94:
95: #endregion
96:
97: }
98: }
99: }