perlquestion
hda
Oh wise monks! <br><br>
I am trying to use [http://search.cpan.org/dist/Math-GSL/lib/Math/GSL/Histogram.pm | Math::GSL::histogram ] to construct an histogram with logarithmic bins. What I want to do is to read the data from an array or a PDL piddle. However, Math::GSL seems to require a "stream", i.e. a file to read data from. I tried to save my data to a file in several formats but I could not manage to get Math::GSL to read it. I am obviously doing something wrong and I will appreciate any hint from you!<br><br>
Here is my code, it terminates with segment fault: <br><br>
<c>
my $fo = gsl_fopen('myfile', 'w'); # sets the output file
my $fi = gsl_fopen( $input_stream ); # here is where I can't understand how it works
my $h = gsl_histogram_alloc (5);
gsl_histogram_fscanf($fi, $h);
my $range = [ 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0 ];
gsl_histogram_set_ranges($h, $range, 4);
gsl_histogram_fprintf($fo, $h, "%g", "%g");
gsl_fclose($fi);
gsl_fclose($fo);
</c>
<br><br>
Thanks in advance!