Hi Monks..
I am trying to multiply matrices but i want someway to calculate the matrix to the power of x .. like matrix ^4 or something like this... i have build a subroutine that accepts a matrix as argument and can multiply itself..
the matrix structure looks like this(just an example)
my %data = (
A => { A => 5, R => -2, N => -1 },
R => { A => -2, R => 7, N => -1 },
N => { A => -1, R => -1, N => 7 },
);
any ideas?
my @aminos= qw(A R N D C Q E G H I L K M F P S T W Y V B Z X);
sub multiplyRates {
my $M1= @_ ;
foreach my $key1 (@aminos) {
foreach my $key2 (@aminos) {
my $prod;
foreach my $key (@aminos) {
$prod += $M1->{$key1}->{$key} * $M1->{$key}->{$key2};
}
$multiplyrate->{$key1}->{$key2} = $prod;
}
$multiplyrate1->{$key1} = $newMutationmatrix1->{$key1};
}
return \%$multiplyrate;
}