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:      /// Purpose
  21:      /// =======
  22:      /// *
  23:      /// scales a vector by a constant.
  24:      /// uses unrolled loops for increment equal to one.
  25:      /// jack dongarra, linpack, 3/11/78.
  26:      /// modified 3/93 to return if incx .le. 0.
  27:      /// modified 12/3/93, array(1) declarations changed to array(*)
  28:      ///</summary>
  29:      public class DSCAL
  30:      {
  31:      
  32:   
  33:          #region Fields
  34:          
  35:          int I = 0; int M = 0; int MP1 = 0; int NINCX = 0; 
  36:   
  37:          #endregion
  38:   
  39:          public DSCAL()
  40:          {
  41:      
  42:          }
  43:      
  44:          /// <summary>
  45:          /// Purpose
  46:          /// =======
  47:          /// *
  48:          /// scales a vector by a constant.
  49:          /// uses unrolled loops for increment equal to one.
  50:          /// jack dongarra, linpack, 3/11/78.
  51:          /// modified 3/93 to return if incx .le. 0.
  52:          /// modified 12/3/93, array(1) declarations changed to array(*)
  53:          ///</summary>
  54:          public void Run(int N, double DA, ref double[] DX, int offset_dx, int INCX)
  55:          {
  56:   
  57:              #region Array Index Correction
  58:              
  59:               int o_dx = -1 + offset_dx; 
  60:   
  61:              #endregion
  62:   
  63:   
  64:              #region Prolog
  65:              
  66:              // *     .. Scalar Arguments ..
  67:              // *     ..
  68:              // *     .. Array Arguments ..
  69:              // *     ..
  70:              // *
  71:              // *  Purpose
  72:              // *  =======
  73:              // **
  74:              // *     scales a vector by a constant.
  75:              // *     uses unrolled loops for increment equal to one.
  76:              // *     jack dongarra, linpack, 3/11/78.
  77:              // *     modified 3/93 to return if incx .le. 0.
  78:              // *     modified 12/3/93, array(1) declarations changed to array(*)
  79:              // *
  80:              // *
  81:              // *     .. Local Scalars ..
  82:              // *     ..
  83:              // *     .. Intrinsic Functions ..
  84:              //      INTRINSIC MOD;
  85:              // *     ..
  86:   
  87:              #endregion
  88:   
  89:   
  90:              #region Body
  91:              
  92:              if (N <= 0 || INCX <= 0) return;
  93:              if (INCX == 1) goto LABEL20;
  94:              // *
  95:              // *        code for increment not equal to 1
  96:              // *
  97:              NINCX = N * INCX;
  98:              for (I = 1; (INCX >= 0) ? (I <= NINCX) : (I >= NINCX); I += INCX)
  99:              {
 100:                  DX[I + o_dx] = DA * DX[I + o_dx];
 101:              }
 102:              return;
 103:              // *
 104:              // *        code for increment equal to 1
 105:              // *
 106:              // *
 107:              // *        clean-up loop
 108:              // *
 109:          LABEL20:  M = FortranLib.Mod(N,5);
 110:              if (M == 0) goto LABEL40;
 111:              for (I = 1; I <= M; I++)
 112:              {
 113:                  DX[I + o_dx] = DA * DX[I + o_dx];
 114:              }
 115:              if (N < 5) return;
 116:          LABEL40:  MP1 = M + 1;
 117:              for (I = MP1; I <= N; I += 5)
 118:              {
 119:                  DX[I + o_dx] = DA * DX[I + o_dx];
 120:                  DX[I + 1 + o_dx] = DA * DX[I + 1 + o_dx];
 121:                  DX[I + 2 + o_dx] = DA * DX[I + 2 + o_dx];
 122:                  DX[I + 3 + o_dx] = DA * DX[I + 3 + o_dx];
 123:                  DX[I + 4 + o_dx] = DA * DX[I + 4 + o_dx];
 124:              }
 125:              return;
 126:   
 127:              #endregion
 128:   
 129:          }
 130:      }
 131:  }