#!/usr/bin/perl -w

@{$A[0]} = (0.5, 0.2, 0.5);
@{$A[1]} = (0.5, 0.2, 0.5);
@{$A[2]} = (0.0, 0.6, 0.0);

@{$B[0]} = (0.3, 0.4, 0.5);
@{$B[1]} = (0.4, 0.1, 0.4);
@{$B[2]} = (0.3, 0.5, 0.1);

$n = 3;

for($i = 0; $i < $n; $i++) {
  for($j = 0; $j < $n; $j++) {
    $C[$i][$j] = 0;
    for($k = 0; $k < $n; $k++) {
      $C[$i][$j] = $C[$i][$j] + $A[$i][$k] * $B[$k][$j];
    }
  }
}

#
# Print the Matrix
#
print "Matrix C =\n";
for($i = 0; $i < $n; $i++) {
  print " | ";
  for($j = 0; $j < $n; $j++) {
    print" $C[$i][$j] ";
  }
print" | \n";
}

