1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2017 - Samuel GOUGEON
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
14 function v = intsplin(x, s)
15 //splin numerical integration.
16 //v = intsplin(x,s) computes the integral of y with respect to x using
17 //splin interpolation and integration.
18 //x and y must be vectors of the same dimension
20 //v = intsplin(s) computes the integral of y assuming unit
21 //spacing between the data points.
29 if size(x,"*")<>size(s,"*") then
30 msg = _("%s: Wrong size for input arguments: Same size expected.\n")
31 error(msprintf(msg, "intsplin"));
38 msg = _("%s: Argument #%d: Real number(s) expected.\n");
39 error(msprintf(msg, "intsplin",1))
42 h = x(2:$) - x(1:$-1);
45 v = sum((h.*(d(1:$-1)-d(2:$))/12 + (y(1:$-1)+y(2:$))/2).*h);
49 v = v + %i*sum((h.*(d(1:$-1)-d(2:$))/12 + (y(1:$-1)+y(2:$))/2).*h);