Calling ARPACK functions from C++ using liboctave

Previously I post on how to call GSL function, now it’s time for ARPACK. In octave, when you run interactively, you just need to run “eigs” for various matrix function. So Octave has provided some bindings to call ARPACK functions. So following the same steps as calling GSL function:
download arpack-1.0.6.tar.gz.
unzip the file and type [...]

C++ code calling GSL (GNU Scientific Library) functions with liboctave

Octave is amazing! I started writing C++ code using liboctave as a library. However, now and then, I need to call some GSL functions from my C++ code. In octave it’s pretty straight forward, you just need to install GSL package from octave-forge.  But, hey, we can extend to our C++ code as well. This [...]

Octave C++ Class Documentation

This is the class documentation for Octave 3.0.2 generated by doxygen:
http://octave.sourceforge.net/doxygen/html/index.html

Installing ARPACK from source

To install ARPACK from source, download the source code and the patch file as instructed in this page.
http://www.caam.rice.edu/software/ARPACK/
If you have retrieved arpack96.tar.gz and patch.tar.gz then issue the following command
zcat arpack96.tar.gz | tar -xvf -
zcat patch.tar.gz | tar -xvf -
and then edit the ARmake.inc to specify the $(home) variable (this is the home [...]

Installing Octave’s binding for ARPACK in Kubuntu Hardy for Sparse Matrix Calculation

Octave Forge provided an octave binding to Arpack to solve large scale sparse matrix. So first download from octave forge packages.
And to install the package, you need to have the header files for suitesparse and libarpack. So type this in console:
sudo apt-get install libsuitesparse-dev libarpack2-dev
after that go to the download folder of Octave’s arpack and [...]

Octave configure cannot find libreadline

somehow my ./configure command for Octave 3.0.3 cannot find libreadline. I have specified in LDFLAGS and CPPFLAGS the directory of my non-standard installation. so in one of the forum, it was suggested to check the config.log, and I found this error message when testing readline:
libreadline.so: undefined reference to `PC’

..

and after googling around, It turns out [...]

Segmentation fault when using .oct function

I created my own function and compile it as .oct. But everytime I run it I got this error
octave:1> finvhalf
panic: Segmentation fault — stopping myself…
attempting to save variables to `octave-core’…
save to `octave-core’ complete
Segmentation fault
The thing is that the output does not really tell what is the error. The compilation was successful as well. It turns [...]

Octave C++ Quick Reference

I found the Octave Wiki which provides a quick reference how to port Octave code to its C++ using Octave’s library. But somehow, recently I can’t access the wiki. Luckily, I can still find it in the Google’s cache search.
You can see it here:
OctCppQuickRef.pdf
UPDATE:
Now I can access the page again. it’s here:
http://wiki.octave.org/wiki.pl?CPPQuickReference

Use fabs for getting the absolute from double

I am porting my Octave code to C++, somehow I always got zero for one expression that I calculate. After debugging, it turns out after I take abs(expression), the values always zero. Argh. I forgot, abs() in C++ is only for integer and long. I need to use fabs() for float or double. Now it [...]

1D Integration of discrete data with non-uniform grid spacing

Octave provides a simple function to do this integration even using non-uniform grid spacing: trapz(x,y)
http://octave.sourceforge.net/doc/f/trapz.html
A similar function exists in Matlab, Mathworks website gives more documentation on how to use it.