X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Ftcosh.c;h=3f84fc8b6c602c9af6c1779ac5e66a27051387c2;hb=f34506723f150a03d5e6e389820bd369b89e30b0;hp=57b5601e97f1ffc4beb9d292ac6debb0306f3fee;hpb=c9266275a7240e07da227b662cc6afcb0000d7a6;p=platform%2Fupstream%2Fmpc.git diff --git a/tests/tcosh.c b/tests/tcosh.c index 57b5601..3f84fc8 100644 --- a/tests/tcosh.c +++ b/tests/tcosh.c @@ -1,27 +1,40 @@ /* test file for mpc_cosh. -Copyright (C) 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2008, 2009 Philippe Th\'eveny, Paul Zimmermann, Andreas Enge -This file is part of GNU MPC. +This file is part of the MPC Library. -GNU MPC is free software; you can redistribute it and/or modify it under -the terms of the GNU Lesser General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your +The MPC Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. -GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for -more details. +The MPC Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see http://www.gnu.org/licenses/ . -*/ +along with the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ +#include #include #include "mpc-tests.h" static void +test_failed (mpc_t op, mpc_t get, mpc_t expected) +{ + printf ("mpc_cosh(op) failed\n with "); + OUT (op); + printf (" "); + OUT (get); + OUT (expected); + exit (1); +} + +static void pure_real_argument (void) { /* cosh(x -i*0) = cosh(x) +i*0 if x<0 */ @@ -38,31 +51,31 @@ pure_real_argument (void) /* cosh(1 +i*0) = cosh(1) +i*0 */ mpc_set_ui_ui (z, 1, 0, MPC_RNDNN); - mpfr_cosh (mpc_realref (u), mpc_realref (z), GMP_RNDN); - mpfr_set_ui (mpc_imagref (u), 0, GMP_RNDN); + mpfr_cosh (MPC_RE (u), MPC_RE (z), GMP_RNDN); + mpfr_set_ui (MPC_IM (u), 0, GMP_RNDN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); /* cosh(1 -i*0) = cosh(1) -i*0 */ mpc_conj (z, z, MPC_RNDNN); mpc_conj (u, u, MPC_RNDNN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); /* cosh(-1 +i*0) = cosh(1) -i*0 */ mpc_neg (z, z, MPC_RNDNN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); /* cosh(-1 -i*0) = cosh(1) +i*0 */ mpc_conj (z, z, MPC_RNDNN); mpc_conj (u, u, MPC_RNDNN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); mpc_clear (cosh_z); mpc_clear (z); @@ -82,33 +95,33 @@ pure_imaginary_argument (void) mpc_init2 (u, 100); mpc_init2 (cosh_z, 100); - /* cosh(+0 +i) = cos(1) + i*0 */ + /* cosh(+0 +i) = cos(1) +i*0 */ mpc_set_ui_ui (z, 0, 1, MPC_RNDNN); - mpfr_cos (mpc_realref (u), mpc_imagref (z), GMP_RNDN); - mpfr_set_ui (mpc_imagref (u), 0, GMP_RNDN); + mpfr_cos (MPC_RE (u), MPC_IM (z), GMP_RNDN); + mpfr_set_ui (MPC_IM (u), 0, GMP_RNDN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); - /* cosh(+0 -i) = cos(1) - i*0 */ + /* cosh(+0 -i) = cos(1) -i*0 */ mpc_conj (z, z, MPC_RNDNN); mpc_conj (u, u, MPC_RNDNN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); - /* cosh(-0 +i) = cos(1) - i*0 */ + /* cosh(-0 +i) = cos(1) -i*0 */ mpc_neg (z, z, MPC_RNDNN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); - /* cosh(-0 -i) = cos(1) + i*0 */ + /* cosh(-0 -i) = cos(1) +i*0 */ mpc_conj (z, z, MPC_RNDNN); mpc_conj (u, u, MPC_RNDNN); mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); + if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z))) + test_failed (z, cosh_z, u); mpc_clear (cosh_z); mpc_clear (z);