Skip to content

Conversation

@oscargus
Copy link
Contributor

@oscargus oscargus commented Jan 30, 2019

References to other Issues or PRs

CLoses #9187

Brief description of what is fixed or changed

I decided to revive #9187 as it seemed useful and easy.

Complex variables are explicitly supported for Theano.
Constant functions do no longer generate a crash.
Explicit support for complex variables in codegen. I updated the comment as it seemed like rust does not support complex variables (although I just found https://autumnai.github.io/cuticula/num/complex/struct.Complex.html but do not know the status of that (hadn't even heard of rust before...))

Other comments

It seems like sympy.utilities.codegen.COMPLEX_ALLOWED is used to control the code generation's use of complex variables. Probably better to pass it through codegen but there may be a reason it is not done (have not analyzed the code that much).

As the FIXME says, one should probably add en exception for the case of explicitly complex variables and code generation in c or rust(?).

Release Notes

  • printing

    • Theano printing now supports complex variables, conjugates and constant functions
  • codegen

    • Fortran code generation now supports complex variables by default (COMPLEX*16)

Christoph Gohle and others added 8 commits March 23, 2015 13:27
By default (i.e. if sympy symbols are not real (x.is_real is False or None)) we assume complex valued (maybe a mechanism to control the default behaviour would be nice)
complex fortran code will be generated if codegen.ALLOW_COMPLEX is set to true. This also fixes the old unit tests.
@sympy-bot
Copy link

sympy-bot commented Jan 30, 2019

Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • codegen

    • Fortran code generation now supports complex variables by default (COMPLEX*16) (#15885 by @oscargus)
  • printing

    • Theano printing now supports complex variables, conjugates and constant functions (#15885 by @oscargus)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->
CLoses #9187

#### Brief description of what is fixed or changed
I decided to revive #9187 as it seemed useful and easy.

Complex variables are explicitly supported for Theano.
Constant functions do no longer generate a crash.
Explicit support for complex variables in codegen. I updated the comment as it seemed like rust does not support complex variables (although I just found https://autumnai.github.io/cuticula/num/complex/struct.Complex.html but do not know the status of that (hadn't even heard of rust before...))

#### Other comments
It seems like `sympy.utilities.codegen.COMPLEX_ALLOWED` is used to control the code generation's use of complex variables. Probably better to pass it through `codegen` but there may be a reason it is not done (have not analyzed the code that much).

As the FIXME says, one should probably add en exception for the case of explicitly complex variables and code generation in c or rust(?).

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* printing
   * Theano printing now supports complex variables, conjugates and constant functions

* codegen
   * Fortran code generation now supports complex variables by default (COMPLEX*16)
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@oscarbenjamin
Copy link
Collaborator

Not sure why the azure tests failed when the Travis tests passed. Closing and reopening to re-run the tests.

@oscarbenjamin
Copy link
Collaborator

Why does this need a COMPLEX_ALLOWED global and a complex_allowed keyword argument? Wouldn't one or the other be enough?

I guess that the keyword argument is preferable but it's difficult to implement because it would need to be added to codegen and propagated through all functions...

@oscargus
Copy link
Contributor Author

oscargus commented Mar 3, 2019

I guess that is the case as well. Clearly propagating it would be the solution. Not sure how tedious it is though...

I'm not sure how it is detected if the data is complex nor how it is handled if there is complex data, but the language cannot handle it. (Basically, I have very limited clues about what is going on in the codegen part...)

@oscarbenjamin
Copy link
Collaborator

I think the code can be improved but it might not be easy to do.

This seems useful so I'll probably merge this soon if no one objects.

@oscargus
Copy link
Contributor Author

As long that we are a bit cautious when merging future PRs that make use of the global variable (so that there are not even more places to change), I agree that this probably can be merged as it would extend the functionality in a useful way.

@oscarbenjamin oscarbenjamin merged commit c162866 into sympy:master Apr 29, 2019
@oscargus oscargus deleted the chrisgee-master branch May 2, 2019 07:58
@sylee957 sylee957 mentioned this pull request Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants