Skip to content

Instantly share code, notes, and snippets.

Created July 29, 2011 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1112869 to your computer and use it in GitHub Desktop.
Save anonymous/1112869 to your computer and use it in GitHub Desktop.
The following works find on my float arrays, but not for int arrays
# First, the definitions needed for the signatures:
dlfunc nci, lib, 'gsl_stats_max', 'dpll'
set_global ['GSL'], 'gsl_stats_max', nci
dlfunc nci, lib, 'gsl_stats_int_max', 'ipll'
set_global ['GSL'], 'gsl_stats_int_max', nci
# $arg will be a Resizable*Array
my sub max ($arg) {
if (pir::typeof($arg[0]) eq 'Float') {
my @ans := pir::new("ResizableFloatArray");
my $fun :=
Q:PIR { %r = get_global ['GSL'], 'gsl_stats_max' };
@ans[0] := $fun($arg, 1, length($arg)[0]);
return @ans;
}
if (pir::typeof($arg[0]) eq 'Integer') {
print("max(Integer) is buggy, sorry");
my @ans := pir::new("ResizableIntegerArray");
my $fun :=
Q:PIR { %r = get_global ['GSL'], 'gsl_stats_int_max' };
@ans[0] := $fun($arg, 1, length($arg)[0]);
return @ans;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment