Well, technically speaking the code is correct - in terms of what _exactly_ is it doing. The code claims to do downSAMPLING, which is just throwing away specified frequencies. Unlike the _decimation_, which uses the low-pass filtering to mitigate the downsampling effects (slower and more complicated).
The effect that you experiencing in this example is called ringing, and this exactly what happens in up/downsampling without filtering.
Thanks for the updated code, Eric!
Works like a charm.
On a side note, and I think it is worth mentioning in the description that the speed-up is noticeable when the matrices are large (in the current example they are small). In my case, I have to solve a big least-squares problem - and invChol, literally, saves the day.
One comment. When I compile this in Linux (x86) on MATLAB 2009, I'm getting these warnings:
/opt/matlab/bin/mex invChol_mex.c -lmwlapack
invChol_mex.c: In function ‘mexFunction’:
invChol_mex.c:75: warning: implicit declaration of function ‘dpotrf_’
invChol_mex.c:87: warning: implicit declaration of function ‘dpotri_’
invChol_mex.c:111: warning: implicit declaration of function ‘spotrf_’
invChol_mex.c:123: warning: implicit declaration of function ‘spotri_’
Not critical, of course, but still.
03 Sep 2012
To calculate the full-width at half-maximum of an input.
Author: Patrick Egan