GSL of C language binding to Perl - native keyword of Raku language is exported to Perl/SPVM

GSL of C language binding to Perl - native keyword of Raku is exported to Perl/SPVM

I success GSL binding by Perl/SPVM!

GSL of C language binding to Perl/SPVM

I export native keyword to Perl/SPVM. This is greate features of Raku language.

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/lib";

use SPVM 'MyGSL';

MyGSL->stat;

package MyGSL {
  native sub stat : void ();
}
#include "spvm_native.h"
#include
#include

#define LEN 6

int32_t SPNATIVE__MyGSL__stat(SPVM_ENV* env, SPVM_VALUE* stack) {
double data[LEN] = {10.5, 18.2, 10.3, 15.4, 16.2, 18.3};

double max = gsl_stats_max( data, 1, LEN );
double min = gsl_stats_min( data, 1, LEN );
double mean = gsl_stats_mean( data, 1, LEN );
double sd = gsl_stats_sd( data, 1, LEN );

printf( "max: \t%f \n", max );
printf( "min: \t%f \n", min );
printf( "mean: \t%f \n", mean);
printf( "sd: \t%f \n", sd );

return 0;
}

use strict;
use warnings;

use SPVM::Builder::Config;
my $bconf = SPVM::Builder::Config->new_default;
$bconf->add_extra_linker_flags('-lgsl');

$bconf;


Leave a comment

About Yuki Kimoto

user-pic I'm Perl Programmer. I LOVE Perl. I want to contribute Perl community and Perl users.