Kernel: SageMath (default)
Call Octave from Sage and back
The code we want to run is in f1.m
in the same directory
two variants below:
The data
warning make all values floats - not ints! otherwise you get that horrible implicit downcast to single vals
In [1]:
[ 1.1 2.0]
[ 3.9 -1.0]
In [2]:
In [0]:
In [0]:
Variant A
Use Sage's octave wrapper to call function f1
In [3]:
In [4]:
(199.1, 200.0)
warning this looks weird ... just first line
In [5]:
'\n\n 1.1 2\n'
In [6]:
(1.1, 2.0)
In [0]:
In [0]:
Variant B
use mat files to exchange data and use a small helper script runit.m
In [7]:
In [8]:
running the driver file runit.m using octave
In [9]:
which saves the result in result.mat
In [10]:
array([[199.1, 200. ],
[201.9, 197. ]])
In [11]:
[199.1 200.0]
[201.9 197.0]
In [12]:
(<type 'sage.matrix.matrix_real_double_dense.Matrix_real_double_dense'>,
Full MatrixSpace of 2 by 2 dense matrices over Real Double Field)
In [0]:
In [0]: