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:      /// DLASET initializes an m-by-n matrix A to BETA on the diagonal and
  27:      /// ALPHA on the offdiagonals.
  28:      /// 
  29:      ///</summary>
  30:      public class DLASET
  31:      {
  32:      
  33:   
  34:          #region Dependencies
  35:          
  36:          LSAME _lsame; 
  37:   
  38:          #endregion
  39:   
  40:   
  41:          #region Fields
  42:          
  43:          int I = 0; int J = 0; 
  44:   
  45:          #endregion
  46:   
  47:          public DLASET(LSAME lsame)
  48:          {
  49:      
  50:   
  51:              #region Set Dependencies
  52:              
  53:              this._lsame = lsame; 
  54:   
  55:              #endregion
  56:   
  57:          }
  58:      
  59:          public DLASET()
  60:          {
  61:      
  62:   
  63:              #region Dependencies (Initialization)
  64:              
  65:              LSAME lsame = new LSAME();
  66:   
  67:              #endregion
  68:   
  69:   
  70:              #region Set Dependencies
  71:              
  72:              this._lsame = lsame; 
  73:   
  74:              #endregion
  75:   
  76:          }
  77:          /// <summary>
  78:          /// Purpose
  79:          /// =======
  80:          /// 
  81:          /// DLASET initializes an m-by-n matrix A to BETA on the diagonal and
  82:          /// ALPHA on the offdiagonals.
  83:          /// 
  84:          ///</summary>
  85:          /// <param name="UPLO">
  86:          /// (input) CHARACTER*1
  87:          /// Specifies the part of the matrix A to be set.
  88:          /// = 'U':      Upper triangular part is set; the strictly lower
  89:          /// triangular part of A is not changed.
  90:          /// = 'L':      Lower triangular part is set; the strictly upper
  91:          /// triangular part of A is not changed.
  92:          /// Otherwise:  All of the matrix A is set.
  93:          ///</param>
  94:          /// <param name="M">
  95:          /// (input) INTEGER
  96:          /// The number of rows of the matrix A.  M .GE. 0.
  97:          ///</param>
  98:          /// <param name="N">
  99:          /// (input) INTEGER
 100:          /// The number of columns of the matrix A.  N .GE. 0.
 101:          ///</param>
 102:          /// <param name="ALPHA">
 103:          /// (input) DOUBLE PRECISION
 104:          /// The constant to which the offdiagonal elements are to be set.
 105:          ///</param>
 106:          /// <param name="BETA">
 107:          /// (input) DOUBLE PRECISION
 108:          /// The constant to which the diagonal elements are to be set.
 109:          ///</param>
 110:          /// <param name="A">
 111:          /// (input/output) DOUBLE PRECISION array, dimension (LDA,N)
 112:          /// On exit, the leading m-by-n submatrix of A is set as follows:
 113:          /// 
 114:          /// if UPLO = 'U', A(i,j) = ALPHA, 1.LE.i.LE.j-1, 1.LE.j.LE.n,
 115:          /// if UPLO = 'L', A(i,j) = ALPHA, j+1.LE.i.LE.m, 1.LE.j.LE.n,
 116:          /// otherwise,     A(i,j) = ALPHA, 1.LE.i.LE.m, 1.LE.j.LE.n, i.ne.j,
 117:          /// 
 118:          /// and, for all UPLO, A(i,i) = BETA, 1.LE.i.LE.min(m,n).
 119:          ///</param>
 120:          /// <param name="LDA">
 121:          /// (input) INTEGER
 122:          /// The leading dimension of the array A.  LDA .GE. max(1,M).
 123:          ///</param>
 124:          public void Run(string UPLO, int M, int N, double ALPHA, double BETA, ref double[] A, int offset_a
 125:                           , int LDA)
 126:          {
 127:   
 128:              #region Array Index Correction
 129:              
 130:               int o_a = -1 - LDA + offset_a; 
 131:   
 132:              #endregion
 133:   
 134:   
 135:              #region Strings
 136:              
 137:              UPLO = UPLO.Substring(0, 1);  
 138:   
 139:              #endregion
 140:   
 141:   
 142:              #region Prolog
 143:              
 144:              // *
 145:              // *  -- LAPACK auxiliary routine (version 3.1) --
 146:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
 147:              // *     November 2006
 148:              // *
 149:              // *     .. Scalar Arguments ..
 150:              // *     ..
 151:              // *     .. Array Arguments ..
 152:              // *     ..
 153:              // *
 154:              // *  Purpose
 155:              // *  =======
 156:              // *
 157:              // *  DLASET initializes an m-by-n matrix A to BETA on the diagonal and
 158:              // *  ALPHA on the offdiagonals.
 159:              // *
 160:              // *  Arguments
 161:              // *  =========
 162:              // *
 163:              // *  UPLO    (input) CHARACTER*1
 164:              // *          Specifies the part of the matrix A to be set.
 165:              // *          = 'U':      Upper triangular part is set; the strictly lower
 166:              // *                      triangular part of A is not changed.
 167:              // *          = 'L':      Lower triangular part is set; the strictly upper
 168:              // *                      triangular part of A is not changed.
 169:              // *          Otherwise:  All of the matrix A is set.
 170:              // *
 171:              // *  M       (input) INTEGER
 172:              // *          The number of rows of the matrix A.  M >= 0.
 173:              // *
 174:              // *  N       (input) INTEGER
 175:              // *          The number of columns of the matrix A.  N >= 0.
 176:              // *
 177:              // *  ALPHA   (input) DOUBLE PRECISION
 178:              // *          The constant to which the offdiagonal elements are to be set.
 179:              // *
 180:              // *  BETA    (input) DOUBLE PRECISION
 181:              // *          The constant to which the diagonal elements are to be set.
 182:              // *
 183:              // *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
 184:              // *          On exit, the leading m-by-n submatrix of A is set as follows:
 185:              // *
 186:              // *          if UPLO = 'U', A(i,j) = ALPHA, 1<=i<=j-1, 1<=j<=n,
 187:              // *          if UPLO = 'L', A(i,j) = ALPHA, j+1<=i<=m, 1<=j<=n,
 188:              // *          otherwise,     A(i,j) = ALPHA, 1<=i<=m, 1<=j<=n, i.ne.j,
 189:              // *
 190:              // *          and, for all UPLO, A(i,i) = BETA, 1<=i<=min(m,n).
 191:              // *
 192:              // *  LDA     (input) INTEGER
 193:              // *          The leading dimension of the array A.  LDA >= max(1,M).
 194:              // *
 195:              // * =====================================================================
 196:              // *
 197:              // *     .. Local Scalars ..
 198:              // *     ..
 199:              // *     .. External Functions ..
 200:              // *     ..
 201:              // *     .. Intrinsic Functions ..
 202:              //      INTRINSIC          MIN;
 203:              // *     ..
 204:              // *     .. Executable Statements ..
 205:              // *
 206:   
 207:              #endregion
 208:   
 209:   
 210:              #region Body
 211:              
 212:              if (this._lsame.Run(UPLO, "U"))
 213:              {
 214:                  // *
 215:                  // *        Set the strictly upper triangular or trapezoidal part of the
 216:                  // *        array to ALPHA.
 217:                  // *
 218:                  for (J = 2; J <= N; J++)
 219:                  {
 220:                      for (I = 1; I <= Math.Min(J - 1, M); I++)
 221:                      {
 222:                          A[I+J * LDA + o_a] = ALPHA;
 223:                      }
 224:                  }
 225:                  // *
 226:              }
 227:              else
 228:              {
 229:                  if (this._lsame.Run(UPLO, "L"))
 230:                  {
 231:                      // *
 232:                      // *        Set the strictly lower triangular or trapezoidal part of the
 233:                      // *        array to ALPHA.
 234:                      // *
 235:                      for (J = 1; J <= Math.Min(M, N); J++)
 236:                      {
 237:                          for (I = J + 1; I <= M; I++)
 238:                          {
 239:                              A[I+J * LDA + o_a] = ALPHA;
 240:                          }
 241:                      }
 242:                      // *
 243:                  }
 244:                  else
 245:                  {
 246:                      // *
 247:                      // *        Set the leading m-by-n submatrix to ALPHA.
 248:                      // *
 249:                      for (J = 1; J <= N; J++)
 250:                      {
 251:                          for (I = 1; I <= M; I++)
 252:                          {
 253:                              A[I+J * LDA + o_a] = ALPHA;
 254:                          }
 255:                      }
 256:                  }
 257:              }
 258:              // *
 259:              // *     Set the first min(M,N) diagonal elements to BETA.
 260:              // *
 261:              for (I = 1; I <= Math.Min(M, N); I++)
 262:              {
 263:                  A[I+I * LDA + o_a] = BETA;
 264:              }
 265:              // *
 266:              return;
 267:              // *
 268:              // *     End of DLASET
 269:              // *
 270:   
 271:              #endregion
 272:   
 273:          }
 274:      }
 275:  }