示例#1
0
int main()
{
    double complex v, z;
    double a = 0.0, b = 0.0;

    puts("Calculate the inverse hyperbolic cosine of a complex number,"
         " cacosh(z)\n");
    puts("Enter the real and imaginary parts of a complex number:");
    if ( scanf("%lf %lf", &a, &b) == 2)
    {
       z = a + b * I;
       printf( "z = %.2f %+.2f*I.\n", creal(z), cimag(z) );

       v = cacosh(z);
       printf( "The cacosh(z) function yields %.2f %+.2f*I.\n",
               creal(v), cimag(v) );
       printf( "The inverse function, ccosh(cacosh(z)),"
               " yields %.2f %+.2f*I.\n",
               creal( ccosh(v)), cimag( ccosh(v)) );
    }
    else
       printf("Invalid input.\n");

    return 0;
}
示例#2
0
//## Complex Complex.cacoshl();
static KMETHOD Complex_cacoshl(KonohaContext *kctx, KonohaStack *sfp)
{
	kComplex *kc = (kComplex *) sfp[0].asObject;
	long double _Complex zl = (long double _Complex)kc->z;
	long double ret = cacosh(zl);
	KReturnFloatValue(ret);
}
示例#3
0
//## Complex Complex.cacoshf();
static KMETHOD Complex_cacoshf(KonohaContext *kctx, KonohaStack *sfp)
{
	kComplex *kc = (kComplex *) sfp[0].asObject;
	float _Complex zf = (float _Complex)kc->z;
	float ret = cacosh(zf);
	KReturnFloatValue(ret);
}
示例#4
0
文件: pr59717.c 项目: 0day-ci/gcc
void
cmplx (double _Complex z)
{
  cabs (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 129 } */
  cacos (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 131 } */
  cacosh (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 133 } */
  carg (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 135 } */
  casin (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 137 } */
  casinh (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 139 } */
  catan (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 141 } */
  catanh (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 143 } */
  ccos (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 145 } */
  ccosh (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 147 } */
  cexp (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 149 } */
  cimag (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 151 } */
  clog (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 153 } */
  conj (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 155 } */
  cpow (z, z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 157 } */
  cproj (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 159 } */
  creal (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 161 } */
  csin (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 163 } */
  csinh (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 165 } */
  csqrt (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 167 } */
  ctan (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 169 } */
  ctanh (z); /* { dg-warning "incompatible implicit" } */
  /* { dg-message "include ..complex.h.." "" { target *-*-* } 171 } */
}
示例#5
0
void
docomplex  (void)
{
#ifndef NO_DOUBLE
  complex double ca, cb, cc;
  double f1;

  ca = 1.0 + 1.0 * I;
  cb = 1.0 - 1.0 * I;

  f1 = cabs  (ca);
  fprintf (stdout, "cabs   : %f\n", f1);

  cc = cacos  (ca);
  fprintf (stdout, "cacos  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = cacosh  (ca);
  fprintf (stdout, "cacosh : %f %fi\n", creal  (cc),
	   cimag  (cc));

  f1 = carg  (ca);
  fprintf (stdout, "carg   : %f\n", f1);

  cc = casin  (ca);
  fprintf (stdout, "casin  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = casinh  (ca);
  fprintf (stdout, "casinh : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = catan  (ca);
  fprintf (stdout, "catan  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = catanh  (ca);
  fprintf (stdout, "catanh : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = ccos  (ca);
  fprintf (stdout, "ccos   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = ccosh  (ca);
  fprintf (stdout, "ccosh  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = cexp  (ca);
  fprintf (stdout, "cexp   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  f1 = cimag  (ca);
  fprintf (stdout, "cimag  : %f\n", f1);

  cc = clog  (ca);
  fprintf (stdout, "clog   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = conj  (ca);
  fprintf (stdout, "conj   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = cpow  (ca, cb);
  fprintf (stdout, "cpow   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = cproj  (ca);
  fprintf (stdout, "cproj  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  f1 = creal  (ca);
  fprintf (stdout, "creal  : %f\n", f1);

  cc = csin  (ca);
  fprintf (stdout, "csin   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = csinh  (ca);
  fprintf (stdout, "csinh  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = csqrt  (ca);
  fprintf (stdout, "csqrt  : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = ctan  (ca);
  fprintf (stdout, "ctan   : %f %fi\n", creal  (cc),
	   cimag  (cc));

  cc = ctanh  (ca);
  fprintf (stdout, "ctanh  : %f %fi\n", creal  (cc),
	   cimag  (cc));
#endif
}
示例#6
0
 f = catanf(f);
 ld = catanl(ld);
 TEST_TRACE(C99 7.3.5.4)
 d = ccos(d);
 f = ccosf(f);
 ld = ccosl(ld);
 TEST_TRACE(C99 7.3.5.5)
 d = csin(d);
 f = csinf(f);
 ld = csinl(ld);
 TEST_TRACE(C99 7.3.5.6)
 d = ctan(d);
 f = ctanf(f);
 ld = ctanl(ld);
 TEST_TRACE(C99 7.3.6.1)
 d = cacosh(d);
 f = cacoshf(f);
 ld = cacoshl(ld);
 TEST_TRACE(C99 7.3.6.2)
 d = casinh(d);
 f = casinhf(f);
 ld = casinhl(ld);
 TEST_TRACE(C99 7.3.6.3)
 d = catanh(d);
 f = catanhf(f);
 ld = catanhl(ld);
 TEST_TRACE(C99 7.3.6.4)
 d = ccosh(d);
 f = ccoshf(f);
 ld = ccoshl(ld);
 TEST_TRACE(C99 7.3.6.5)
示例#7
0
CAMLprim value math_cacosh(value x) {
  CAMLparam1(x);
  CAMLreturn(caml_copy_complex(cacosh(Complex_val(x))));
}
示例#8
0
void test06 ( )

/******************************************************************************/
/*
  Purpose:

    TEST06: intrinsic functions for double complex variables.

  Licensing:

    This code is distributed under the GNU LGPL license.

  Modified:

    07 November 2010

  Author:

    John Burkardt
*/
{
    double complex a = {1.0 + 2.0 * I};

    printf ( "\n" );
    printf ( "TEST06\n" );
    printf ( "  Apply intrinsic functions to DOUBLE COMPLEX variables\n" );
    /*
      Print them.
    */
    printf ( "\n" );
    /*
      Note that "I" by itself is NOT a complex number, nor is it the
      imaginary unit.  You have to cast it to ( complex ) or ( double complex )
      or multiply it by a float or double before it results in a numerical
      result.
    */
    printf ( "  ( double complex ) I =  (%14.6g,%14.6g)\n", ( double complex ) I );
    printf ( "  a =                     (%14.6g,%14.6g)\n", a );
    printf ( "  - a =                   (%14.6g,%14.6g)\n", - a );
    printf ( "  a + 3 =                 (%14.6g,%14.6g)\n", a + 3 );
    printf ( "  a + (0,5) =             (%14.6g,%14.6g)\n", a + ( 0, 5 ) );
    printf ( "  4 * a =                 (%14.6g,%14.6g)\n", 4 * a );
    printf ( "  a / 8 =                 (%14.6g,%14.6g)\n", a / 8 );
    printf ( "  a * a =                 (%14.6g,%14.6g)\n", a * a );
    printf ( "  cpow ( a, 2 ) =         (%14.6g,%14.6g)\n", cpow ( a, 2 ) );
    printf ( "  cpow ( 2, a ) =         (%14.6g,%14.6g)\n", cpow ( 2, a ) );
    printf ( "  cpow ( a, a ) =         (%14.6g,%14.6g)\n", cpow ( a, a ) );
    printf ( "  1/a =                   (%14.6g,%14.6g)\n", 1.0 / a );
    printf ( "\n" );
    printf ( "  cabs(a) =                %14.6g\n",         cabs ( a ) );
    printf ( "  cacos(a) =              (%14.6g,%14.6g)\n", cacos ( a ) );
    printf ( "  cacosh(a) =             (%14.6g,%14.6g)\n", cacosh ( a ) );
    printf ( "  carg(a) =                %14.6g\n",         carg ( a ) );
    printf ( "  casin(a) =              (%14.6g,%14.6g)\n", casin ( a ) );
    printf ( "  casinh(a) =             (%14.6g,%14.6g)\n", casinh ( a ) );
    printf ( "  catan(a) =              (%14.6g,%14.6g)\n",
             creal ( catan ( a ) ), cimag ( catan ( a ) ) );
    printf ( "  catanh(a) =             (%14.6g,%14.6g)\n",
             creal ( catanh ( a ) ), cimag ( catanh ( a ) ) );
    printf ( "  ccos(a) =               (%14.6g,%14.6g)\n",
             creal ( ccos ( a ) ), cimag ( ccos ( a ) ) );
    printf ( "  ccosh(a) =              (%14.6g,%14.6g)\n",
             creal ( ccosh ( a ) ), cimag ( ccosh ( a ) ) );
    printf ( "  cexp(a) =               (%14.6g,%14.6g)\n",
             creal ( cexp ( a ) ), cimag ( cexp ( a ) ) );
    printf ( "  cimag(a) =               %14.6g\n",         cimag ( a ) );
    printf ( "  clog(a) =               (%14.6g,%14.6g)\n",
             creal ( clog ( a ) ), cimag ( clog ( a ) ) );
    printf ( "  (double complex)(1) =   (%14.6g,%14.6g)\n",
             creal ( ( double complex ) ( 1 ) ), cimag ( ( double complex ) ( 1 ) ) );
    printf ( "  (double complex)(4.0) = (%14.6g,%14.6g)\n",
             creal ( ( double complex ) ( 4.0 ) ), cimag ( ( double complex ) ( 4.0 ) ) );
    printf ( "  conj(a) =               (%14.6g,%14.6g)\n",
             creal ( conj ( a ) ), cimag ( conj ( a ) ) );
    printf ( "  cproj(a) =              (%14.6g,%14.6g)\n",
             creal ( cproj ( a ) ), cimag ( cproj ( a ) ) );
    printf ( "  creal(a) =               %14.6g\n",         creal ( a ) );
    printf ( "  csin(a) =               (%14.6g,%14.6g)\n",
             creal ( csin ( a ) ), cimag ( csin ( a ) ) );
    printf ( "  csinh(a) =              (%14.6g,%14.6g)\n",
             creal ( csinh ( a ) ), cimag ( csinh ( a ) ) );
    printf ( "  csqrt(a) =              (%14.6g,%14.6g)\n",
             creal ( csqrt ( a ) ), cimag ( csqrt ( a ) ) );
    printf ( "  ctan(a) =               (%14.6g,%14.6g)\n",
             creal ( ctan ( a ) ), cimag ( ctan ( a ) ) );
    printf ( "  ctanh(a) =              (%14.6g,%14.6g)\n",
             creal ( ctanh ( a ) ), cimag ( ctanh ( a ) ) );
    printf ( "  (int)(a) =               %10d\n",           ( int ) ( a ) );

    return;
}
示例#9
0
文件: cacoshl.c 项目: KGG814/AOS
long double complex cacoshl(long double complex z)
{
	return cacosh(z);
}
示例#10
0
TEST(complex, cacosh) {
  ASSERT_EQ(0.0, cacosh(1.0));
}