  `   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:      /// DLASSQ  returns the values  scl  and  smsq  such that`
`  27:      /// `
`  28:      /// ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,`
`  29:      /// `
`  30:      /// where  x( i ) = X( 1 + ( i - 1 )*INCX ). The value of  sumsq  is`
`  31:      /// assumed to be non-negative and  scl  returns the value`
`  32:      /// `
`  33:      /// scl = max( scale, abs( x( i ) ) ).`
`  34:      /// `
`  35:      /// scale and sumsq must be supplied in SCALE and SUMSQ and`
`  36:      /// scl and smsq are overwritten on SCALE and SUMSQ respectively.`
`  37:      /// `
`  38:      /// The routine makes only one pass through the vector x.`
`  39:      /// `
`  40:      ///</summary>`
`  41:      public class DLASSQ`
`  42:      {`
`  43:      `
`  44:   `
`  45:          #region Fields`
`  46:          `
`  47:          const double ZERO = 0.0E+0; int IX = 0; double ABSXI = 0; `
`  48:   `
`  49:          #endregion`
`  50:   `
`  51:          public DLASSQ()`
`  52:          {`
`  53:      `
`  54:          }`
`  55:      `
`  56:          /// <summary>`
`  57:          /// Purpose`
`  58:          /// =======`
`  59:          /// `
`  60:          /// DLASSQ  returns the values  scl  and  smsq  such that`
`  61:          /// `
`  62:          /// ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,`
`  63:          /// `
`  64:          /// where  x( i ) = X( 1 + ( i - 1 )*INCX ). The value of  sumsq  is`
`  65:          /// assumed to be non-negative and  scl  returns the value`
`  66:          /// `
`  67:          /// scl = max( scale, abs( x( i ) ) ).`
`  68:          /// `
`  69:          /// scale and sumsq must be supplied in SCALE and SUMSQ and`
`  70:          /// scl and smsq are overwritten on SCALE and SUMSQ respectively.`
`  71:          /// `
`  72:          /// The routine makes only one pass through the vector x.`
`  73:          /// `
`  74:          ///</summary>`
`  75:          /// <param name="N">`
`  76:          /// (input) INTEGER`
`  77:          /// The number of elements to be used from the vector X.`
`  78:          ///</param>`
`  79:          /// <param name="X">`
`  80:          /// (input) DOUBLE PRECISION array, dimension (N)`
`  81:          /// The vector for which a scaled sum of squares is computed.`
`  82:          /// x( i )  = X( 1 + ( i - 1 )*INCX ), 1 .LE. i .LE. n.`
`  83:          ///</param>`
`  84:          /// <param name="INCX">`
`  85:          /// (input) INTEGER`
`  86:          /// The increment between successive values of the vector X.`
`  87:          /// INCX .GT. 0.`
`  88:          ///</param>`
`  89:          /// <param name="SCALE">`
`  90:          /// and sumsq must be supplied in SCALE and SUMSQ and`
`  91:          ///</param>`
`  92:          /// <param name="SUMSQ">`
`  93:          /// (input/output) DOUBLE PRECISION`
`  94:          /// On entry, the value  sumsq  in the equation above.`
`  95:          /// On exit, SUMSQ is overwritten with  smsq , the basic sum of`
`  96:          /// squares from which  scl  has been factored out.`
`  97:          ///</param>`
`  98:          public void Run(int N, double[] X, int offset_x, int INCX, ref double SCALE, ref double SUMSQ)`
`  99:          {`
` 100:   `
` 101:              #region Array Index Correction`
` 102:              `
` 103:               int o_x = -1 + offset_x; `
` 104:   `
` 105:              #endregion`
` 106:   `
` 107:   `
` 108:              #region Prolog`
` 109:              `
` 110:              // *`
` 111:              // *  -- LAPACK auxiliary routine (version 3.1) --`
` 112:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..`
` 113:              // *     November 2006`
` 114:              // *`
` 115:              // *     .. Scalar Arguments ..`
` 116:              // *     ..`
` 117:              // *     .. Array Arguments ..`
` 118:              // *     ..`
` 119:              // *`
` 120:              // *  Purpose`
` 121:              // *  =======`
` 122:              // *`
` 123:              // *  DLASSQ  returns the values  scl  and  smsq  such that`
` 124:              // *`
` 125:              // *     ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,`
` 126:              // *`
` 127:              // *  where  x( i ) = X( 1 + ( i - 1 )*INCX ). The value of  sumsq  is`
` 128:              // *  assumed to be non-negative and  scl  returns the value`
` 129:              // *`
` 130:              // *     scl = max( scale, abs( x( i ) ) ).`
` 131:              // *`
` 132:              // *  scale and sumsq must be supplied in SCALE and SUMSQ and`
` 133:              // *  scl and smsq are overwritten on SCALE and SUMSQ respectively.`
` 134:              // *`
` 135:              // *  The routine makes only one pass through the vector x.`
` 136:              // *`
` 137:              // *  Arguments`
` 138:              // *  =========`
` 139:              // *`
` 140:              // *  N       (input) INTEGER`
` 141:              // *          The number of elements to be used from the vector X.`
` 142:              // *`
` 143:              // *  X       (input) DOUBLE PRECISION array, dimension (N)`
` 144:              // *          The vector for which a scaled sum of squares is computed.`
` 145:              // *             x( i )  = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.`
` 146:              // *`
` 147:              // *  INCX    (input) INTEGER`
` 148:              // *          The increment between successive values of the vector X.`
` 149:              // *          INCX > 0.`
` 150:              // *`
` 151:              // *  SCALE   (input/output) DOUBLE PRECISION`
` 152:              // *          On entry, the value  scale  in the equation above.`
` 153:              // *          On exit, SCALE is overwritten with  scl , the scaling factor`
` 154:              // *          for the sum of squares.`
` 155:              // *`
` 156:              // *  SUMSQ   (input/output) DOUBLE PRECISION`
` 157:              // *          On entry, the value  sumsq  in the equation above.`
` 158:              // *          On exit, SUMSQ is overwritten with  smsq , the basic sum of`
` 159:              // *          squares from which  scl  has been factored out.`
` 160:              // *`
` 161:              // * =====================================================================`
` 162:              // *`
` 163:              // *     .. Parameters ..`
` 164:              // *     ..`
` 165:              // *     .. Local Scalars ..`
` 166:              // *     ..`
` 167:              // *     .. Intrinsic Functions ..`
` 168:              //      INTRINSIC          ABS;`
` 169:              // *     ..`
` 170:              // *     .. Executable Statements ..`
` 171:              // *`
` 172:   `
` 173:              #endregion`
` 174:   `
` 175:   `
` 176:              #region Body`
` 177:              `
` 178:              if (N > 0)`
` 179:              {`
` 180:                  for (IX = 1; (INCX >= 0) ? (IX <= 1 + (N - 1) * INCX) : (IX >= 1 + (N - 1) * INCX); IX += INCX)`
` 181:                  {`
` 182:                      if (X[IX + o_x] != ZERO)`
` 183:                      {`
` 184:                          ABSXI = Math.Abs(X[IX + o_x]);`
` 185:                          if (SCALE < ABSXI)`
` 186:                          {`
` 187:                              SUMSQ = 1 + SUMSQ * Math.Pow(SCALE / ABSXI,2);`
` 188:                              SCALE = ABSXI;`
` 189:                          }`
` 190:                          else`
` 191:                          {`
` 192:                              SUMSQ = SUMSQ + Math.Pow(ABSXI / SCALE,2);`
` 193:                          }`
` 194:                      }`
` 195:                  }`
` 196:              }`
` 197:              return;`
` 198:              // *`
` 199:              // *     End of DLASSQ`
` 200:              // *`
` 201:   `
` 202:              #endregion`
` 203:   `
` 204:          }`
` 205:      }`
` 206:  }`