Hi
At 01:08 AM 2/20/2006, I BioKid wrote:
Dear All,
Is there any program/module to calculate matrix average
How about:
#!/usr/bin/perl
use warnings;
use strict;
my @sum;
while(<DATA>){
chomp;
my @line = split;
my $line_avg;
for(@line){
$line_avg += $_ ;
}
$line_avg = $line_avg / @line;
push @sum, $line_avg;
}
my $sumlines;
for (@sum){
$sumlines += $_;
}
my $mat_avg = $sumlines / @sum;
print "$mat_avg\n";
__DATA__
11 22 43 54 50
27 87 74 32 10
66 58 98 78 20
22 23 44 16 34
* assume no missing cell and missing line.
shiping
:-) :-) :-)
I have a matrix of NxN and I need to see the average of the same
for example
11 22 43 54 50
27 87 74 32 10
66 58 98 78 20
22 23 44 16 34
I have gone through Math::Matrix
http://search.cpan.org/~ulpfr/Math-Matrix-0.4/Matrix.pm
<http://search.cpan.org/%7Eulpfr/Math-Matrix-0.4/Matrix.pm>
and Math::Cephes::Matrix - but none of them have a provison to do matrix
average calculation.
thanks in advance,
Happy Perl !!!
--
S Khadar
"Refrain from illusions, insist on work and not words,
patiently seek divine and scientific truth."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>