Contact:
sales@biotechnologyforums.com to feature here

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PERL Program - Matrix Transpose
#1
print "Enter 3*3 Array Elements : ";
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    $matrix[$row][$col] = <STDIN>;
  }
}

# Print the original matrix
print "Entered Matrix is : \n";
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    printf("%3d", $matrix[$row][$col]);
  }
  print "\n";
}

#Transposing the matrix
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    $matrix_transpose[$row][$col] = $matrix[$col][$row];
  }
}

# Print the matrix in 3 integer spaces : "%3d"
print "Transpose of the Matrix is :\n";
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    printf("%3d", $matrix_transpose[$row][$col]);
  }
  print "\n";
}

# Check for Symmetric Matrix
$isSymmetric = 0;
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
if ($matrix[$row][$col] != $matrix[$col][$row])
{ $isSymmetric = 1; print $isSymmetric; }
  }
}
if($isSymmetric==0)
{ print("Matrix is symmetric. \n"); }
else
{ print("Matrix is not symmetric. \n"); }
  

Possibly Related Threads...
Thread
Author
  /  
Last Post
Replies: 0
Views: 629
04-25-2017, 03:18 PM
Last Postbinu
Replies: 0
Views: 529
04-25-2017, 03:13 PM
Last Postbinu
Replies: 0
Views: 413
04-25-2017, 03:05 PM
Last Postbinu
Replies: 0
Views: 625
04-24-2017, 05:46 PM
Last Postbinu
Replies: 0
Views: 445
04-24-2017, 05:38 PM
Last Postbinu



Users browsing this thread:
1 Guest(s)

PERL Program - Matrix Transpose00