Commit fdc40520 authored by Daniel Kochmański's avatar Daniel Kochmański

complex float: extend math_dispatch macros and add appropriate stubs

parent a0a92dc2
......@@ -102,4 +102,5 @@ ecl_abs_complex(cl_object x)
MATH_DEF_DISPATCH1_NE(abs, @[abs], @[number],
ecl_abs_fixnum, ecl_abs_bignum, ecl_abs_rational,
ecl_abs_single_float, ecl_abs_double_float, ecl_abs_long_float,
ecl_abs_complex);
ecl_abs_complex,
/* implementme */ absfailed, absfailed, absfailed);
......@@ -37,4 +37,5 @@ MATH_DEF_DISPATCH1_NE(conjugate, @[conjugate], @[number],
ecl_conjugate_real, ecl_conjugate_real, ecl_conjugate_real,
ecl_conjugate_real, ecl_conjugate_real,
ecl_conjugate_real,
ecl_conjugate_complex);
ecl_conjugate_complex,
/* implementme */ conjugatefailed, conjugatefailed, conjugatefailed);
......@@ -67,4 +67,5 @@ ecl_cos_complex(cl_object x)
MATH_DEF_DISPATCH1(cos, @[cos], @[number],
ecl_cos_rational, ecl_cos_rational, ecl_cos_rational,
ecl_cos_single_float, ecl_cos_double_float, ecl_cos_long_float,
ecl_cos_complex);
ecl_cos_complex,
/* implementme */ cos_nefailed, cos_nefailed, cos_nefailed);
......@@ -70,4 +70,5 @@ ecl_cosh_complex(cl_object x)
MATH_DEF_DISPATCH1(cosh, @[cosh], @[number],
ecl_cosh_rational, ecl_cosh_rational, ecl_cosh_rational,
ecl_cosh_single_float, ecl_cosh_double_float, ecl_cosh_long_float,
ecl_cosh_complex);
ecl_cosh_complex,
/* implementme */ cosh_nefailed, cosh_nefailed, cosh_nefailed);
......@@ -66,4 +66,5 @@ ecl_exp_complex(cl_object x)
MATH_DEF_DISPATCH1(exp, @[exp], @[number],
ecl_exp_rational, ecl_exp_rational, ecl_exp_rational,
ecl_exp_single_float, ecl_exp_double_float, ecl_exp_long_float,
ecl_exp_complex);
ecl_exp_complex,
/* implementme */ exp_nefailed, exp_nefailed, exp_nefailed);
......@@ -20,8 +20,6 @@
#include <ecl/impl/math_fenv.h>
#include <ecl/impl/math_dispatch.h>
#include <stdlib.h> /* for abort() */
#pragma STDC FENV_ACCESS ON
cl_fixnum
......@@ -81,7 +79,8 @@ expt_zero(cl_object x, cl_object y)
return ecl_make_complex(z, ecl_make_fixnum(0));
default:
/* We will never reach this */
abort();
if (ty > tx) FEwrong_type_nth_arg(@[expt], 1, x, @[number]);
else FEwrong_type_nth_arg(@[expt], 2, y, @[number]);
}
}
......
......@@ -107,7 +107,8 @@ ecl_log1_complex(cl_object x)
MATH_DEF_DISPATCH1(log1, @[log], @[number],
ecl_log1_rational, ecl_log1_bignum, ecl_log1_rational,
ecl_log1_single_float, ecl_log1_double_float, ecl_log1_long_float,
ecl_log1_complex);
ecl_log1_complex,
/* implementme */ log1_nefailed, log1_nefailed, log1_nefailed);
cl_object
ecl_log2(cl_object x, cl_object y)
......@@ -221,4 +222,5 @@ ecl_log1p_complex(cl_object x)
MATH_DEF_DISPATCH1(log1p, @[si::log1p], @[number],
ecl_log1p_rational, ecl_log1p_simple, ecl_log1p_rational,
ecl_log1p_single_float, ecl_log1p_double_float, ecl_log1p_long_float,
ecl_log1p_complex);
ecl_log1p_complex,
/* implementme */ log1p_nefailed, log1p_nefailed, log1p_nefailed);
......@@ -62,4 +62,5 @@ MATH_DEF_DISPATCH1_BOOL(minusp, @[minusp], @[real],
ecl_minusp_fixnum, ecl_minusp_big, ecl_minusp_ratio,
ecl_minusp_single_float, ecl_minusp_double_float,
ecl_minusp_long_float,
minuspfailed)
minuspfailed,
minuspfailed, minuspfailed, minuspfailed)
......@@ -64,4 +64,5 @@ MATH_DEF_DISPATCH1_NE(negate, @[-], @[number],
ecl_negate_fix, ecl_negate_big, ecl_negate_ratio,
ecl_negate_single_float, ecl_negate_double_float,
ecl_negate_long_float,
ecl_negate_complex);
ecl_negate_complex,
/* implementme */ negatefailed, negatefailed, negatefailed);
......@@ -67,7 +67,8 @@ MATH_DEF_DISPATCH1_NE(one_minus, @[1-], @[number],
ecl_one_minus_fix, ecl_one_minus_big, ecl_one_minus_ratio,
ecl_one_minus_single_float, ecl_one_minus_double_float,
ecl_one_minus_long_float,
ecl_one_minus_complex);
ecl_one_minus_complex,
/* implementme */ one_minusfailed, one_minusfailed, one_minusfailed);
/* (1- x) */
cl_object
......
......@@ -67,7 +67,8 @@ MATH_DEF_DISPATCH1_NE(one_plus, @[1+], @[number],
ecl_one_plus_fix, ecl_one_plus_big, ecl_one_plus_ratio,
ecl_one_plus_single_float, ecl_one_plus_double_float,
ecl_one_plus_long_float,
ecl_one_plus_complex);
ecl_one_plus_complex,
/* implementme */ one_plusfailed, one_plusfailed, one_plusfailed);
/* (1+ x) */
cl_object
......
......@@ -63,4 +63,5 @@ MATH_DEF_DISPATCH1_BOOL(plusp, @[plusp], @[real],
ecl_plusp_fixnum, ecl_plusp_big, ecl_plusp_ratio,
ecl_plusp_single_float, ecl_plusp_double_float,
ecl_plusp_long_float,
pluspfailed)
pluspfailed,
/* implementme*/ pluspfailed, pluspfailed, pluspfailed)
......@@ -70,4 +70,5 @@ ecl_sin_complex(cl_object x)
MATH_DEF_DISPATCH1(sin, @[sin], @[number],
ecl_sin_rational, ecl_sin_rational, ecl_sin_rational,
ecl_sin_single_float, ecl_sin_double_float, ecl_sin_long_float,
ecl_sin_complex);
ecl_sin_complex,
/* implementme */ sin_nefailed, sin_nefailed, sin_nefailed);
......@@ -71,4 +71,5 @@ ecl_sinh_complex(cl_object x)
MATH_DEF_DISPATCH1(sinh, @[sinh], @[number],
ecl_sinh_rational, ecl_sinh_rational, ecl_sinh_rational,
ecl_sinh_single_float, ecl_sinh_double_float, ecl_sinh_long_float,
ecl_sinh_complex);
ecl_sinh_complex,
/* implementme */ sinh_nefailed, sinh_nefailed, sinh_nefailed);
......@@ -84,4 +84,5 @@ ecl_sqrt_complex(cl_object x)
MATH_DEF_DISPATCH1(sqrt, @[sqrt], @[number],
ecl_sqrt_rational, ecl_sqrt_rational, ecl_sqrt_rational,
ecl_sqrt_single_float, ecl_sqrt_double_float, ecl_sqrt_long_float,
ecl_sqrt_complex);
ecl_sqrt_complex,
/* implementme */ sqrt_nefailed, sqrt_nefailed, sqrt_nefailed);
......@@ -77,4 +77,5 @@ ecl_tan_complex(cl_object x)
MATH_DEF_DISPATCH1(tan, @[tan], @[number],
ecl_tan_rational, ecl_tan_rational, ecl_tan_rational,
ecl_tan_single_float, ecl_tan_double_float, ecl_tan_long_float,
ecl_tan_complex);
ecl_tan_complex,
/* implementme */ tan_nefailed, tan_nefailed, tan_nefailed);
......@@ -63,4 +63,5 @@ ecl_tanh_complex(cl_object x)
MATH_DEF_DISPATCH1(tanh, @[tanh], @[number],
ecl_tanh_rational, ecl_tanh_rational, ecl_tanh_rational,
ecl_tanh_single_float, ecl_tanh_double_float, ecl_tanh_long_float,
ecl_tanh_complex);
ecl_tanh_complex,
/* implementme */ tanh_nefailed, tanh_nefailed, tanh_nefailed);
......@@ -63,4 +63,5 @@ MATH_DEF_DISPATCH1_BOOL(zerop, @[zerop], @[number],
ecl_zerop_fixnum, ecl_zerop_ratio, ecl_zerop_ratio,
ecl_zerop_single_float, ecl_zerop_double_float,
ecl_zerop_long_float,
ecl_zerop_complex)
ecl_zerop_complex,
/* implementme */ zeropfailed, zeropfailed, zeropfailed)
......@@ -28,29 +28,44 @@ typedef cl_object (*math_one_arg_fn)(cl_object);
#else
#define MATH_LONG_DOUBLE(opt)
#endif
#define MATH_DEF_DISPATCH1_NE(name,id,type,fix,big,ratio,single_float,double_float,long_float,complex) \
#ifdef ECL_COMPLEX_FLOAT
#define MATH_CFLOAT(c1,c2,c3) c1, c2, c3
#else
#define MATH_CFLOAT(c1,c2,c3)
#endif
#define MATH_DEF_DISPATCH1_NE(name,id,type,fix,big,ratio, \
single_float,double_float,long_float, \
complex,csfloat,cdfloat,clfloat) \
static cl_object name##failed(cl_object x) { \
FEwrong_type_only_arg(id, x, type); \
} \
static const math_one_arg_fn name##dispatch[t_complex+1]= { \
name##failed, /* t_start */ \
name##failed, /* t_list */ \
name##failed, /* t_character */ \
fix, big, ratio, /* t_fixnum, bignum, ratio */ \
single_float, double_float, /* t_singlefloat, t_doublefloat */ \
MATH_LONG_DOUBLE(long_float) /* t_longfloat, optional */ \
complex }; \
static const math_one_arg_fn name##dispatch[t_last_number+1]= { \
name##failed, /* t_start */ \
name##failed, /* t_list */ \
name##failed, /* t_character */ \
fix, big, ratio, /* t_fixnum, t_bignum, t_ratio */ \
single_float, /* t_singlefloat */ \
double_float, /* t_doublefloat */ \
MATH_LONG_DOUBLE(long_float) /* t_longfloat */ \
complex, /* t_complex */ \
MATH_CFLOAT(csfloat,cdfloat,clfloat) /* t_c?float */ }; \
cl_object ecl_##name(cl_object arg) \
{ \
int t = ECL_IMMEDIATE(arg); \
int t = ECL_IMMEDIATE(arg); \
if (t == 0) { \
t = arg->d.t; \
unlikely_if (t > t_complex) return name##failed(arg); \
unlikely_if (t > t_last_number) return name##failed(arg); \
} \
return name##dispatch[t](arg); \
}
#define MATH_DEF_DISPATCH1(name,id,type,fix,big,ratio,single_float,double_float,long_float,complex) \
MATH_DEF_DISPATCH1_NE(name##_ne,id,type,fix,big,ratio,single_float,double_float,long_float,complex) \
#define MATH_DEF_DISPATCH1(name,id,type,fix,big,ratio, \
single_float,double_float,long_float, \
complex,csfloat,cdfloat,clfloat) \
MATH_DEF_DISPATCH1_NE(name##_ne,id,type,fix,big,ratio, \
single_float,double_float,long_float, \
complex,csfloat,cdfloat,clfloat) \
cl_object ecl_##name(cl_object arg) \
{ \
cl_object out; \
......@@ -61,24 +76,28 @@ typedef cl_object (*math_one_arg_fn)(cl_object);
}
typedef int (*math_one_arg_bool_fn)(cl_object);
#define MATH_DEF_DISPATCH1_BOOL(name,id,type,fix,big,ratio,single_float,double_float,long_float,complex) \
#define MATH_DEF_DISPATCH1_BOOL(name,id,type,fix,big,ratio, \
single_float,double_float,long_float, \
complex,csfloat,cdfloat,clfloat) \
static int name##failed(cl_object x) { \
FEwrong_type_only_arg(id, x, type); \
} \
static const math_one_arg_bool_fn name##dispatch[t_complex+1]= { \
name##failed, /* t_start */ \
name##failed, /* t_list */ \
name##failed, /* t_character */ \
fix, big, ratio, /* t_fixnum, bignum, ratio */ \
single_float, double_float, /* t_singlefloat, t_doublefloat */ \
MATH_LONG_DOUBLE(long_float) /* t_longfloat, optional */ \
complex }; \
static const math_one_arg_bool_fn name##dispatch[t_last_number+1]= {\
name##failed, /* t_start */ \
name##failed, /* t_list */ \
name##failed, /* t_character */ \
fix, big, ratio, /* t_fixnum, t_bignum, t_ratio */ \
single_float, /* t_singlefloat */ \
double_float, /* t_doublefloat */ \
MATH_LONG_DOUBLE(long_float) /* t_longfloat */ \
complex, /* t_complex */ \
MATH_CFLOAT(csfloat,cdfloat,clfloat) /* t_c?float */ }; \
int ecl_##name(cl_object arg) \
{ \
int t = ECL_IMMEDIATE(arg); \
int t = ECL_IMMEDIATE(arg); \
if (t == 0) { \
t = arg->d.t; \
unlikely_if (t > t_complex) return name##failed(arg); \
unlikely_if (t > t_last_number) return name##failed(arg); \
} \
return name##dispatch[t](arg); \
}
......
......@@ -20,13 +20,76 @@
#include <ecl/internal.h> /* for unlikely_if */
#define MATH_DISPATCH2_LABEL(t1,t2) case ((t1)*(t_complex+1)+(t2)):
#define MATH_DISPATCH2_LABEL(t1,t2) case ((t1)*(t_last_number+1)+(t2)):
#define MATH_DISPATCH2_BEGIN(x,y) { \
int tx = ecl_t_of(x), ty = ecl_t_of(y); \
unlikely_if (ty > t_complex) { goto DISPATCH2_ERROR; } \
switch (tx * (t_complex+1) + ty)
unlikely_if (ty > t_last_number) { goto DISPATCH2_ERROR; } \
switch (tx * (t_last_number+1) + ty)
#define MATH_DISPATCH2_END } (void)0
#define CASE_CLFLOAT_FIXNUM \
MATH_DISPATCH2_LABEL(t_clfloat,t_fixnum)
#define CASE_CLFLOAT_BIGNUM \
MATH_DISPATCH2_LABEL(t_clfloat,t_bignum)
#define CASE_CLFLOAT_RATIO \
MATH_DISPATCH2_LABEL(t_clfloat,t_ratio)
#define CASE_CLFLOAT_SINGLE_FLOAT \
MATH_DISPATCH2_LABEL(t_clfloat,t_singlefloat)
#define CASE_CLFLOAT_DOUBLE_FLOAT \
MATH_DISPATCH2_LABEL(t_clfloat,t_doublefloat)
#define CASE_CLFLOAT_LONG_FLOAT \
MATH_DISPATCH2_LABEL(t_clfloat,t_longfloat)
#define CASE_CLFLOAT_COMPLEX \
MATH_DISPATCH2_LABEL(t_clfloat,t_complex)
#define CASE_CLFLOAT_CSFLOAT \
MATH_DISPATCH2_LABEL(t_clfloat,t_csfloat)
#define CASE_CLFLOAT_CDFLOAT \
MATH_DISPATCH2_LABEL(t_clfloat,t_cdfloat)
#define CASE_CLFLOAT_CLFLOAT \
MATH_DISPATCH2_LABEL(t_clfloat,t_clfloat)
#define CASE_CDFLOAT_FIXNUM \
MATH_DISPATCH2_LABEL(t_cdfloat,t_fixnum)
#define CASE_CDFLOAT_BIGNUM \
MATH_DISPATCH2_LABEL(t_cdfloat,t_bignum)
#define CASE_CDFLOAT_RATIO \
MATH_DISPATCH2_LABEL(t_cdfloat,t_ratio)
#define CASE_CDFLOAT_SINGLE_FLOAT \
MATH_DISPATCH2_LABEL(t_cdfloat,t_singlefloat)
#define CASE_CDFLOAT_DOUBLE_FLOAT \
MATH_DISPATCH2_LABEL(t_cdfloat,t_doublefloat)
#define CASE_CDFLOAT_LONG_FLOAT \
MATH_DISPATCH2_LABEL(t_cdfloat,t_longfloat)
#define CASE_CDFLOAT_COMPLEX \
MATH_DISPATCH2_LABEL(t_cdfloat,t_complex)
#define CASE_CDFLOAT_CSFLOAT \
MATH_DISPATCH2_LABEL(t_cdfloat,t_csfloat)
#define CASE_CDFLOAT_CDFLOAT \
MATH_DISPATCH2_LABEL(t_cdfloat,t_cdfloat)
#define CASE_CDFLOAT_CLFLOAT \
MATH_DISPATCH2_LABEL(t_cdfloat,t_clfloat)
#define CASE_CSFLOAT_FIXNUM \
MATH_DISPATCH2_LABEL(t_csfloat,t_fixnum)
#define CASE_CSFLOAT_BIGNUM \
MATH_DISPATCH2_LABEL(t_csfloat,t_bignum)
#define CASE_CSFLOAT_RATIO \
MATH_DISPATCH2_LABEL(t_csfloat,t_ratio)
#define CASE_CSFLOAT_SINGLE_FLOAT \
MATH_DISPATCH2_LABEL(t_csfloat,t_singlefloat)
#define CASE_CSFLOAT_DOUBLE_FLOAT \
MATH_DISPATCH2_LABEL(t_csfloat,t_doublefloat)
#define CASE_CSFLOAT_LONG_FLOAT \
MATH_DISPATCH2_LABEL(t_csfloat,t_longfloat)
#define CASE_CSFLOAT_COMPLEX \
MATH_DISPATCH2_LABEL(t_csfloat,t_complex)
#define CASE_CSFLOAT_CSFLOAT \
MATH_DISPATCH2_LABEL(t_csfloat,t_csfloat)
#define CASE_CSFLOAT_CDFLOAT \
MATH_DISPATCH2_LABEL(t_csfloat,t_cdfloat)
#define CASE_CSFLOAT_CLFLOAT \
MATH_DISPATCH2_LABEL(t_csfloat,t_clfloat)
#define CASE_COMPLEX_FIXNUM \
MATH_DISPATCH2_LABEL(t_complex,t_fixnum)
#define CASE_COMPLEX_BIGNUM \
......@@ -41,6 +104,12 @@
MATH_DISPATCH2_LABEL(t_complex,t_longfloat)
#define CASE_COMPLEX_COMPLEX \
MATH_DISPATCH2_LABEL(t_complex,t_complex)
#define CASE_COMPLEX_CSFLOAT \
MATH_DISPATCH2_LABEL(t_complex,t_csfloat)
#define CASE_COMPLEX_CDFLOAT \
MATH_DISPATCH2_LABEL(t_complex,t_cdfloat)
#define CASE_COMPLEX_CLFLOAT \
MATH_DISPATCH2_LABEL(t_complex,t_clfloat)
#define CASE_LONG_FLOAT_FIXNUM \
MATH_DISPATCH2_LABEL(t_longfloat,t_fixnum)
......@@ -56,6 +125,12 @@
MATH_DISPATCH2_LABEL(t_longfloat,t_longfloat)
#define CASE_LONG_FLOAT_COMPLEX \
MATH_DISPATCH2_LABEL(t_longfloat,t_complex)
#define CASE_LONG_FLOAT_CSFLOAT \
MATH_DISPATCH2_LABEL(t_longfloat,t_csfloat)
#define CASE_LONG_FLOAT_CDFLOAT \
MATH_DISPATCH2_LABEL(t_longfloat,t_cdfloat)
#define CASE_LONG_FLOAT_CLFLOAT \
MATH_DISPATCH2_LABEL(t_longfloat,t_clfloat)
#define CASE_DOUBLE_FLOAT_FIXNUM \
MATH_DISPATCH2_LABEL(t_doublefloat,t_fixnum)
......@@ -71,6 +146,12 @@
MATH_DISPATCH2_LABEL(t_doublefloat,t_longfloat)
#define CASE_DOUBLE_FLOAT_COMPLEX \
MATH_DISPATCH2_LABEL(t_doublefloat,t_complex)
#define CASE_DOUBLE_FLOAT_CSFLOAT \
MATH_DISPATCH2_LABEL(t_doublefloat,t_csfloat)
#define CASE_DOUBLE_FLOAT_CDFLOAT \
MATH_DISPATCH2_LABEL(t_doublefloat,t_cdfloat)
#define CASE_DOUBLE_FLOAT_CLFLOAT \
MATH_DISPATCH2_LABEL(t_doublefloat,t_clfloat)
#define CASE_SINGLE_FLOAT_FIXNUM \
MATH_DISPATCH2_LABEL(t_singlefloat,t_fixnum)
......@@ -86,6 +167,12 @@
MATH_DISPATCH2_LABEL(t_singlefloat,t_longfloat)
#define CASE_SINGLE_FLOAT_COMPLEX \
MATH_DISPATCH2_LABEL(t_singlefloat,t_complex)
#define CASE_SINGLE_FLOAT_CSFLOAT \
MATH_DISPATCH2_LABEL(t_singlefloat,t_csfloat)
#define CASE_SINGLE_FLOAT_CDFLOAT \
MATH_DISPATCH2_LABEL(t_singlefloat,t_cdfloat)
#define CASE_SINGLE_FLOAT_CLFLOAT \
MATH_DISPATCH2_LABEL(t_singlefloat,t_clfloat)
#define CASE_RATIO_FIXNUM \
MATH_DISPATCH2_LABEL(t_ratio,t_fixnum)
......@@ -101,6 +188,12 @@
MATH_DISPATCH2_LABEL(t_ratio,t_longfloat)
#define CASE_RATIO_COMPLEX \
MATH_DISPATCH2_LABEL(t_ratio,t_complex)
#define CASE_RATIO_CSFLOAT \
MATH_DISPATCH2_LABEL(t_ratio,t_csfloat)
#define CASE_RATIO_CDFLOAT \
MATH_DISPATCH2_LABEL(t_ratio,t_cdfloat)
#define CASE_RATIO_CLFLOAT \
MATH_DISPATCH2_LABEL(t_ratio,t_clfloat)
#define CASE_BIGNUM_FIXNUM \
MATH_DISPATCH2_LABEL(t_bignum,t_fixnum)
......@@ -116,6 +209,12 @@
MATH_DISPATCH2_LABEL(t_bignum,t_longfloat)
#define CASE_BIGNUM_COMPLEX \
MATH_DISPATCH2_LABEL(t_bignum,t_complex)
#define CASE_BIGNUM_CSFLOAT \
MATH_DISPATCH2_LABEL(t_bignum,t_csfloat)
#define CASE_BIGNUM_CDFLOAT \
MATH_DISPATCH2_LABEL(t_bignum,t_cdfloat)
#define CASE_BIGNUM_CLFLOAT \
MATH_DISPATCH2_LABEL(t_bignum,t_clfloat)
#define CASE_FIXNUM_FIXNUM \
MATH_DISPATCH2_LABEL(t_fixnum,t_fixnum)
......@@ -131,6 +230,13 @@
MATH_DISPATCH2_LABEL(t_fixnum,t_longfloat)
#define CASE_FIXNUM_COMPLEX \
MATH_DISPATCH2_LABEL(t_fixnum,t_complex)
#define CASE_FIXNUM_CSFLOAT \
MATH_DISPATCH2_LABEL(t_fixnum,t_csfloat)
#define CASE_FIXNUM_CDFLOAT \
MATH_DISPATCH2_LABEL(t_fixnum,t_cdfloat)
#define CASE_FIXNUM_CLFLOAT \
MATH_DISPATCH2_LABEL(t_fixnum,t_clfloat)
#define CASE_UNKNOWN(routine,x,y,type) \
default: DISPATCH2_ERROR: \
if (!ecl_numberp(x)) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment