<div>Just a note about how the SVD can be used in CImg : Either it uses the Lapack routines (if &#39;#define cimg_use_lapack&#39;) is defined</div><div>before including the &quot;CImg.h&quot; header, either it uses his own routine (inspired from the NR).</div>
<div>Here is an example of such an use (here, Lapack is not mandatory) :</div><div><br></div><div><div>#include &quot;CImg.h&quot;</div><div>using namespace cimg_library;</div><div><br></div><div>int main() {</div><div><br>
</div><div>  // Create one &#39;noisy&#39; 5x5 identity matrix (uniform noise with amplitude 0.1).</div><div>  const CImg&lt;&gt; I = CImg&lt;&gt;::identity_matrix(5).noise(0.1,1);</div><div><br></div><div>  // Compute the SVD of the matrix I.</div>
<div>  CImg&lt;&gt; U,S,V;</div><div>  I.SVD(U,S,V);</div><div><br></div><div>  // Print diagonal coefficient (in vector) S.</div><div>  // (should all be around 1).</div><div>  S.print(&quot;Diag coefs.&quot;);</div><div>
<br></div><div>  // Rebuild a version J of I from U,S,V (J and I should be equal !).</div><div>  const CImg&lt;&gt; J = U*S.get_diagonal()*V.get_transpose();</div><div><br></div><div>  // Print the mean squared error between I and J</div>
<div>  // (should be very close to 0).</div><div>  std::fprintf(stderr,&quot;Error(I,J) = %g\n&quot;,I.MSE(J));</div><div><br></div><div>  return 0;</div><div>}</div></div><div><br></div><div>To compile this with minimal dependencies (on Linux) :</div>
<div><br></div><div>g++ -o toto toto.cpp -Dcimg_display=0</div><div><br></div><div>and the execution gives :</div><div><br></div><div><div>$ ./toto</div><div>Diag coefs.: this = 0xbf8fd200, size = (1,5,1,1) [20 b], data = (float*)0x9a100d8..0x9a100eb (non-shared) = [ 1.15535 ; 1.05855 ; 1.02251 ; 0.9813 ; 0.86202 ], min = 0.86202, max = 1.15535, mean = 1.01595, std = 0.107453, coords(min) = (0,4,0,0), coords(max) = (0,0,0,0).</div>
<div>Error(I,J) = 3.95106e-14</div></div><div><br></div><div>That&#39;s it, you see this is quite easy to use, and this doesn&#39;t require any external libraries to link with (just a header to include).</div><div><br></div>
<div>David.</div><div><br></div><div><br></div><br>-- <br>-----------------------------------------------------------------------------<br>David Tschumperlé<br>CNRS Researcher<br>GREYC (UMR-CNRS 6072)         E-mail: <a href="mailto:David.Tschumperle@greyc.ensicaen.fr">David.Tschumperle@greyc.ensicaen.fr</a><br>
6, Bd du Marechal Juin        Tel: +33 (0)2-31-45-29-24<br>F-14050 CAEN Cedex            Fax: +33 (0)2-31-45-26-98<br>France                        <a href="http://www.greyc.ensicaen.fr/~dtschump">http://www.greyc.ensicaen.fr/~dtschump</a><br>
-----------------------------------------------------------------------------<br><br>