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:      public class DAXPY
  20:      {
  21:      
  22:   
  23:          #region Fields
  24:          
  25:          int I = 0; int IX = 0; int IY = 0; int M = 0; int MP1 = 0; 
  26:   
  27:          #endregion
  28:   
  29:          public DAXPY()
  30:          {
  31:      
  32:          }
  33:      
  34:          public void Run(int N, double DA, double[] DX, int offset_dx, int INCX, ref double[] DY, int offset_dy, int INCY)
  35:          {
  36:   
  37:              #region Array Index Correction
  38:              
  39:               int o_dx = -1 + offset_dx;  int o_dy = -1 + offset_dy; 
  40:   
  41:              #endregion
  42:   
  43:              // c
  44:              // c     constant times a vector plus a vector.
  45:              // c     uses unrolled loops for increments equal to one.
  46:              // c     jack dongarra, linpack, 3/11/78.
  47:              // c     modified 12/3/93, array(1) declarations changed to array(*)
  48:              // c
  49:              // c
  50:   
  51:              #region Body
  52:              
  53:              if (N <= 0) return;
  54:              if (DA == 0.0E0) return;
  55:              if (INCX == 1 && INCY == 1) goto LABEL20;
  56:              // c
  57:              // c        code for unequal increments or equal increments
  58:              // c          not equal to 1
  59:              // c
  60:              IX = 1;
  61:              IY = 1;
  62:              if (INCX < 0) IX = ( - N + 1) * INCX + 1;
  63:              if (INCY < 0) IY = ( - N + 1) * INCY + 1;
  64:              for (I = 1; I <= N; I++)
  65:              {
  66:                  DY[IY + o_dy] = DY[IY + o_dy] + DA * DX[IX + o_dx];
  67:                  IX = IX + INCX;
  68:                  IY = IY + INCY;
  69:              }
  70:              return;
  71:              // c
  72:              // c        code for both increments equal to 1
  73:              // c
  74:              // c
  75:              // c        clean-up loop
  76:              // c
  77:          LABEL20:  M = FortranLib.Mod(N,4);
  78:              if (M == 0) goto LABEL40;
  79:              for (I = 1; I <= M; I++)
  80:              {
  81:                  DY[I + o_dy] = DY[I + o_dy] + DA * DX[I + o_dx];
  82:              }
  83:              if (N < 4) return;
  84:          LABEL40:  MP1 = M + 1;
  85:              for (I = MP1; I <= N; I += 4)
  86:              {
  87:                  DY[I + o_dy] = DY[I + o_dy] + DA * DX[I + o_dx];
  88:                  DY[I + 1 + o_dy] = DY[I + 1 + o_dy] + DA * DX[I + 1 + o_dx];
  89:                  DY[I + 2 + o_dy] = DY[I + 2 + o_dy] + DA * DX[I + 2 + o_dx];
  90:                  DY[I + 3 + o_dy] = DY[I + 3 + o_dy] + DA * DX[I + 3 + o_dx];
  91:              }
  92:              return;
  93:   
  94:              #endregion
  95:   
  96:          }
  97:      }
  98:  }