Skip to content

Commit

Permalink
allow hash or hashref for opts. This is for symmetry with SingleDim
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed May 9, 2012
1 parent 597a8fe commit 76a0c99
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/PerlGSL/Integration/MultiDim.pm
Expand Up @@ -17,16 +17,19 @@ our @EXPORT_OK = ( qw/
/ );

sub int_multi {
my $opts;
if (eval { ref $_[-1] eq 'HASH' }) {
$opts = pop;
croak "int_multi requires 3 arguments, aside from an options hash(ref)"
unless @_ >= 3;

my ($sub, $xl, $xu) = (shift, shift, shift);

my %opts;
if (@_) {
%opts = ref $_[0] ? %{shift()} : @_;
}
$opts->{calls} ||= 500000;

croak "int_multi requires 3 arguments, aside from an options hashref"
unless @_ == 3;
$opts{calls} ||= 500000;

my $ret = c_int_multi(@_, $opts->{calls});
my $ret = c_int_multi($sub, $xl, $xu, $opts{calls});
return wantarray ? @$ret : $ret->[0];
}

Expand Down

0 comments on commit 76a0c99

Please sign in to comment.