Math::GSL 0.18 on CPAN

| | Comments (0) | TrackBacks (0)
Grab the latest Math::GSL to get these spiffy features and bugfixes:

  • Made Math::GSL play nice with latest and greatest GSL 1.12
  • Added swap() to Vector objects with tests and docs
  • Added p-norms to Vector objects via norm() and normalize()
  • Added operator overloading so that
abs $vector == $vector->norm
  • Added as_vector() to Matrix and MatrixComplex objects
  • Added inverse(), is_square(), det(),  lndet(), zero() and identity() to Matrix objects
  • Added inverse(), is_square(), det(),  lndet(), zero(), identity() and hermitian() to MatrixComplex objects
  • Added dot product to Matrix objects
  • Fixed various typos in documentation
  • Fixed warnings about overloaded operators in Matrix and BLAS
  • Overloaded '==' and '!=' for MatrixComplex and Matrix objects
  • Fixed amd64 -fPIC compile failure
  • Added tests to Monte and refactored Sort tests
  • Refactored and improve error checking in callback interface
  • Fixed 'NaN' test failures (thanks CPANtesters!)
Enjoy!

Math::GSL 0.17_01 on CPAN

| | Comments (1) | TrackBacks (0)
Math::GSL is still in active development and we have been working hard to make sure that it is compatible with the most recent GSL, which is 1.12 released on Dec 16 2008. This release is mostly for CPANTesters to see what bugs they can shake out of it, but it contains these tasty features:

  • Make Math::GSL play nice with GSL 1.12
  • Added swap() to Vector objects with tests and docs
  • Added p-norms to Vector objects via norm() and normalize()
  • Added operator overloading so that : abs $vector == $vector->norm
  • Added as_vector() to Matrix and MatrixComplex objects
  • Added inverse(), is_square(), det(),  lndet(), zero() and identity() to Matrix objects
  • Added inverse(), is_square(), det(),  lndet(), zero(), identity() and hermitian() to MatrixComplex objects
  • Added dot product to Matrix objects
  • Fixed various typos in documentation
  • Fixed warnings about overloaded operators in Matrix and BLAS
Enjoy!

Matrix Eigenvalues in Perl Don't Get Much Easier

| | Comments (0) | TrackBacks (0)
The Matrix subsystem has really grown up in the last few days since the 0.16 release, including easy-to-use methods to calculate Matrix eigenvalues. All kinds of other methods are now available, like
my $det1 = $A->det;      # determinant
my $det2 = abs $A;       # determinant

my $inv = $A->inverse;  
my @eigs = $A->eigenvalues;

my ($eigenvalues, $eigenvectors) = $matrix->eigenpair;
my ($eig1,$eig2) = @$eigenvalues;
my ($u,$v)       = @$eigenvectors;
Compare this new script for calculating eigenvalues and eigenvectors of a nonsymmetric matrix to the old version. Yes, quite an improvement and quite pleasing to the eye now. Note that $A->eigenvalues; returns a list of Math::Complex objects because in general the eigenvalues of a real matrix can be complex. Only if your matrix is symmetric are you guaranteed real eigenvalues.
I just pushed Math::GSL 0.16 to CPAN, it should be showing up here Real Soon Now, depending on how much traffic the dump trucks hit on the intertubes

  • Fixed RT#40947: configure_requires ExtUtils::PkgConfig bug
  • Operator overloading for addition, multiplication and subtraction on Matrix objects (Thierry)
  • Fix an include bug in Histogram2D which caused the build to fail (Thierry)
  • Added reverse() and swap() methods to VectorComplex objects with tests and docs
  • as_list() and get() now work on VectorComplex objects
    • as_list() returns a list of Math::Complex objects
    • get() returns a list of Math::GSL::Complex objects
  • Math::GSL::Test::ok_status() now takes an optional message argument
  • Added KNOWN_BUGS
  • Added Math::GSL::Test::is_status_ok()
  • New subsytems: VectorComplex and MatrixComplex
  • Operator overloading for addition and subtraction with vectors
  • Added example: examples/matrix/nonsymmetric_eigen
    • Shows how to find the eigenvalues of a nonsymmetric matrix
  • Added copy() method to vectors
  • Improved Vector docs
  • Sped up vector dot products by 15x using BLAS function gsl_blas_ddot
    • NOTE: using gsl_blas_ddot($x->raw,$y->raw) directly is still about 10 times faster than $x * $y due to error checking and function call overhead
  • Separated POD and Perl code out of SWIG interface files, yay for proper syntax highlighting
  • Added stub test files for Heapsort, IEEEUtils, Multimin, Siman, Wavelet2D
  • All test files now keep track of how many tests should run

Back on track

| | Comments (0) | TrackBacks (0)
I haven't been able to add code to Math::GSL since about a month because of a tricky bug I had with the build process. Not only was it tricky, it was well hidden and pretty stupid to fix once I saw it.

Now that it's fixed I've been able to commit some code concerning overloading operators + and - in Math::GSL::Matrix. It's been tested and documented but it could still enjoy more documentation. End term exams are coming pretty fast to me so I won't finish overloading multiplication of matrices before one or two weeks.

Ho and Math::GSL 0.16 should be out soon, stay tuned!

Math::GSL 0.15_05

| | Comments (0) | TrackBacks (0)
I just pushed Math::GSL 0.15_05 to CPAN, which includes these fixes since 0.15_04 : 

  • Fixed RT#40947: configure_requires ExtUtils::PkgConfig bug 
  • Added reverse() method to VectorComplex objects with tests and docs 
  • as_list() and get() now work on VectorComplex objects 
    • as_list() returns a list of Math::Complex objects 
    • get() returns a list of Math::GSL::Complex objects

Enjoy!

Updates and Promises

| | Comments (0) | TrackBacks (0)
Yes, it has been quiet here but development on Math::GSL has steadily continued behind-the-scenes. I just pushed a dev release (0.15_04) to CPAN, it should be hitting a mirror near you soon. If the CPANTesters don't find anything horribly wrong with it, it will probably become 0.16. Some new features of 0.16 will be:

  • New subsytems: VectorComplex and MatrixComplex
  • Operator overloading for addition and subtraction with vectors
  • Added example: examples/matrix/nonsymmetric_eigen
        Shows how to find the eigenvalues of a nonsymmetric matrix
  • Added copy() method to vectors
  •  Improved Vector docs
  • Sped up vector dot products by 15x using BLAS function gsl_blas_ddot
        NOTE: using gsl_blas_ddot($x->raw,$y->raw) directly is still about 10 times faster 
              than $x * $y due to error checking and function call overhead
  • Separated POD and Perl code out of SWIG interface files, yay for proper syntax highlighting
  • Added stub test files for Heapsort, IEEEUtils, Multimin, Siman, Wavelet2D
  • All test files now keep track of how many tests should run and other important infrastructure changes

Only a few of the changes are user-facing but they are important in terms of the long-term development and health of Math::GSL. 

While I have been making these back-end changes I have been prototyping a web-based interface to Math::GSL using jQuery. I have many functional parts but no coherent interface that I am willing to inflict on users. But I promise you that soon you will be able to use Math::GSL via your browser and bypass the whole "what-do-you-mean-i-have-to-compile-it" issue. 

Complex Eigenvalues with Math::GSL

| | Comments (0) | TrackBacks (0)
After a question arose recently about finding complex eigenvalues of non-symmetric matrices, I wrote this example to show how it can be done with Math::GSL. The current example is called examples/matrix/nonsymmetric_eigen in the Math::GSL source, which will be in the 0.16 Math::GSL release. It uses the gsl_eigen_nonsymmv() function to do all the hard work, the rest is twiddling complex numbers. The documentation for this can be found with perldoc Math::GSL::Eigen or here.(The HTML rendering of the POD needs some work...) You can read the original C documentation for this function here.

 It is a well known theorem of linear algebra that symmetric matrices can have only real eigenvalues. Thus it is much easier to find eigenvalues of symmetric matrices because there is no possibility of complex numbers arising. You can do this with Math::MatrixReal, which is written in pure-Perl.

The output of examples/matrix/nonsymmetric_eigen looks like:

Finding eigenvalue/eigenvectors for
[ 0  -1 ]
[ 1   0 ]

Eigenvectors:

u = (0.707106781186547,-0.707106781186547i)
v = (0.707106781186547,0.707106781186547i)

Eigenvalues:

lambda_0 = i
lambda_1 = -i


By the way, sqrt(2)/2 = 0.707106...

I am not quite happy with how long the program is, mainly because I have not written a Perlish interface around Complex Vectors and Matrices yet, so it is all in that script right now. The stringification could be built into the object and therefore reduce the length of that code dramatically.

Inside Look of Math::GSL

| | Comments (0) | TrackBacks (0)
Here is a breakdown of how many lines of code (roughly) are in different languages in the Math::GSL codebase:

  • 280889 lines - XS ( C-like Perl internals autogenerated by SWIG)
  • 60181 lines  - Total Perl (generated by SWIG)
  •  22941  lines- Hand-written Perl 
    •  8617 lines - Tests
    • 13731 lines - POD (this actually includes some Perl implementation, probably <5%). Much of this was autogenerated from the GSL C documentation and reformatted, but it stills needs work, especially in making the POD render to HTML in a more pleasant way.
  • 1112   lines - SWIG
The reason why Math::GSL requires something like SWIG becomes very apparent. The SWIG interface files are roughly 1/280th the length of the raw XS source code. No reasonable  person would be hacking on Perl internals, but not even a reasonable Perl hacker wants to write all that error checking boilerplate cruft. Thanks SWIG!

This was made possible by ripping all Perl code out of the SWIG interface files and putting them in the pod/ directory. It is not strictly POD but a simple naming scheme was key and the majority of the files do happen to be POD, so whatev. And now vim correctly syntax highlights the files! I think there is something to be said for sticking to one language per file. 

Post-Mentor-Summit Wrap Up

| | Comments (0) | TrackBacks (0)
I took a bit of a break after releasing Math::GSL 0.14 and tried not to stare at a screen too much  during the GSOC08 conference, when I could be interacting with open source developers from around the world IRL. I met developers from Git, Xmms2, VLC, PHP, Zikula, OpenAFS, Boost, Jikes RVM, Squeak, MusicBrainz, Worldforge, Minix3, the list goes on. People shared many ideas about making sustainable open source projects, getting and keeping members in your community and dealing with "troublesome" members.  Daniel Svensson from Xmms2 also showed me some git-fu relating to rebasing.

But that doesn't mean that Math::GSL development has come to a halt! Since 0.14 Thierry added operator overloading for addition in Vector. This sparked my interest and I then did subtraction. The current code will vectorize operations that you learn "don't make sense" in grade school, such as: $v - 5 , where v is a vector. Math::GSL will go ahead and subtract 5 from every element in $v. You can also do 2 + $v and you will get a new vector where 2 has been added to each element of $v.


Also, I reorganized the directory structure so that all SWIG interface files are now in the swig/ subdirectory, instead of clogging up the root directory. All SWIG-generated XS code and object files are thrown in there as well. This should make the Math::GSL codebase easier to navigate. 

Screw you, spammers! Clicky Web Analytics