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"); }
Like Post Reply
  

Possibly Related Threads…
Thread
Author
  /  
Last Post
Replies: 0
Views: 6,931
10-24-2018, 04:30 AM
Last Postsj26
Replies: 0
Views: 7,311
04-25-2017, 03:18 PM
Last Postbinu
Replies: 0
Views: 7,895
04-25-2017, 03:13 PM
Last Postbinu
Replies: 0
Views: 8,170
04-25-2017, 03:05 PM
Last Postbinu
Replies: 0
Views: 8,974
04-24-2017, 05:46 PM
Last Postbinu



Users browsing this thread:
1 Guest(s)

PERL Program - Matrix Transpose00