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: /// DTRTI2 computes the inverse of a real upper or lower triangular
27: /// matrix.
28: ///
29: /// This is the Level 2 BLAS version of the algorithm.
30: ///
31: ///</summary>
32: public class DTRTI2
33: {
34:
35:
36: #region Dependencies
37:
38: LSAME _lsame; DSCAL _dscal; DTRMV _dtrmv; XERBLA _xerbla;
39:
40: #endregion
41:
42:
43: #region Fields
44:
45: const double ONE = 1.0E+0; bool NOUNIT = false; bool UPPER = false; int J = 0; double AJJ = 0;
46:
47: #endregion
48:
49: public DTRTI2(LSAME lsame, DSCAL dscal, DTRMV dtrmv, XERBLA xerbla)
50: {
51:
52:
53: #region Set Dependencies
54:
55: this._lsame = lsame; this._dscal = dscal; this._dtrmv = dtrmv; this._xerbla = xerbla;
56:
57: #endregion
58:
59: }
60:
61: public DTRTI2()
62: {
63:
64:
65: #region Dependencies (Initialization)
66:
67: LSAME lsame = new LSAME();
68: DSCAL dscal = new DSCAL();
69: XERBLA xerbla = new XERBLA();
70: DTRMV dtrmv = new DTRMV(lsame, xerbla);
71:
72: #endregion
73:
74:
75: #region Set Dependencies
76:
77: this._lsame = lsame; this._dscal = dscal; this._dtrmv = dtrmv; this._xerbla = xerbla;
78:
79: #endregion
80:
81: }
82: /// <summary>
83: /// Purpose
84: /// =======
85: ///
86: /// DTRTI2 computes the inverse of a real upper or lower triangular
87: /// matrix.
88: ///
89: /// This is the Level 2 BLAS version of the algorithm.
90: ///
91: ///</summary>
92: /// <param name="UPLO">
93: /// (input) CHARACTER*1
94: /// Specifies whether the matrix A is upper or lower triangular.
95: /// = 'U': Upper triangular
96: /// = 'L': Lower triangular
97: ///</param>
98: /// <param name="DIAG">
99: /// (input) CHARACTER*1
100: /// Specifies whether or not the matrix A is unit triangular.
101: /// = 'N': Non-unit triangular
102: /// = 'U': Unit triangular
103: ///</param>
104: /// <param name="N">
105: /// (input) INTEGER
106: /// The order of the matrix A. N .GE. 0.
107: ///</param>
108: /// <param name="A">
109: /// (input/output) DOUBLE PRECISION array, dimension (LDA,N)
110: /// On entry, the triangular matrix A. If UPLO = 'U', the
111: /// leading n by n upper triangular part of the array A contains
112: /// the upper triangular matrix, and the strictly lower
113: /// triangular part of A is not referenced. If UPLO = 'L', the
114: /// leading n by n lower triangular part of the array A contains
115: /// the lower triangular matrix, and the strictly upper
116: /// triangular part of A is not referenced. If DIAG = 'U', the
117: /// diagonal elements of A are also not referenced and are
118: /// assumed to be 1.
119: ///
120: /// On exit, the (triangular) inverse of the original matrix, in
121: /// the same storage format.
122: ///</param>
123: /// <param name="LDA">
124: /// (input) INTEGER
125: /// The leading dimension of the array A. LDA .GE. max(1,N).
126: ///</param>
127: /// <param name="INFO">
128: /// (output) INTEGER
129: /// = 0: successful exit
130: /// .LT. 0: if INFO = -k, the k-th argument had an illegal value
131: ///</param>
132: public void Run(string UPLO, string DIAG, int N, ref double[] A, int offset_a, int LDA, ref int INFO)
133: {
134:
135: #region Array Index Correction
136:
137: int o_a = -1 - LDA + offset_a;
138:
139: #endregion
140:
141:
142: #region Strings
143:
144: UPLO = UPLO.Substring(0, 1); DIAG = DIAG.Substring(0, 1);
145:
146: #endregion
147:
148:
149: #region Prolog
150:
151: // *
152: // * -- LAPACK routine (version 3.1) --
153: // * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
154: // * November 2006
155: // *
156: // * .. Scalar Arguments ..
157: // * ..
158: // * .. Array Arguments ..
159: // * ..
160: // *
161: // * Purpose
162: // * =======
163: // *
164: // * DTRTI2 computes the inverse of a real upper or lower triangular
165: // * matrix.
166: // *
167: // * This is the Level 2 BLAS version of the algorithm.
168: // *
169: // * Arguments
170: // * =========
171: // *
172: // * UPLO (input) CHARACTER*1
173: // * Specifies whether the matrix A is upper or lower triangular.
174: // * = 'U': Upper triangular
175: // * = 'L': Lower triangular
176: // *
177: // * DIAG (input) CHARACTER*1
178: // * Specifies whether or not the matrix A is unit triangular.
179: // * = 'N': Non-unit triangular
180: // * = 'U': Unit triangular
181: // *
182: // * N (input) INTEGER
183: // * The order of the matrix A. N >= 0.
184: // *
185: // * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
186: // * On entry, the triangular matrix A. If UPLO = 'U', the
187: // * leading n by n upper triangular part of the array A contains
188: // * the upper triangular matrix, and the strictly lower
189: // * triangular part of A is not referenced. If UPLO = 'L', the
190: // * leading n by n lower triangular part of the array A contains
191: // * the lower triangular matrix, and the strictly upper
192: // * triangular part of A is not referenced. If DIAG = 'U', the
193: // * diagonal elements of A are also not referenced and are
194: // * assumed to be 1.
195: // *
196: // * On exit, the (triangular) inverse of the original matrix, in
197: // * the same storage format.
198: // *
199: // * LDA (input) INTEGER
200: // * The leading dimension of the array A. LDA >= max(1,N).
201: // *
202: // * INFO (output) INTEGER
203: // * = 0: successful exit
204: // * < 0: if INFO = -k, the k-th argument had an illegal value
205: // *
206: // * =====================================================================
207: // *
208: // * .. Parameters ..
209: // * ..
210: // * .. Local Scalars ..
211: // * ..
212: // * .. External Functions ..
213: // * ..
214: // * .. External Subroutines ..
215: // * ..
216: // * .. Intrinsic Functions ..
217: // INTRINSIC MAX;
218: // * ..
219: // * .. Executable Statements ..
220: // *
221: // * Test the input parameters.
222: // *
223:
224: #endregion
225:
226:
227: #region Body
228:
229: INFO = 0;
230: UPPER = this._lsame.Run(UPLO, "U");
231: NOUNIT = this._lsame.Run(DIAG, "N");
232: if (!UPPER && !this._lsame.Run(UPLO, "L"))
233: {
234: INFO = - 1;
235: }
236: else
237: {
238: if (!NOUNIT && !this._lsame.Run(DIAG, "U"))
239: {
240: INFO = - 2;
241: }
242: else
243: {
244: if (N < 0)
245: {
246: INFO = - 3;
247: }
248: else
249: {
250: if (LDA < Math.Max(1, N))
251: {
252: INFO = - 5;
253: }
254: }
255: }
256: }
257: if (INFO != 0)
258: {
259: this._xerbla.Run("DTRTI2", - INFO);
260: return;
261: }
262: // *
263: if (UPPER)
264: {
265: // *
266: // * Compute inverse of upper triangular matrix.
267: // *
268: for (J = 1; J <= N; J++)
269: {
270: if (NOUNIT)
271: {
272: A[J+J * LDA + o_a] = ONE / A[J+J * LDA + o_a];
273: AJJ = - A[J+J * LDA + o_a];
274: }
275: else
276: {
277: AJJ = - ONE;
278: }
279: // *
280: // * Compute elements 1:j-1 of j-th column.
281: // *
282: this._dtrmv.Run("Upper", "No transpose", DIAG, J - 1, A, offset_a, LDA
283: , ref A, 1+J * LDA + o_a, 1);
284: this._dscal.Run(J - 1, AJJ, ref A, 1+J * LDA + o_a, 1);
285: }
286: }
287: else
288: {
289: // *
290: // * Compute inverse of lower triangular matrix.
291: // *
292: for (J = N; J >= 1; J += - 1)
293: {
294: if (NOUNIT)
295: {
296: A[J+J * LDA + o_a] = ONE / A[J+J * LDA + o_a];
297: AJJ = - A[J+J * LDA + o_a];
298: }
299: else
300: {
301: AJJ = - ONE;
302: }
303: if (J < N)
304: {
305: // *
306: // * Compute elements j+1:n of j-th column.
307: // *
308: this._dtrmv.Run("Lower", "No transpose", DIAG, N - J, A, J + 1+(J + 1) * LDA + o_a, LDA
309: , ref A, J + 1+J * LDA + o_a, 1);
310: this._dscal.Run(N - J, AJJ, ref A, J + 1+J * LDA + o_a, 1);
311: }
312: }
313: }
314: // *
315: return;
316: // *
317: // * End of DTRTI2
318: // *
319:
320: #endregion
321:
322: }
323: }
324: }