<?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: Complex Numbers in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243169#M2539</link>
    <description>&lt;P&gt;You will have to write your own modules. The functions you specify are all elementwise operations, so they don't require any linear algegra. Be sure to vectorize your functions for efficiency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an example, the Arg function returns the polar angle. You can use some of the ideas in this blog post about &lt;A href="http://blogs.sas.com/content/iml/2015/06/10/polar-angle-curve.html" target="_self"&gt;"Computing polar angles from data."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another example is complex multiplication, which I would implement as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* Complex multiplication of A*B. 
   A vector of complex numbers is a two-column 
   matrix where Re(A)=A[,1] and Im(A)=A[,2]. 
   If A = x + iy and B = u + iv then 
   C = A*B = (x#u - y#v) + i(x#v + y#u)
*/
start cplxMult(A, B);
   C = j(nrow(A),2);
   C[,1] = A[,1]#B[,1] - A[,2]#B[,2];
   C[,2] = A[,1]#B[,2] + A[,2]#B[,1];
   return( C );
finish;

/* test it */
A = {2  0, /* pure real */
     0  3, /* pure imag */
     1  3,
    -1 -5};
B = {3  0, /* pure real */
     0 -4, /* pure imag */
     1 -3, /* conjugate */
     4  2};
C = cplxMult(A, B);
print C;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you create a nice library of complex operations, I encourage you &lt;A href="https://communities.sas.com/t5/SAS-IML-File-Exchange/tkb-p/sas_iml%40tkb" target="_self"&gt;post it to the SAS/IML File Exchange &lt;/A&gt;when you are finished.&amp;nbsp; I think others might find it interesting and potentially useful.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jan 2016 13:25:45 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-01-13T13:25:45Z</dc:date>
    <item>
      <title>Complex Numbers</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243043#M2537</link>
      <description>&lt;P&gt;I'd like to work with complex numbers in SAS/IML.&amp;nbsp; In particular, I'd like to&amp;nbsp;do option pricing in the Heston model as described in &lt;A href="http://www2.math.uni-wuppertal.de/~kahl/publications/NotSoComplexLogarithmsInTheHestonModel.pdf" target="_self"&gt;Kahl and Jaeckel&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume the complex numbers will be represented as two-component matrices.&amp;nbsp; I also assume I'll be using modules to do complex arithmetic, including multiplication and division, as well as things like arg(c), |c|, exp(c), ln(c), for complex c.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a standard implementation of these compex arithmetic modules that I can use, or will I have to write my own?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 20:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243043#M2537</guid>
      <dc:creator>mcs</dc:creator>
      <dc:date>2016-01-12T20:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Numbers</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243104#M2538</link>
      <description>&lt;P&gt;Ohh, I would doubt SAS can do some&amp;nbsp;&lt;SPAN&gt; complex arithmetic. I never saw the function or operator related to complex number in SAS/IML .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You need Mathematics or Matlab .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Maybe&amp;nbsp;@Rick Wicklin could guide you to somewhere . He is PhD of Applied Mathematic .&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 01:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243104#M2538</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-13T01:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Numbers</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243169#M2539</link>
      <description>&lt;P&gt;You will have to write your own modules. The functions you specify are all elementwise operations, so they don't require any linear algegra. Be sure to vectorize your functions for efficiency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an example, the Arg function returns the polar angle. You can use some of the ideas in this blog post about &lt;A href="http://blogs.sas.com/content/iml/2015/06/10/polar-angle-curve.html" target="_self"&gt;"Computing polar angles from data."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another example is complex multiplication, which I would implement as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* Complex multiplication of A*B. 
   A vector of complex numbers is a two-column 
   matrix where Re(A)=A[,1] and Im(A)=A[,2]. 
   If A = x + iy and B = u + iv then 
   C = A*B = (x#u - y#v) + i(x#v + y#u)
*/
start cplxMult(A, B);
   C = j(nrow(A),2);
   C[,1] = A[,1]#B[,1] - A[,2]#B[,2];
   C[,2] = A[,1]#B[,2] + A[,2]#B[,1];
   return( C );
finish;

/* test it */
A = {2  0, /* pure real */
     0  3, /* pure imag */
     1  3,
    -1 -5};
B = {3  0, /* pure real */
     0 -4, /* pure imag */
     1 -3, /* conjugate */
     4  2};
C = cplxMult(A, B);
print C;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you create a nice library of complex operations, I encourage you &lt;A href="https://communities.sas.com/t5/SAS-IML-File-Exchange/tkb-p/sas_iml%40tkb" target="_self"&gt;post it to the SAS/IML File Exchange &lt;/A&gt;when you are finished.&amp;nbsp; I think others might find it interesting and potentially useful.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 13:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Complex-Numbers/m-p/243169#M2539</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-13T13:25:45Z</dc:date>
    </item>
  </channel>
</rss>

