summaryrefslogtreecommitdiff
path: root/tests/ttan.c
diff options
context:
space:
mode:
authorthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2008-10-17 14:50:27 +0000
committerthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2008-10-17 14:50:27 +0000
commitd5a3ca63260b399f31fb5e4b40b8ea542e1d6c94 (patch)
treefdfe342392f733c02852de04737c9281cf9c1967 /tests/ttan.c
parentd9b9bbac92266eb7fe10f6bd8348ad318a68a980 (diff)
downloadmpc-d5a3ca63260b399f31fb5e4b40b8ea542e1d6c94.tar.gz
tests/tgeneric_ccc.c, tests/tgeneric_ccs.c, tests/tgeneric_ccu.c, tests/tgeneric_cc.c, tests/tgeneric_cfc.c, tests/tgeneric_cuuc.c, tests/tgeneric_fc.c, tests/tgeneric_ccf.c, tests/tgeneric_cuc.c: code moved into test/tgeneric.c.
tests/read_data_cc.c: code moved into tests/read_data.c. tests/mpc-tests.h: helper test function are in this new library tests/tgeneric.c: generic are reuse tests for all function prototypes used in MPC. tests/read_data.c: read data in a file. tests/comparisons.c: comparaison function working also with special values tests/random.c: functions become public tests/tsub_ui.c: use new libmpc-tests tests/tconj.c: use new libmpc-tests tests/tmul_ui.c: use new libmpc-tests tests/tmul_2exp.c: use new libmpc-tests tests/texp.c: use new libmpc-tests tests/tsinh.c: use new libmpc-tests tests/tneg.c: use new libmpc-tests tests/tui_div.c: use new libmpc-tests tests/tsub_fr.c: use new libmpc-tests tests/tdiv_2exp.c: use new libmpc-tests tests/tmul_fr.c: use new libmpc-tests tests/tadd_ui.c: use new libmpc-tests tests/tsqrt.c: use new libmpc-tests tests/ttanh.c: use new libmpc-tests tests/tfr_div.c: use new libmpc-tests tests/tnorm.c: use new libmpc-tests tests/tadd_fr.c: use new libmpc-tests tests/tfr_sub.c: use new libmpc-tests tests/tui_ui_sub.c: use new libmpc-tests tests/tmul_si.c: use new libmpc-tests tests/tdiv_ui.c: use new libmpc-tests tests/tlog.c: use new libmpc-tests tests/tdiv.c: use new libmpc-tests tests/ttan.c: use new libmpc-tests tests/tcos.c: use new libmpc-tests tests/tadd.c: use new libmpc-tests tests/tsin.c: use new libmpc-tests tests/tsub.c: use new libmpc-tests tests/tcosh.c: use new libmpc-tests tests/tmul.c: use new libmpc-tests tests/tabs.c: use new libmpc-tests tests/tsqr.c: use new libmpc-tests tests/tdiv_fr.c: use new libmpc-tests tests/tui_sub.c: removed because mpc_ui_sub is a macro. tests/abs.dat: new test file for mpc_abs. tests/Makefile.am: record previous changes. git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@258 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/ttan.c')
-rw-r--r--tests/ttan.c286
1 files changed, 6 insertions, 280 deletions
diff --git a/tests/ttan.c b/tests/ttan.c
index f021eac..d63a251 100644
--- a/tests/ttan.c
+++ b/tests/ttan.c
@@ -19,19 +19,10 @@ 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 <stdio.h>
#include <stdlib.h>
-#include "gmp.h"
-#include "mpfr.h"
-#include "mpc.h"
+#include "mpc-tests.h"
#include "mpc-impl.h"
-#include "random.c"
-#define TEST_FUNCTION mpc_tan
-#include "tgeneric_cc.c"
-
-#include "read_data_cc.c"
-
static void
test_failed (mpc_t op, mpc_t get, mpc_t expected)
{
@@ -43,272 +34,6 @@ test_failed (mpc_t op, mpc_t get, mpc_t expected)
exit (1);
}
-/* check special values as defined in C99 standard */
-static void
-special (void)
-{
- mpc_t z;
- mpc_t t;
- mpc_t c99;
-
- mpc_init (z);
- mpc_init (t);
- mpc_init (c99);
-
- /* tan(+Inf +i*Inf) = +/-0 +i */
- mpfr_set_inf (MPC_RE (z), +1);
- mpfr_set_inf (MPC_IM (z), +1);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_cmp_si (MPC_IM (t), +1) != 0)
- {
- mpfr_set_ui (MPC_RE(c99), 0, GMP_RNDN);
- mpfr_set_ui (MPC_IM(c99), 1, GMP_RNDN);
- test_failed (z, t, c99);
- }
-
- /* tan(+Inf -i*Inf) = +/-0 -i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_cmp_si (MPC_IM (t), -1) != 0)
- {
- mpfr_set_ui (MPC_RE(c99), 0, GMP_RNDN);
- mpfr_set_si (MPC_IM(c99), -1, GMP_RNDN);
- test_failed (z, t, c99);
- }
-
- /* tan(-Inf +i*Inf) = -/+0 +i */
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_cmp_si (MPC_IM (t), +1) != 0)
- {
- mpfr_set_ui (MPC_RE(c99), 0, GMP_RNDN);
- mpfr_set_si (MPC_IM(c99), -1, GMP_RNDN);
- mpc_neg (c99, c99, MPC_RNDNN);
- test_failed (z, t, c99);
- }
-
- /* tan(-Inf -i*Inf) = -/+0 -i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_cmp_si (MPC_IM (t), -1) != 0)
- {
- mpfr_set_ui (MPC_RE(c99), 0, GMP_RNDN);
- mpfr_set_ui (MPC_IM(c99), 1, GMP_RNDN);
- mpc_neg (c99, c99, MPC_RNDNN);
- test_failed (z, t, c99);
- }
-
- /* tan(-Inf +i*y) = NaN+i*NaN, when y is finite */
- /* tan(+Inf +i*y) = NaN+i*NaN, when y is finite */
- mpfr_set_si (MPC_IM (z), -1, GMP_RNDN);
- mpfr_set_nan (MPC_RE (c99));
- mpfr_set_nan (MPC_IM (c99));
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpfr_set_ui (MPC_IM (z), 0, GMP_RNDN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- /* tan(x +i*NaN) = NaN +i*NaN, when x is non zero */
- mpfr_set_inf (MPC_RE (z), +1);
- mpfr_set_nan (MPC_IM (z));
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpfr_set_ui (MPC_RE (z), 1, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- /* tan(NaN +i*NaN) = NaN +i*NaN */
- mpfr_set_nan (MPC_RE (z));
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- /* tan(NaN +i*y) = NaN +i*NaN, when y is finite */
- mpfr_set_ui (MPC_IM (z), -1, GMP_RNDN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpfr_set_ui (MPC_IM (z), 0, GMP_RNDN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_nan_p (MPC_RE (t)) || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, c99);
-
- /* tan (NaN -i*Inf) = +/-0 -i */
- mpfr_set_inf (MPC_IM (z), -1);
- mpc_set_si_si (c99, 0, -1, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_cmp_si (MPC_IM (t), -1) != 0)
- test_failed (z, t, c99);
-
- /* tan (NaN +i*Inf) = +/-0 +i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_conj (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_cmp_si (MPC_IM (t), +1) !=0)
- test_failed (z, t, c99);
-
- /* tan(+0 +i*NaN) = +0 +i*NaN */
- mpfr_set_ui (MPC_RE (z), 0, GMP_RNDN);
- mpfr_set_nan (MPC_IM (z));
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_signbit (MPC_RE (t))
- || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, z);
-
- /* tan(-0 +i*NaN) = -0 +i*NaN */
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (!mpfr_zero_p (MPC_RE (t)) || mpfr_signbit (MPC_RE (t)) == 0
- || !mpfr_nan_p (MPC_IM (t)))
- test_failed (z, t, z);
-
- /* tan(x -i*Inf) = 0*sin(2*x)-i */
- /* tan(x +i*Inf) = 0*sin(2*x)+i */
- /* tan(0.5 -i*Inf) = +0 -i */
- mpfr_set_ui_2exp (MPC_RE (z), 1, -1, GMP_RNDN);
- mpfr_set_inf (MPC_IM (z), -1);
- mpc_set_si_si (c99, 0, -1, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(0.5 +i*Inf) = +0 +i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_conj (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(-0.5 -i*Inf) = -0 -i */
- mpc_neg (z, z, MPC_RNDNN);
- mpc_neg (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(-0.5 +i*Inf) = -0 +i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_conj (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(+0 -i*Inf) = +0 -i */
- mpfr_set_ui (MPC_RE (z), 0, GMP_RNDN);
- mpc_conj (z, z, MPC_RNDNN);
- mpc_neg (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(+0 +i*Inf) = +0 +i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_conj (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(-0 -i*Inf) = -0 -i */
- mpc_neg (z, z, MPC_RNDNN);
- mpc_neg (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(-0 +i*Inf) = -0 +i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_conj (c99, c99, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, c99))
- test_failed (z, t, c99);
-
- /* tan(+0 +0*i) = +0 +0*i */
- mpc_set_ui_ui (z, 0, 0, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, z))
- test_failed (z, t, z);
-
- /* tan(+0 -0*i) = +0 -0*i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, z))
- test_failed (z, t, z);
-
- /* tan(-0 +0*i) = -0 +0*i */
- mpc_neg (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, z))
- test_failed (z, t, z);
-
- /* tan(-0 -0*i) = -0 -0*i */
- mpc_conj (z, z, MPC_RNDNN);
- mpc_tan (t, z, MPC_RNDNN);
- if (mpc_cmp (t, z))
- test_failed (z, t, z);
-
- mpc_clear (c99);
- mpc_clear (t);
- mpc_clear (z);
-}
-
static void
pure_real_argument (void)
{
@@ -534,14 +259,15 @@ check_53 (void)
int
main (void)
{
+ DECL_V_CC_FUNC (f, mpc_tan);
+
test_start ();
- data_check ("tan.dat");
- special ();
+ data_check (f, "tan.dat");
+ tgeneric (f, 2, 512, 7, 4);
+
pure_real_argument ();
pure_imaginary_argument ();
-
- tgeneric (2, 512, 7, 4);
check_53 ();
test_end ();