sage: octave('4+10') # optional
14
sage: octave('date') # optional; random output
18-Oct-2007
sage: octave('5*10 + 6') # optional
56
sage: octave('(6+6)/3') # optional
4
sage: octave('9')^2 # optional
81
sage: a = octave(10); b = octave(20); c = octave(30) # optional
sage: avg = (a+b+c)/3 # optional
sage: avg # optional
20
sage: parent(avg) # optional
Octave
sage: my_scalar = octave('3.1415') # optional
sage: my_scalar # optional
3.1415
sage: my_vector1 = octave('[1,5,7]') # optional
sage: my_vector1 # optional
1 5 7
sage: my_vector2 = octave('[1;5;7]') # optional
sage: my_vector2 # optional
1
5
7
sage: my_vector1 * my_vector2 # optional
75
Module-level Functions
| ) |
Spawn a new Octave command-line session.
This requires that the optional octave program be installed and in your PATH, but no optional Sage packages need be installed.
sage: octave_console() # not tested GNU Octave, version 2.1.73 (i386-apple-darwin8.5.3). Copyright (C) 2006 John W. Eaton. ... octave:1> 2+3 ans = 5 octave:2> [ctl-d]
Pressing ctrl-d exits the octave console and returns you to SAGE. octave, like SAGE, remembers its history from one session to another.
| ) |
Return the version of Octave installed.
sage: octave_version() # optional -- requires octave; and output is random '2.9.12'
| ) |
sage: from sage.interfaces.octave import reduce_load_Octave sage: reduce_load_Octave() Octave
Class: Octave
sage: octave.eval("a = [ 1, 1, 2; 3, 5, 8; 13, 21, 33 ]") # optional
'a =
1 1 2 3 5 8 13 21 33
'
sage: octave.eval("b = [ 1; 3; 13]") # optional
'b =
1 3 13
'
sage: octave.eval("c=a \ b") # solves linear equation: a*c = b # optional random output
'c =
1 7.21645e-16 -7.21645e-16
'
sage: octave.eval("c") # optional random output
'c =
1 7.21645e-16 -7.21645e-16
'
| self, [maxread=100], [script_subdirectory=], [logfile=None], [server=None], [server_tmpdir=None]) |
sage: octave == loads(dumps(octave)) True
Functions: clear,
console,
de_system_plot,
get,
quit,
sage2octave_matrix_string,
set,
solve_linear_system,
version
| self, var) |
Clear the variable named var.
sage: octave.set('x', '2') #optional -- requires Octave
sage: octave.clear('x') #optional
sage: octave.get('x') #optional
"error: `x' undefined near line ... column 1"
| self) |
Spawn a new Octave command-line session.
This requires that the optional octave program be installed and in your PATH, but no optional Sage packages need be installed.
sage: octave_console() # not tested GNU Octave, version 2.1.73 (i386-apple-darwin8.5.3). Copyright (C) 2006 John W. Eaton. ... octave:1> 2+3 ans = 5 octave:2> [ctl-d]
Pressing ctrl-d exits the octave console and returns you to SAGE. octave, like SAGE, remembers its history from one session to another.
| self, f, ics, trange) |
Plots (using octave's interface to gnuplot) the solution
to a
system of differential equations.
Input:
sage: octave.de_system_plot(['x+y','x-y'], [1,-1], [0,2]) # not tested -- does this actually work (on OS X it fails for me -- William Stein, 2007-10)
This should yield the two plots
on the same graph
(the
-axis is the horizonal axis) of the system of ODEs
| self, var) |
Get the value of the variable var.
sage: octave.set('x', '2') #optional -- requires Octave
sage: octave.get('x') #optional
' 2'
| self, [verbose=False]) |
sage: o = Octave() sage: o._start() #optional -- requires Octave sage: o.quit(True) #optional Exiting spawned Octave process.
| self, A) |
Return an octave matrix from a SAGE matrix.
Input: A SAGE matrix with entries in the rationals or reals.
Output: A string that evaluates to an Octave matrix.
sage: M33 = MatrixSpace(QQ,3,3) sage: A = M33([1,2,3,4,5,6,7,8,0]) sage: octave.sage2octave_matrix_string(A) # requires optional octave '[1, 2, 3; 4, 5, 6; 7, 8, 0]'
Author: David Joyner and William Stein
| self, var, value) |
Set the variable var to the given value.
sage: octave.set('x', '2') #optional -- requires Octave
sage: octave.get('x') #optional
' 2'
| self, A, b) |
Use octave to compute a solution x to A*x = b, as a list.
Input:
sage: M33 = MatrixSpace(QQ,3,3) sage: A = M33([1,2,3,4,5,6,7,8,0]) sage: V3 = VectorSpace(QQ,3) sage: b = V3([1,2,3]) sage: octave.solve_linear_system(A,b) # requires optional octave (and output is slightly random in low order bits) [-0.33333299999999999, 0.66666700000000001, -3.5236600000000002e-18]
Author: David Joyner and William Stein
| self) |
Return the version of Octave.
Output: string
sage: octave.version() # optional and random output depending on version '2.1.73'
Special Functions: __init__,
__reduce__,
_install_hints,
_object_class,
_quit_string,
_read_in_file_command,
_start
| self) |
sage: octave.__reduce__() (<function reduce_load_Octave at 0x...>, ())
| self) |
Returns hints on how to install Octave.
sage: print octave._install_hints() You must get ...
| self) |
sage: octave._object_class() <class 'sage.interfaces.octave.OctaveElement'>
| self) |
sage: octave._quit_string() 'quit;'
| self, filename) |
sage: filename = tmp_filename()
sage: octave._read_in_file_command(filename)
'source("...");'
| self) |
Starts the Octave process.
sage: o = Octave() #optioanl -- requires Octave sage: o.is_running() #optional False sage: o._start() #optional sage: o.is_running() #optional True
Class: OctaveElement
Special Functions: _matrix_
| self, R) |
Return Sage matrix from this octave element.
sage: A = octave('[1,2;3,4]') # optional octave package
sage: matrix(ZZ, A)
[1 2]
[3 4]
sage: A = octave('[1,2;3,4.5]') # optional octave package
sage: matrix(RR, A)
[1.00000000000000 2.00000000000000]
[3.00000000000000 4.50000000000000]
See About this document... for information on suggesting changes.