mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Very basic comparison functionality for complex nums
This commit is contained in:
parent
ea8a09f184
commit
9c64faa3df
2 changed files with 13 additions and 0 deletions
|
@ -728,6 +728,9 @@ typedef struct {
|
||||||
/** Access a bignum's `mp_int` directly */
|
/** Access a bignum's `mp_int` directly */
|
||||||
#define bignum_value(x) (((bignum_type *) x)->bn)
|
#define bignum_value(x) (((bignum_type *) x)->bn)
|
||||||
|
|
||||||
|
/** Access the complex number directly */
|
||||||
|
#define complex_num_value(x) (((complex_num_type *) x)->value)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This enumeration complements the comparison types from LibTomMath,
|
* This enumeration complements the comparison types from LibTomMath,
|
||||||
* and provides constants for each of the comparison operators.
|
* and provides constants for each of the comparison operators.
|
||||||
|
|
10
runtime.c
10
runtime.c
|
@ -1434,6 +1434,10 @@ int FUNC_OP(void *data, object x, object y) { \
|
||||||
result = Cyc_bignum_cmp(BN_CMP, x, tx, y, ty); \
|
result = Cyc_bignum_cmp(BN_CMP, x, tx, y, ty); \
|
||||||
} else if (tx == double_tag && ty == bignum_tag) { \
|
} else if (tx == double_tag && ty == bignum_tag) { \
|
||||||
result = (double_value(x)) OP mp_get_double(&bignum_value(y)); \
|
result = (double_value(x)) OP mp_get_double(&bignum_value(y)); \
|
||||||
|
} else if (tx == complex_num_tag && ty == complex_num_tag) { \
|
||||||
|
result = (complex_num_value(x)) == (complex_num_value(y)); \
|
||||||
|
} else if (tx == complex_num_tag && ty != complex_num_tag) { \
|
||||||
|
} else if (tx != complex_num_tag && ty == complex_num_tag) { \
|
||||||
} else { \
|
} else { \
|
||||||
make_string(s, "Bad argument type"); \
|
make_string(s, "Bad argument type"); \
|
||||||
make_pair(c1, y, NULL); \
|
make_pair(c1, y, NULL); \
|
||||||
|
@ -1511,6 +1515,12 @@ object FUNC_FAST_OP(void *data, object x, object y) { \
|
||||||
return Cyc_bignum_cmp(BN_CMP, x, tx, y, ty) ? boolean_t : boolean_f; \
|
return Cyc_bignum_cmp(BN_CMP, x, tx, y, ty) ? boolean_t : boolean_f; \
|
||||||
} else if (tx == double_tag && ty == bignum_tag) { \
|
} else if (tx == double_tag && ty == bignum_tag) { \
|
||||||
return (double_value(x)) OP mp_get_double(&bignum_value(x)) ? boolean_t : boolean_f; \
|
return (double_value(x)) OP mp_get_double(&bignum_value(x)) ? boolean_t : boolean_f; \
|
||||||
|
} else if (tx == complex_num_tag && ty == complex_num_tag) { \
|
||||||
|
return ((complex_num_value(x)) == (complex_num_value(y))) ? boolean_t : boolean_f; \
|
||||||
|
} else if (tx == complex_num_tag && ty != complex_num_tag) { \
|
||||||
|
return boolean_f; \
|
||||||
|
} else if (tx != complex_num_tag && ty == complex_num_tag) { \
|
||||||
|
return boolean_f; \
|
||||||
} else { \
|
} else { \
|
||||||
goto bad_arg_type_error; \
|
goto bad_arg_type_error; \
|
||||||
} \
|
} \
|
||||||
|
|
Loading…
Add table
Reference in a new issue