in reply to Re: Multiplying matrices
in thread Multiplying matrices
Taking a stab at an example, would the PDL code look something like this?
My calculation by hand seems to agree with the first two values. The rest is left as an exercise for the user.use PDL; # amino acids in this order in the reaction rates pdl # A R N D C Q E G H I L K M F P S T W Y V B Z X $rates = pdl [ [ 5, -2, -1 ], [ -2, 7, -1 ], [ -1, -1, 7 ], ]; $multiplied_rates = $rates x $rates; print $multiplied_rates;
Looks a lot easier than the OP's code, if you can overcome the fear of the new. And it's kinda cool :)
Edit:If I'd checked before posting, I would have linked to The Perl Data Language (PDL): A Quick Reference Guide or RFC: Getting Started with PDL (the Perl Data Language) both of which have lots of examples.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Multiplying matrices
by etj (Priest) on May 20, 2022 at 15:41 UTC |