For many years, I too have suggested people look at
PDL, but it's only now reflecting on zentara's suggestion that I see PDL could really use some example code up on perlmonks. Unfortunately, I'm not a big PDL user, so you might want to jump onto the
PDL mailing list or peruse the
Quantified Onion for more knowledgeable answers.
Taking a stab at an example, would the PDL code look something like this?
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;
My calculation by hand seems to agree with the first two values. The rest is left as an exercise for the user.
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.
Sometimes I can think of 6 impossible LDAP attributes before breakfast.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.