in reply to how to get average of matrices' elements?
The first time through your nested for loops, @m_avrg is uninitialized. You can uninitialized with:
my @m_avrg; for my $i ( 0 .. 2 ) { $m_avrg[$i] = [ map { $_ = 0 } 1 .. 3 ]; # $m_avrg[$i] = [ map { $_ => 0 } 1 .. 3 ]; # WRONG! }
UPDATE: I copy'n'pasted the wrong code originally. Yes, Anon's x operator is better.
See also: Basic debugging checklist
Use 4 single spaces for each level of indentation.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how to get average of matrices' elements?
by Anonymous Monk on Nov 30, 2016 at 19:07 UTC | |
by toolic (Bishop) on Nov 30, 2016 at 19:13 UTC | |
by Anonymous Monk on Nov 30, 2016 at 19:39 UTC | |
Re^2: how to get average of matrices' elements?
by Anonymous Monk on Nov 30, 2016 at 19:10 UTC |
In Section
Seekers of Perl Wisdom