home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmlsrc23.zoo / pmlsrc / cacos.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-19  |  1.8 KB  |  87 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    cacos   complex double precision arc cosine
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    cacos
  29.  *    complex functions
  30.  *    machine independent routines
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex arc cosine of
  36.  *    a double precision complex argument.
  37.  *
  38.  *  USAGE
  39.  *
  40.  *    COMPLEX cacos (z)
  41.  *    COMPLEX z;
  42.  *
  43.  *  PROGRAMMER
  44.  *
  45.  *    Fred Fish
  46.  *    Tempe,Az 85281
  47.  *    (602) 966-8871
  48.  *
  49.  *  INTERNALS
  50.  *
  51.  *    Computes complex arc cosine of z = x + jy from:
  52.  *
  53.  *        cacos(z) = -j * clog(z + j * csqrt(1-z*z))
  54.  *
  55.  */
  56.  
  57. #if defined (__M68881__) && !defined (_M68881)
  58. /*# define _M68881*/
  59. #endif
  60.  
  61. #include <stdio.h>
  62. #include <math.h>
  63. #include "pml.h"
  64.  
  65. COMPLEX cacos (z)
  66. COMPLEX z;
  67. {
  68.     COMPLEX temp;
  69.     double swaptemp;
  70.  
  71.     temp = cmult(z, z);
  72.     temp.real = 1.0 - temp.real;
  73.     temp.imag = -temp.imag;
  74.     temp = csqrt (temp);
  75.     swaptemp = temp.real;
  76.     temp.real = -temp.imag;
  77.     temp.imag = swaptemp;
  78.     temp.real += z.real;
  79.     temp.imag += z.imag;
  80.     temp = clog (temp);
  81.     z.real = temp.imag;
  82.     z.imag = -temp.real;
  83.  
  84.     return (z);
  85. }
  86.  
  87.