Next: , Previous: Iterative Techniques, Up: Sparse Matrices


22.5 Using Sparse Matrices in Oct-files

An oct-file is a means of writing an Octave function in a compilable language like C++, rather than as a script file. This results in a significant acceleration in the code. It is not the purpose of this section to discuss how to write an oct-file, or discuss what they are. There are already two 1 very good references on oct-files themselves. Users who are not familiar with oct-files are urged to read these references to fully understand this chapter. The examples discussed here assume that the oct-file is written entirely in C++.

There are three classes of sparse objects that are of interest to the user.

SparseMatrix
A double precision sparse matrix class
SparseComplexMatrix
A Complex sparse matrix class
SparseBoolMatrix
A boolen sparse matrix class

All of these classes inherit from the Sparse<T> template class, and so all have similar capabilities and usage. The Sparse<T> class was based on Octave Array<T> class, and so users familar with Octave's Array classes will be comfortable with the use of the sparse classes.

The sparse classes will not be entirely described in this section, due to their similar with the existing Array classes. However, there are a few differences due the different nature of sparse objects, and these will be described. Firstly, although it is fundamentally possible to have N-dimensional sparse objects, the Octave sparse classes do not allow them at this time. So all operations of the sparse classes must be 2-dimensional. This means that in fact SparseMatrix is similar to Octave's Matrix class rather than its NDArray class.


Footnotes

[1] Paul Thomas "Dal Segno al Coda - The octave dynamically linked function cookbook", http://perso.wanadoo.fr/prthomas/intro.html, and Cristophe Spiel "Del Coda Al Fine - Pushing Octave's Limits", http://octave.sourceforge.net/coda/coda.pdf