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:      /// DLASWP performs a series of row interchanges on the matrix A.
  27:      /// One row interchange is initiated for each of rows K1 through K2 of A.
  28:      /// 
  29:      ///</summary>
  30:      public class DLASWP
  31:      {
  32:      
  33:   
  34:          #region Fields
  35:          
  36:          int I = 0; int I1 = 0; int I2 = 0; int INC = 0; int IP = 0; int IX = 0; int IX0 = 0; int J = 0; int K = 0; int N32 = 0; 
  37:          double TEMP = 0;
  38:   
  39:          #endregion
  40:   
  41:          public DLASWP()
  42:          {
  43:      
  44:          }
  45:      
  46:          /// <summary>
  47:          /// Purpose
  48:          /// =======
  49:          /// 
  50:          /// DLASWP performs a series of row interchanges on the matrix A.
  51:          /// One row interchange is initiated for each of rows K1 through K2 of A.
  52:          /// 
  53:          ///</summary>
  54:          /// <param name="N">
  55:          /// (input) INTEGER
  56:          /// The number of columns of the matrix A.
  57:          ///</param>
  58:          /// <param name="A">
  59:          /// (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  60:          /// On entry, the matrix of column dimension N to which the row
  61:          /// interchanges will be applied.
  62:          /// On exit, the permuted matrix.
  63:          ///</param>
  64:          /// <param name="LDA">
  65:          /// (input) INTEGER
  66:          /// The leading dimension of the array A.
  67:          ///</param>
  68:          /// <param name="K1">
  69:          /// (input) INTEGER
  70:          /// The first element of IPIV for which a row interchange will
  71:          /// be done.
  72:          ///</param>
  73:          /// <param name="K2">
  74:          /// (input) INTEGER
  75:          /// The last element of IPIV for which a row interchange will
  76:          /// be done.
  77:          ///</param>
  78:          /// <param name="IPIV">
  79:          /// (input) INTEGER array, dimension (K2*abs(INCX))
  80:          /// The vector of pivot indices.  Only the elements in positions
  81:          /// K1 through K2 of IPIV are accessed.
  82:          /// IPIV(K) = L implies rows K and L are to be interchanged.
  83:          ///</param>
  84:          /// <param name="INCX">
  85:          /// (input) INTEGER
  86:          /// The increment between successive values of IPIV.  If IPIV
  87:          /// is negative, the pivots are applied in reverse order.
  88:          ///</param>
  89:          public void Run(int N, ref double[] A, int offset_a, int LDA, int K1, int K2, int[] IPIV, int offset_ipiv
  90:                           , int INCX)
  91:          {
  92:   
  93:              #region Array Index Correction
  94:              
  95:               int o_a = -1 - LDA + offset_a;  int o_ipiv = -1 + offset_ipiv; 
  96:   
  97:              #endregion
  98:   
  99:   
 100:              #region Prolog
 101:              
 102:              // *
 103:              // *  -- LAPACK auxiliary routine (version 3.1) --
 104:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
 105:              // *     November 2006
 106:              // *
 107:              // *     .. Scalar Arguments ..
 108:              // *     ..
 109:              // *     .. Array Arguments ..
 110:              // *     ..
 111:              // *
 112:              // *  Purpose
 113:              // *  =======
 114:              // *
 115:              // *  DLASWP performs a series of row interchanges on the matrix A.
 116:              // *  One row interchange is initiated for each of rows K1 through K2 of A.
 117:              // *
 118:              // *  Arguments
 119:              // *  =========
 120:              // *
 121:              // *  N       (input) INTEGER
 122:              // *          The number of columns of the matrix A.
 123:              // *
 124:              // *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
 125:              // *          On entry, the matrix of column dimension N to which the row
 126:              // *          interchanges will be applied.
 127:              // *          On exit, the permuted matrix.
 128:              // *
 129:              // *  LDA     (input) INTEGER
 130:              // *          The leading dimension of the array A.
 131:              // *
 132:              // *  K1      (input) INTEGER
 133:              // *          The first element of IPIV for which a row interchange will
 134:              // *          be done.
 135:              // *
 136:              // *  K2      (input) INTEGER
 137:              // *          The last element of IPIV for which a row interchange will
 138:              // *          be done.
 139:              // *
 140:              // *  IPIV    (input) INTEGER array, dimension (K2*abs(INCX))
 141:              // *          The vector of pivot indices.  Only the elements in positions
 142:              // *          K1 through K2 of IPIV are accessed.
 143:              // *          IPIV(K) = L implies rows K and L are to be interchanged.
 144:              // *
 145:              // *  INCX    (input) INTEGER
 146:              // *          The increment between successive values of IPIV.  If IPIV
 147:              // *          is negative, the pivots are applied in reverse order.
 148:              // *
 149:              // *  Further Details
 150:              // *  ===============
 151:              // *
 152:              // *  Modified by
 153:              // *   R. C. Whaley, Computer Science Dept., Univ. of Tenn., Knoxville, USA
 154:              // *
 155:              // * =====================================================================
 156:              // *
 157:              // *     .. Local Scalars ..
 158:              // *     ..
 159:              // *     .. Executable Statements ..
 160:              // *
 161:              // *     Interchange row I with row IPIV(I) for each of rows K1 through K2.
 162:              // *
 163:   
 164:              #endregion
 165:   
 166:   
 167:              #region Body
 168:              
 169:              if (INCX > 0)
 170:              {
 171:                  IX0 = K1;
 172:                  I1 = K1;
 173:                  I2 = K2;
 174:                  INC = 1;
 175:              }
 176:              else
 177:              {
 178:                  if (INCX < 0)
 179:                  {
 180:                      IX0 = 1 + (1 - K2) * INCX;
 181:                      I1 = K2;
 182:                      I2 = K1;
 183:                      INC =  - 1;
 184:                  }
 185:                  else
 186:                  {
 187:                      return;
 188:                  }
 189:              }
 190:              // *
 191:              N32 = (N / 32) * 32;
 192:              if (N32 != 0)
 193:              {
 194:                  for (J = 1; J <= N32; J += 32)
 195:                  {
 196:                      IX = IX0;
 197:                      for (I = I1; (INC >= 0) ? (I <= I2) : (I >= I2); I += INC)
 198:                      {
 199:                          IP = IPIV[IX + o_ipiv];
 200:                          if (IP != I)
 201:                          {
 202:                              for (K = J; K <= J + 31; K++)
 203:                              {
 204:                                  TEMP = A[I+K * LDA + o_a];
 205:                                  A[I+K * LDA + o_a] = A[IP+K * LDA + o_a];
 206:                                  A[IP+K * LDA + o_a] = TEMP;
 207:                              }
 208:                          }
 209:                          IX = IX + INCX;
 210:                      }
 211:                  }
 212:              }
 213:              if (N32 != N)
 214:              {
 215:                  N32 = N32 + 1;
 216:                  IX = IX0;
 217:                  for (I = I1; (INC >= 0) ? (I <= I2) : (I >= I2); I += INC)
 218:                  {
 219:                      IP = IPIV[IX + o_ipiv];
 220:                      if (IP != I)
 221:                      {
 222:                          for (K = N32; K <= N; K++)
 223:                          {
 224:                              TEMP = A[I+K * LDA + o_a];
 225:                              A[I+K * LDA + o_a] = A[IP+K * LDA + o_a];
 226:                              A[IP+K * LDA + o_a] = TEMP;
 227:                          }
 228:                      }
 229:                      IX = IX + INCX;
 230:                  }
 231:              }
 232:              // *
 233:              return;
 234:              // *
 235:              // *     End of DLASWP
 236:              // *
 237:   
 238:              #endregion
 239:   
 240:          }
 241:      }
 242:  }