I have a subroutine I am very satisfied with. Its arguments are a string and a short list, say, (var1,var2). After parsing some templates, making some input files, running some programs and parsing some output files, it spits out a floating point number.

Now I want to make a three dimensional plot of the mathematical function this subroutine represents as a function of var1 and var2. This requires I make loop through hundreds of values of var1 and var2. I read about PDL--which implements "vectorization" using "threads" and "piddles"--all completely new terms to me. I do not understand how they work (and yes, I have read all the perldocs on them several times.)

I was wondering if there was some way to implement this vectorization technique--or something similar as a more efficient alternative to for loops.

I am not currently using more than one cpu, but I have access to more at a network (just not at my home computer) so any parallel advice would be appreciated as well.

In reply to How to vectorize a subroutine--perhapse using PDL piddles or threads by Feynman

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.