Dearest monks, I have an array of hashes which I call @database. The keys for all the hashes are identical--they all have the same number of keys and the keys have the same names. I want to take dot products (and from that angles) of the first hash with the other hashes using PDL. Here is what I have:
my $pdl1 = pdl (values(%{$database[0]})); my $n1 = norm $pdl1; my ($pdl2, $n2, $dotproduct, $d, @angles); for (0..$3database) { $pdl2 = pdl (values (%{$database[$_]})); $n2 = norm $pdl2; $dotproduct = inner ($n1, $n2); $d = dotproduct->sclr(); $angles[$_] = (180/3.1415926)*acos($d); }
My problem is that the angles aren't right. could it be that perl is not sorting the values of each hash consistently? Is there a way to easily and efficiently correct for this? Yours humbly, Evan

In reply to Lining up many hash values by Evanovich

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.