Hi all:  OK, I've checked in this patch.

Thanks,

  Doug

[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611

On Wed, 27 Oct 2010, Andres Jordan wrote:

Hi Doug, Jason,

Thanks, that explains it, I had not thought of repeated X values.
Patch seems like a good idea....

-Andres

On Wed, Oct 27, 2010 at 11:45 AM, Doug Hunt <[email protected]> wrote:
Hi Andres:  The problem occurs when there are two identical X values passed
in.  No sort will solve that problem.  What we're really getting at here is
a way to catch *any* error from the GSL interp routines.

I'm using the cspline interpolator for thousands of profiles--occasionally
one has two identical X values.  I'd like to be able to put the call to the
interpolator in an eval block and have it catch the error.

This small patch allows that.

Regards,

 Doug Hunt

[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611

On Wed, 27 Oct 2010, Andres Jordan wrote:

Hi Doug,

That should not happen, the init method in GSL::INTERP is supposed to
sort X by default (take a look at gsl_interp.pd). The error you
mention should show up only if you pass a non-monotonically increasing
set of X values *and* specify {Sort => 0} as an option. So I'm
confused by the reported behaviour...

-Andres

ps. the relevant bit of code in gsl_interp.pd is

 if($$opt{Sort} != 0){
  my $idx = PDL::Ufunc::qsorti($x);
  $x = $x->index($idx);
  $y = $y->index($idx);
 }



On Tue, Oct 26, 2010 at 1:46 PM, Doug Hunt <[email protected]> wrote:

Hi all:  In the default interpolation interface to GSL, if one uses a set
of
X values that are not monotonically increasing, GSL fails hard:

gsl: interp.c:83: ERROR: x values must be monotonically increasing
Default GSL error handler invoked.

this error cannot be caught by an exception handler, so is troublesome in
production code.

My collegue Jason Lin has found a simple patch which fixes this problem
(attached).  This patch just turns off the default GSL error handler
which
just calls 'stop'.

I've downloaded the latest GIT sources and applied it.  It seems to work.
 Any objections if I apply this patch?  Here is a test case for it:


--------------------------------------------------------------------------
my $nx = ($x)*($x<=3) + ($x-1)*($x>3); # x value not monotonically
increasing
my $i; eval { $i = PDL::GSL::INTERP->init('cspline',$nx, $y) };
like($@,qr/invalid argument supplied by user/,"module exception
handling");

--------------------------------------------------------------------------

I'm reluctant to add this to gsl_interp.t because it will cause the test
suite to fail hard if the patch has not been applied.

If there are no objections, I'll apply this patch in a couple of days.

Thanks,

 Doug


[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611


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





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

Reply via email to