Skip Navigation Links
Numerical Libraries
Linear Algebra
Differential Equations
Optimization
Samples
Skip Navigation Links
Linear Algebra
CSLapack
CSBlas
   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:      /// LSAME returns .TRUE. if CA is the same letter as CB regardless of
  27:      /// case.
  28:      /// 
  29:      ///</summary>
  30:      public class LSAME
  31:      {
  32:      
  33:   
  34:          #region Fields
  35:          
  36:          int INTA = 0; int INTB = 0; int ZCODE = 0; 
  37:   
  38:          #endregion
  39:   
  40:          public LSAME()
  41:          {
  42:      
  43:          }
  44:      
  45:          /// <summary>
  46:          /// Purpose
  47:          /// =======
  48:          /// 
  49:          /// LSAME returns .TRUE. if CA is the same letter as CB regardless of
  50:          /// case.
  51:          /// 
  52:          ///</summary>
  53:          /// <param name="CA">
  54:          /// (input) CHARACTER*1
  55:          ///</param>
  56:          /// <param name="CB">
  57:          /// (input) CHARACTER*1
  58:          /// CA and CB specify the single characters to be compared.
  59:          ///</param>
  60:          public bool Run(string CA, string CB)
  61:          {
  62:          bool lsame = false;
  63:   
  64:              #region Strings
  65:              
  66:              CA = CA.Substring(0, 1);  CB = CB.Substring(0, 1);  
  67:   
  68:              #endregion
  69:   
  70:   
  71:              #region Prolog
  72:              
  73:              // *
  74:              // *  -- LAPACK auxiliary routine (version 3.1) --
  75:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  76:              // *     November 2006
  77:              // *
  78:              // *     .. Scalar Arguments ..
  79:              // *     ..
  80:              // *
  81:              // *  Purpose
  82:              // *  =======
  83:              // *
  84:              // *  LSAME returns .TRUE. if CA is the same letter as CB regardless of
  85:              // *  case.
  86:              // *
  87:              // *  Arguments
  88:              // *  =========
  89:              // *
  90:              // *  CA      (input) CHARACTER*1
  91:              // *  CB      (input) CHARACTER*1
  92:              // *          CA and CB specify the single characters to be compared.
  93:              // *
  94:              // * =====================================================================
  95:              // *
  96:              // *     .. Intrinsic Functions ..
  97:              //      INTRINSIC          ICHAR;
  98:              // *     ..
  99:              // *     .. Local Scalars ..
 100:              // *     ..
 101:              // *     .. Executable Statements ..
 102:              // *
 103:              // *     Test if the characters are equal
 104:              // *
 105:   
 106:              #endregion
 107:   
 108:   
 109:              #region Body
 110:              
 111:              lsame = CA == CB;
 112:              if (lsame) return lsame;
 113:              // *
 114:              // *     Now test for equivalence if both characters are alphabetic.
 115:              // *
 116:              ZCODE = Convert.ToInt32('Z');
 117:              // *
 118:              // *     Use 'Z' rather than 'A' so that ASCII can be detected on Prime
 119:              // *     machines, on which ICHAR returns a value with bit 8 set.
 120:              // *     ICHAR('A') on Prime machines returns 193 which is the same as
 121:              // *     ICHAR('A') on an EBCDIC machine.
 122:              // *
 123:              INTA = Convert.ToInt32(Convert.ToChar(CA));
 124:              INTB = Convert.ToInt32(Convert.ToChar(CB));
 125:              // *
 126:              if (ZCODE == 90 || ZCODE == 122)
 127:              {
 128:                  // *
 129:                  // *        ASCII is assumed - ZCODE is the ASCII code of either lower or
 130:                  // *        upper case 'Z'.
 131:                  // *
 132:                  if (INTA >= 97 && INTA <= 122) INTA = INTA - 32;
 133:                  if (INTB >= 97 && INTB <= 122) INTB = INTB - 32;
 134:                  // *
 135:              }
 136:              else
 137:              {
 138:                  if (ZCODE == 233 || ZCODE == 169)
 139:                  {
 140:                      // *
 141:                      // *        EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or
 142:                      // *        upper case 'Z'.
 143:                      // *
 144:                      if (INTA >= 129 && INTA <= 137 || INTA >= 145 && INTA <= 153 || INTA >= 162 && INTA <= 169) INTA = INTA + 64;
 145:                      if (INTB >= 129 && INTB <= 137 || INTB >= 145 && INTB <= 153 || INTB >= 162 && INTB <= 169) INTB = INTB + 64;
 146:                      // *
 147:                  }
 148:                  else
 149:                  {
 150:                      if (ZCODE == 218 || ZCODE == 250)
 151:                      {
 152:                          // *
 153:                          // *        ASCII is assumed, on Prime machines - ZCODE is the ASCII code
 154:                          // *        plus 128 of either lower or upper case 'Z'.
 155:                          // *
 156:                          if (INTA >= 225 && INTA <= 250) INTA = INTA - 32;
 157:                          if (INTB >= 225 && INTB <= 250) INTB = INTB - 32;
 158:                      }
 159:                  }
 160:              }
 161:              lsame = INTA == INTB;
 162:              // *
 163:              // *     RETURN
 164:              // *
 165:              // *     End of LSAME
 166:              // *
 167:          return lsame;
 168:   
 169:              #endregion
 170:   
 171:          }
 172:      }
 173:  }