Subject: | Performance patch for transpose() |
In a recent discussion on perlmonks
(http://perlmonks.org/?node_id=739466), 'oshalla' came up with a a
faster transpose() implementation than the one in Math::Matrix. Being
as I borrowed your transpose() code from this module initially, I felt
it only fitting that I should pass the performance patch back up to you :-)
It seems to provide about a 3-4x speed increase over the implementation
currently in Math::Matrix over all sizes of test matrices that both he
and I tried it upon.
-------- snip --------
sub transpose_gmch {
my ($matrix) = shift ;
my @result = () ;
my $lc = $#{$matrix->[0]} ;
for my $col (0..$lc) {
push @result, [map $_->[$col], @$matrix] ;
} ;
return( \@result );
}