[BACK]Return to standard_complex_numbers_polar.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Numbers

File: [local] / OpenXM_contrib / PHC / Ada / Math_Lib / Numbers / standard_complex_numbers_polar.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:26 2000 UTC (23 years, 7 months ago) by maekawa
Branch: PHC, MAIN
CVS Tags: v2, maekawa-ipv6, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, HEAD
Changes since 1.1: +0 -0 lines

Import the second public release of PHCpack.

OKed by Jan Verschelde.

with Standard_Mathematical_Functions;    use Standard_Mathematical_Functions;

package body Standard_Complex_Numbers_Polar is

  function Radius ( c : Complex_Number ) return double_float is
  begin
    return SQRT(REAL_PART(c)**2 + IMAG_PArt(c)**2);
  end Radius;

  function Angle ( c : Complex_Number ) return double_float is
  begin
    return Standard_Mathematical_Functions.Angle(IMAG_PART(c),REAL_PART(c));
  end Angle;

  function Root ( c : Complex_Number; n,i : natural ) return Complex_Number is

    arg,radius_c,angle_c : double_float;
    tmp : Complex_Number;

  begin
    arg := (2.0 * PI * double_float(i)) / double_float(n);
    radius_c := RADIUS(c)**(1.0/double_float(n));
    angle_c := ANGLE(c)/double_float(n);
    tmp := Create(radius_c)*Create(COS(angle_c),SIN(angle_c));
    return Create(COS(arg),SIN(arg))*tmp;
  end Root;

end Standard_Complex_Numbers_Polar;