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:      /// DLADIV performs complex division in  real arithmetic
  27:      /// 
  28:      /// a + i*b
  29:      /// p + i*q = ---------
  30:      /// c + i*d
  31:      /// 
  32:      /// The algorithm is due to Robert L. Smith and can be found
  33:      /// in D. Knuth, The art of Computer Programming, Vol.2, p.195
  34:      /// 
  35:      ///</summary>
  36:      public class DLADIV
  37:      {
  38:      
  39:   
  40:          #region Fields
  41:          
  42:          double E = 0; double F = 0; 
  43:   
  44:          #endregion
  45:   
  46:          public DLADIV()
  47:          {
  48:      
  49:          }
  50:      
  51:          /// <summary>
  52:          /// Purpose
  53:          /// =======
  54:          /// 
  55:          /// DLADIV performs complex division in  real arithmetic
  56:          /// 
  57:          /// a + i*b
  58:          /// p + i*q = ---------
  59:          /// c + i*d
  60:          /// 
  61:          /// The algorithm is due to Robert L. Smith and can be found
  62:          /// in D. Knuth, The art of Computer Programming, Vol.2, p.195
  63:          /// 
  64:          ///</summary>
  65:          /// <param name="A">
  66:          /// + i*b
  67:          ///</param>
  68:          /// <param name="B">
  69:          /// (input) DOUBLE PRECISION
  70:          ///</param>
  71:          /// <param name="C">
  72:          /// + i*d
  73:          ///</param>
  74:          /// <param name="D">
  75:          /// (input) DOUBLE PRECISION
  76:          /// The scalars a, b, c, and d in the above expression.
  77:          ///</param>
  78:          /// <param name="P">
  79:          /// (output) DOUBLE PRECISION
  80:          ///</param>
  81:          /// <param name="Q">
  82:          /// (output) DOUBLE PRECISION
  83:          /// The scalars p and q in the above expression.
  84:          ///</param>
  85:          public void Run(double A, double B, double C, double D, ref double P, ref double Q)
  86:          {
  87:   
  88:              #region Prolog
  89:              
  90:              // *
  91:              // *  -- LAPACK auxiliary routine (version 3.1) --
  92:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  93:              // *     November 2006
  94:              // *
  95:              // *     .. Scalar Arguments ..
  96:              // *     ..
  97:              // *
  98:              // *  Purpose
  99:              // *  =======
 100:              // *
 101:              // *  DLADIV performs complex division in  real arithmetic
 102:              // *
 103:              // *                        a + i*b
 104:              // *             p + i*q = ---------
 105:              // *                        c + i*d
 106:              // *
 107:              // *  The algorithm is due to Robert L. Smith and can be found
 108:              // *  in D. Knuth, The art of Computer Programming, Vol.2, p.195
 109:              // *
 110:              // *  Arguments
 111:              // *  =========
 112:              // *
 113:              // *  A       (input) DOUBLE PRECISION
 114:              // *  B       (input) DOUBLE PRECISION
 115:              // *  C       (input) DOUBLE PRECISION
 116:              // *  D       (input) DOUBLE PRECISION
 117:              // *          The scalars a, b, c, and d in the above expression.
 118:              // *
 119:              // *  P       (output) DOUBLE PRECISION
 120:              // *  Q       (output) DOUBLE PRECISION
 121:              // *          The scalars p and q in the above expression.
 122:              // *
 123:              // *  =====================================================================
 124:              // *
 125:              // *     .. Local Scalars ..
 126:              // *     ..
 127:              // *     .. Intrinsic Functions ..
 128:              //      INTRINSIC          ABS;
 129:              // *     ..
 130:              // *     .. Executable Statements ..
 131:              // *
 132:   
 133:              #endregion
 134:   
 135:              if (Math.Abs(D) < Math.Abs(C))
 136:              {
 137:                  E = D / C;
 138:                  F = C + D * E;
 139:                  P = (A + B * E) / F;
 140:                  Q = (B - A * E) / F;
 141:              }
 142:              else
 143:              {
 144:                  E = C / D;
 145:                  F = D + C * E;
 146:                  P = (B + A * E) / F;
 147:                  Q = ( - A + B * E) / F;
 148:              }
 149:              // *
 150:              return;
 151:              // *
 152:              // *     End of DLADIV
 153:              // *
 154:          }
 155:      }
 156:  }