Skip to content

Commit 6cd53d1

Browse files
committed
Next Prime, GCD, LCM, mod and quotient working
1 parent 5ad2393 commit 6cd53d1

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

ext/symengine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(RUBY_WRAPPER_SRC
55
ruby_rational.c
66
ruby_constant.c
77
ruby_function.c
8+
ruby_ntheory.c
89
symengine_macros.c
910
symengine.c
1011
)

ext/symengine/ruby_ntheory.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "ruby_ntheory.h"
22

3-
VALUE cfunction_onearg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*), VALUE operand1) {
3+
VALUE cntheory_onearg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*), VALUE operand1) {
44
basic_struct *cresult;
55
VALUE result;
66

@@ -16,7 +16,7 @@ VALUE cfunction_onearg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*), V
1616
return result;
1717
}
1818

19-
VALUE cfunction_twoarg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*, const basic_struct*), VALUE operand1, VALUE operand2) {
19+
VALUE cntheory_twoarg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*, const basic_struct*), VALUE operand1, VALUE operand2) {
2020
basic_struct *cresult;
2121
VALUE result;
2222

@@ -37,22 +37,22 @@ VALUE cfunction_twoarg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*, co
3737
return result;
3838
}
3939

40-
VALUE cfunction_nextprime(VALUE self, VALUE operand1) {
41-
return cfunction_onearg(nthoery_gcd, operand1);
40+
VALUE cntheory_nextprime(VALUE self, VALUE operand1) {
41+
return cntheory_onearg(ntheory_nextprime, operand1);
4242
}
4343

44-
VALUE cfunction_gcd(VALUE self, VALUE operand1, VALUE operand2) {
45-
return cfunction_twoarg(ntheory_gcd, operand1, operand2);
44+
VALUE cntheory_gcd(VALUE self, VALUE operand1, VALUE operand2) {
45+
return cntheory_twoarg(ntheory_gcd, operand1, operand2);
4646
}
4747

48-
VALUE cfunction_lcm(VALUE self, VALUE operand1, VALUE operand2) {
49-
return cfunction_twoarg(ntheory_lcm, operand1, operand2);
48+
VALUE cntheory_lcm(VALUE self, VALUE operand1, VALUE operand2) {
49+
return cntheory_twoarg(ntheory_lcm, operand1, operand2);
5050
}
5151

52-
VALUE cfunction_mod(VALUE self, VALUE operand1, VALUE operand2) {
53-
return cfunction_twoarg(ntheory_mod, operand1, operand2);
52+
VALUE cntheory_mod(VALUE self, VALUE operand1, VALUE operand2) {
53+
return cntheory_twoarg(ntheory_mod, operand1, operand2);
5454
}
5555

56-
VALUE cfunction_quotient(VALUE self, VALUE operand1, VALUE operand2) {
57-
return cfunction_twoarg(ntheory_quotient, operand1, operand2);
56+
VALUE cntheory_quotient(VALUE self, VALUE operand1, VALUE operand2) {
57+
return cntheory_twoarg(ntheory_quotient, operand1, operand2);
5858
}

ext/symengine/ruby_ntheory.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
#include "symengine.h"
99
#include "symengine_macros.h"
1010

11-
VALUE cfunction_onearg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*), VALUE operand1);
12-
VALUE cfunction_twoarg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*, const basic_struct*), VALUE operand1, VALUE operand2);
11+
VALUE cntheory_onearg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*), VALUE operand1);
12+
VALUE cntheory_twoarg(void (*cwfunc_ptr)(basic_struct*, const basic_struct*, const basic_struct*), VALUE operand1, VALUE operand2);
1313

14-
VALUE cfunction_gcd(VALUE self, VALUE operand1, VALUE operand2);
15-
VALUE cfunction_lcm(VALUE self, VALUE operand1, VALUE operand2);
16-
VALUE cfunction_nextprime(VALUE self, VALUE operand1);
17-
VALUE cfunction_mod(VALUE self, VALUE operand1, VALUE operand2);
18-
VALUE cfunction_quotient(VALUE self, VALUE operand1, VALUE operand2);
19-
//VALUE cfunction_fibonacci(VALUE self, VALUE operand1);
20-
//VALUE cfunction_lucas(VALUE self, VALUE operand1);
21-
//VALUE cfunction_binomial(VALUE self, VALUE operand1, VALUE operand2);
14+
VALUE cntheory_gcd(VALUE self, VALUE operand1, VALUE operand2);
15+
VALUE cntheory_lcm(VALUE self, VALUE operand1, VALUE operand2);
16+
VALUE cntheory_nextprime(VALUE self, VALUE operand1);
17+
VALUE cntheory_mod(VALUE self, VALUE operand1, VALUE operand2);
18+
VALUE cntheory_quotient(VALUE self, VALUE operand1, VALUE operand2);
19+
//VALUE cntheory_fibonacci(VALUE self, VALUE operand1);
20+
//VALUE cntheory_lucas(VALUE self, VALUE operand1);
21+
//VALUE cntheory_binomial(VALUE self, VALUE operand1, VALUE operand2);
2222

2323
#endif //RUBY_NTHEORY_H_

ext/symengine/symengine.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ void Init_symengine() {
147147
rb_define_module_function(m_symengine, "gamma", cfunction_gamma, 1);
148148

149149
//NTheory Functions as Module Level Functions
150-
rb_define_module_function(m_symengine, "gcd", cfunction_gcd, 2);
151-
rb_define_module_function(m_symengine, "lcm", cfunction_lcm, 2);
152-
rb_define_module_function(m_symengine, "nextprime", cfunction_nextprime, 1);
153-
rb_define_module_function(m_symengine, "mod", cfunction_mod, 2);
154-
rb_define_module_function(m_symengine, "quotient", cfunction_quotient, 2);
155-
rb_define_module_function(m_symengine, "fibonacci", cfunction_fibonacci, 1);
156-
rb_define_module_function(m_symengine, "lucas", cfunction_lucas, 1);
157-
rb_define_module_function(m_symengine, "binomial", cfunction_binomial, 2);
150+
rb_define_module_function(m_symengine, "gcd", cntheory_gcd, 2);
151+
rb_define_module_function(m_symengine, "lcm", cntheory_lcm, 2);
152+
rb_define_module_function(m_symengine, "nextprime", cntheory_nextprime, 1);
153+
rb_define_module_function(m_symengine, "mod", cntheory_mod, 2);
154+
rb_define_module_function(m_symengine, "quotient", cntheory_quotient, 2);
155+
//rb_define_module_function(m_symengine, "fibonacci", cntheory_fibonacci, 1);
156+
//rb_define_module_function(m_symengine, "lucas", cntheory_lucas, 1);
157+
//rb_define_module_function(m_symengine, "binomial", cntheory_binomial, 2);
158158

159159
}

symengine_version.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
46f54aeafbf2a93be0c8b1d492666f56f0ccbe73
1+
5e88e62b42c38200573eecf688d90b46beb38a77
2+

0 commit comments

Comments
 (0)