ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 31 Jul 2016 02:29:59 +0200Pass arguments to an octave callhttps://ask.sagemath.org/question/34274/pass-arguments-to-an-octave-call/ Hi, given, say, a = [1,2,3,4], is it possible to pass this vector to an octave call, like octave('a+1')? Of course, this last does not work.
Fri, 29 Jul 2016 14:09:33 +0200https://ask.sagemath.org/question/34274/pass-arguments-to-an-octave-call/Answer by vdelecroix for <p>Hi, given, say, a = [1,2,3,4], is it possible to pass this vector to an octave call, like octave('a+1')? Of course, this last does not work.</p>
https://ask.sagemath.org/question/34274/pass-arguments-to-an-octave-call/?answer=34277#post-id-34277It depends on your Sage version (and also octave version actually, see [trac ticket 21135](https://trac.sagemath.org/ticket/21135)). I am able to do in a Sage console
sage: a = [1,2,3,4]
sage: a_octave = octave(a)
sage: norm_octave = a_octave.norm() #this is calling the function "norm" from octave
sage: norm_octave
5.47723
sage: type(norm_octave)
<class 'sage.interfaces.octave.OctaveElement'>
sage: my_norm = norm_octave.sage() # this converts it as a Sage element
sage: type(my_norm)
<type 'sage.rings.real_double.RealDoubleElement'>
Another option is to use the Python module [oct2py](https://pypi.python.org/pypi/oct2py). If you want to use it from Sage (and not only from Python) you need to do the following
$ sage -pip install oct2py --user
(the argument "--user" here is optional if you have write access to your Sage installation). Once the above step done, you can use oct2py in SageSun, 31 Jul 2016 02:29:59 +0200https://ask.sagemath.org/question/34274/pass-arguments-to-an-octave-call/?answer=34277#post-id-34277