44void sympify (VALUE operand2 , basic_struct * cbasic_operand2 ) {
55
66 basic_struct * temp ;
7- VALUE new_operand2 , num , den ;
8- VALUE real , imag ;
7+ VALUE new_operand2 ;
8+ VALUE a , b ;
99 double f ;
10+ char * c ;
11+ rb_cBigDecimal = CLASS_OF (rb_eval_string ("BigDecimal.new('0.0001')" ));
1012
1113 switch (TYPE (operand2 )) {
1214 case T_FIXNUM :
@@ -20,15 +22,15 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
2022 break ;
2123
2224 case T_RATIONAL :
23- num = rb_funcall (operand2 , rb_intern ("numerator" ), 0 , NULL );
24- den = rb_funcall (operand2 , rb_intern ("denominator" ), 0 , NULL );
25+ a = rb_funcall (operand2 , rb_intern ("numerator" ), 0 , NULL );
26+ b = rb_funcall (operand2 , rb_intern ("denominator" ), 0 , NULL );
2527
2628 basic num_basic , den_basic ;
2729 basic_new_stack (num_basic );
2830 basic_new_stack (den_basic );
2931
30- get_symintfromval (num , num_basic );
31- get_symintfromval (den , den_basic );
32+ get_symintfromval (a , num_basic );
33+ get_symintfromval (b , den_basic );
3234
3335 rational_set (cbasic_operand2 , num_basic , den_basic );
3436
@@ -37,17 +39,17 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
3739 break ;
3840
3941 case T_COMPLEX :
40- real = rb_funcall (operand2 , rb_intern ("real" ), 0 , NULL );
41- imag = rb_funcall (operand2 , rb_intern ("imaginary" ), 0 , NULL );
42+ a = rb_funcall (operand2 , rb_intern ("real" ), 0 , NULL );
43+ b = rb_funcall (operand2 , rb_intern ("imaginary" ), 0 , NULL );
4244
4345 basic real_basic ;
4446 basic imag_basic ;
4547
4648 basic_new_stack (real_basic );
4749 basic_new_stack (imag_basic );
4850
49- sympify (real , real_basic );
50- sympify (imag , imag_basic );
51+ sympify (a , real_basic );
52+ sympify (b , imag_basic );
5153
5254 basic_const_I (cbasic_operand2 );
5355 basic_mul (cbasic_operand2 , cbasic_operand2 , imag_basic );
@@ -59,10 +61,18 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
5961 break ;
6062
6163 case T_DATA :
64+ c = rb_obj_classname (operand2 );
65+ #ifdef HAVE_SYMENGINE_MPFR
66+ if (CLASS_OF (operand2 ) == rb_cBigDecimal ){
67+ c = RSTRING_PTR ( rb_funcall (operand2 , rb_intern ("to_s" ), 1 , rb_str_new2 ("F" )) );
68+ real_mpfr_set_str (cbasic_operand2 , c , 200 );
69+ break ;
70+ }
71+ #endif //HAVE_SYMENGINE_MPFR
72+
6273 Data_Get_Struct (operand2 , basic_struct , temp );
6374 basic_assign (cbasic_operand2 , temp );
6475 break ;
65-
6676 }
6777}
6878
@@ -87,12 +97,20 @@ VALUE Klass_of_Basic(const basic_struct *basic_ptr) {
8797 return c_integer ;
8898 case SYMENGINE_REAL_DOUBLE :
8999 return c_real_double ;
100+ #ifdef HAVE_SYMENGINE_MPFR
101+ case SYMENGINE_REAL_MPFR :
102+ return c_real_mpfr ;
103+ #endif //HAVE_SYMENGINE_MPFR
90104 case SYMENGINE_RATIONAL :
91105 return c_rational ;
92106 case SYMENGINE_COMPLEX :
93107 return c_complex ;
94108 case SYMENGINE_COMPLEX_DOUBLE :
95109 return c_complex_double ;
110+ #ifdef HAVE_SYMENGINE_MPC
111+ case SYMENGINE_COMPLEX_MPC :
112+ return c_complex_mpc ;
113+ #endif //HAVE_SYMENGINE_MPFR
96114 case SYMENGINE_CONSTANT :
97115 return c_constant ;
98116 case SYMENGINE_ADD :
0 commit comments