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: /// IEEECK is called from the ILAENV to verify that Infinity and
27: /// possibly NaN arithmetic is safe (i.e. will not trap).
28: ///
29: ///</summary>
30: public class IEEECK
31: {
32:
33:
34: #region Fields
35:
36: double NAN1 = 0; double NAN2 = 0; double NAN3 = 0; double NAN4 = 0; double NAN5 = 0; double NAN6 = 0; double NEGINF = 0;
37: double NEGZRO = 0;double NEWZRO = 0; double POSINF = 0;
38:
39: #endregion
40:
41: public IEEECK()
42: {
43:
44: }
45:
46: /// <summary>
47: /// Purpose
48: /// =======
49: ///
50: /// IEEECK is called from the ILAENV to verify that Infinity and
51: /// possibly NaN arithmetic is safe (i.e. will not trap).
52: ///
53: ///</summary>
54: /// <param name="ISPEC">
55: /// (input) INTEGER
56: /// Specifies whether to test just for inifinity arithmetic
57: /// or whether to test for infinity and NaN arithmetic.
58: /// = 0: Verify infinity arithmetic only.
59: /// = 1: Verify infinity and NaN arithmetic.
60: ///</param>
61: /// <param name="ZERO">
62: /// (input) REAL
63: /// Must contain the value 0.0
64: /// This is passed to prevent the compiler from optimizing
65: /// away this code.
66: ///</param>
67: /// <param name="ONE">
68: /// (input) REAL
69: /// Must contain the value 1.0
70: /// This is passed to prevent the compiler from optimizing
71: /// away this code.
72: ///</param>
73: public int Run(int ISPEC, double ZERO, double ONE)
74: {
75: int ieeeck = 0;
76:
77: #region Prolog
78:
79: // *
80: // * -- LAPACK auxiliary routine (version 3.1) --
81: // * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
82: // * November 2006
83: // *
84: // * .. Scalar Arguments ..
85: // * ..
86: // *
87: // * Purpose
88: // * =======
89: // *
90: // * IEEECK is called from the ILAENV to verify that Infinity and
91: // * possibly NaN arithmetic is safe (i.e. will not trap).
92: // *
93: // * Arguments
94: // * =========
95: // *
96: // * ISPEC (input) INTEGER
97: // * Specifies whether to test just for inifinity arithmetic
98: // * or whether to test for infinity and NaN arithmetic.
99: // * = 0: Verify infinity arithmetic only.
100: // * = 1: Verify infinity and NaN arithmetic.
101: // *
102: // * ZERO (input) REAL
103: // * Must contain the value 0.0
104: // * This is passed to prevent the compiler from optimizing
105: // * away this code.
106: // *
107: // * ONE (input) REAL
108: // * Must contain the value 1.0
109: // * This is passed to prevent the compiler from optimizing
110: // * away this code.
111: // *
112: // * RETURN VALUE: INTEGER
113: // * = 0: Arithmetic failed to produce the correct answers
114: // * = 1: Arithmetic produced the correct answers
115: // *
116: // * .. Local Scalars ..
117: // * ..
118: // * .. Executable Statements ..
119:
120: #endregion
121:
122:
123: #region Body
124:
125: ieeeck = 1;
126: // *
127: POSINF = ONE / ZERO;
128: if (POSINF <= ONE)
129: {
130: ieeeck = 0;
131: return ieeeck;
132: }
133: // *
134: NEGINF = - ONE / ZERO;
135: if (NEGINF >= ZERO)
136: {
137: ieeeck = 0;
138: return ieeeck;
139: }
140: // *
141: NEGZRO = ONE / (NEGINF + ONE);
142: if (NEGZRO != ZERO)
143: {
144: ieeeck = 0;
145: return ieeeck;
146: }
147: // *
148: NEGINF = ONE / NEGZRO;
149: if (NEGINF >= ZERO)
150: {
151: ieeeck = 0;
152: return ieeeck;
153: }
154: // *
155: NEWZRO = NEGZRO + ZERO;
156: if (NEWZRO != ZERO)
157: {
158: ieeeck = 0;
159: return ieeeck;
160: }
161: // *
162: POSINF = ONE / NEWZRO;
163: if (POSINF <= ONE)
164: {
165: ieeeck = 0;
166: return ieeeck;
167: }
168: // *
169: NEGINF = NEGINF * POSINF;
170: if (NEGINF >= ZERO)
171: {
172: ieeeck = 0;
173: return ieeeck;
174: }
175: // *
176: POSINF = POSINF * POSINF;
177: if (POSINF <= ONE)
178: {
179: ieeeck = 0;
180: return ieeeck;
181: }
182: // *
183: // *
184: // *
185: // *
186: // * Return if we were only asked to check infinity arithmetic
187: // *
188: if (ISPEC == 0) return ieeeck;
189: // *
190: NAN1 = POSINF + NEGINF;
191: // *
192: NAN2 = POSINF / NEGINF;
193: // *
194: NAN3 = POSINF / POSINF;
195: // *
196: NAN4 = POSINF * ZERO;
197: // *
198: NAN5 = NEGINF * NEGZRO;
199: // *
200: NAN6 = NAN5 * 0.0;
201: // *
202: if (NAN1 == NAN1)
203: {
204: ieeeck = 0;
205: return ieeeck;
206: }
207: // *
208: if (NAN2 == NAN2)
209: {
210: ieeeck = 0;
211: return ieeeck;
212: }
213: // *
214: if (NAN3 == NAN3)
215: {
216: ieeeck = 0;
217: return ieeeck;
218: }
219: // *
220: if (NAN4 == NAN4)
221: {
222: ieeeck = 0;
223: return ieeeck;
224: }
225: // *
226: if (NAN5 == NAN5)
227: {
228: ieeeck = 0;
229: return ieeeck;
230: }
231: // *
232: if (NAN6 == NAN6)
233: {
234: ieeeck = 0;
235: return ieeeck;
236: }
237: // *
238: return ieeeck;
239:
240: #endregion
241:
242: }
243: }
244: }