<?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 using MKL routines in C++ in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/using-MKL-routines-in-C/m-p/909531#M12037</link>
    <description>Hi all, I'm new to MKL. I should admit that I'm not very familiar with the concepts of linkages between MKL and C++. It would be great if someone could give me some hints!&lt;BR /&gt;&lt;BR /&gt;For example, I want to find the eigenvalues of a 2x2 non-symmetric real matrix. I would like to use the routine "dgeev" with C++ in Linux. Here is what I wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;#include &lt;BASIC.H&gt; // with MKL library included&lt;BR /&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; int n=2, lwork=-1, info;&lt;BR /&gt; double *a, *wr, *wi, *vl, *vr, *work;&lt;BR /&gt; a=new double[n*n];&lt;BR /&gt; a[0]=1.2; a[1]=2.3; a[2]=3.4; a[3]=4.5;  // the 4 matrix elements&lt;BR /&gt; wr=new double&lt;N&gt;;&lt;BR /&gt; wi=new double&lt;N&gt;;&lt;BR /&gt; work=new double[1];&lt;BR /&gt; dgeev("N", "N", &amp;amp;n, a, &amp;amp;n, wr, wi, vl, &amp;amp;n, vr, &amp;amp;n, work, &amp;amp;lwork, &amp;amp;info);&lt;BR /&gt;&lt;BR /&gt; cout &amp;lt;&amp;lt; "eigenvalues(real part) =
" &amp;lt;&amp;lt; wr[0] &amp;lt;&amp;lt; "	" &amp;lt;&amp;lt; wr[1] &amp;lt;&amp;lt; "
";&lt;BR /&gt; cout &amp;lt;&amp;lt; "eigenvalues(imag part) =
" &amp;lt;&amp;lt; wi[0] &amp;lt;&amp;lt; "	" &amp;lt;&amp;lt; wi[1] &amp;lt;&amp;lt; "
";&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/N&gt;&lt;/N&gt;&lt;/BASIC.H&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Then I compiled and ran it. The actual eigenvalues should be non-zero real numbers, however the above program gave me all zeros. I have tried many modifications but it just gave zeros. Is there anything wrong with my codes?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Wenling Chan&lt;BR /&gt;</description>
    <pubDate>Tue, 18 Sep 2007 17:42:43 GMT</pubDate>
    <dc:creator>chuenhung</dc:creator>
    <dc:date>2007-09-18T17:42:43Z</dc:date>
    <item>
      <title>using MKL routines in C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/using-MKL-routines-in-C/m-p/909531#M12037</link>
      <description>Hi all, I'm new to MKL. I should admit that I'm not very familiar with the concepts of linkages between MKL and C++. It would be great if someone could give me some hints!&lt;BR /&gt;&lt;BR /&gt;For example, I want to find the eigenvalues of a 2x2 non-symmetric real matrix. I would like to use the routine "dgeev" with C++ in Linux. Here is what I wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;#include &lt;BASIC.H&gt; // with MKL library included&lt;BR /&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; int n=2, lwork=-1, info;&lt;BR /&gt; double *a, *wr, *wi, *vl, *vr, *work;&lt;BR /&gt; a=new double[n*n];&lt;BR /&gt; a[0]=1.2; a[1]=2.3; a[2]=3.4; a[3]=4.5;  // the 4 matrix elements&lt;BR /&gt; wr=new double&lt;N&gt;;&lt;BR /&gt; wi=new double&lt;N&gt;;&lt;BR /&gt; work=new double[1];&lt;BR /&gt; dgeev("N", "N", &amp;amp;n, a, &amp;amp;n, wr, wi, vl, &amp;amp;n, vr, &amp;amp;n, work, &amp;amp;lwork, &amp;amp;info);&lt;BR /&gt;&lt;BR /&gt; cout &amp;lt;&amp;lt; "eigenvalues(real part) =
" &amp;lt;&amp;lt; wr[0] &amp;lt;&amp;lt; "	" &amp;lt;&amp;lt; wr[1] &amp;lt;&amp;lt; "
";&lt;BR /&gt; cout &amp;lt;&amp;lt; "eigenvalues(imag part) =
" &amp;lt;&amp;lt; wi[0] &amp;lt;&amp;lt; "	" &amp;lt;&amp;lt; wi[1] &amp;lt;&amp;lt; "
";&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/N&gt;&lt;/N&gt;&lt;/BASIC.H&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Then I compiled and ran it. The actual eigenvalues should be non-zero real numbers, however the above program gave me all zeros. I have tried many modifications but it just gave zeros. Is there anything wrong with my codes?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Wenling Chan&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Sep 2007 17:42:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/using-MKL-routines-in-C/m-p/909531#M12037</guid>
      <dc:creator>chuenhung</dc:creator>
      <dc:date>2007-09-18T17:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: using MKL routines in C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/using-MKL-routines-in-C/m-p/909532#M12038</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/274537"&gt;chuenhung@hotmail.com&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; Hi all, I'm new to MKL. I should admit that I'm not very familiar with the concepts of linkages between MKL and C++. It would be great if someone could give me some hints!&lt;BR /&gt;&lt;BR /&gt;For example, I want to find the eigenvalues of a 2x2 non-symmetric real matrix. I would like to use the routine "dgeev" with C++ in Linux. Here is what I wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: #800080;"&gt;#include &lt;BASIC.H&gt; // with MKL library included&lt;BR /&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; int n=2, lwork=-1, info;&lt;BR /&gt; double *a, *wr, *wi, *vl, *vr, *work;&lt;BR /&gt; a=new double[n*n];&lt;BR /&gt; a[0]=1.2; a[1]=2.3; a[2]=3.4; a[3]=4.5;  // the 4 matrix elements&lt;BR /&gt; wr=new double&lt;N&gt;;&lt;BR /&gt; wi=new double&lt;N&gt;;&lt;BR /&gt; work=new double[1];&lt;BR /&gt; dgeev("N", "N", &amp;amp;n, a, &amp;amp;n, wr, wi, vl, &amp;amp;n, vr, &amp;amp;n, work, &amp;amp;lwork, &amp;amp;info);&lt;BR /&gt;&lt;BR /&gt; cout &amp;lt;&amp;lt; "eigenvalues(real part) = " &amp;lt;&amp;lt; wr[0] &amp;lt;&amp;lt; "	" &amp;lt;&amp;lt; wr[1] &amp;lt;&amp;lt; " ";&lt;BR /&gt; cout &amp;lt;&amp;lt; "eigenvalues(imag part) = " &amp;lt;&amp;lt; wi[0] &amp;lt;&amp;lt; "	" &amp;lt;&amp;lt; wi[1] &amp;lt;&amp;lt; " ";&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/N&gt;&lt;/N&gt;&lt;/BASIC.H&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Then I compiled and ran it. The actual eigenvalues should be non-zero real numbers, however the above program gave me all zeros. I have tried many modifications but it just gave zeros. Is there anything wrong with my codes?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Wenling Chan&lt;BR /&gt; &lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Setting lwork = -1 will only determine optimum size of work variable. You need to obtain the value of work returned by the function dgeev, then revise the values of work and lwork and re-run with appropriate values.&lt;BR /&gt;&lt;BR /&gt;See MKL Reference guide for setting appropriate values of lwork.&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Mar 2009 19:09:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/using-MKL-routines-in-C/m-p/909532#M12038</guid>
      <dc:creator>MikeLevine</dc:creator>
      <dc:date>2009-03-02T19:09:58Z</dc:date>
    </item>
  </channel>
</rss>

