in reply to Obtain matrix info
I still don't entirely like the complex parsing. But at least now I can say 5-3j, unlike your code where you had to say 5+-3j. Oddly enough, I don't know why Math::Complex doesn't have an input parser. It should!use Math::Complex; use CGI qw(param); for my $i (1..$varno) { for my $j (1..$varno) { next unless my $val = param("val-$i-$j"); if (my($re, $im) = $val =~ /(.*)([-+].*)[ij]/) { $matrix[$i][$j] = cplx($re, $im); } else { $matrix[$i][$j] = cplx($val, 0); } } }
-- Randal L. Schwartz, Perl hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Obtain matrix info
by sinan (Sexton) on Jul 30, 2000 at 15:07 UTC |