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: /// -- LAPACK auxiliary routine (version 3.1) --
21: /// Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
22: /// November 2006
23: /// Purpose
24: /// =======
25: ///
26: /// DLARF applies a real elementary reflector H to a real m by n matrix
27: /// C, from either the left or the right. H is represented in the form
28: ///
29: /// H = I - tau * v * v'
30: ///
31: /// where tau is a real scalar and v is a real vector.
32: ///
33: /// If tau = 0, then H is taken to be the unit matrix.
34: ///
35: ///</summary>
36: public class DLARF
37: {
38:
39:
40: #region Dependencies
41:
42: DGEMV _dgemv; DGER _dger; LSAME _lsame;
43:
44: #endregion
45:
46:
47: #region Fields
48:
49: const double ONE = 1.0E+0; const double ZERO = 0.0E+0;
50:
51: #endregion
52:
53: public DLARF(DGEMV dgemv, DGER dger, LSAME lsame)
54: {
55:
56:
57: #region Set Dependencies
58:
59: this._dgemv = dgemv; this._dger = dger; this._lsame = lsame;
60:
61: #endregion
62:
63: }
64:
65: public DLARF()
66: {
67:
68:
69: #region Dependencies (Initialization)
70:
71: LSAME lsame = new LSAME();
72: XERBLA xerbla = new XERBLA();
73: DGEMV dgemv = new DGEMV(lsame, xerbla);
74: DGER dger = new DGER(xerbla);
75:
76: #endregion
77:
78:
79: #region Set Dependencies
80:
81: this._dgemv = dgemv; this._dger = dger; this._lsame = lsame;
82:
83: #endregion
84:
85: }
86: /// <summary>
87: /// Purpose
88: /// =======
89: ///
90: /// DLARF applies a real elementary reflector H to a real m by n matrix
91: /// C, from either the left or the right. H is represented in the form
92: ///
93: /// H = I - tau * v * v'
94: ///
95: /// where tau is a real scalar and v is a real vector.
96: ///
97: /// If tau = 0, then H is taken to be the unit matrix.
98: ///
99: ///</summary>
100: /// <param name="SIDE">
101: /// (input) CHARACTER*1
102: /// = 'L': form H * C
103: /// = 'R': form C * H
104: ///</param>
105: /// <param name="M">
106: /// (input) INTEGER
107: /// The number of rows of the matrix C.
108: ///</param>
109: /// <param name="N">
110: /// (input) INTEGER
111: /// The number of columns of the matrix C.
112: ///</param>
113: /// <param name="V">
114: /// (input) DOUBLE PRECISION array, dimension
115: /// (1 + (M-1)*abs(INCV)) if SIDE = 'L'
116: /// or (1 + (N-1)*abs(INCV)) if SIDE = 'R'
117: /// The vector v in the representation of H. V is not used if
118: /// TAU = 0.
119: ///</param>
120: /// <param name="INCV">
121: /// (input) INTEGER
122: /// The increment between elements of v. INCV .LT..GT. 0.
123: ///</param>
124: /// <param name="TAU">
125: /// (input) DOUBLE PRECISION
126: /// The value tau in the representation of H.
127: ///</param>
128: /// <param name="C">
129: /// (input/output) DOUBLE PRECISION array, dimension (LDC,N)
130: /// On entry, the m by n matrix C.
131: /// On exit, C is overwritten by the matrix H * C if SIDE = 'L',
132: /// or C * H if SIDE = 'R'.
133: ///</param>
134: /// <param name="LDC">
135: /// (input) INTEGER
136: /// The leading dimension of the array C. LDC .GE. max(1,M).
137: ///</param>
138: /// <param name="WORK">
139: /// (workspace) DOUBLE PRECISION array, dimension
140: /// (N) if SIDE = 'L'
141: /// or (M) if SIDE = 'R'
142: ///</param>
143: public void Run(string SIDE, int M, int N, double[] V, int offset_v, int INCV, double TAU
144: , ref double[] C, int offset_c, int LDC, ref double[] WORK, int offset_work)
145: {
146:
147: #region Array Index Correction
148:
149: int o_v = -1 + offset_v; int o_c = -1 - LDC + offset_c; int o_work = -1 + offset_work;
150:
151: #endregion
152:
153:
154: #region Strings
155:
156: SIDE = SIDE.Substring(0, 1);
157:
158: #endregion
159:
160:
161: #region Prolog
162:
163: // *
164: // * -- LAPACK auxiliary routine (version 3.1) --
165: // * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
166: // * November 2006
167: // *
168: // * .. Scalar Arguments ..
169: // * ..
170: // * .. Array Arguments ..
171: // * ..
172: // *
173: // * Purpose
174: // * =======
175: // *
176: // * DLARF applies a real elementary reflector H to a real m by n matrix
177: // * C, from either the left or the right. H is represented in the form
178: // *
179: // * H = I - tau * v * v'
180: // *
181: // * where tau is a real scalar and v is a real vector.
182: // *
183: // * If tau = 0, then H is taken to be the unit matrix.
184: // *
185: // * Arguments
186: // * =========
187: // *
188: // * SIDE (input) CHARACTER*1
189: // * = 'L': form H * C
190: // * = 'R': form C * H
191: // *
192: // * M (input) INTEGER
193: // * The number of rows of the matrix C.
194: // *
195: // * N (input) INTEGER
196: // * The number of columns of the matrix C.
197: // *
198: // * V (input) DOUBLE PRECISION array, dimension
199: // * (1 + (M-1)*abs(INCV)) if SIDE = 'L'
200: // * or (1 + (N-1)*abs(INCV)) if SIDE = 'R'
201: // * The vector v in the representation of H. V is not used if
202: // * TAU = 0.
203: // *
204: // * INCV (input) INTEGER
205: // * The increment between elements of v. INCV <> 0.
206: // *
207: // * TAU (input) DOUBLE PRECISION
208: // * The value tau in the representation of H.
209: // *
210: // * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
211: // * On entry, the m by n matrix C.
212: // * On exit, C is overwritten by the matrix H * C if SIDE = 'L',
213: // * or C * H if SIDE = 'R'.
214: // *
215: // * LDC (input) INTEGER
216: // * The leading dimension of the array C. LDC >= max(1,M).
217: // *
218: // * WORK (workspace) DOUBLE PRECISION array, dimension
219: // * (N) if SIDE = 'L'
220: // * or (M) if SIDE = 'R'
221: // *
222: // * =====================================================================
223: // *
224: // * .. Parameters ..
225: // * ..
226: // * .. External Subroutines ..
227: // * ..
228: // * .. External Functions ..
229: // * ..
230: // * .. Executable Statements ..
231: // *
232:
233: #endregion
234:
235:
236: #region Body
237:
238: if (this._lsame.Run(SIDE, "L"))
239: {
240: // *
241: // * Form H * C
242: // *
243: if (TAU != ZERO)
244: {
245: // *
246: // * w := C' * v
247: // *
248: this._dgemv.Run("Transpose", M, N, ONE, C, offset_c, LDC
249: , V, offset_v, INCV, ZERO, ref WORK, offset_work, 1);
250: // *
251: // * C := C - v * w'
252: // *
253: this._dger.Run(M, N, - TAU, V, offset_v, INCV, WORK, offset_work
254: , 1, ref C, offset_c, LDC);
255: }
256: }
257: else
258: {
259: // *
260: // * Form C * H
261: // *
262: if (TAU != ZERO)
263: {
264: // *
265: // * w := C * v
266: // *
267: this._dgemv.Run("No transpose", M, N, ONE, C, offset_c, LDC
268: , V, offset_v, INCV, ZERO, ref WORK, offset_work, 1);
269: // *
270: // * C := C - w * v'
271: // *
272: this._dger.Run(M, N, - TAU, WORK, offset_work, 1, V, offset_v
273: , INCV, ref C, offset_c, LDC);
274: }
275: }
276: return;
277: // *
278: // * End of DLARF
279: // *
280:
281: #endregion
282:
283: }
284: }
285: }