The Riemann Zeta Function

| | Comments (0) | TrackBacks (0)
Here is a view of the Riemann Zeta function graphed from x=1.2 to 10. You will notice a sharp spike as x goes toward 1, where it shoots off to infinity. The Riemann Zeta function at x=1 is the harmonic series. Since *everybody* knows the harmonic series diverges, so does the Riemann Zeta function at x=1. As x gets larger, the function approaches 1 quickly. This function directly determines the statistical properties of the distribution of prime numbers, so mathematician go wild studying everything about it.

gsl_sf_zeta.png
If you can prove that the only solutions to the equation Zeta(z) = 0 occur on the line Re(z) = 1/2 (aka The Riemann Hypothesis), then you get a million bucks!

Sexy Bessel Functions with Chart::Clicker

| | Comments (0) | TrackBacks (0)
These charts are created with Perl and Math::GSL via the great new charting module Chart::Clicker, which uses the Cairo library to produce very nice alpha transparency and other visual eye candy. Here are the first two Bessel Functions of the First Kind (J0(x), J1(x)) and the first two Spherical Bessel Functions (j0(x), j1(x)). Bessel Functions of the First Kind usually arise in a problem that has circular or cylindrical symmetry, while the the latter occur when spherical symmetry is present. These functions where discovered when German mathematician/astronomer Friedrich Wilhelm Bessel was studying the motion of the planets and comets in the early 19th century.

The script to generate these charts is examples/clicker/chart in the latest bleed branch of Math::GSL. A release to CPAN is coming soon... gsl_sf_bessel_j0.pnggsl_sf_bessel_j1.pnggsl_sf_bessel_j0.pnggsl_sf_bessel_j1.png

Google Summer of Code 2008 Recap

| | Comments (0) | TrackBacks (0)
What an amazing summer! I really couldn't have imagined all the things that I would learn or teach, the obstacles that would make it challenging or the people that I would meet.

Thierry Moisan submitted the Math::GSL proposal that was chosen by The Perl Foundation for one of the five slots that we received. It was well-written and organized, but I reordered some of the milestones, pushing more difficult subsystems to the end so that they wouldn't stall development. Thierry made 226 git commits during GSOC08, which ranged from tests, POD documentation, SWIG typemaps and Perl implementation. He is mostly responsible for an immense amount of tests and documentation in the BLAS, Linalg, Matrix and Fit subsystems. Thierry also wrote a function graphing program using perl/Tk, which is in the "examples" directory of the distribution.

I live in Portland and Thierry is in Quebec City, so we mostly communicated through gchat, email and git commit messages, which seemed pretty effective. Public mailing lists like pdx-pm and swig-user were also helpful, as well as all the feedback I got when I gave a talk featuring Math::GSL at the Advanced Topics Portland Linux User Group (ATPLUG).

GSOC08 really provided the impetus to make Math::GSL a reality. I had a prototype (read: hackish script) that implemented only the Special Functions of GSL in 2000 and then it just sat around until Thierry's proposal.

As of the end of GSOC08, 41/48 of the Math::GSL subsystems were fully functional. The few remaining subsystems required callbacks, which were only partially implemented. As of this writing though, I have cracked the case and started to fully implement the remaining subsystems with Thierry. Numerical derivatives and integration (Deriv and Integration) are already supported.

 This summer has also spawned two mailing lists, the math-gsl-dev google group and the perl-scientific-computing group. The first is for Math::GSL development and usage in particular, the second is for a broader audience. I envision Math::GSL as only the beginning of a suite of modules (or a custom Perl distribution)  that enable scientists to "do science" in a quick and efficient way with Perl. If this sounds interesting, please come join and start some gossip!

I believe that Thierry grew tremendously as a developer, he became proficient using git and doing advanced vim hackery as well being introduced to new programming concepts (like typemaps) and new libraries (Tk).  Knowing that I helped introduce a new member to the open source community while hacking on something cool (and making it work!) is the best payment that I could get. That and maybe a tshirt.


Math::GSL 0.10 released to CPAN

| | Comments (0) | TrackBacks (0)
Math::GSL has been kicking around on CPAN for a few days now, and seems to be doing well with the CPANtesters , except for multi-threaded Perls. This is a very important piece of information to learn, since I develop on FreeBSD 6.x and Ubuntu 8.x, which come with single-threaded Perls, and I had of course recompiled my own Perl from source, but single-threaded is again the default in Configure.

The Build fails like this:

gcc -I/usr/lib/perl/5.8/CORE -c -shared -Wall -fpic -Dbool=char -Wno-strict-aliasing -Wno-unused-function -Wno-unused-value -Wno-unused-function -Wno-unused-variable -o
BLAS_wrap.o BLAS_wrap.c
In file included from /usr/lib/perl/5.8/CORE/op.h:
497,
                from /usr/lib/perl/5.8/CORE/perl.h:2754,
                from BLAS_wrap.c:716:
/usr/lib/perl/5.8/CORE/reentr.h:612: error: field '_crypt_struct' has
incomplete type
In file included from /usr/lib/perl/5.8/CORE/perl.h:3950,
                from BLAS_wrap.c:716:
/usr/lib/perl/5.8/CORE/proto.h:297: error: expected declaration
specifiers or '...' before 'off64_t'
/usr/lib/perl/5.8/CORE/proto.h:299: error: expected '=', ',', ';', 'asm'
or '__attribute__' before 'Perl_do_sysseek'
/usr/lib/perl/5.8/CORE/proto.h:300: error: expected '=', ',', ';', 'asm'
or '__attribute__' before 'Perl_do_tell'
/usr/lib/perl/5.8/CORE/proto.h:2005: error:
expected '=', ',', ';', 'asm' or '__attribute__'
before 'Perl_PerlIO_tell'
/usr/lib/perl/5.8/CORE/proto.h:2006: error: expected declaration
specifiers or '...' before 'off64_t'
error building .o file from 'BLAS_wrap.c'
at /tmp/Math-GSL-0.08/_build/lib/MyModuleBuilder.pm line 167.

Does anyone know of extra build flags which are necessary when building XS modules on multi-threaded Perls?



Math::GSL 0.08 released to CPAN

| | Comments (0) | TrackBacks (0)
Coming to a CPAN mirror near you, a brand spanking new Math::GSL, now with Cygwin support!

Enjoy!

week 11 report

| | Comments (0) | TrackBacks (0)
There's only one week left to the google summer of code part of the project! Time passed really fast this summer. Last week I started a overall review of all the subsystems of the project to make sure that everything is fine for the pencil down date which is this Friday, august 18. I preferred adding more documentation to the subsystems than adding code to the Tk example since I think it's more important at the moment. I'll touch the Tk example this week if I have enough time but I plan to first finish my overall review before.

I've learned a lot this summer on various aspect of programming : using git, vim and Tk,  Object-Oriented programming, and better Perl programming. I plan to continue to work on this project even after the end of google summer of code. Of course I'd like to thank Jonathan Leto who gave me his time and knowledge. Without him, this project wouldn't exist.

Week 10 report

| | Comments (0) | TrackBacks (0)
Last week I worked on making the documentation more HTML friendly. I added basic documentation to the remaining subsystems not yet implemented. We also released a public version on CPAN. I fixed various bugs that we received from the CPANT tester. There are still little issues to look at for this release like the META.yml file which doesn't output exactly the right things but this is not anything major. I worked on the example using Tk::TableDataset to add a menu and various additions to it. I've learn a lot about Tk and GUI  while working on this example. I also discovered the Perl::Tidy module to make the perl code easier to read. Finally, I finished the Sum subsystem, it is now fully functional.

In the next week I will complete the overall documentation by adding more concrete examples to all the functional subsystems. These examples will probably mainly come from the tests we've already wrote for those subsystems. I also wish to add more functions and change a bit more the code of the Tk::TableDataset example. Depending on the time left, I might also add more Object-Oriented wrappers.

Example using Tk::PlotDataset

| | Comments (0) | TrackBacks (0)
Here is an a screenshot of the example file examples/tkplotdataset:
View image


#!/usr/bin/perl 
use Tk;
use Tk::PlotDataset;
use Tk::LineGraphDataset;
use Math::GSL::SF qw/:all/;
use strict;

my $window = MainWindow->new(
    -title => 'Math::GSL Plot',
);
my @region = map { $_/10 } (-400 .. -1, 0, 1 .. 400);
my @data1  = map { gsl_sf_bessel_J0($_) } (@region);
my $dataset1 = LineGraphDataset->new(
    -name => 'gsl_sf_bessel_J0',
    -xData => \@region,
    -yData => \@data1,
    -yAxis => 'Y',
    -color => 'red'
);

my @data2 = map { gsl_sf_bessel_J1($_) } (@region);
my $dataset2 = LineGraphDataset->new(
    -name => 'gsl_sf_bessel_J1',
    -xData => \@region,
    -yData => \@data2,
    -yAxis => 'Y1',
    -color => 'blue'
);

my $graph = $window->PlotDataset(
    -width => 500,
    -height => 500,
    -background => 'snow'
) -> pack(-fill => 'both', -expand => 1);

$graph->addDatasets($dataset1, $dataset2);
$graph->plot;
MainLoop;
exit(1);

Week 9 report

| | Comments (0) | TrackBacks (0)
This week I finished the Fit subsystem. I also worked on Histogram which only has two functions that I don't understand that should be tested to be completed. Multifit is almost finished too, I simply have a little problem with constants from GSL that I need for a few functions to be working. Interp is functional now but some function aren't tested yet (even in the GSL source code). I also added documentation to various subsystems : Wavelet, Histogram2D, BLAS, Interp, Vector and Matrix. I added some typemaps to Matrix to make the view_array functions fully functional.

I've done some more reading on the vim functionalities and I've been trying stuff with the ex commands while developing this week. I've even been aple to create my own mapping for compiling/running c++ code directly from vim.

Jonathan has put our work on CPAN and we already received some testing results from CPANT. This week I will concentrate on fixing problems arising from these testing results, finishing Histogram2D, refactoring tests to remove the "is" functions when we test float numbers and taking a look for other subsystems that I could make work with the current typemaps.

Week 8 report

| | Comments (0) | TrackBacks (0)
This week I almost finished BLAS, it only needs some more documentation and fixing a few tests. I also added new wrappers to Matrix which let the user set values of a matrix row by row (set_row) or column by column(set_col), output a column matrix(col), output a row matrix(col) and I made modifcations to the wrapper as_list that Jonathan already wrote which output the matrix as a list. I added more documentation to Histogram. Finally I took a look at other modules I could work on this week with our current tyepmaps. I chose the following modules to work on this week : Multifit, Interp, Wavelet and NTuple. I'll also take a look at Fit but the only function I tried to test died so I might have to play with the current typemaps.