|
2 | 2 | #include "ruby_basic.h" |
3 | 3 | #include "ruby_symbol.h" |
4 | 4 | #include "ruby_integer.h" |
| 5 | +#include "ruby_number.h" |
5 | 6 | #include "ruby_real_double.h" |
6 | 7 | #include "ruby_constant.h" |
7 | 8 | #include "ruby_complex.h" |
8 | 9 | #include "ruby_complex_double.h" |
| 10 | +#include "ruby_complex_mpc.h" |
9 | 11 | #include "ruby_real_mpfr.h" |
10 | 12 | #include "ruby_function.h" |
11 | 13 | #include "ruby_ntheory.h" |
@@ -58,52 +60,66 @@ void Init_symengine() |
58 | 60 | rb_define_module_function(m_symengine, "convert", cutils_sympify, 1); |
59 | 61 | rb_define_global_function("SymEngine", cutils_sympify, 1); |
60 | 62 |
|
| 63 | + // evalf as a Module Level Function |
| 64 | + rb_define_module_function(m_symengine, "_evalf", cutils_evalf, 3); |
| 65 | + |
61 | 66 | // Symbol class |
62 | 67 | c_symbol = rb_define_class_under(m_symengine, "Symbol", c_basic); |
63 | 68 | rb_define_alloc_func(c_symbol, cbasic_alloc); |
64 | 69 | rb_define_method(c_symbol, "initialize", csymbol_init, 1); |
65 | 70 |
|
| 71 | + // Number class |
| 72 | + c_number = rb_define_class_under(m_symengine, "Number", c_basic); |
| 73 | + rb_define_alloc_func(c_number, cbasic_alloc); |
| 74 | + rb_define_method(c_number, ">", cnumber_gt, 1); |
| 75 | + rb_define_method(c_number, "<", cnumber_lt, 1); |
| 76 | + rb_define_method(c_number, ">=", cnumber_gt_e, 1); |
| 77 | + rb_define_method(c_number, "<=", cnumber_lt_e, 1); |
| 78 | + |
66 | 79 | // Integer class |
67 | | - c_integer = rb_define_class_under(m_symengine, "Integer", c_basic); |
| 80 | + c_integer = rb_define_class_under(m_symengine, "Integer", c_number); |
68 | 81 | rb_define_alloc_func(c_integer, cbasic_alloc); |
69 | 82 | rb_define_method(c_integer, "initialize", cinteger_init, 1); |
70 | 83 | rb_define_method(c_integer, "%", cntheory_mod, 1); |
71 | 84 |
|
72 | 85 | // RealDouble Class |
73 | | - c_real_double = rb_define_class_under(m_symengine, "RealDouble", c_basic); |
| 86 | + c_real_double = rb_define_class_under(m_symengine, "RealDouble", c_number); |
74 | 87 | rb_define_alloc_func(c_real_double, cbasic_alloc); |
75 | 88 | rb_define_method(c_real_double, "to_f", crealdouble_to_float, 0); |
76 | 89 |
|
77 | 90 | // Rational class |
78 | | - c_rational = rb_define_class_under(m_symengine, "Rational", c_basic); |
| 91 | + c_rational = rb_define_class_under(m_symengine, "Rational", c_number); |
79 | 92 | rb_define_alloc_func(c_rational, cbasic_alloc); |
80 | 93 |
|
81 | 94 | // Complex class |
82 | | - c_complex = rb_define_class_under(m_symengine, "Complex", c_basic); |
| 95 | + c_complex = rb_define_class_under(m_symengine, "Complex", c_number); |
83 | 96 | rb_define_alloc_func(c_complex, cbasic_alloc); |
84 | 97 | rb_define_method(c_complex, "real", ccomplex_real_part, 0); |
85 | 98 | rb_define_method(c_complex, "imaginary", ccomplex_imaginary_part, 0); |
86 | 99 |
|
87 | 100 | // ComplexDouble class |
88 | 101 | c_complex_double |
89 | | - = rb_define_class_under(m_symengine, "ComplexDouble", c_basic); |
| 102 | + = rb_define_class_under(m_symengine, "ComplexDouble", c_number); |
90 | 103 | rb_define_alloc_func(c_complex_double, cbasic_alloc); |
91 | 104 | rb_define_method(c_complex_double, "real", ccomplex_double_real_part, 0); |
92 | 105 | rb_define_method(c_complex_double, "imaginary", |
93 | 106 | ccomplex_double_imaginary_part, 0); |
94 | 107 |
|
95 | 108 | #ifdef HAVE_SYMENGINE_MPFR |
96 | 109 | // RealMPFR class |
97 | | - c_real_mpfr = rb_define_class_under(m_symengine, "RealMPFR", c_basic); |
| 110 | + c_real_mpfr = rb_define_class_under(m_symengine, "RealMPFR", c_number); |
98 | 111 | rb_define_alloc_func(c_real_mpfr, cbasic_alloc); |
99 | 112 | rb_define_method(c_real_mpfr, "initialize", crealmpfr_init, 2); |
100 | 113 | rb_define_method(c_real_mpfr, "to_f", crealmpfr_to_float, 0); |
101 | 114 | #endif // HAVE_SYMENGINE_MPFR |
102 | 115 |
|
103 | 116 | #ifdef HAVE_SYMENGINE_MPC |
104 | 117 | // ComplexMPC class |
105 | | - c_complex_mpc = rb_define_class_under(m_symengine, "ComplexMPC", c_basic); |
| 118 | + c_complex_mpc = rb_define_class_under(m_symengine, "ComplexMPC", c_number); |
106 | 119 | rb_define_alloc_func(c_complex_mpc, cbasic_alloc); |
| 120 | + rb_define_method(c_complex_mpc, "real", ccomplex_mpc_real_part, 0); |
| 121 | + rb_define_method(c_complex_mpc, "imaginary", ccomplex_mpc_imaginary_part, |
| 122 | + 0); |
107 | 123 | #endif // HAVE_SYMENGINE_MPC |
108 | 124 |
|
109 | 125 | // Constant class |
|
0 commit comments