Posts Tagged ‘Octave’

Season’s End

During this summer, I participated in the Season of KDE, working on a Octave backend for Cantor with my mentor and Cantor author Alexander Rieder. I’m proud to say I have achieved my goal. In addition to running Octave commands directly from Cantor’s worksheet, all convenience features supported by both Cantor and Octave support are available:

  • Syntax highlighting for functions, variables, operators and strings
  • Tab-completion
  • Easy access to function documentation / syntax help
  • Easy 2D and 3D plotting of functions, with plots integrated in the worksheet
  • Linear algebra extension for defining matrices and computing their inverse, eigenvectors and eigenvalues
  • Integrated script editor and runner
  • Possibility to interrupt or restart Octave at any time

I haven’t been really regular with blogging, so I would like to apologize and give you something better in return: a screencast. Please excuse my bad english and strange voice, I’m really not a good speaker in any language.

Also, it was only after I finished that I remembered it would be better to make a presentation with untranslated Cantor. I hope I explained everything I did well enough.

Hi-quality version

Low-quality version

I would really like to thank the KDE team (especially Lydia) for organizing this, and my mentor Alexander for help and guidance (and finding me more things to do 🙂 ). I will certainly continue working on (and with) KDE.


Octave-backend improvements

I’m having a bit of a pause between the exams, so I’m doing some hacking on the new Octave backend for Cantor. Thing are going very well, probably better (especially faster) that I expected.

The basic input-output sending between Cantor and the command-line process was working some time ago, and I recently added support for embedding graphics into the worksheet.

This week I was working on cosmetics: Autocompletion, syntax highlighting and pop-up help.

Completion for functions and variables

Completion for functions and variables

Completion was easy, octave provides a completion_matches() function which takes a string argument and return all functions and variables starting with that string.

Syntax highlighting and help

Highlighter - there can be only one.

Syntax help was also quite straightforward, through the use of Octave’s built-in help() command. Highlighting was where I spent most of the time, because as a command-line program Octave has no native support for it.

There’s a handy command called ‘who’ that lists all currently visible variables, so I retrieved the variable name list with it and used it in the highlighter. I then hardcoded a list of all recognised operators and keywords.

The toughest nut was getting a list of all functions from Octave. There’s no (at least known to me) equivalent to ‘who’ for functions, so I had to improvise. I didn’t want to hardcode all the functions, as is done for the Maxima backend, because, as we all know, hardcoding is bad, and there’s always the possibility of future changes to Octave language. The closest I could get is using completion_matches() with an empty string, but that returns all the internal constants, environment variables, and files in the current directory. I filtered them out the best I could, and the end result work well, despite there being more that 1600 functions.

Embedded plots in Cantor

Embedded plots in Cantor

Another think I worked on this week is getting as much plotting code as possible from C++ to an octave script. This not only unclutters the worksheet (there used to be a long line of commands instead of cantor_plot#d()), but makes simple changes to plotting faster by not requiring a recompile. Tweaking the size of the plot to prevent it from filling the whole page didn’t even need a new session, just an update to the script.

Hello Planet

Since my blog is now shown on PlanetKDE, I believe I should write a formal introduction:

My name is Miha Čančula, I’m a second year Physics student from Slovenia. My involvment in KDE this summer is mainly composed of two parts:

Octave backend for Cantor

I didn’t make it into GSoC with this, so now it’s a part of the Season of KDE, mentored by Alexander Rieder. I should be doing this after I finish my exams, which will be in July and August, but I made quite a progress even before the exam period. Pretty much all the functionality is already there, I’m even using it for my Numerical methods class. What’s missing is completion and syntax highlighting, those will have to wait for about a month, when I’ll have some free time, and when I discuss it with the mentor.

KDE4 port/rewrite of Knights

For my current pet project, I chose something less serious, and something I figured to be quite easy to go. It is smooth sailing so far, but interfacing with console programs (a recurring theme for me, that’s also how Cantor talks to Octave) and the chess server took some time, documentation searching and experimentation.

Currently supported is a hot-seat game on one computer, playing against an XBoard-compliant chess engine, and the Free Internet Chess Server. I’m still not sure how to interface with Crafty, although XBoard and the old Knights support it. I’ll take a deeper look into their sources soon. And as promised in my previos post, a screenshot of playing on FICS:

As you can see, the default theme is the one from Knights for KDE3 with consent from its author, Troy Corbin. He didin’t have a SVG version, so they’re all PNG’s inside a SVG file. I would very much like a new, completely scalable theme as the default one, as it would look much nicer. Also included is a vector Tux theme, which looks much better, but the penguins aren’t really suitable for being the default.