mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-15 09:20:23 -07:00
Use static constants for rational and complexes
This commit is contained in:
parent
fe56a0c5a9
commit
445d269d6e
3 changed files with 30 additions and 6 deletions
|
|
@ -405,7 +405,7 @@ cl_sqrt(cl_object x)
|
|||
FEwrong_type_only_arg(@[sqrt], x, @[number]);
|
||||
}
|
||||
if (tx == t_complex) {
|
||||
z = ecl_make_ratio(MAKE_FIXNUM(1), MAKE_FIXNUM(2));
|
||||
z = cl_core.plus_half;
|
||||
z = cl_expt(x, z);
|
||||
} else if (ecl_minusp(x)) {
|
||||
z = ecl_make_complex(MAKE_FIXNUM(0), cl_sqrt(ecl_negate(x)));
|
||||
|
|
|
|||
|
|
@ -1011,6 +1011,12 @@ ecl_def_ct_long_float(ldbl_zero,0,static,const);
|
|||
ecl_def_ct_long_float(ldbl_zero_neg,-0.0l,static,const);
|
||||
#endif
|
||||
|
||||
ecl_def_ct_ratio(plus_half,MAKE_FIXNUM(1),MAKE_FIXNUM(2),static,const);
|
||||
ecl_def_ct_ratio(minus_half,MAKE_FIXNUM(-1),MAKE_FIXNUM(2),static,const);
|
||||
ecl_def_ct_complex(flt_imag_unit,&flt_zerodata,&flt_onedata,static,const);
|
||||
ecl_def_ct_complex(flt_imag_unit_neg,&flt_zerodata,&flt_one_negdata,static,const);
|
||||
ecl_def_ct_complex(flt_imag_two,&flt_zerodata,&flt_twodata,static,const);
|
||||
|
||||
#ifdef ECL_LONG_FLOAT
|
||||
ecl_def_ct_long_float(float_pi,ECL_PI_L,static,const);
|
||||
#else
|
||||
|
|
@ -1092,11 +1098,11 @@ init_number(void)
|
|||
cl_core.longfloat_minus_zero = cl_core.longfloat_zero;
|
||||
# endif
|
||||
#endif
|
||||
cl_core.plus_half = ecl_make_ratio(MAKE_FIXNUM(1), MAKE_FIXNUM(2));
|
||||
cl_core.minus_half = ecl_make_ratio(MAKE_FIXNUM(-1), MAKE_FIXNUM(2));
|
||||
cl_core.imag_unit = ecl_make_complex(flt_zero, flt_one);
|
||||
cl_core.minus_imag_unit = ecl_make_complex(flt_zero, flt_one_neg);
|
||||
cl_core.imag_two = ecl_make_complex(flt_zero, flt_two);
|
||||
cl_core.plus_half = plus_half; /* ecl_make_ratio(MAKE_FIXNUM(1), MAKE_FIXNUM(2)); */
|
||||
cl_core.minus_half = minus_half; /* ecl_make_ratio(MAKE_FIXNUM(-1), MAKE_FIXNUM(2)); */
|
||||
cl_core.imag_unit = flt_imag_unit; /* ecl_make_complex(flt_zero, flt_one); */
|
||||
cl_core.minus_imag_unit = flt_imag_unit_neg; /* ecl_make_complex(flt_zero, flt_one_neg); */
|
||||
cl_core.imag_two = flt_imag_two; /* ecl_make_complex(flt_zero, flt_two);*/
|
||||
|
||||
ECL_SET(@'pi', float_pi);
|
||||
ECL_SET(@'*random-state*', ecl_make_random_state(Ct));
|
||||
|
|
|
|||
|
|
@ -79,6 +79,24 @@
|
|||
(double)(f) }; \
|
||||
static const cl_object name = (cl_object)(& name ## data)
|
||||
|
||||
#define ecl_def_ct_long_float(name,f,static,const) \
|
||||
static const struct ecl_longfloat name ## data = { \
|
||||
(int8_t)t_longfloat, 0, 0, 0, \
|
||||
(long double)(f) }; \
|
||||
static const cl_object name = (cl_object)(& name ## data)
|
||||
|
||||
#define ecl_def_ct_ratio(name,num,den,static,const) \
|
||||
static const struct ecl_ratio name ## data = { \
|
||||
(int8_t)t_ratio, 0, 0, 0, \
|
||||
den, num }; \
|
||||
static const cl_object name = (cl_object)(& name ## data)
|
||||
|
||||
#define ecl_def_ct_complex(name,real,imag,static,const) \
|
||||
static const struct ecl_complex name ## data = { \
|
||||
(int8_t)t_complex, 0, 0, 0, \
|
||||
(cl_object)real, (cl_object)imag }; \
|
||||
static const cl_object name = (cl_object)(& name ## data)
|
||||
|
||||
#define ecl_def_ct_vector(name,type,raw,len,static,const) \
|
||||
static const struct ecl_vector name ## data = { \
|
||||
(int8_t)t_vector, 0, (type), 0, \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue