<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Vectorization Function Performance Comparison in Mathcad</title>
    <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980907#M214682</link>
    <description>&lt;P&gt;I also just used my powers of email sending to direct attention to Stuart's technical implementation suggestion above.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2024 13:44:06 GMT</pubDate>
    <dc:creator>DJNewman</dc:creator>
    <dc:date>2024-10-30T13:44:06Z</dc:date>
    <item>
      <title>Vectorization Function Performance Comparison</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980707#M214664</link>
      <description>&lt;P&gt;Following&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/269238"&gt;@DJNewman&lt;/a&gt;&amp;nbsp;'s message on the topic of implicit vectorization of range variable being removed from Mathcad Prime 10, I looked at the referenced support article CS416474.&amp;nbsp; &amp;nbsp;The resolution to the "problem" was to use a range-to-vector conversion program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I use the term "vectorize" in the mathematical sense of "convert a matrix to a vector" rather than the programming sense of carrying out operations in parallel (e.g.&lt;EM&gt;, Mathcad's vectorize operator&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The suggested function &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;Range2Vec&amp;nbsp;&lt;/FONT&gt;&lt;/EM&gt;is similar to one I usually use (&lt;FONT face="book antiqua,palatino"&gt;&lt;EM&gt;vec&lt;/EM&gt;&lt;/FONT&gt;) except that instead of stack it uses indexing to add new elements to the constructed vector.&amp;nbsp; &amp;nbsp;I vaguely recall that stacking is inefficient time-wise compared to indexing, so I thought it would be interesting to see how the two variants compared.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I thought, "Hey, why stop at two mousetraps? Let's build some more to see if anything hits paydirt".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I played with a few variants and concluded yet again that stacking is probably slower than indexing.&amp;nbsp; However, there isn't much objectively in it even for a few million elements, even in nested arrays.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that most of the variants tested fully convert nested arrays to vectors, whilst &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;Range2Vec&lt;/FONT&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;vec&lt;/FONT&gt;&lt;/EM&gt;` do not - they're only targeted at vectorizing the first level of an array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take the results with several pinches of salt.&amp;nbsp; The times depend upon what else your computer is doing.&amp;nbsp; In the example below &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;Range2Vec&lt;/FONT&gt;&lt;/EM&gt; is shown to perform worse than the rest.&amp;nbsp; This is very unusual.&amp;nbsp; Range2Vec holds Gold or Silver during most runs, as it should, given it doesn't have to have code to deal with nesting. .&amp;nbsp; Besides, the worksheet's probably full of bugs, anyway.&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having said that, the times are reasonably consistent in showing "bands" of times.&amp;nbsp; The slowest two functions are usually&amp;nbsp;&lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;vec&lt;/FONT&gt; &lt;/EM&gt;(&lt;EM&gt;uses&amp;nbsp;&lt;/EM&gt;&lt;FONT face="book antiqua,palatino"&gt;stack&lt;/FONT&gt;&lt;EM&gt; to add elements&lt;/EM&gt;) and &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;vec3&lt;/FONT&gt; &lt;/EM&gt;(&lt;EM&gt;uses &lt;/EM&gt;&lt;FONT face="book antiqua,palatino"&gt;trim&lt;/FONT&gt;&lt;EM&gt; rather than&amp;nbsp;&lt;/EM&gt;&lt;FONT face="book antiqua,palatino"&gt;submatrix&lt;/FONT&gt; &lt;EM&gt;to remove the dummy empty array values&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024 10 29 F.png" style="width: 786px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/113266iE0F86BB43D4BDE83/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024 10 29 F.png" alt="2024 10 29 F.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stuart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;References:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.ptc.com/t5/Mathcad/Exclude-some-values/m-p/980366/highlight/true#M214627" target="_blank" rel="noopener"&gt;https://community.ptc.com/t5/Mathcad/Exclude-some-values/m-p/980366/highlight/true#M214627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.ptc.com/en/support/article/CS416474" target="_blank" rel="noopener"&gt;Article - CS416474 :&amp;nbsp;Inline evaluation to convert range into vector worked in Mathcad Prime 1.0-9.0, but now fails in Mathcad Prime 10.0&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Vectorization_(mathematics" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/Vectorization_(mathematics&lt;/A&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 16:56:34 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980707#M214664</guid>
      <dc:creator>StuartBruff</dc:creator>
      <dc:date>2024-10-29T16:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Vectorization Function Performance Comparison</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980719#M214666</link>
      <description>&lt;P&gt;Something to (possibly, no promises) think about for Mathcad Prime 11: We're strongly pushing R&amp;amp;D to put in a built-in vec() function that should also do this. So you may wish to repeat your testing once that's out. (If it happens.)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 17:25:55 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980719#M214666</guid>
      <dc:creator>DJNewman</dc:creator>
      <dc:date>2024-10-29T17:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Vectorization Function Performance Comparison</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980793#M214670</link>
      <description>&lt;P&gt;That sounds great, Dave. I certainly look forward to doing that round of tests again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is implemented, please consider my comments about naming the function. The naming style for other functions that create and manipulate arrays tends to be short, lowercase, and meaningful. Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an aside, will the function be limited in scope or capable of vectorizing any type of array (including arbitrarily-deeply nested ones)?&amp;nbsp; As you (PTC) can write functions that take optional arguments, perhaps a depth limit could be incorporated - there are occasions when it's only required to go so far down a data structure.&amp;nbsp; Here's a quick and brutal version of &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;vec&lt;/FONT&gt; &lt;/EM&gt;that takes a (non-optional) &lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;depth&lt;/FONT&gt; &lt;/EM&gt;argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;vec7&lt;/FONT&gt;&lt;/EM&gt; definition:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024 10 30 B.png" style="width: 578px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/113301i877968E585BAC680/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024 10 30 B.png" alt="2024 10 30 B.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face="book antiqua,palatino"&gt;vec7&lt;/FONT&gt; &lt;/EM&gt;applied to a slightly nested data structure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024 10 30 A.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/113302iBAE4F6DD42A0480C/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024 10 30 A.png" alt="2024 10 30 A.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oh, as it's a closely related issue, could you please ask the development team to include an &lt;FONT face="book antiqua,palatino"&gt;IsRange&lt;/FONT&gt; function (&lt;EM&gt;that doesn't evaluate a range if evaluated rather than used in a definition!&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stuart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 02:00:08 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980793#M214670</guid>
      <dc:creator>StuartBruff</dc:creator>
      <dc:date>2024-10-30T02:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Vectorization Function Performance Comparison</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980886#M214680</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/269238"&gt;@DJNewman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Something to (possibly, no promises) think about for Mathcad Prime 11: We're strongly pushing R&amp;amp;D to put in a built-in vec() function that should also do this. So you may wish to repeat your testing once that's out. (If it happens.)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please keep on pushing .... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 12:17:16 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980886#M214680</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2024-10-30T12:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Vectorization Function Performance Comparison</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980907#M214682</link>
      <description>&lt;P&gt;I also just used my powers of email sending to direct attention to Stuart's technical implementation suggestion above.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 13:44:06 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980907#M214682</guid>
      <dc:creator>DJNewman</dc:creator>
      <dc:date>2024-10-30T13:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Vectorization Function Performance Comparison</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980941#M214687</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/269238"&gt;@DJNewman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I also just used my powers of email sending to direct attention to Stuart's technical implementation suggestion above.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, Dave.&amp;nbsp; I'll keep my fingers and other digits crossed that the email falls on fertile ground.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stuart&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 15:40:43 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Vectorization-Function-Performance-Comparison/m-p/980941#M214687</guid>
      <dc:creator>StuartBruff</dc:creator>
      <dc:date>2024-10-30T15:40:43Z</dc:date>
    </item>
  </channel>
</rss>

