Dear all ,
I am not very much efficient in perl . I used to write small script of code usually by using file handler . I have written a code for multplication of 2*3 matrix . I want to use this code efficiently so that it can be any order or user input type matrix mean to say that any order . I have also attached wrote my code here . Kindly give some suggestion of modify the code as my requirement .
#!/usr/bin/perl
#############################################
# Multiplication os 2*3 Matrix #
#############################################
###############################################################################
print "First Matrix 2*3 :--->\n";
@a=([2,3,4],[2,5,6]);
for ($i=0; $i < 2; $i++)
{
for ($j=0; $j < 3; $j++)
{
print "$a[$i][$j]\t";
}
print "\n\n";
}
################################################################################
print "Second Matrix 3*2 :-->\n";
@b=([6,7],[7,8],[8,9]);
for ($m=0; $m < 3; $m++)
{
for ($n=0; $n < 2; $n++)
{
print "$b[$m][$n]\t";
}
print "\n\n";
}
################################################################################
print "Matrix multiplication which is in order of 2*2 :--->\n";
@c=();
for ($x=0;$x<2;$x++)
{
for ($o=0;$o<2;$o++)
{
for ($p=0;$p<3;$p++)
{
$c[$x][$o]+= $a[$o][$p] * $b[$p][$o];
}
}
}
for($z=0;$z<2;$z++)
{
for($y=0;$y<2;$y++)
{
print "$c[$z][$y]\t";
}
print "\n\n";
}
################################################################################