Commit 0c8fe7e2 authored by Daniel Kochmański's avatar Daniel Kochmański

cleanup: line breaks, dead code removal

parent 3766821b
......@@ -28,8 +28,6 @@
@(return num);
@)
#ifdef MATH_DISPATCH2_BEGIN
static cl_object
complex_divide(cl_object ar, cl_object ai, cl_object br, cl_object bi)
{
......@@ -174,152 +172,3 @@ ecl_divide(cl_object x, cl_object y)
}
MATH_DISPATCH2_END;
}
#else
cl_object
ecl_divide(cl_object x, cl_object y)
{
cl_object z, z1, z2;
switch (ecl_t_of(x)) {
case t_fixnum:
case t_bignum:
switch (ecl_t_of(y)) {
case t_fixnum:
if (y == ecl_make_fixnum(0))
FEdivision_by_zero(x, y);
case t_bignum:
if (ecl_minusp(y) == TRUE) {
x = ecl_negate(x);
y = ecl_negate(y);
}
return ecl_make_ratio(x, y);
case t_ratio:
z = ecl_times(x, y->ratio.den);
return ecl_make_ratio(z, y->ratio.num);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) / ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) / ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) / ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[/], 2, y, @[number]);
}
case t_ratio:
switch (ecl_t_of(y)) {
case t_fixnum:
if (y == ecl_make_fixnum(0))
FEdivision_by_zero(x, y);
case t_bignum:
z = ecl_times(x->ratio.den, y);
return ecl_make_ratio(x->ratio.num, z);
case t_ratio:
z = ecl_times(x->ratio.num,y->ratio.den);
z1 = ecl_times(x->ratio.den,y->ratio.num);
return ecl_make_ratio(z, z1);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) / ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) / ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) / ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[/], 2, y, @[number]);
}
case t_singlefloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_single_float(ecl_single_float(x) / ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_single_float(ecl_single_float(x) / ecl_to_double(y));
case t_singlefloat:
return ecl_make_single_float(ecl_single_float(x) / ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_single_float(x) / ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_single_float(x) / ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[/], 2, y, @[number]);
}
case t_doublefloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_double_float(ecl_double_float(x) / ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_double_float(ecl_double_float(x) / ecl_to_double(y));
case t_singlefloat:
return ecl_make_double_float(ecl_double_float(x) / ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_double_float(x) / ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_double_float(x) / ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[/], 2, y, @[number]);
}
#ifdef ECL_LONG_FLOAT
case t_longfloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_long_float(ecl_long_float(x) / ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_long_float(ecl_long_float(x) / ecl_to_double(y));
case t_singlefloat:
return ecl_make_long_float(ecl_long_float(x) / ecl_single_float(y));
case t_doublefloat:
return ecl_make_long_float(ecl_long_float(x) / ecl_double_float(y));
case t_longfloat:
return ecl_make_long_float(ecl_long_float(x) / ecl_long_float(y));
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[/], 2, y, @[number]);
}
#endif
case t_complex:
if (ecl_t_of(y) != t_complex) {
z1 = ecl_divide(x->complex.real, y);
z2 = ecl_divide(x->complex.imag, y);
return ecl_make_complex(z1, z2);
} else if (1) {
/* #C(z1 z2) = #C(xr xi) * #C(yr -yi) */
z1 = ecl_plus(ecl_times(x->complex.real, y->complex.real),
ecl_times(x->complex.imag, y->complex.imag));
z2 = ecl_minus(ecl_times(x->complex.imag, y->complex.real),
ecl_times(x->complex.real, y->complex.imag));
} else {
COMPLEX: /* INV: x is real, y is complex */
/* #C(z1 z2) = x * #C(yr -yi) */
z1 = ecl_times(x, y->complex.real);
z2 = ecl_negate(ecl_times(x, y->complex.imag));
}
z = ecl_plus(ecl_times(y->complex.real, y->complex.real),
ecl_times(y->complex.imag, y->complex.imag));
z = ecl_make_complex(ecl_divide(z1, z), ecl_divide(z2, z));
return(z);
default:
FEwrong_type_nth_arg(@[/], 1, x, @[number]);
}
}
#endif
......@@ -28,8 +28,6 @@
@(return diff);
@)
#ifdef MATH_DISPATCH2_BEGIN
cl_object
ecl_minus(cl_object x, cl_object y)
{
......@@ -173,163 +171,3 @@ ecl_minus(cl_object x, cl_object y)
}
MATH_DISPATCH2_END;
}
#else
cl_object
ecl_minus(cl_object x, cl_object y)
{
cl_fixnum i, j, k;
cl_object z, z1;
switch (ecl_t_of(x)) {
case t_fixnum:
switch(ecl_t_of(y)) {
case t_fixnum:
return ecl_make_integer(ecl_fixnum(x) - ecl_fixnum(y));
case t_bignum:
return _ecl_fix_minus_big(ecl_fixnum(x), y);
case t_ratio:
z = ecl_times(x, y->ratio.den);
z = ecl_minus(z, y->ratio.num);
return ecl_make_ratio(z, y->ratio.den);
case t_singlefloat:
return ecl_make_single_float(ecl_fixnum(x) - ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_fixnum(x) - ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_fixnum(x) - ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[-], 2, y, @[number]);
}
case t_bignum:
switch (ecl_t_of(y)) {
case t_fixnum:
return _ecl_big_plus_fix(x, -ecl_fixnum(y));
case t_bignum:
return _ecl_big_minus_big(x, y);
case t_ratio:
z = ecl_times(x, y->ratio.den);
z = ecl_minus(z, y->ratio.num);
return ecl_make_ratio(z, y->ratio.den);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) - ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) - ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) - ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[-], 2, y, @[number]);
}
case t_ratio:
switch (ecl_t_of(y)) {
case t_fixnum:
case t_bignum:
z = ecl_times(x->ratio.den, y);
z = ecl_minus(x->ratio.num, z);
return ecl_make_ratio(z, x->ratio.den);
case t_ratio:
z = ecl_times(x->ratio.num,y->ratio.den);
z1 = ecl_times(x->ratio.den,y->ratio.num);
z = ecl_minus(z, z1);
z1 = ecl_times(x->ratio.den,y->ratio.den);
return ecl_make_ratio(z, z1);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) - ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) - ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) - ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[-], 2, y, @[number]);
}
case t_singlefloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_single_float(ecl_single_float(x) - ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_single_float(ecl_single_float(x) - ecl_to_double(y));
case t_singlefloat:
return ecl_make_single_float(ecl_single_float(x) - ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_single_float(x) - ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_single_float(x) - ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[-], 2, y, @[number]);
}
case t_doublefloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_double_float(ecl_double_float(x) - ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_double_float(ecl_double_float(x) - ecl_to_double(y));
case t_singlefloat:
return ecl_make_double_float(ecl_double_float(x) - ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_double_float(x) - ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_double_float(x) - ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[-], 2, y, @[number]);
}
#ifdef ECL_LONG_FLOAT
case t_longfloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_long_float(ecl_long_float(x) - fix(y));
case t_bignum:
case t_ratio:
return ecl_make_long_float(ecl_long_float(x) - ecl_to_double(y));
case t_singlefloat:
return ecl_make_long_float(ecl_long_float(x) - ecl_single_float(y));
case t_doublefloat:
return ecl_make_long_float(ecl_long_float(x) - ecl_double_float(y));
case t_longfloat:
return ecl_make_long_float(ecl_long_float(x) - ecl_long_float(y));
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[-], 2, y, @[number]);
}
#endif
COMPLEX:
return ecl_make_complex(ecl_minus(x, y->complex.real),
ecl_negate(y->complex.imag));
case t_complex:
if (ecl_t_of(y) != t_complex) {
z = ecl_minus(x->complex.real, y);
z1 = x->complex.imag;
} else {
z = ecl_minus(x->complex.real, y->complex.real);
z1 = ecl_minus(x->complex.imag, y->complex.imag);
}
return ecl_make_complex(z, z1);
default:
FEwrong_type_nth_arg(@[-], 1, x, @[number]);
}
}
#endif
......@@ -25,8 +25,6 @@
@(return sum)
@)
#ifdef MATH_DISPATCH2_BEGIN
cl_object
ecl_plus(cl_object x, cl_object y)
{
......@@ -169,161 +167,3 @@ ecl_plus(cl_object x, cl_object y)
}
MATH_DISPATCH2_END;
}
#else
cl_object
ecl_plus(cl_object x, cl_object y)
{
cl_fixnum i, j;
cl_object z, z1;
switch (ecl_t_of(x)) {
case t_fixnum:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_integer(ecl_fixnum(x) + ecl_fixnum(y));
case t_bignum:
return _ecl_big_plus_fix(y, ecl_fixnum(x));
case t_ratio:
z = ecl_times(x, y->ratio.den);
z = ecl_plus(z, y->ratio.num);
return ecl_make_ratio(z, y->ratio.den);
case t_singlefloat:
return ecl_make_single_float(ecl_fixnum(x) + ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_fixnum(x) + ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_fixnum(x) + ecl_long_float(y));
#endif
case t_complex:
COMPLEX: /* INV: x is real, y is complex */
return ecl_make_complex(ecl_plus(x, y->complex.real),
y->complex.imag);
default:
FEwrong_type_nth_arg(@[+], 2, y, @[number]);
}
case t_bignum:
switch (ecl_t_of(y)) {
case t_fixnum:
return _ecl_big_plus_fix(x, ecl_fixnum(y));
case t_bignum:
return _ecl_big_plus_big(x, y);
case t_ratio:
z = ecl_times(x, y->ratio.den);
z = ecl_plus(z, y->ratio.num);
return ecl_make_ratio(z, y->ratio.den);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) + ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) + ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) + ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[+], 2, y, @[number]);
}
case t_ratio:
switch (ecl_t_of(y)) {
case t_fixnum:
case t_bignum:
z = ecl_times(x->ratio.den, y);
z = ecl_plus(x->ratio.num, z);
return ecl_make_ratio(z, x->ratio.den);
case t_ratio:
z1 = ecl_times(x->ratio.num,y->ratio.den);
z = ecl_times(x->ratio.den,y->ratio.num);
z = ecl_plus(z1, z);
z1 = ecl_times(x->ratio.den,y->ratio.den);
return ecl_make_ratio(z, z1);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) + ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) + ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) + ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[+], 2, y, @[number]);
}
case t_singlefloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_single_float(ecl_single_float(x) + ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_single_float(ecl_single_float(x) + ecl_to_double(y));
case t_singlefloat:
return ecl_make_single_float(ecl_single_float(x) + ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_single_float(x) + ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_single_float(x) + ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[+], 2, y, @[number]);
}
case t_doublefloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_double_float(ecl_double_float(x) + ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_double_float(ecl_double_float(x) + ecl_to_double(y));
case t_singlefloat:
return ecl_make_double_float(ecl_double_float(x) + ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_double_float(x) + ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_double_float(x) + ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[+], 2, y, @[number]);
}
#ifdef ECL_LONG_FLOAT
case t_longfloat:
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_long_float(ecl_long_float(x) + ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_long_float(ecl_long_float(x) + ecl_to_double(y));
case t_singlefloat:
return ecl_make_long_float(ecl_long_float(x) + ecl_single_float(y));
case t_doublefloat:
return ecl_make_long_float(ecl_long_float(x) + ecl_double_float(y));
case t_longfloat:
return ecl_make_long_float(ecl_long_float(x) + ecl_long_float(y));
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[+], 2, y, @[number]);
}
#endif
case t_complex:
if (ecl_t_of(y) != t_complex) {
cl_object aux = x;
x = y; y = aux;
goto COMPLEX;
}
z = ecl_plus(x->complex.real, y->complex.real);
z1 = ecl_plus(x->complex.imag, y->complex.imag);
return ecl_make_complex(z, z1);
default:
FEwrong_type_nth_arg(@[+], 1, x, @[number]);
}
}
#endif
......@@ -25,8 +25,6 @@
@(return prod);
@)
#ifdef MATH_DISPATCH2_BEGIN
cl_object
ecl_times(cl_object x, cl_object y)
{
......@@ -173,168 +171,3 @@ ecl_times(cl_object x, cl_object y)
}
MATH_DISPATCH2_END;
}
#else
cl_object
ecl_times(cl_object x, cl_object y)
{
cl_object z, z1;
switch (ecl_t_of(x)) {
case t_fixnum:
switch (ecl_t_of(y)) {
case t_fixnum:
return _ecl_fix_times_fix(ecl_fixnum(x),ecl_fixnum(y));
case t_bignum:
return _ecl_big_times_fix(y, ecl_fixnum(x));
case t_ratio:
z = ecl_times(x, y->ratio.num);
return ecl_make_ratio(z, y->ratio.den);
case t_singlefloat:
return ecl_make_single_float(ecl_fixnum(x) * ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_fixnum(x) * ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_fixnum(x) * ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[*], 2, y, @[number]);
}
case t_bignum:
switch (ecl_t_of(y)) {
case t_fixnum:
return _ecl_big_times_fix(x, ecl_fixnum(y));
case t_bignum:
return _ecl_big_times_big(x, y);
case t_ratio:
z = ecl_times(x, y->ratio.num);
return ecl_make_ratio(z, y->ratio.den);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) * ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) * ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) * ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[*], 2, y, @[number]);
}
case t_ratio:
switch (ecl_t_of(y)) {
case t_fixnum:
case t_bignum:
z = ecl_times(x->ratio.num, y);
return ecl_make_ratio(z, x->ratio.den);
case t_ratio:
z = ecl_times(x->ratio.num,y->ratio.num);
z1 = ecl_times(x->ratio.den,y->ratio.den);
return ecl_make_ratio(z, z1);
case t_singlefloat:
return ecl_make_single_float(ecl_to_double(x) * ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_to_double(x) * ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_to_double(x) * ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[*], 2, y, @[number]);
}
case t_singlefloat: {
float fx = ecl_single_float(x);
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_single_float(fx * ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_single_float(fx * ecl_to_double(y));
case t_singlefloat:
return ecl_make_single_float(fx * ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(fx * ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(fx * ecl_long_float(y));
#endif
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[*], 2, y, @[number]);
}
}
case t_doublefloat: {
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_double_float(ecl_double_float(x) * ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_double_float(ecl_double_float(x) * ecl_to_double(y));
case t_singlefloat:
return ecl_make_double_float(ecl_double_float(x) * ecl_single_float(y));
case t_doublefloat:
return ecl_make_double_float(ecl_double_float(x) * ecl_double_float(y));
#ifdef ECL_LONG_FLOAT
case t_longfloat:
return ecl_make_long_float(ecl_double_float(x) * ecl_long_float(y));
#endif
case t_complex: {
COMPLEX: /* INV: x is real, y is complex */
return ecl_make_complex(ecl_times(x, y->complex.real),
ecl_times(x, y->complex.imag));
}
default:
FEwrong_type_nth_arg(@[*], 2, y, @[number]);
}
}
#ifdef ECL_LONG_FLOAT
case t_longfloat: {
long double lx = ecl_long_float(x);
switch (ecl_t_of(y)) {
case t_fixnum:
return ecl_make_long_float(lx * ecl_fixnum(y));
case t_bignum:
case t_ratio:
return ecl_make_long_float(lx * ecl_to_double(y));
case t_singlefloat:
return ecl_make_long_float(lx * ecl_single_float(y));
case t_doublefloat:
return ecl_make_long_float(lx * ecl_double_float(y));
case t_longfloat:
return ecl_make_long_float(lx * ecl_long_float(y));
case t_complex:
goto COMPLEX;
default:
FEwrong_type_nth_arg(@[*], 2, y, @[number]);
}
}
#endif
case t_complex:
{
cl_object z11, z12, z21, z22;
if (ecl_t_of(y) != t_complex) {
cl_object aux = x;
x = y; y = aux;
goto COMPLEX;
}
z11 = ecl_times(x->complex.real, y->complex.real);
z12 = ecl_times(x->complex.imag, y->complex.imag);
z21 = ecl_times(x->complex.imag, y->complex.real);
z22 = ecl_times(x->complex.real, y->complex.imag);
return ecl_make_complex(ecl_minus(z11, z12), ecl_plus(z21, z22));
}
default:
FEwrong_type_nth_arg(@[*], 1, x, @[number]);
}
}
#endif
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