~steve-sk2/mingw-w64/oneiric

« back to all changes in this revision

Viewing changes to mingw-w64-crt/complex/cacosl.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-11-18 00:04:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101118000446-xe24b423su55onyl
Tags: 1.0+20101003-1
* New maintainer. (Closes: #594371.)
* New upstream snapshot:
  - Includes getopt.h. (Closes: #569914.)
* Build g++ for Win64. (Closes: #600451.)
* Standards-Version 3.9.1 (new packaging).
* Include patch from
  http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revision=3715
  as suggested by Rafaël Carré.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * This file has no copyright assigned and is placed in the Public Domain.
3
 
 * This file is part of the w64 mingw-runtime package.
4
 
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5
 
 */
6
 
/*
7
 
   cacosl.c
8
 
   Contributed by Danny Smith
9
 
   2004-01-04
10
 
*/
11
 
 
12
 
#include <math.h>
13
 
#include <complex.h>
14
 
 
15
 
#if 0
16
 
/* cacos (Z) = -I * clog(Z + I * csqrt(1 - Z * Z)) */
17
 
 
18
 
long double complex cacosl (long double  complex Z)
19
 
{
20
 
  long double complex Res;
21
 
  long double x, y;
22
 
 
23
 
  x = __real__ Z;
24
 
  y = __imag__ Z;
25
 
 
26
 
  if (y == 0.0L)
27
 
    {
28
 
      __real__ Res = acosl (x);
29
 
      __imag__ Res = 0.0L;
30
 
    }
31
 
 
32
 
  else
33
 
    {
34
 
      long double complex ZZ;
35
 
      /* Z * Z = ((x - y) * (x + y)) + (2.0 * x * y) * I */
36
 
      /* caculate 1 - Z * Z */
37
 
      __real__ ZZ = 1.0L - (x - y) * (x + y);
38
 
      __imag__ ZZ = -2.0L * x * y;
39
 
 
40
 
       
41
 
       Res = csqrtl(ZZ);
42
 
 
43
 
      /* calculate ZZ + I * sqrt (ZZ) */
44
 
    
45
 
      __real__ ZZ = x - __imag__ Res;
46
 
      __imag__ ZZ = y + __real__ Res;
47
 
       
48
 
      ZZ = clogl(ZZ);
49
 
 
50
 
      /* mult by -I */
51
 
 
52
 
      __real__ Res  =  __imag__ ZZ;
53
 
      __imag__ Res = - __real__ ZZ;
54
 
    }
55
 
  return Res;
56
 
}
57
 
 
58
 
#else
59
 
 
60
 
/* cacos ( Z ) =  pi/2 - casin ( Z ) */
61
 
#ifndef _M_PI_2L
62
 
#define _M_PI_2L 1.5707963267948966192313L
63
 
#endif
64
 
long double complex cacosl (long double complex Z)
65
 
{
66
 
  long double complex Res  = casinl (Z);
67
 
  __real__ Res = _M_PI_2L - __real__ Res;
68
 
  __imag__ Res = - __imag__ Res;
69
 
  return Res;
70
 
}
71
 
#endif
 
1
/**
 
2
 * This file has no copyright assigned and is placed in the Public Domain.
 
3
 * This file is part of the w64 mingw-runtime package.
 
4
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 
5
 */
 
6
/*
 
7
   cacosl.c
 
8
   Contributed by Danny Smith
 
9
   2004-01-04
 
10
*/
 
11
 
 
12
#include <math.h>
 
13
#include <complex.h>
 
14
 
 
15
#if 0
 
16
/* cacos (Z) = -I * clog(Z + I * csqrt(1 - Z * Z)) */
 
17
 
 
18
long double complex cacosl (long double  complex Z)
 
19
{
 
20
  long double complex Res;
 
21
  long double x, y;
 
22
 
 
23
  x = __real__ Z;
 
24
  y = __imag__ Z;
 
25
 
 
26
  if (y == 0.0L)
 
27
    {
 
28
      __real__ Res = acosl (x);
 
29
      __imag__ Res = 0.0L;
 
30
    }
 
31
 
 
32
  else
 
33
    {
 
34
      long double complex ZZ;
 
35
      /* Z * Z = ((x - y) * (x + y)) + (2.0 * x * y) * I */
 
36
      /* caculate 1 - Z * Z */
 
37
      __real__ ZZ = 1.0L - (x - y) * (x + y);
 
38
      __imag__ ZZ = -2.0L * x * y;
 
39
 
 
40
       
 
41
       Res = csqrtl(ZZ);
 
42
 
 
43
      /* calculate ZZ + I * sqrt (ZZ) */
 
44
    
 
45
      __real__ ZZ = x - __imag__ Res;
 
46
      __imag__ ZZ = y + __real__ Res;
 
47
       
 
48
      ZZ = clogl(ZZ);
 
49
 
 
50
      /* mult by -I */
 
51
 
 
52
      __real__ Res  =  __imag__ ZZ;
 
53
      __imag__ Res = - __real__ ZZ;
 
54
    }
 
55
  return Res;
 
56
}
 
57
 
 
58
#else
 
59
 
 
60
/* cacos ( Z ) =  pi/2 - casin ( Z ) */
 
61
#ifndef _M_PI_2L
 
62
#define _M_PI_2L 1.5707963267948966192313L
 
63
#endif
 
64
long double complex cacosl (long double complex Z)
 
65
{
 
66
  long double complex Res  = casinl (Z);
 
67
  __real__ Res = _M_PI_2L - __real__ Res;
 
68
  __imag__ Res = - __imag__ Res;
 
69
  return Res;
 
70
}
 
71
#endif