<?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 best way to add a value to all elements in a vector in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784735#M1737</link>
    <description>I don't think that you understood the thrust of my remarks. There is nothing to optimize in a calculation that is not even performed!&lt;BR /&gt;&lt;BR /&gt;So far, you have stated that you want a routine to add a constant to a vector, and you did not like the ones that were suggested. &lt;BR /&gt;&lt;BR /&gt;If you state details of how the added constant plays a role in subsequent calculations, further suggestions may become possible.&lt;BR /&gt;</description>
    <pubDate>Mon, 26 Mar 2012 18:17:47 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2012-03-26T18:17:47Z</dc:date>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784725#M1727</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Is there a betterway to add a value to all elements in a vector than this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cblas_saxpy(arrSize, &amp;amp;m_anyvalue, m_pU, 1, m_pX, 1 );&lt;BR /&gt;&lt;BR /&gt;where&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;m_pU = a vector of ones&lt;/P&gt;&lt;P&gt;m_pX = the vector I want to add m_anyvalue to&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2012 09:03:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784725#M1727</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-26T09:03:24Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784726#M1728</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;cblas_saxpydoesn't lookright routine to use. My recommendation will be:&lt;BR /&gt;&lt;BR /&gt;vsLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y )&lt;BR /&gt;&lt;STRONG&gt;&lt;BR /&gt;Description&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The v?LinearFrac function performs linear fraction transformation of vectors a by vector b with scalar parameters: scaling multipliers scalea, scaleb and shifting addends shifta, shiftb:&lt;/P&gt;&lt;P&gt;y&lt;I&gt;=(scaleaa&lt;I&gt;+shifta)/(scalebb&lt;I&gt;+shiftb), i=1,2  n&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Just set scalea=1.0f, scaleb=0.0f, shiftb=1.0f&lt;BR /&gt;&lt;BR /&gt;I hope that helps,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2012 09:29:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784726#M1728</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2012-03-26T09:29:04Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784727#M1729</link>
      <description>Thanks! I'll try that instead!&lt;BR /&gt;&lt;BR /&gt;Is the function smart enough to avoid performing the unnecessary computations?</description>
      <pubDate>Mon, 26 Mar 2012 09:54:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784727#M1729</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-26T09:54:51Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784728#M1730</link>
      <description>Hello again,&lt;BR /&gt;&lt;BR /&gt;Yes, the function should be able to effectively handlesuch subtle cases. Let me know if it works fine.&lt;BR /&gt;&lt;BR /&gt;With one more note. y&lt;I&gt;=x&lt;I&gt;+scale stresses the ADD unit only. It means in particular that, for example, MUL unit is iddle while performaing vector ADD. (Please remember all modern Intel CPUs can issue add and mul operations simultaneously). If you use Intel C++ compiler (which has quite good vectorizer) you might get better overall performance if you can mix this computation (y&lt;I&gt;=x&lt;I&gt;+scale) with other stuff so that all CPU compute units are busy.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Sergey&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Mon, 26 Mar 2012 10:07:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784728#M1730</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2012-03-26T10:07:32Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784729#M1731</link>
      <description>&lt;P&gt;Oh no, it seems there is no overload for complex input... &lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2012 10:07:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784729#M1731</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-26T10:07:37Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784730#M1732</link>
      <description>Correct. Only real single and double precision variant for v?LinearFrac</description>
      <pubDate>Mon, 26 Mar 2012 10:11:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784730#M1732</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2012-03-26T10:11:04Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784731#M1733</link>
      <description>So you may be better off using your compiler (such as Intel or recent gcc).</description>
      <pubDate>Mon, 26 Mar 2012 13:28:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784731#M1733</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-03-26T13:28:48Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784732#M1734</link>
      <description>How? (I am not really a programmer so it is not obvious to me) Do you mean I should just write a for loop and trust the compiler to optimize it?</description>
      <pubDate>Mon, 26 Mar 2012 16:30:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784732#M1734</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-26T16:30:26Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784733#M1735</link>
      <description>&lt;I&gt;How? (I am not really a programmer so it is not obvious to me)&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;In that case, you may want to use mathematical reasoning to see if you can avoid a redundant calculation altogether. &lt;BR /&gt;&lt;BR /&gt;For example, if &lt;I&gt;z&lt;/I&gt; is a complex-valued n-vector, and the desired result is, say, &lt;I&gt;w&lt;/I&gt; =  &lt;I&gt;z = u + i v&lt;/I&gt;, and you wish to add the real number &lt;I&gt;c&lt;/I&gt; to the real parts of the components of &lt;I&gt;z&lt;/I&gt;, you can compute &lt;I&gt;w&lt;/I&gt;&lt;SUB&gt;1&lt;/SUB&gt;&lt;I&gt; = (u + n c) + i v &lt;/I&gt;as the modified result.&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Mar 2012 17:45:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784733#M1735</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-03-26T17:45:29Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784734#M1736</link>
      <description>Sure, but how do I optimize it? The re/im parts of the complex numbers are interleaved in the array. I cant use the functions mentioned above and writing a for-loop with a step increment of 2 doesn't seem so tempting.&lt;BR /&gt;&lt;BR /&gt;Wouldn't it be nice to add a function to VML that does addition with a constant?</description>
      <pubDate>Mon, 26 Mar 2012 18:05:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784734#M1736</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-26T18:05:30Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784735#M1737</link>
      <description>I don't think that you understood the thrust of my remarks. There is nothing to optimize in a calculation that is not even performed!&lt;BR /&gt;&lt;BR /&gt;So far, you have stated that you want a routine to add a constant to a vector, and you did not like the ones that were suggested. &lt;BR /&gt;&lt;BR /&gt;If you state details of how the added constant plays a role in subsequent calculations, further suggestions may become possible.&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Mar 2012 18:17:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784735#M1737</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-03-26T18:17:47Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784736#M1738</link>
      <description>Exactly.&lt;BR /&gt;&lt;BR /&gt;for (i=0; i&lt;N&gt;&lt;/N&gt;{&lt;BR /&gt; x&lt;I&gt; += c;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Intel C++ compiler should nicely vectorize the loop&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sergey&lt;/I&gt;</description>
      <pubDate>Tue, 27 Mar 2012 04:18:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784736#M1738</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2012-03-27T04:18:10Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784737#M1739</link>
      <description>mecej4:&lt;BR /&gt;&lt;BR /&gt;Yup, nothing like a calculation that never needs to be done:) I don't have any particular problem, but I can imagine that in some cases one can get away with an initialization to a contant instead of an addition. Example:&lt;BR /&gt;&lt;BR /&gt;a = zeros&lt;BR /&gt;a = a + b*c &lt;BR /&gt;a = a + d&lt;BR /&gt;&lt;BR /&gt;can be changed to&lt;BR /&gt;&lt;BR /&gt;a = d&lt;BR /&gt;a = a + b*c&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there something like a "vector-memset" in MKL?</description>
      <pubDate>Tue, 27 Mar 2012 09:05:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784737#M1739</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-27T09:05:08Z</dc:date>
    </item>
    <item>
      <title>best way to add a value to all elements in a vector</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784738#M1740</link>
      <description>Ah - nice! Thanks Sergey!</description>
      <pubDate>Tue, 27 Mar 2012 09:07:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/best-way-to-add-a-value-to-all-elements-in-a-vector/m-p/784738#M1740</guid>
      <dc:creator>madir</dc:creator>
      <dc:date>2012-03-27T09:07:13Z</dc:date>
    </item>
  </channel>
</rss>

