Skip to content

Commit 46c4b0c

Browse files
committed
Merge branch 'master' into mpfr_mpc
2 parents 166dd25 + f23599d commit 46c4b0c

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

ext/symengine/symengine.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ void Init_symengine() {
125125
c_zeta = rb_define_class_under(m_symengine, "Zeta", c_function);
126126
c_gamma = rb_define_class_under(m_symengine, "Gamma", c_function);
127127

128+
//Abs Class
129+
c_abs = rb_define_class_under(m_symengine, "Abs", c_function);
130+
128131
//TrigFunction SubClasses
129132
c_sin = rb_define_class_under(m_symengine, "Sin", c_trig_function);
130133
c_cos = rb_define_class_under(m_symengine, "Cos", c_trig_function);

ext/symengine/symengine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ VALUE c_lambertw;
2727
VALUE c_dirichlet_eta;
2828
VALUE c_zeta;
2929
VALUE c_gamma;
30+
VALUE c_abs;
3031
VALUE c_sin;
3132
VALUE c_cos;
3233
VALUE c_tan;

ext/symengine/symengine_utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ VALUE Klass_of_Basic(const basic_struct *basic_ptr) {
113113
return c_mul;
114114
case SYMENGINE_POW:
115115
return c_pow;
116+
case SYMENGINE_ABS:
117+
return c_abs;
116118
case SYMENGINE_SIN:
117119
return c_sin;
118120
case SYMENGINE_COS:

spec/functions_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
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
[

0 commit comments

Comments
 (0)