<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Lapack in c++ benutzen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe Lapack (Linear Algebra Package) 3.1.1-67.1<br />
(Architektur: x86_64) unter YAST (Suse 11) als rpm<br />
installiert (<a href="http://www.netlib.org/lapack/" rel="nofollow">http://www.netlib.org/lapack/</a>)</p>
<p>Dabei wurden laut YAST insgesamt 3 Dateien installiert:</p>
<p>/usr/lib64/liblapack.a<br />
/usr/lib64/liblapack.so<br />
/usr/lib64/liblapack_pic.a</p>
<p>Da ich keine lapack.h Datei finden kann, weiss ich<br />
nicht, wie die Library in mein C++ Code einbinden<br />
soll?</p>
<p>Compilieren mit (gcc version 4.3.1)</p>
<p>g++ -O -I/usr/include <a href="http://testlapack.cc" rel="nofollow">testlapack.cc</a> -o myprog -L/usr/lib64 -llapack</p>
<p>führt zu :</p>
<p>testlapack.cc:2:21: error: lapack.h: Datei oder Verzeichnis nicht gefunden<br />
<a href="http://testlapack.cc" rel="nofollow">testlapack.cc</a>: In function ‘int main()’:<br />
<a href="http://testlapack.cc:33" rel="nofollow">testlapack.cc:33</a>: error: ‘dgesv’ was not declared in this scope</p>
<p>Das Testprogramm sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;lapack.h&gt; 
#define MAX 10

int main(){
   // Values needed for dgesv
   int n;
   int nrhs = 1;
   double a[MAX][MAX];
   double b[1][MAX];
   int lda = MAX;
   int ldb = MAX;
   int ipiv[MAX];
   int info;
   // Other values
   int i,j;

   // Read the values of the matrix
   std::cout &lt;&lt; &quot;Enter n \n&quot;;
   std::cin &gt;&gt; n;
   std::cout &lt;&lt; &quot;On each line type a row of the matrix A followed by one element of b:\n&quot;;
   for(i = 0; i &lt; n; i++){
     std::cout &lt;&lt; &quot;row &quot; &lt;&lt; i &lt;&lt; &quot; &quot;;
     for(j = 0; j &lt; n; j++)std::cin &gt;&gt; a[j][i];
     std::cin &gt;&gt; b[0][i];
   }

   // Solve the linear system
   dgesv(n, nrhs, &amp;a[0][0], lda, ipiv, &amp;b[0][0], ldb, &amp;info);

   // Check for success
   if(info == 0)
   {
      // Write the answer
      std::cout &lt;&lt; &quot;The answer is\n&quot;;
      for(i = 0; i &lt; n; i++)
        std::cout &lt;&lt; &quot;b[&quot; &lt;&lt; i &lt;&lt; &quot;]\t&quot; &lt;&lt; b[0][i] &lt;&lt; &quot;\n&quot;;
   }
   else
   {
      // Write an error message
      std::cerr &lt;&lt; &quot;dgesv returned error &quot; &lt;&lt; info &lt;&lt; &quot;\n&quot;;
   }
   return info;
}
</code></pre>
<p>Hat jemand Erfahrung mit Lapack?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/229193/lapack-in-c-benutzen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 03:26:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/229193.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Dec 2008 18:06:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Lapack in c++ benutzen on Mon, 08 Dec 2008 18:06:37 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe Lapack (Linear Algebra Package) 3.1.1-67.1<br />
(Architektur: x86_64) unter YAST (Suse 11) als rpm<br />
installiert (<a href="http://www.netlib.org/lapack/" rel="nofollow">http://www.netlib.org/lapack/</a>)</p>
<p>Dabei wurden laut YAST insgesamt 3 Dateien installiert:</p>
<p>/usr/lib64/liblapack.a<br />
/usr/lib64/liblapack.so<br />
/usr/lib64/liblapack_pic.a</p>
<p>Da ich keine lapack.h Datei finden kann, weiss ich<br />
nicht, wie die Library in mein C++ Code einbinden<br />
soll?</p>
<p>Compilieren mit (gcc version 4.3.1)</p>
<p>g++ -O -I/usr/include <a href="http://testlapack.cc" rel="nofollow">testlapack.cc</a> -o myprog -L/usr/lib64 -llapack</p>
<p>führt zu :</p>
<p>testlapack.cc:2:21: error: lapack.h: Datei oder Verzeichnis nicht gefunden<br />
<a href="http://testlapack.cc" rel="nofollow">testlapack.cc</a>: In function ‘int main()’:<br />
<a href="http://testlapack.cc:33" rel="nofollow">testlapack.cc:33</a>: error: ‘dgesv’ was not declared in this scope</p>
<p>Das Testprogramm sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;lapack.h&gt; 
#define MAX 10

int main(){
   // Values needed for dgesv
   int n;
   int nrhs = 1;
   double a[MAX][MAX];
   double b[1][MAX];
   int lda = MAX;
   int ldb = MAX;
   int ipiv[MAX];
   int info;
   // Other values
   int i,j;

   // Read the values of the matrix
   std::cout &lt;&lt; &quot;Enter n \n&quot;;
   std::cin &gt;&gt; n;
   std::cout &lt;&lt; &quot;On each line type a row of the matrix A followed by one element of b:\n&quot;;
   for(i = 0; i &lt; n; i++){
     std::cout &lt;&lt; &quot;row &quot; &lt;&lt; i &lt;&lt; &quot; &quot;;
     for(j = 0; j &lt; n; j++)std::cin &gt;&gt; a[j][i];
     std::cin &gt;&gt; b[0][i];
   }

   // Solve the linear system
   dgesv(n, nrhs, &amp;a[0][0], lda, ipiv, &amp;b[0][0], ldb, &amp;info);

   // Check for success
   if(info == 0)
   {
      // Write the answer
      std::cout &lt;&lt; &quot;The answer is\n&quot;;
      for(i = 0; i &lt; n; i++)
        std::cout &lt;&lt; &quot;b[&quot; &lt;&lt; i &lt;&lt; &quot;]\t&quot; &lt;&lt; b[0][i] &lt;&lt; &quot;\n&quot;;
   }
   else
   {
      // Write an error message
      std::cerr &lt;&lt; &quot;dgesv returned error &quot; &lt;&lt; info &lt;&lt; &quot;\n&quot;;
   }
   return info;
}
</code></pre>
<p>Hat jemand Erfahrung mit Lapack?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1627163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1627163</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 08 Dec 2008 18:06:37 GMT</pubDate></item><item><title><![CDATA[Reply to Lapack in c++ benutzen on Mon, 08 Dec 2008 20:23:27 GMT]]></title><description><![CDATA[<p>hast du eventuell die dev-pakete vergessen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1627251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1627251</guid><dc:creator><![CDATA[the_nic]]></dc:creator><pubDate>Mon, 08 Dec 2008 20:23:27 GMT</pubDate></item><item><title><![CDATA[Reply to Lapack in c++ benutzen on Mon, 08 Dec 2008 20:45:19 GMT]]></title><description><![CDATA[<p>Was meinst du genau?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1627263</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1627263</guid><dc:creator><![CDATA[NoPanic2007]]></dc:creator><pubDate>Mon, 08 Dec 2008 20:45:19 GMT</pubDate></item><item><title><![CDATA[Reply to Lapack in c++ benutzen on Tue, 09 Dec 2008 06:56:32 GMT]]></title><description><![CDATA[<p>dev-Pakete sind die Pakete für Entwickler (developer), darin sind normalerweise die header, Dokumentation usw. Was du bisher hat sind nur die puren Bibliotheken, die benötigt werden um fertig kompilierte Programme zu linken (statisch oder dynamisch).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1627429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1627429</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 09 Dec 2008 06:56:32 GMT</pubDate></item></channel></rss>