referencing sympy commands in Octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

referencing sympy commands in Octave

Browning, Robert S IV ERDC-RDE-GSL-MS CIV
I am using the symbolic toolbox and am wondering if there is a way to directly call sympy/python commands in an Octave script?

The reason I ask is that the quorem MatLab command does not appear to be supported yet. If I could simply call the div sympy command I could use that as a work-around. If this is not possible, is there a way I can write my own script to add to Octave to do this? How would I go about doing that?

Thanks,

_________________________________________________
Robert S. Browning IV
Research Structural Engineer
U.S. Army Engineer Research & Development Center

3909 Halls Ferry Road
CEERD-GS-M, Bldg 5008
Vicksburg, MS  39180-6199

Office:  601-634-5228
Fax:  601-634-2309
Email:  [hidden email]


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: referencing sympy commands in Octave

Mike Miller-4
On Fri, Jun 30, 2017 at 14:00:04 +0000, Browning, Robert S IV ERDC-RDE-GSL-MS CIV wrote:
> I am using the symbolic toolbox and am wondering if there is a way to
> directly call sympy/python commands in an Octave script?

If you mean an easy way to call a SymPy function on an Octave symbolic
variable, it is possible but not easy or encouraged.

For example, you can call

    syms x y
    result = python_cmd ("_outs = prod(_ins)", x, y)

and the result will be the product "x*y".

At some point in the future it may be possible to call Python functions
directly on symbolic variables, for example

    py.sympy.prod ({x, y})

but not at the moment.

> The reason I ask is that the quorem MatLab command does not appear to
> be supported yet. If I could simply call the div sympy command I could
> use that as a work-around. If this is not possible, is there a way I
> can write my own script to add to Octave to do this? How would I go
> about doing that?

Are you willing to write or help develop a Matlab compatible quorem
function for the symbolic package?

If so, the best thing you could do would be to contribute an
implementation of this function, following the example of other @sym
functions in the symbolic package, and file a PR to add this function to
the package at https://github.com/cbm755/octsympy/pulls. This will
ensure it gets added to the next release of the package for all users.

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: referencing sympy commands in Octave

Colin Macdonald-2
On 30/06/17 11:31 AM, Mike Miller wrote:
> Are you willing to write or help develop a Matlab compatible quorem
> function for the symbolic package?
>
> If so, the best thing you could do would be to contribute an
> implementation of this function, following the example of other @sym
> functions in the symbolic package, and file a PR to add this function to
> the package athttps://github.com/cbm755/octsympy/pulls. This will
> ensure it gets added to the next release of the package for all users.

Yes, that would be really great!

A long time ago, I started working on quorem (on the "quorem" branch).
It might be totally wrong so feel free to try your own approach!

You can find my partial code here:

https://github.com/cbm755/octsympy/blob/quorem/inst/%40sym/quorem.m

best,
Colin

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: referencing sympy commands in Octave

Browning, Robert S IV ERDC-RDE-GSL-MS CIV
So to test out the function you just sent Colin, do I just need to put it in a directory I'm working from in Octave? And then try to use it from the command line or in another script?

-Bob Browning


-----Original Message-----
From: Colin Macdonald [mailto:[hidden email]]
Sent: Friday, June 30, 2017 4:29 PM
To: [hidden email]
Cc: Browning, Robert S IV ERDC-RDE-GSL-MS CIV <[hidden email]>
Subject: Re: referencing sympy commands in Octave

On 30/06/17 11:31 AM, Mike Miller wrote:
> Are you willing to write or help develop a Matlab compatible quorem
> function for the symbolic package?
>
> If so, the best thing you could do would be to contribute an
> implementation of this function, following the example of other @sym
> functions in the symbolic package, and file a PR to add this function
> to the package
> atBlockedhttps://github.com/cbm755/octsympy/pullsBlocked. This will ensure it gets added to the next release of the package for all users.

Yes, that would be really great!

A long time ago, I started working on quorem (on the "quorem" branch).
It might be totally wrong so feel free to try your own approach!

You can find my partial code here:

Blockedhttps://github.com/cbm755/octsympy/blob/quorem/inst/%40sym/quorem.mBlocked

best,
Colin

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: referencing sympy commands in Octave

Colin Macdonald-2
On 30/06/17 03:09 PM, Browning, Robert S IV ERDC-RDE-GSL-MS CIV wrote:
> So to test out the function you just sent Colin, do I just need to put it in a directory I'm working from in Octave? And then try to use it from the command line or in another script?

Yes, that probably works, although it will then get called for non-sym
inputs too.

Eventually, you can test it in
"c:\whereever\your\packages\are\installed\symbolic\@sym\quorem.m"
(search your computer for sym.m to find this)

There are some test cases written at the bottom of the file, try "test
quorem" to run these.

Please do follow up about this!

Colin

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: referencing sympy commands in Octave

Browning, Robert S IV ERDC-RDE-GSL-MS CIV
Thanks Colin. I will definitely try to take a look at this as I'd like to learn to add stuff into Octave. I've been very impressed with its capabilities and hope it continues to improve.

Regards,

-Bob Browning



-----Original Message-----
From: Colin Macdonald [mailto:[hidden email]]
Sent: Friday, June 30, 2017 6:49 PM
To: Browning, Robert S IV ERDC-RDE-GSL-MS CIV <[hidden email]>; [hidden email]
Subject: Re: referencing sympy commands in Octave

On 30/06/17 03:09 PM, Browning, Robert S IV ERDC-RDE-GSL-MS CIV wrote:
> So to test out the function you just sent Colin, do I just need to put it in a directory I'm working from in Octave? And then try to use it from the command line or in another script?

Yes, that probably works, although it will then get called for non-sym inputs too.

Eventually, you can test it in
"c:\whereever\your\packages\are\installed\symbolic\@sym\quorem.m"
(search your computer for sym.m to find this)

There are some test cases written at the bottom of the file, try "test quorem" to run these.

Please do follow up about this!

Colin

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: referencing sympy commands in Octave

Francesco Potortì
In reply to this post by Colin Macdonald-2
Mike Miller:
>> Are you willing to write or help develop a Matlab compatible quorem
>> function for the symbolic package?

Colin Macdonald:
>Yes, that would be really great!
>
>A long time ago, I started working on quorem (on the "quorem" branch).
>It might be totally wrong so feel free to try your own approach!

Maybe you already know, but I'll state that because it's important.  If
you write a function for Octave, you should not adapt it from a Matlab
function: that would be a copyright violation, because Octave's
licensing terms are different from Matlab's.

You should use the Matlab code only to run it and test it, and the
Matlab documentation only for understanding how it works from the
outside.

You can implement it from scratch or from a published algorithm, but not
by copying or adapting code from sources which are not GPL-compatible.

--
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...