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:      /// DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
  27:      /// overflow.
  28:      /// 
  29:      ///</summary>
  30:      public class DLAPY2
  31:      {
  32:      
  33:   
  34:          #region Fields
  35:          
  36:          const double ZERO = 0.0E0; const double ONE = 1.0E0; double W = 0; double XABS = 0; double YABS = 0; double Z = 0; 
  37:   
  38:          #endregion
  39:   
  40:          public DLAPY2()
  41:          {
  42:      
  43:          }
  44:      
  45:          /// <summary>
  46:          /// Purpose
  47:          /// =======
  48:          /// 
  49:          /// DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
  50:          /// overflow.
  51:          /// 
  52:          ///</summary>
  53:          /// <param name="X">
  54:          /// (input) DOUBLE PRECISION
  55:          ///</param>
  56:          /// <param name="Y">
  57:          /// (input) DOUBLE PRECISION
  58:          /// X and Y specify the values x and y.
  59:          ///</param>
  60:          public double Run(double X, double Y)
  61:          {
  62:          double dlapy2 = 0;
  63:   
  64:              #region Prolog
  65:              
  66:              // *
  67:              // *  -- LAPACK auxiliary routine (version 3.1) --
  68:              // *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
  69:              // *     November 2006
  70:              // *
  71:              // *     .. Scalar Arguments ..
  72:              // *     ..
  73:              // *
  74:              // *  Purpose
  75:              // *  =======
  76:              // *
  77:              // *  DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
  78:              // *  overflow.
  79:              // *
  80:              // *  Arguments
  81:              // *  =========
  82:              // *
  83:              // *  X       (input) DOUBLE PRECISION
  84:              // *  Y       (input) DOUBLE PRECISION
  85:              // *          X and Y specify the values x and y.
  86:              // *
  87:              // *  =====================================================================
  88:              // *
  89:              // *     .. Parameters ..
  90:              // *     ..
  91:              // *     .. Local Scalars ..
  92:              // *     ..
  93:              // *     .. Intrinsic Functions ..
  94:              //      INTRINSIC          ABS, MAX, MIN, SQRT;
  95:              // *     ..
  96:              // *     .. Executable Statements ..
  97:              // *
  98:   
  99:              #endregion
 100:   
 101:              XABS = Math.Abs(X);
 102:              YABS = Math.Abs(Y);
 103:              W = Math.Max(XABS, YABS);
 104:              Z = Math.Min(XABS, YABS);
 105:              if (Z == ZERO)
 106:              {
 107:                  dlapy2 = W;
 108:              }
 109:              else
 110:              {
 111:                  dlapy2 = W * Math.Sqrt(ONE + Math.Pow(Z / W,2));
 112:              }
 113:              return dlapy2;
 114:              // *
 115:              // *     End of DLAPY2
 116:              // *
 117:          }
 118:      }
 119:  }