Skip to content

Commit 8932ada

Browse files
committed
UndefFunction
1 parent 91b414b commit 8932ada

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

ext/symengine/symengine_utils.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
88
VALUE a, b;
99
double f;
1010
char *c;
11-
rb_cBigDecimal = CLASS_OF(rb_eval_string("BigDecimal.new('0.0001')"));
1211

1312
switch(TYPE(operand2)) {
1413
case T_FIXNUM:
@@ -63,7 +62,7 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
6362
case T_DATA:
6463
c = rb_obj_classname(operand2);
6564
#ifdef HAVE_SYMENGINE_MPFR
66-
if(CLASS_OF(operand2) == rb_cBigDecimal){
65+
if (strcmp(c, "BigDecimal") == 0) {
6766
c = RSTRING_PTR( rb_funcall(operand2, rb_intern("to_s"), 1, rb_str_new2("F")) );
6867
real_mpfr_set_str(cbasic_operand2, c, 200);
6968
break;

lib/symengine.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module SymEngine
22
class << self
3-
43
# Defines a shortcut for SymEngine::Symbol.new() allowing multiple symbols
54
# to be created all at once.
65
#
@@ -29,6 +28,10 @@ def symbols ary_or_string, *params
2928
end
3029
end
3130
end
31+
32+
def SymEngine.Function(n)
33+
return SymEngine::UndefFunction.new(n)
34+
end
3235
end
3336

3437
require 'symengine/symengine'
@@ -37,3 +40,4 @@ def symbols ary_or_string, *params
3740
require 'symengine/integer'
3841
require 'symengine/complex'
3942
require 'symengine/complex_double'
43+
require 'symengine/undef_function'

lib/symengine/undef_function.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module SymEngine
2+
class UndefFunction
3+
4+
def initialize(n)
5+
@name = n
6+
end
7+
8+
def call(*args)
9+
SymEngine::FunctionSymbol.new(@name, *args)
10+
end
11+
12+
end
13+
end

0 commit comments

Comments
 (0)