<?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: Elementwise Product in Matrix in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/233998#M2485</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;vec = mat[ , #];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS/IML supports many elementwise operations. Two articles you might want to read are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2011/06/06/use-subscript-reduction-operators.html" target="_self"&gt;"Use subscript reduction operators"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2012/05/23/compute-statistics-for-each-row-by-using-subscript-operators.html" target="_self"&gt;"Compute statistics for each row by using subscript operators"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Nov 2015 12:57:21 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-11-10T12:57:21Z</dc:date>
    <item>
      <title>Elementwise Product in Matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/233982#M2484</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this message finds you well.&lt;/P&gt;
&lt;P&gt;I have a matrix, let's say MAT, and I would like to make the product of the elements on&amp;nbsp;each row and output the resulting vector in VEC.&lt;/P&gt;
&lt;P&gt;So VEC i = product MAT[ i , 1:NCOL(MAT)].&lt;/P&gt;
&lt;P&gt;I simply figured it out using a do loop as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;do i&amp;nbsp;= 1 to nrow(&lt;SPAN&gt;MAT&lt;/SPAN&gt;);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do r = 1 to ncol(&lt;SPAN&gt;MAT&lt;/SPAN&gt;);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;VEC &lt;/SPAN&gt;[&amp;nbsp;i&amp;nbsp;,1]=&lt;SPAN&gt;VEC &lt;/SPAN&gt;[i,1]*&lt;SPAN&gt;MAT&lt;/SPAN&gt;[i,r];&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it takes too much time to run the above instructions since I have to run the same instructions 300,000 times (in different scenarios).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do&amp;nbsp;you have any better idea&amp;nbsp;to optimize the runtime?&lt;/P&gt;
&lt;P&gt;Thanks a lot in advance.&lt;/P&gt;
&lt;P&gt;Raphaël&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 10:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/233982#M2484</guid>
      <dc:creator>NewbieRaph</dc:creator>
      <dc:date>2015-11-10T10:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Elementwise Product in Matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/233998#M2485</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;vec = mat[ , #];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS/IML supports many elementwise operations. Two articles you might want to read are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2011/06/06/use-subscript-reduction-operators.html" target="_self"&gt;"Use subscript reduction operators"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2012/05/23/compute-statistics-for-each-row-by-using-subscript-operators.html" target="_self"&gt;"Compute statistics for each row by using subscript operators"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 12:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/233998#M2485</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-11-10T12:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Elementwise Product in Matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/234009#M2486</link>
      <description>&lt;P&gt;Thanks Rick! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It works perfectly and is 60 seconds faster for 20 scenarios.&lt;/P&gt;
&lt;P&gt;You are my savior!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I notice that you already posted it 3 years ago in your second link...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Raphael&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 14:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/234009#M2486</guid>
      <dc:creator>NewbieRaph</dc:creator>
      <dc:date>2015-11-10T14:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Elementwise Product in Matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/234032#M2487</link>
      <description>&lt;P&gt;Great. Remember to click the "Accept as Solution" button&amp;nbsp;so that others can see that the question has been answered.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 15:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/234032#M2487</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-11-10T15:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Elementwise Product in Matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/234058#M2488</link>
      <description>&lt;P&gt;Done!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Raphaël&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 16:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Elementwise-Product-in-Matrix/m-p/234058#M2488</guid>
      <dc:creator>NewbieRaph</dc:creator>
      <dc:date>2015-11-10T16:33:44Z</dc:date>
    </item>
  </channel>
</rss>

