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