I'm assuming you need to integrate between points that aren't 
necessarily your xvals points?  I've used the PDL::Func module for 
this--the docs say it "contains useful functions", which probably isn't 
a specific enough advertisement for its true functionality.  If you have 
Slatec installed, then you're in luck.  You just specify your 
Hermite-schemed object, then tell it to integrate between your two 
points.  Something like:

use PDL::Func;
$obj = PDL::Func->init(Interpolate=>'Hermite');
$obj->set(x=>xvals(10),y=>xvals(10)); #or whatever your real x and y are
p $obj->integrate(x=>pdl(0,4.5)); #the points to integrate between
10.125

to compute the area of an isosceles right triangle with legs of length 
4.5.  There are other options, as well as functions to interpolate and 
differentiate.

cheers,
Derek

Hernán De Angelis wrote:
> Dear all,
>
> I wonder if someone can illuminate me on numerical integration with
> PDL. I have tried (almost) hard with both chia (PDL::Slatec) and
> gslinteg_qng (PDL::GSL::INTEG) but got a bit swamped.
>
> Essentially, I have two piddles coming from the output of "hist": one
> contains xvals and the other the frequencies. What I need to do is to
> calculate the integral of that histogram over different intervals .
>
> My actual code looks like this (using GSL):
>
> use PDL;
> use PDL::GSL::INTEG;
>
> my $xmin = min $a; # the minimum limit of integration
> my $xmax = max $glacier; # maximum limit
> my $s_ave = avg $s; # some value extracted from another piddle
>
> my $epsrel = 0;  # this value is taken from the example in the documentation
> my $epsabs = 1e-3;  # same as above, but a bit higher
> my ($a1,$abserr,$ierr,$neval); # define variables
>
> # try to integrate. $b is a 1-D piddle containing the
> ($a1,$abserr,$ierr,$neval) = gslinteg_qng( $b, $zmin, $s_ave, 
> $epsrel,$epsabs);
>
>
> Then I get this:
>
> Not a CODE reference at
> /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi/PDL/GSL/INTEG.pm
> line 589.
>
>
> May be there is a problem because I did not define a certain
> subroutine &myfunc, but the fact is that I do not have a function in
> the traditional sense, but two list of values, one representing the
> independent variable and the other the (unknown) function values.
>
> Any hint will be appreciated,
>
>
> Thanks in advance
>
>
> Hernán
>
>
>
>   


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to