`   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.0) --`
`  21:      /// Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,`
`  22:      /// Courant Institute, Argonne National Lab, and Rice University`
`  23:      /// September 30, 1994`
`  24:      /// Purpose`
`  25:      /// =======`
`  26:      /// `
`  27:      /// DRSCL multiplies an n-element real vector x by the real scalar 1/a.`
`  28:      /// This is done without overflow or underflow as long as`
`  29:      /// the final result x/a does not overflow or underflow.`
`  30:      /// `
`  31:      ///</summary>`
`  32:      public class DRSCL`
`  33:      {`
`  34:      `
`  35:   `
`  36:          #region Dependencies`
`  37:          `
`  38:          DLAMCH _dlamch; DSCAL _dscal; DLABAD _dlabad; `
`  39:   `
`  40:          #endregion`
`  41:   `
`  42:   `
`  43:          #region Fields`
`  44:          `
`  45:          const double ONE = 1.0E+0; const double ZERO = 0.0E+0; bool DONE = false; double BIGNUM = 0; double CDEN = 0; `
`  46:          double CDEN1 = 0;double CNUM = 0; double CNUM1 = 0; double MUL = 0; double SMLNUM = 0; `
`  47:   `
`  48:          #endregion`
`  49:   `
`  50:          public DRSCL(DLAMCH dlamch, DSCAL dscal, DLABAD dlabad)`
`  51:          {`
`  52:      `
`  53:   `
`  54:              #region Set Dependencies`
`  55:              `
`  56:              this._dlamch = dlamch; this._dscal = dscal; this._dlabad = dlabad; `
`  57:   `
`  58:              #endregion`
`  59:   `
`  60:          }`
`  61:      `
`  62:          public DRSCL()`
`  63:          {`
`  64:      `
`  65:   `
`  66:              #region Dependencies (Initialization)`
`  67:              `
`  68:              LSAME lsame = new LSAME();`
`  69:              DLAMC3 dlamc3 = new DLAMC3();`
`  70:              DSCAL dscal = new DSCAL();`
`  71:              DLABAD dlabad = new DLABAD();`
`  72:              DLAMC1 dlamc1 = new DLAMC1(dlamc3);`
`  73:              DLAMC4 dlamc4 = new DLAMC4(dlamc3);`
`  74:              DLAMC5 dlamc5 = new DLAMC5(dlamc3);`
`  75:              DLAMC2 dlamc2 = new DLAMC2(dlamc3, dlamc1, dlamc4, dlamc5);`
`  76:              DLAMCH dlamch = new DLAMCH(lsame, dlamc2);`
`  77:   `
`  78:              #endregion`
`  79:   `
`  80:   `
`  81:              #region Set Dependencies`
`  82:              `
`  83:              this._dlamch = dlamch; this._dscal = dscal; this._dlabad = dlabad; `
`  84:   `
`  85:              #endregion`
`  86:   `
`  87:          }`
`  88:          /// <summary>`
`  89:          /// Purpose`
`  90:          /// =======`
`  91:          /// `
`  92:          /// DRSCL multiplies an n-element real vector x by the real scalar 1/a.`
`  93:          /// This is done without overflow or underflow as long as`
`  94:          /// the final result x/a does not overflow or underflow.`
`  95:          /// `
`  96:          ///</summary>`
`  97:          /// <param name="N">`
`  98:          /// (input) INTEGER`
`  99:          /// The number of components of the vector x.`
` 100:          ///</param>`
` 101:          /// <param name="SA">`
` 102:          /// (input) DOUBLE PRECISION`
` 103:          /// The scalar a which is used to divide each component of x.`
` 104:          /// SA must be .GE. 0, or the subroutine will divide by zero.`
` 105:          ///</param>`
` 106:          /// <param name="SX">`
` 107:          /// (input/output) DOUBLE PRECISION array, dimension`
` 108:          /// (1+(N-1)*abs(INCX))`
` 109:          /// The n-element vector x.`
` 110:          ///</param>`
` 111:          /// <param name="INCX">`
` 112:          /// (input) INTEGER`
` 113:          /// The increment between successive values of the vector SX.`
` 114:          /// .GT. 0:  SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i),     1.LT. i.LE. n`
` 115:          ///</param>`
` 116:          public void Run(int N, double SA, ref double[] SX, int offset_sx, int INCX)`
` 117:          {`
` 118:   `
` 119:              #region Array Index Correction`
` 120:              `
` 121:               int o_sx = -1 + offset_sx; `
` 122:   `
` 123:              #endregion`
` 124:   `
` 125:   `
` 126:              #region Prolog`
` 127:              `
` 128:              // *`
` 129:              // *  -- LAPACK auxiliary routine (version 3.0) --`
` 130:              // *     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,`
` 131:              // *     Courant Institute, Argonne National Lab, and Rice University`
` 132:              // *     September 30, 1994`
` 133:              // *`
` 134:              // *     .. Scalar Arguments ..`
` 135:              // *     ..`
` 136:              // *     .. Array Arguments ..`
` 137:              // *     ..`
` 138:              // *`
` 139:              // *  Purpose`
` 140:              // *  =======`
` 141:              // *`
` 142:              // *  DRSCL multiplies an n-element real vector x by the real scalar 1/a.`
` 143:              // *  This is done without overflow or underflow as long as`
` 144:              // *  the final result x/a does not overflow or underflow.`
` 145:              // *`
` 146:              // *  Arguments`
` 147:              // *  =========`
` 148:              // *`
` 149:              // *  N       (input) INTEGER`
` 150:              // *          The number of components of the vector x.`
` 151:              // *`
` 152:              // *  SA      (input) DOUBLE PRECISION`
` 153:              // *          The scalar a which is used to divide each component of x.`
` 154:              // *          SA must be >= 0, or the subroutine will divide by zero.`
` 155:              // *`
` 156:              // *  SX      (input/output) DOUBLE PRECISION array, dimension`
` 157:              // *                         (1+(N-1)*abs(INCX))`
` 158:              // *          The n-element vector x.`
` 159:              // *`
` 160:              // *  INCX    (input) INTEGER`
` 161:              // *          The increment between successive values of the vector SX.`
` 162:              // *          > 0:  SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i),     1< i<= n`
` 163:              // *`
` 164:              // * =====================================================================`
` 165:              // *`
` 166:              // *     .. Parameters ..`
` 167:              // *     ..`
` 168:              // *     .. Local Scalars ..`
` 169:              // *     ..`
` 170:              // *     .. External Functions ..`
` 171:              // *     ..`
` 172:              // *     .. External Subroutines ..`
` 173:              // *     ..`
` 174:              // *     .. Intrinsic Functions ..`
` 175:              //      INTRINSIC          ABS;`
` 176:              // *     ..`
` 177:              // *     .. Executable Statements ..`
` 178:              // *`
` 179:              // *     Quick return if possible`
` 180:              // *`
` 181:   `
` 182:              #endregion`
` 183:   `
` 184:   `
` 185:              #region Body`
` 186:              `
` 187:              if (N <= 0) return;`
` 188:              // *`
` 189:              // *     Get machine parameters`
` 190:              // *`
` 191:              SMLNUM = this._dlamch.Run("S");`
` 192:              BIGNUM = ONE / SMLNUM;`
` 193:              this._dlabad.Run(ref SMLNUM, ref BIGNUM);`
` 194:              // *`
` 195:              // *     Initialize the denominator to SA and the numerator to 1.`
` 196:              // *`
` 197:              CDEN = SA;`
` 198:              CNUM = ONE;`
` 199:              // *`
` 200:          LABEL10:;`
` 201:              CDEN1 = CDEN * SMLNUM;`
` 202:              CNUM1 = CNUM / BIGNUM;`
` 203:              if (Math.Abs(CDEN1) > Math.Abs(CNUM) && CNUM != ZERO)`
` 204:              {`
` 205:                  // *`
` 206:                  // *        Pre-multiply X by SMLNUM if CDEN is large compared to CNUM.`
` 207:                  // *`
` 208:                  MUL = SMLNUM;`
` 209:                  DONE = false;`
` 210:                  CDEN = CDEN1;`
` 211:              }`
` 212:              else`
` 213:              {`
` 214:                  if (Math.Abs(CNUM1) > Math.Abs(CDEN))`
` 215:                  {`
` 216:                      // *`
` 217:                      // *        Pre-multiply X by BIGNUM if CDEN is small compared to CNUM.`
` 218:                      // *`
` 219:                      MUL = BIGNUM;`
` 220:                      DONE = false;`
` 221:                      CNUM = CNUM1;`
` 222:                  }`
` 223:                  else`
` 224:                  {`
` 225:                      // *`
` 226:                      // *        Multiply X by CNUM / CDEN and return.`
` 227:                      // *`
` 228:                      MUL = CNUM / CDEN;`
` 229:                      DONE = true;`
` 230:                  }`
` 231:              }`
` 232:              // *`
` 233:              // *     Scale the vector X by MUL`
` 234:              // *`
` 235:              this._dscal.Run(N, MUL, ref SX, offset_sx, INCX);`
` 236:              // *`
` 237:              if (!DONE) goto LABEL10;`
` 238:              // *`
` 239:              return;`
` 240:              // *`
` 241:              // *     End of DRSCL`
` 242:              // *`
` 243:   `
` 244:              #endregion`
` 245:   `
` 246:          }`
` 247:      }`
` 248:  }`