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