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: /// <summary>
20: /// Purpose
21: /// =======
22: ///
23: /// takes the sum of the absolute values.
24: /// jack dongarra, linpack, 3/11/78.
25: /// modified 3/93 to return if incx .le. 0.
26: /// modified 12/3/93, array(1) declarations changed to array(*)
27: ///</summary>
28: public class DASUM
29: {
30:
31:
32: #region Fields
33:
34: double DTEMP = 0; int I = 0; int M = 0; int MP1 = 0; int NINCX = 0;
35:
36: #endregion
37:
38: public DASUM()
39: {
40:
41: }
42:
43: /// <summary>
44: /// Purpose
45: /// =======
46: ///
47: /// takes the sum of the absolute values.
48: /// jack dongarra, linpack, 3/11/78.
49: /// modified 3/93 to return if incx .le. 0.
50: /// modified 12/3/93, array(1) declarations changed to array(*)
51: ///</summary>
52: public double Run(int N, double[] DX, int offset_dx, int INCX)
53: {
54: double dasum = 0;
55:
56: #region Array Index Correction
57:
58: int o_dx = -1 + offset_dx;
59:
60: #endregion
61:
62:
63: #region Prolog
64:
65: // * .. Scalar Arguments ..
66: // * ..
67: // * .. Array Arguments ..
68: // * ..
69: // *
70: // * Purpose
71: // * =======
72: // *
73: // * takes the sum of the absolute values.
74: // * jack dongarra, linpack, 3/11/78.
75: // * modified 3/93 to return if incx .le. 0.
76: // * modified 12/3/93, array(1) declarations changed to array(*)
77: // *
78: // *
79: // * .. Local Scalars ..
80: // * ..
81: // * .. Intrinsic Functions ..
82: // INTRINSIC DABS,MOD;
83: // * ..
84:
85: #endregion
86:
87:
88: #region Body
89:
90: dasum = 0.0E0;
91: DTEMP = 0.0E0;
92: if (N <= 0 || INCX <= 0) return dasum;
93: if (INCX == 1) goto LABEL20;
94: // *
95: // * code for increment not equal to 1
96: // *
97: NINCX = N * INCX;
98: for (I = 1; (INCX >= 0) ? (I <= NINCX) : (I >= NINCX); I += INCX)
99: {
100: DTEMP = DTEMP + Math.Abs(DX[I + o_dx]);
101: }
102: dasum = DTEMP;
103: return dasum;
104: // *
105: // * code for increment equal to 1
106: // *
107: // *
108: // * clean-up loop
109: // *
110: LABEL20: M = FortranLib.Mod(N,6);
111: if (M == 0) goto LABEL40;
112: for (I = 1; I <= M; I++)
113: {
114: DTEMP = DTEMP + Math.Abs(DX[I + o_dx]);
115: }
116: if (N < 6) goto LABEL60;
117: LABEL40: MP1 = M + 1;
118: for (I = MP1; I <= N; I += 6)
119: {
120: DTEMP = DTEMP + Math.Abs(DX[I + o_dx]) + Math.Abs(DX[I + 1 + o_dx]) + Math.Abs(DX[I + 2 + o_dx]) + Math.Abs(DX[I + 3 + o_dx]) + Math.Abs(DX[I + 4 + o_dx]) + Math.Abs(DX[I + 5 + o_dx]);
121: }
122: LABEL60: dasum = DTEMP;
123: return dasum;
124:
125: #endregion
126:
127: }
128: }
129: }