<?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: SAS IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230894#M2415</link>
    <description>&lt;P&gt;This works for me.&amp;nbsp; Try&amp;nbsp;using&amp;nbsp;commas to make the output more clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;print A, B;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Oct 2015 11:28:41 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2015-10-21T11:28:41Z</dc:date>
    <item>
      <title>SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230892#M2414</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me with an answer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given e.g. the following statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;A=I(2);&lt;/P&gt;&lt;P&gt;B=expmatrix(A);&lt;/P&gt;&lt;P&gt;print A B;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then the printed matrix A is I-halved instead of I. Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 11:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230892#M2414</guid>
      <dc:creator>dannegrila</dc:creator>
      <dc:date>2015-10-21T11:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230894#M2415</link>
      <description>&lt;P&gt;This works for me.&amp;nbsp; Try&amp;nbsp;using&amp;nbsp;commas to make the output more clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;print A, B;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 11:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230894#M2415</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-10-21T11:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230895#M2416</link>
      <description>&lt;P&gt;thaks for the answer. it doesn't work; same effect... it seems that I should put the "print" option for A before exponetiating the matrix... quite strange...&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 11:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230895#M2416</guid>
      <dc:creator>dannegrila</dc:creator>
      <dc:date>2015-10-21T11:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230897#M2417</link>
      <description>&lt;P&gt;expmatrix is not an in-built function, it is an IML module that is read from the library.&amp;nbsp;&amp;nbsp;So it is possible we have different versions of the library, and that your versions modifies the matrix A.&amp;nbsp;&amp;nbsp;You can examine the source code of the module by entering&lt;/P&gt;
&lt;P&gt;COPY SASHELP.IML.EXPMATRIX.SOURCE into the SAS command box.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230897#M2417</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-10-21T12:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230902#M2419</link>
      <description>&lt;P&gt;This does not happen in PROC IML, but it does happen in SAS/IML Studio.&lt;/P&gt;
&lt;P&gt;I'm guessing that you are running this in SAS/IML Studio or got a copy of the module that is distributed with SAS/IML Studio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are right: The ExpMatrix function is incorrectly changing your input matrix A.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a simple fix: Use the following (correct) module to store a new module in SAS/IML Studio. As long as the new module is stored in a location earlier in the search path, you will pick up the new copy. This should happen automatically, unless you have changed the default search path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In summary, run the following in&amp;nbsp;SAS/IML Studio one time.&amp;nbsp; From then on, you will pick up the correct behavior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start ExpMatrix( A );
    /* Compute a matrix exponential. Algorithm from 
       Golub/Van Loan, 2nd ed, p. 558. Based on 
       Moler &amp;amp; Van Loan (1978) "Nineteen Dubious Ways 
       to Compute the Exponential of a Matrix," 
       SIAM Review 20, 801-836.

       Given delta&amp;gt;0 and an nxn matrix A, the algorithm
       computes F = exp(A+E) where 
       InfinityNorm(E)&amp;lt;= delta*InfinityNorm(A). 
       We use a delta of approx 1e-15. */

    AX = A;
    n = nrow(AX);
    InfinityNorm = max( abs(AX)[+,] );
    j = max( 0, 1+floor( Log2(InfinityNorm) ) );
    AX = AX / 2##j;

    /* Compute Pade' approximation to exp(A) */
    X = AX;
    c = 0.5;
    M = I(n) + c*AX;
    D = I(n) - c*AX;
    q = 6; /* try to approximate with 6 terms (implies delta approx 1e-15)*/
    do k = 2 to q;
       c = c*(q-k+1)/( (2*q-k+1)*k );
       X = AX*X;
       M = M + c*X;
       D = D + (-1)##k * c*X;
    end;
    F = solve(D,M);
    do k = 1 to j;
       F = F*F;
    end;
    return ( F );
finish ExpMatrix;
store module=ExpMatrix;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230902#M2419</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-10-21T12:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230912#M2422</link>
      <description>&lt;P&gt;Yep:)&lt;/P&gt;&lt;P&gt;Thanks for your help Rick; a brilliant answer; it works !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230912#M2422</guid>
      <dc:creator>dannegrila</dc:creator>
      <dc:date>2015-10-21T12:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230918#M2423</link>
      <description>&lt;P&gt;In order to avoid the expmatrix function, I could tried to approximate the exponential matrix by writing in IML the Taylor expansion (summation up to e.g.100), but I would prefer your option. Thanks Rick!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230918#M2423</guid>
      <dc:creator>dannegrila</dc:creator>
      <dc:date>2015-10-21T12:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230924#M2425</link>
      <description>&lt;P&gt;I should have mentioned an even simpler solution, pass in a COPY of your matrix instead of the matrix itself!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start MyExpMatrix(A);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A2 = A; /* copy it; A2 gets changed, but A&amp;nbsp;does not */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; return( ExpMatrix(A2) );&lt;/P&gt;
&lt;P&gt;finish;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 13:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230924#M2425</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-10-21T13:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230931#M2426</link>
      <description>&lt;P&gt;Many thanks Rick.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 13:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML/m-p/230931#M2426</guid>
      <dc:creator>dannegrila</dc:creator>
      <dc:date>2015-10-21T13:17:44Z</dc:date>
    </item>
  </channel>
</rss>

