Rank: 1866 based on 29 downloads (last 30 days) and 2 files submitted
photo

Umberto Picchini

E-mail

Personal Profile:

Ph.D. in Statistics. My researches are mainly devoted to parameter estimation techniques for nonlinear dynamical models with emphasis on stochastic differential equations.

Personal page:
http://www.maths.lth.se/matstat/staff/umberto/

My Stochastic Differential Equations Toolbox for MATLAB can be found at:
http://sdetoolbox.sourceforge.net

Professional Interests:
Stochastic processes, dynamical models, stochastic differential equations, parameter estimation

 

Watch this Author's files

 

Files Posted by Umberto View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
13 Oct 2006 Fast Trapezoidal Integration Similar to TRAPZ but (up to) 16x-times faster. Equally spaced data NOT required. Author: Umberto Picchini integration, trapezoidal, mex, fast, quick 8 3
  • 3.75
3.8 | 4 ratings
20 Apr 2006 Fast Linear Interpolation Performs linear interpolation with a speed acceleration of (up to) 4x. Author: Umberto Picchini interpolation, mex, linear, approximation, fast, quick 21 1
  • 4.33333
4.3 | 3 ratings
Comments and Ratings on Umberto's Files View all
Updated File Comment by Comments Rating
04 Aug 2010 Fast Linear Interpolation Performs linear interpolation with a speed acceleration of (up to) 4x. Author: Umberto Picchini Erik

Great job! I achieved a speed up of 70x compared to interp1

19 Sep 2008 Fast Trapezoidal Integration Similar to TRAPZ but (up to) 16x-times faster. Equally spaced data NOT required. Author: Umberto Picchini Optican, Lance

trapzf does not allow for unevenly sampled data, even though the comment claims it does. Matlab's trapz does allow for uneven data. To correct this, the following change must be made to the C code of trapzf, here called trapzfu. Note that the speedup on a 64-bit WinXP computer of trapfzu over trapz was about 10-fold. Unrolling the loop in trapzfu2.c provides another 20% improvement in speed.

--- trapzfu.c ------
/* F=trapzfu(X,Y) computes the integral of Y with respect to X using
    the trapezoidal method. X and Y must be vectors of the same length.
    For trapzf to work properly:
    X must be a STRICTLY monotonically increasing vector.
    X does not need to be evenly spaced.
 
    C. Quaia, National Eye Institute, NIH, DHHS
 */

#include "mex.h"

void trapzfu( double *area, double *xv, double *yv, int N) {
        register int i;
        
        *area = 0;
        for (i = 0; i < (N-1); i++) {
                *area = *area + (xv[i+1] - xv[i]) * (yv[i] + yv[i+1]);
        }
        *area = *area / 2;
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
        int N, N1, N2;
        double *area;
        double *xv, *yv ;
        
        N1 = mxGetNumberOfElements(prhs[0]);
        N2 = mxGetNumberOfElements(prhs[1]);
        if (N1 != N2)
                mexErrMsgTxt("Input x and y must have the same length");
        else
                N = N1;
        if (N < 2)
                mexErrMsgTxt("The minimum length is 2");
        
        xv = mxGetPr(prhs[0]);
        yv = mxGetPr(prhs[1]);
        plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
        area = mxGetPr(plhs[0]);
        
        trapzfu(area, xv, yv, N);
}

------------ trapzfu2.c --------
/* F=trapzfu2(X,Y) computes the integral of Y with respect to X using
    the trapezoidal method. X and Y must be vectors of the same length.
    For trapzf to work properly:
    X must be a STRICTLY monotonically increasing vector.
    X does not need to be evenly spaced.

    L. Optican, NEI/NIH/DHHS

 */

#include "mex.h"

void trapzfu2( double *area, double *xv, double *yv, int N) {
        register int i, j,r;
        
        *area = 0;
        i = 0;
        r = (N - 1) % 4;
        for(; i < r; i++) {
                // *area += (xv[i+1] - xv[i]) * (yv[i] + yv[i+1]);
                *area += (xv[i+1] - xv[i]) * (yv[i+1] + yv[i]);
        }
        
        for(; i <= (N-4); i += 4) {
                *area += (xv[i+1] - xv[i]) * (yv[i+1] + yv[i]);
                *area += (xv[i+2] - xv[i+1]) * (yv[i+2] + yv[i+1]);
                *area += (xv[i+3] - xv[i+2]) * (yv[i+3] + yv[i+2]);
                *area += (xv[i+4] - xv[i+3]) * (yv[i+4] + yv[i+3]);
        }
        *area = *area / 2;
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
        int N, N1, N2;
        double *area;
        double *xv, *yv ;
        
        N1 = mxGetNumberOfElements(prhs[0]);
        N2 = mxGetNumberOfElements(prhs[1]);
        if (N1 != N2)
                mexErrMsgTxt("Input x and y must have the same length");
        else
                N = N1;
        if (N < 2)
                mexErrMsgTxt("The minimum length is 2");
        
        xv = mxGetPr(prhs[0]);
        yv = mxGetPr(prhs[1]);
        plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
        area = mxGetPr(plhs[0]);
        
        trapzfu2(area, xv, yv, N);
}

06 Mar 2008 Fast Trapezoidal Integration Similar to TRAPZ but (up to) 16x-times faster. Equally spaced data NOT required. Author: Umberto Picchini hhh, lll

not good

14 Feb 2008 Fast Trapezoidal Integration Similar to TRAPZ but (up to) 16x-times faster. Equally spaced data NOT required. Author: Umberto Picchini prabhu2003, mm

thanks

04 Jul 2007 Fast Linear Interpolation Performs linear interpolation with a speed acceleration of (up to) 4x. Author: Umberto Picchini Nievinski, Felipe
Top Tags Applied by Umberto
fast, mex, quick, approximation, integration
Files Tagged by Umberto View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
13 Oct 2006 Fast Trapezoidal Integration Similar to TRAPZ but (up to) 16x-times faster. Equally spaced data NOT required. Author: Umberto Picchini integration, trapezoidal, mex, fast, quick 8 3
  • 3.75
3.8 | 4 ratings
20 Apr 2006 Fast Linear Interpolation Performs linear interpolation with a speed acceleration of (up to) 4x. Author: Umberto Picchini interpolation, mex, linear, approximation, fast, quick 21 1
  • 4.33333
4.3 | 3 ratings

Contact us at files@mathworks.com