You can subclass the CCodePrinter and change the method for sympy.I to
print as you like. Examples are here:
http://docs.sympy.org/latest/modules/printing.html


Jason
moorepants.info
+01 530-601-9791

On Thu, May 12, 2016 at 8:01 PM, chaowen guo <gcwenken....@ttu.edu> wrote:

> Hi:
>
> The output of sympy.ccode(1+sympy.I) is '1+I'
>
> However, in c++14 mode, like g++ -std=c++14 source.cpp, the g++ compiler
> does not think I is the imaginary unit.
>
> But in the http://en.cppreference.com/w/cpp/numeric/complex, I know that
> after
>
> using namespace std::complex_literals;
> I can use 1i to represent the imaginary unit.
>
> So how to tell ccode not to convert sympy.I into I but 1i?
>
> I just know that there just exists ccode to convert sympy expression into c 
> code. But I can not find any cppcode to convert sympy expression into c++ 
> code.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/4177732d-3956-4f12-b2b9-7edc27e845a4%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/4177732d-3956-4f12-b2b9-7edc27e845a4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAP7f1AiF55f8Q2hm%2BK27E39-HS%3DGL5VKxqNUcJrzEhKE_fbHbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to