List sorted files/folder based on time or date

To list the files/folder sorted based on time, simply type
ls -lt
the -l is for “long” format display, and -t is to sort based on its “time”. to sort in reverse order, type
ls -lrt

Advertisements

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 out that my output from this function is a ColumnVector object, but I need to specify the size of this object. So in the initialization,

ColumnVector x(args(0).vector_value());
int len=x.length();
ColumnVector vret(len);

where vret is the variable name to return. This solves the problem.

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 works just fine.

how to create a package from svn (subversion) folder

After developing my code for quite sometime, now it is ready to release its 1.0 version.
svn export my-working-copy my-dest-folder
This copy action omit the “.svn” folder inside. So all the svn info is not copied. And then, just archive the folder as usual.

tar czvf yourpackage.tar.gz ./yourfolder

more info on svn export:
http://svnbook.red-bean.com/nightly/en/svn.ref.svn.c.export.html

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.

Writing mixed code Octave and C++

I need to speed up my Octave code, so I decided to port some of them to C++. The great things is that, it turns out not so difficult to port from the available octave code to C++. Octave provides the library to do matrix operations, vector, eigenvalue, linear algebra in C++ objects/functions.

For more info, the first step is to go to the Octave Wiki:

http://wiki.octave.org/wiki.pl?CategoryExternal

Then, read an easy introductory article

http://perso.wanadoo.fr/prthomas/intro.html

And the most useful page for me is the CPP Quick Reference:

http://wiki.octave.org/wiki.pl?CPPQuickReference

Octave C++ class doxygen documentation:

http://octave.sourceforge.net/doxygen/html/index.html

And there is this document written by Mathias on how to use liboctave for your C++ code:

http://www.mathias-michel.de/index.php?page=4&site=4