File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ void Init_symengine() {
114114 c_zeta = rb_define_class_under (m_symengine , "Zeta" , c_function );
115115 c_gamma = rb_define_class_under (m_symengine , "Gamma" , c_function );
116116
117+ //Abs Class
118+ c_abs = rb_define_class_under (m_symengine , "Abs" , c_function );
119+
117120 //TrigFunction SubClasses
118121 c_sin = rb_define_class_under (m_symengine , "Sin" , c_trig_function );
119122 c_cos = rb_define_class_under (m_symengine , "Cos" , c_trig_function );
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ VALUE c_lambertw;
2525VALUE c_dirichlet_eta ;
2626VALUE c_zeta ;
2727VALUE c_gamma ;
28+ VALUE c_abs ;
2829VALUE c_sin ;
2930VALUE c_cos ;
3031VALUE c_tan ;
Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ VALUE Klass_of_Basic(const basic_struct *basic_ptr) {
101101 return c_mul ;
102102 case SYMENGINE_POW :
103103 return c_pow ;
104+ case SYMENGINE_ABS :
105+ return c_abs ;
104106 case SYMENGINE_SIN :
105107 return c_sin ;
106108 case SYMENGINE_COS :
Original file line number Diff line number Diff line change 22 let ( :pi ) { SymEngine ::PI }
33 let ( :e ) { SymEngine ::E }
44 let ( :x ) { sym ( "x" ) }
5+ let ( :y ) { sym ( "y" ) }
6+
7+ context "Abs" do
8+ context "with a symbol" do
9+ subject { SymEngine ::abs ( x ) }
10+ it { is_expected . to be_a SymEngine ::Abs }
11+ end
12+ context "with an integer" do
13+ subject { SymEngine ::abs ( SymEngine ( 1 ) ) }
14+ it { is_expected . to be_a SymEngine ::Integer }
15+ end
16+ context "with a symbol addition" do
17+ subject { SymEngine ::abs ( x +y ) }
18+ it { is_expected . to be_a SymEngine ::Abs }
19+ end
20+ context "with a function of a symbol" do
21+ subject { SymEngine ::abs ( SymEngine ::sin ( x ) ) }
22+ it { is_expected . to be_a SymEngine ::Abs }
23+ end
24+ end
525
626 context '2*x' do
727 [
You can’t perform that action at this time.
0 commit comments