Most of the time, installing things with MacPorts is pretty easy; however, I have found that GNU Octave can be a little tricky. That being said, it’s still pretty easy to get Octave up and running in both Snow Leopard and Lion.
At the time of this post, here’s two version of Octave to choose from: octave (version 3.2.4) and octave-devel (version 3.4.3). For my money, I like octave-devel. In my brief testing with the two, the biggest difference for me was that the graphs plotted in octave-devel looked more like their OS counterparts. With octave, I found the scaling of elements on the graph to be different sizes and that bugged me.
To install Octave, run the following from the terminal:
sudo port install octave-devel +gcc45
And then wait…as there are a lot of things that need being compiled.
I added the gcc45 variant because one of the dependencies, atlas, needs gcc45 to compile. This ensures that both of those are in sync.
Feel free to add other variants if you like, like X11 support or offline documentation. To get a full list, run:
port variants octave-devel
Plotting
When you install Octave via MacPorts, AquaTerm also gets installed. AquaTerm is basically a vector renderer which Octave can use to plot its graphs. I like AquaTerm because the graphs look really smooth and nice, like you would expect on a Mac :)
If you have installed the X11 variant, you can also choose to do the rendering from within X11. The way you control this is through the environment variable, GNUTERM.
Set GNUTERM to x11 when you want to do your graphing in X11 and set GNUTERM to aqua when you want to do your graphing in AquaTerm. You can read more about setting environment variables on StackOverflow.
If you are running Octave and wish to change the GNUTERM there, you can do so with the setenv function, like so.
>> % Create some sample data
>> x = [-4 -2 0 2 4 6 8];
>> y = x .^ 2;
>>
>> % Plot X in X11.
>> setenv("GNUTERM", "x11");
>> plot(x, y);
>>
>> % Plot X in AquaTerm.
>> setenv("GNUTERM", "aqua");
>> plot(x, y);
With this, you can also compare the different rendering apps and discover which one you like more.
Did MacPorts give you a 64-bit executable?
Under Lion 10.7.1, MacPorts gives an executable that reports when run:
Octave was configure for “i386-apple-darwin11.1.0″
disregard! :)
sh-3.2# file /opt/local/bin/octave
/opt/local/bin/octave: Mach-O 64-bit executable x86_64
It appears that the octave-devel package does not install 64-bit versions of its linear algebra dependencies. i.e. We still have 32-bit memory limitations even though we have run a 64-bit executable. e.g.
% Load a 3GB uint8 vector (32-bit limits to 2GB)
octave:1> a = zeros(1024^3*3, 1, ‘uint8′);
error: memory exhausted or requested size too large for range of Octave’s index type — trying to return to prompt
Source: http://www.gnu.org/software/octave/doc/interpreter/Compiling-Octave-with-64_002dbit-Indexing.html
this works perfectly under Lion 10.7.2, thanks for sharing, just what I needed.
Pingback: Making Octave for Mac draw images | Robert Castle Consulting