Hello,
Looping through the matrix elements is probably most common thing people do
in matrix computation. And because of some weird reason I am not aware of,
the only way to do this efficiently is to write your program in C. So
everybody I know sooner or later switches to C because of the speed issues.
In perl this is very very inefficient. In matlab at least (even though a
double for loop takes 100 times more time) it is possible to implement it
in finite time. So people ended up using matlab loops despite its slowness
because writing in C is painful, time consuming and requires a C compiler,
which not always exist in every platform.
PDL has PP, which is very nice, but you still need to compile the code (Is
this correct? Is there any documentation about how to compile pp code?).
Matlab has also mex, which is similar to PP. But people doesn't use it
unless they have to. And C compilers are not available in every platform.
It will be nice to have, if not all, at least some of the PP functionality
to perl. Similar to "foreach", maybe a new efficient loop structure such as
loop $i, $j ( @piddle, [dimensions to loop]){
}
....
Of course there should be a compact scalar also (probably C style integer
and doubles) without any overhead for the efficiency.
For example the pp code:
pp_def('sumit',
Pars => 'a(n); [o]b();',
Code => '
double tmp;
tmp = 0;
loop(n) %{
tmp += $a();
%}
$b() = tmp;
');
Should be able to be written without loss of efficiency:
sub sumit{
my @a = @_;
$tmp = 0;
loop $i (@a, [0]) {
$tmp += $a[$i];
}
my $b = tmp;
return $b;
}
Here all the scalar should be somehow similar to C scalars for efficiency.
Baris.