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: /// DGETRS solves a system of linear equations
27: /// A * X = B or A' * X = B
28: /// with a general N-by-N matrix A using the LU factorization computed
29: /// by DGETRF.
30: ///
31: ///</summary>
32: public class DGETRS
33: {
34:
35:
36: #region Dependencies
37:
38: LSAME _lsame; DLASWP _dlaswp; DTRSM _dtrsm; XERBLA _xerbla;
39:
40: #endregion
41:
42:
43: #region Fields
44:
45: const double ONE = 1.0E+0; bool NOTRAN = false;
46:
47: #endregion
48:
49: public DGETRS(LSAME lsame, DLASWP dlaswp, DTRSM dtrsm, XERBLA xerbla)
50: {
51:
52:
53: #region Set Dependencies
54:
55: this._lsame = lsame; this._dlaswp = dlaswp; this._dtrsm = dtrsm; this._xerbla = xerbla;
56:
57: #endregion
58:
59: }
60:
61: public DGETRS()
62: {
63:
64:
65: #region Dependencies (Initialization)
66:
67: LSAME lsame = new LSAME();
68: DLASWP dlaswp = new DLASWP();
69: XERBLA xerbla = new XERBLA();
70: DTRSM dtrsm = new DTRSM(lsame, xerbla);
71:
72: #endregion
73:
74:
75: #region Set Dependencies
76:
77: this._lsame = lsame; this._dlaswp = dlaswp; this._dtrsm = dtrsm; this._xerbla = xerbla;
78:
79: #endregion
80:
81: }
82: /// <summary>
83: /// Purpose
84: /// =======
85: ///
86: /// DGETRS solves a system of linear equations
87: /// A * X = B or A' * X = B
88: /// with a general N-by-N matrix A using the LU factorization computed
89: /// by DGETRF.
90: ///
91: ///</summary>
92: /// <param name="TRANS">
93: /// (input) CHARACTER*1
94: /// Specifies the form of the system of equations:
95: /// = 'N': A * X = B (No transpose)
96: /// = 'T': A'* X = B (Transpose)
97: /// = 'C': A'* X = B (Conjugate transpose = Transpose)
98: ///</param>
99: /// <param name="N">
100: /// (input) INTEGER
101: /// The order of the matrix A. N .GE. 0.
102: ///</param>
103: /// <param name="NRHS">
104: /// (input) INTEGER
105: /// The number of right hand sides, i.e., the number of columns
106: /// of the matrix B. NRHS .GE. 0.
107: ///</param>
108: /// <param name="A">
109: /// (input) DOUBLE PRECISION array, dimension (LDA,N)
110: /// The factors L and U from the factorization A = P*L*U
111: /// as computed by DGETRF.
112: ///</param>
113: /// <param name="LDA">
114: /// (input) INTEGER
115: /// The leading dimension of the array A. LDA .GE. max(1,N).
116: ///</param>
117: /// <param name="IPIV">
118: /// (input) INTEGER array, dimension (N)
119: /// The pivot indices from DGETRF; for 1.LE.i.LE.N, row i of the
120: /// matrix was interchanged with row IPIV(i).
121: ///</param>
122: /// <param name="B">
123: /// (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
124: /// On entry, the right hand side matrix B.
125: /// On exit, the solution matrix X.
126: ///</param>
127: /// <param name="LDB">
128: /// (input) INTEGER
129: /// The leading dimension of the array B. LDB .GE. max(1,N).
130: ///</param>
131: /// <param name="INFO">
132: /// (output) INTEGER
133: /// = 0: successful exit
134: /// .LT. 0: if INFO = -i, the i-th argument had an illegal value
135: ///</param>
136: public void Run(string TRANS, int N, int NRHS, double[] A, int offset_a, int LDA, int[] IPIV, int offset_ipiv
137: , ref double[] B, int offset_b, int LDB, ref int INFO)
138: {
139:
140: #region Array Index Correction
141:
142: int o_a = -1 - LDA + offset_a; int o_ipiv = -1 + offset_ipiv; int o_b = -1 - LDB + offset_b;
143:
144: #endregion
145:
146:
147: #region Strings
148:
149: TRANS = TRANS.Substring(0, 1);
150:
151: #endregion
152:
153:
154: #region Prolog
155:
156: // *
157: // * -- LAPACK routine (version 3.1) --
158: // * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
159: // * November 2006
160: // *
161: // * .. Scalar Arguments ..
162: // * ..
163: // * .. Array Arguments ..
164: // * ..
165: // *
166: // * Purpose
167: // * =======
168: // *
169: // * DGETRS solves a system of linear equations
170: // * A * X = B or A' * X = B
171: // * with a general N-by-N matrix A using the LU factorization computed
172: // * by DGETRF.
173: // *
174: // * Arguments
175: // * =========
176: // *
177: // * TRANS (input) CHARACTER*1
178: // * Specifies the form of the system of equations:
179: // * = 'N': A * X = B (No transpose)
180: // * = 'T': A'* X = B (Transpose)
181: // * = 'C': A'* X = B (Conjugate transpose = Transpose)
182: // *
183: // * N (input) INTEGER
184: // * The order of the matrix A. N >= 0.
185: // *
186: // * NRHS (input) INTEGER
187: // * The number of right hand sides, i.e., the number of columns
188: // * of the matrix B. NRHS >= 0.
189: // *
190: // * A (input) DOUBLE PRECISION array, dimension (LDA,N)
191: // * The factors L and U from the factorization A = P*L*U
192: // * as computed by DGETRF.
193: // *
194: // * LDA (input) INTEGER
195: // * The leading dimension of the array A. LDA >= max(1,N).
196: // *
197: // * IPIV (input) INTEGER array, dimension (N)
198: // * The pivot indices from DGETRF; for 1<=i<=N, row i of the
199: // * matrix was interchanged with row IPIV(i).
200: // *
201: // * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
202: // * On entry, the right hand side matrix B.
203: // * On exit, the solution matrix X.
204: // *
205: // * LDB (input) INTEGER
206: // * The leading dimension of the array B. LDB >= max(1,N).
207: // *
208: // * INFO (output) INTEGER
209: // * = 0: successful exit
210: // * < 0: if INFO = -i, the i-th argument had an illegal value
211: // *
212: // * =====================================================================
213: // *
214: // * .. Parameters ..
215: // * ..
216: // * .. Local Scalars ..
217: // * ..
218: // * .. External Functions ..
219: // * ..
220: // * .. External Subroutines ..
221: // * ..
222: // * .. Intrinsic Functions ..
223: // INTRINSIC MAX;
224: // * ..
225: // * .. Executable Statements ..
226: // *
227: // * Test the input parameters.
228: // *
229:
230: #endregion
231:
232:
233: #region Body
234:
235: INFO = 0;
236: NOTRAN = this._lsame.Run(TRANS, "N");
237: if (!NOTRAN && !this._lsame.Run(TRANS, "T") && !this._lsame.Run(TRANS, "C"))
238: {
239: INFO = - 1;
240: }
241: else
242: {
243: if (N < 0)
244: {
245: INFO = - 2;
246: }
247: else
248: {
249: if (NRHS < 0)
250: {
251: INFO = - 3;
252: }
253: else
254: {
255: if (LDA < Math.Max(1, N))
256: {
257: INFO = - 5;
258: }
259: else
260: {
261: if (LDB < Math.Max(1, N))
262: {
263: INFO = - 8;
264: }
265: }
266: }
267: }
268: }
269: if (INFO != 0)
270: {
271: this._xerbla.Run("DGETRS", - INFO);
272: return;
273: }
274: // *
275: // * Quick return if possible
276: // *
277: if (N == 0 || NRHS == 0) return;
278: // *
279: if (NOTRAN)
280: {
281: // *
282: // * Solve A * X = B.
283: // *
284: // * Apply row interchanges to the right hand sides.
285: // *
286: this._dlaswp.Run(NRHS, ref B, offset_b, LDB, 1, N, IPIV, offset_ipiv
287: , 1);
288: // *
289: // * Solve L*X = B, overwriting B with X.
290: // *
291: this._dtrsm.Run("Left", "Lower", "No transpose", "Unit", N, NRHS
292: , ONE, A, offset_a, LDA, ref B, offset_b, LDB);
293: // *
294: // * Solve U*X = B, overwriting B with X.
295: // *
296: this._dtrsm.Run("Left", "Upper", "No transpose", "Non-unit", N, NRHS
297: , ONE, A, offset_a, LDA, ref B, offset_b, LDB);
298: }
299: else
300: {
301: // *
302: // * Solve A' * X = B.
303: // *
304: // * Solve U'*X = B, overwriting B with X.
305: // *
306: this._dtrsm.Run("Left", "Upper", "Transpose", "Non-unit", N, NRHS
307: , ONE, A, offset_a, LDA, ref B, offset_b, LDB);
308: // *
309: // * Solve L'*X = B, overwriting B with X.
310: // *
311: this._dtrsm.Run("Left", "Lower", "Transpose", "Unit", N, NRHS
312: , ONE, A, offset_a, LDA, ref B, offset_b, LDB);
313: // *
314: // * Apply row interchanges to the solution vectors.
315: // *
316: this._dlaswp.Run(NRHS, ref B, offset_b, LDB, 1, N, IPIV, offset_ipiv
317: , - 1);
318: }
319: // *
320: return;
321: // *
322: // * End of DGETRS
323: // *
324:
325: #endregion
326:
327: }
328: }
329: }