Wrappers for Real Double #954

Merged
merged 5 commits into from May 28, 2016

Projects

None yet

2 participants

@rajithv
Contributor
rajithv commented May 25, 2016
@rajithv rajithv Real_Double wrappers
5d11115
@isuruf isuruf and 1 other commented on an outdated diff May 25, 2016
symengine/cwrapper.cpp
@@ -186,6 +187,11 @@ void integer_set_str(basic s, char *c)
s->m = SymEngine::integer(integer_class(c));
}
+void real_double_set_str(basic s, char *c)
@isuruf
isuruf May 25, 2016 Member

Use a double as input. void basic_set_d(basic s, double d)

@rajithv
rajithv May 26, 2016 Contributor

That as an extra one or instead of this? I was looking at the integer example.

@isuruf
isuruf May 26, 2016 Member

Instead of this. integer one has several types of input. In this case though, a double is enough.

rajithv added some commits May 26, 2016
@rajithv rajithv Functions for Complex
befc9d6
@rajithv rajithv Changing real_double_set_str -> real_double_set_d
e0b6fde
@rajithv rajithv Real part and imaginary part cwrappers
382a917
@isuruf isuruf commented on the diff May 26, 2016
symengine/tests/cwrapper/test_cwrapper.c
SYMENGINE_C_ASSERT(!is_a_Symbol(e));
SYMENGINE_C_ASSERT(!is_a_Rational(e));
SYMENGINE_C_ASSERT(!is_a_Integer(e));
SYMENGINE_C_ASSERT(is_a_Complex(e));
+ complex_real_part(f, e);
+ s = basic_str(f);
+
+ SYMENGINE_C_ASSERT(strcmp(s, "100/47") == 0);
+ SYMENGINE_C_ASSERT(!is_a_Symbol(f));
+ SYMENGINE_C_ASSERT(is_a_Rational(f));
+ SYMENGINE_C_ASSERT(!is_a_Integer(f));
+ SYMENGINE_C_ASSERT(!is_a_Complex(f));
@isuruf
isuruf May 26, 2016 Member

You need to free s everytime. basic_str_free(s);

@isuruf isuruf commented on an outdated diff May 27, 2016
symengine/tests/cwrapper/test_cwrapper.c
basic_free_stack(e);
basic_free_stack(f);
}
+void test_real_double()
+{
+ basic d;
+ basic_new_stack(d);
+ real_double_set_d(d, 123.456);
+
+ char *s2;
+ s2 = basic_str(d);
+
+ SYMENGINE_C_ASSERT(basic_get_type(d) == SYMENGINE_REAL_DOUBLE);
+ SYMENGINE_C_ASSERT(strcmp(s2, "123.456") == 0);
+
@isuruf
isuruf May 27, 2016 Member

Free s2 here

@rajithv rajithv Minor correction
f73b302
@isuruf isuruf changed the title from [WIP] Wrappers for Real Double to Wrappers for Real Double May 28, 2016
@isuruf isuruf merged commit 5a877cb into symengine:master May 28, 2016

4 checks passed

codecov/patch 100% of diff hit (target 65.64%)
Details
codecov/project 65.67% (+<.01%) compared to 6ffde88
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment