Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 5097163ab97e88381b38e65e6523ca4c > files > 9

cminpack-devel-1.3.0-2.fc16.i686.rpm

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<!-- <link rel="stylesheet" type="text/css" href="../../fd.css" /> -->
<meta name="description"
content="C/C++ version of Minpack, the software for solving nonlinear equations and nonlinear least squares problems" />
<meta name="keywords"
content="Minpack, C++, C, Nonlinear equations, Nonlinear least-squares, Levenberg-Marquardt" />
<title>C/C++ Minpack</title>
</head>
<body>

<h1>C/C++ Minpack</h1>

<h2>What is Minpack?</h2>

<p>This is the official description of Minpack, from the original ReadMe file:
Minpack includes software for solving nonlinear equations and
nonlinear least squares problems.  Five algorithmic paths each include
a core subroutine and an easy-to-use driver.  The algorithms proceed
either from an analytic specification of the Jacobian matrix or
directly from the problem functions.  The paths include facilities for
systems of equations with a banded Jacobian matrix, for least squares
problems with a large amount of data, and for checking the consistency
of the Jacobian matrix with the functions.</p>

<p>The original authors of the FORTRAN version are Jorge More', Burt
Garbow, and Ken Hillstrom from Argonne National Laboratory, and the
code can be obtained from <a href="http://www.netlib.org/">Netlib</a>.</p>

<p>Minpack is probably the best open-source implementation of the
Levenberg-Marquardt algorithm (in fact, it is even better, since it
adds to L-M automatic variables scaling). There is another open-source
L-M implementation in C/C++, <a
href="http://www.ics.forth.gr/~lourakis/levmar/">levmar by Manolis
Lourakis</a>, but unfortunately is is released under the GPL, which
restricts its inclusion in commercial software. Minpack is licensed under a BSD-like license (available in the distribution).</p>

<h2>What about CMinpack?</h2>

<p>In July 2002 (before <a
href="http://www.ics.forth.gr/~lourakis/levmar/">levmar</a>), Manolis
Lourakis (lourakis at ics forth gr) released a <a
href="http://www.netlib.org/minpack/cminpack.tar">C version of
Minpack, called CMinpack</a>, obtained from the FORTRAN version using f2c and some
limited manual editing. However, this version had several problems,
which came from the FORTRAN version:</p>
<ol>
<li>All the function prototypes were following the original FORTRAN call conventions, so that all parameters are passed by reference (if a function needs an int parameter, you have to pass a pointer to this int).</li>
<li>There were lots of static variables in the code, thus you could not optimize a function which required calling Minpack to be evaluated (a minimization-of-minimization problem for example): <em>The Minpack code is not reentrant.</em></li>
<li>If the function to be optimized has to use extra parameters or data (this is the case most of the time), the only way to access them was though global variables, which is very bad, especially if you want to use the same function with different data in different threads: <em>The Minpack code is not MT-Safe.</em></li>
<li>There was no C/C++ include file.</li>
<li>Examples and tests were missing from the distribution, although there are some FORTRAN examples in the documentation.</li>
</ol>

<h2>Why is C/C++ Minpack better?</h2>

<p>I took a dozen of hours to rework all these problems, and came out with a pure C version of Minpack, with has standard (ISO C99) parameters passing, is fully reentrant, multithread-safe, and has a full set of examples and tests:</p>
<ol>
<li>Input variables are now passed by value, output variables are passed by reference. The keyword "const" is used as much as possible for constant arrays. The return value of each function is now used to get the function status (it was obtained via the IFLAG or INFO parameter in Minpack).</li>
<li>All non-const static variables were removed, and the code was tested after that. Luckily, Minpack didn't use the nastiest feature in FORTRAN: all local variables are static, so that a function can behave differently when you call it several times.</li>
<li>The function to be minimized and all the Minpack functions now take an extra "void*" argument, which can be used to pass any pointer-to-struct or pointer-to-class, and you can put all you extra parameters and data in that struct. Just cast this pointer to the appropriate pointer type in your function, and there they are! There is no need for global variables anymore. Be careful if you access the same object from different threads, though (a solution is to protect this extra data with a mutex).</li>
<li>The Debian project did a C include file for Minpack. It still needed some work (add consts and C++ compatibility), so I did this work, and used the include file for the FORTRAN version as the base for my C/C++ version.</li>
<li>The Debian project also translated all the FORTRAN examples to C. I worked from these to produce examples which also call my C/C++ version of Minpack instead of the FORTRAN version. Also included in the distribution are reference output files produced by the test runs (for comparison).</li>
</ol>

<h2>Distribution</h2>

<p>The distribution contains:</p>
<ul>
<li>The CMinpack code, where static and global variables were removed (it is thus reentrant, but not MT-Safe).</li>
<li>The C/C++ Minpack code (reentrant and MT-Safe).</li>
<li>C and C++-compatible include files for Minpack or CMinpack (minpack.h) and C/C++ Minpack (cminpack.h), and Unix Makefiles.</li>
<li>Full original documentation, translated to HTML, and all the examples, tests, and reference test results, so that you can check if the code runs properly on your machine before really using it.</li>
<li>The extra covariance function "covar", with sample uses in the tlmder and tlmdir examples. Note that the result of covar has to be scaled by some factor, as shown in the source file examples/tlmderc.c (look for the documentation of the NAG function E04YCF for further explanations).</li>
</ul>

<p>It is distributed under the original Minpack license (see the file CopyrightMINPACK.txt in the distribution).</p>

<h3>Download</h3>
<ul>
  <li><a href="cminpack-1.3.0.tar.gz">cminpack-1.3.0.tar.gz</a> (latest version)</li>
  <li><a href="cminpack-1.2.2.tar.gz">cminpack-1.2.2.tar.gz</a></li>
  <li><a href="cminpack-1.2.1.tar.gz">cminpack-1.2.1.tar.gz</a></li>
  <li><a href="cminpack-1.2.0.tar.gz">cminpack-1.2.0.tar.gz</a></li>
  <li><a href="cminpack-1.1.5.tar.gz">cminpack-1.1.5.tar.gz</a></li>
  <li><a href="cminpack-1.1.4.tar.gz">cminpack-1.1.4.tar.gz</a></li>
  <li><a href="cminpack-1.1.3.tar.gz">cminpack-1.1.3.tar.gz</a></li>
  <li><a href="cminpack-1.1.1.tar.gz">cminpack-1.1.1.tar.gz</a></li>
  <li><a href="cminpack-1.0.4.tar.gz">cminpack-1.0.4.tar.gz</a></li>
  <li><a href="cminpack-1.0.3.tar.gz">cminpack-1.0.3.tar.gz</a></li>
  <li><a href="cminpack-1.0.2.tar.gz">cminpack-1.0.2.tar.gz</a></li>
  <li><a href="cminpack-1.0.1.tar.gz">cminpack-1.0.1.tar.gz</a></li>
</ul>

<h3>Compiling and testing CMinpack</h3>

<p>The standard, double-precision version of CMinpack can be built and installed using <code>cmake</code>.<p>
<p>If you want to test thoroughly CMinpack, if you want to build a single-precision (float) or half-precision CMinpack, or if you want to build the FORTRAN version, you can use the Makefile-based build:</p>
<ul>
  <li>"<code>make</code>" builds the standard double-precision version of CMinpack as the static library <code>libcminpack.a</code></li>
  <li>"<code>make float</code>" builds the single-precision (float) version of CMinpack as the static library <code>libcminpacks.a</code></li>
  <li>"<code>make half</code>" builds the half-precision version of CMinpack as the static library <code>libcminpackh.a</code> (this requires the <a href="http://savannah.nongnu.org/download/openexr">OpenEXR ILM Base libraries</a>)</li>
  <li>"<code>make fortran</code>" builds the double-precision FORTRAN version of Minpack as the static library <code>fortran/libminpack.a</code> (this requires a FORTRAN compiler, such as gfortran, g77 or g95)</li>
  <li>"<code>make cuda</code>" builds the single-precision CUDA version of Minpack as the static library <code>cuda/libcuminpack.a</code> (this requires the CUDA SDK)</li>
  <li>"<code>make check</code>" builds and runs the standard and intensive tests for thh double-precision and single-precision CMinpack (as of version 1.2.2, there are only two small differences in the single-precision tests for lmder and lmstr)</li>
  <li>"<code>make checkhalf</code>" builds and runs the standard and intensive tests for the half-precision version of CMinpack</li>
  <li>"<code>make checkfail</code>" builds and runs the CMinpack tests that fail (probably because of differences in the maths between FORTRAN and C)</li>
</ul>

<h3>Using CMinpack</h3>

<p>The CMinpack calls have the same name as the FORTRAN functions, in lowercase (e.g. <code>lmder(...)</code>). See the links to the documentation below, or take a look at the simple examples in the <code>examples</code> directory of the distribution. The simple examples are named after the function they call: <code>tlmder.c</code> is the simple example for <code>lmder</code>.</p>
<p>If you want to use the single precision CMinpack, you should define __cminpack_float__ before including <code>cminpack.h</code>. __cminpack_half__ has to be defined for the half-precision version (and the code needs to be compiled with a C++ compiler).</p>
<p>The single-precision versions of the functions are prefixed by "s" (as in "<code>slmder(...)</code>"), and the half-precision are prefixed by "h".</p>
<p>CMinpack defines __cminpack_real__ as the floating point type, and the __cminpack_func__() macro can be used to call CMinpack functions independently of the precision used (as in the examples). However, you shouldn't use these macros in your own code, since your code is probably designed for a specific precision.</p>

<h2>Documentation</h2>
<ul>
  <li>The <a href="minpack-documentation.txt">original documentation for MINPACK</a></li>
  <li>The <a href="man.html">Debian GNU/Linux manual pages for MINPACK</a></li>
  <li><a href="http://en.wikipedia.org/wiki/MINPACK">MINPACK on Wikipedia</a></li>
  <li>User Guide for MINPACK-1 : <a href="http://www-unix.mcs.anl.gov/~more/ANL8074a.pdf">Chapters 1-3</a>, <a href="http://www-unix.mcs.anl.gov/~more/ANL8074b.pdf">Chapter 4</a></li>
</ul>

<h2>Equivalence table with other libraries</h2>
<p>The following table may be useful if you need to switch to or from another library.</p>
<table>
<caption>Equivalence table between MINPACK and NAG, NPL, SLATEC, levmar and <a href="http://www.gnu.org/software/gsl/">GSL</a></caption>
<tr><th>MINPACK</th> <th>NAG          </th> <th>NPL   </th> <th>SLATEC</th> <th>levmar     </th> <th>GSL                           </th></tr>
<tr><td>lmdif  </td> <td>E04FCF       </td> <td>LSQNDN</td> <td>DNLS1 </td> <td>dlevmar_dif</td> <td>                              </td></tr>
<tr><td>lmdif1 </td> <td>E04FYF       </td> <td>LSNDN1</td> <td>DNLS1E</td> <td>dlevmar_dif</td> <td>                              </td></tr>
<tr><td>lmder  </td> <td>E04GDF/E04GBF</td> <td>LSQFDN</td> <td>DNLS1 </td> <td>dlevmar_der</td> <td>gsl_multifit_fdfsolver_lmsder</td></tr>
<tr><td>lmder1 </td> <td>E04GZF       </td> <td>LSFDN2</td> <td>DNLS1E</td> <td>dlevmar_der</td> <td>                              </td></tr>
<tr><td>lmstr  </td> <td>*            </td> <td>*     </td> <td>DNLS1 </td> <td>           </td> <td>                              </td></tr>
<tr><td>hybrd  </td> <td>C05NCF       </td> <td>*     </td> <td>DNSQ  </td> <td>           </td> <td>                              </td></tr>
<tr><td>hybrd1 </td> <td>C05NBF       </td> <td>*     </td> <td>DNSQE </td> <td>           </td> <td>                              </td></tr>
<tr><td>hybrj  </td> <td>C05PCF       </td> <td>*     </td> <td>DNSQ  </td> <td>           </td> <td>                              </td></tr>
<tr><td>hybrj1 </td> <td>C05PBF       </td> <td>*     </td> <td>DNSQE </td> <td>           </td> <td>                              </td></tr>
<tr><td>covar  </td> <td>E04YCF       </td> <td>*     </td> <td>DCOV  </td> <td>           </td> <td>gsl_multifit_covar            </td></tr>
</table>

<h2>Other MINPACK implementations</h2>
<ul>
  <li>by John Burkardt: <a href="http://people.sc.fsu.edu/~jburkardt/cpp_src/minpack/minpack.html">C++</a>, <a href="http://people.sc.fsu.edu/~jburkardt/f77_src/minpack/minpack.html">FORTRAN77</a>, <a href="http://people.sc.fsu.edu/~jburkardt/f_src/minpack/minpack.html">FORTRAN90</a>.</li>
  <li>by Steve Verrill: <a href="http://www1.fpl.fs.fed.us/Minpack_f77.java">Java</a> (<a href="http://www1.fpl.fs.fed.us/optimization/Minpack_f77.html">documentation</a>, <a href="http://www1.fpl.fs.fed.us/minpack.prob.html">problems</a>).</li>
  <li>by Alan Miller: <a href="http://jblevins.org/mirror/amiller/lm.zip">FORTRAN90</a>.</li>
  <li><a href="http://quantlib.org/">Quantlib</a> has a C++ MINPACK hidden deep inside (<a href="http://quantlib.svn.sourceforge.net/viewvc/quantlib/trunk/QuantLib/ql/math/optimization/lmdif.cpp">C++</a>, <a href="http://quantlib.svn.sourceforge.net/viewvc/quantlib/trunk/QuantLib/ql/math/optimization/lmdif.hpp">header</a>, <a href="http://www.quantcode.com/modules/mydownloads/singlefile.php?cid=10&lid=436">tutorial</a>).</li>
  <li>GPL-licensed implementations of MINPACK algorithms in C are availaible from the <a href="http://www.gnu.org/software/gsl/">GNU Scientific Library</a>.</li>
  <li>Python library scipy, module <code>scipy.optimize.leastsq</code>,</li>
  <li><a href="http://www.ittvis.com/">IDL</a>, add-on <a href="http://cow.physics.wisc.edu/~craigm/idl/fitting.html">MPFIT</a>.</li>
  <li><a href="http://www.r-project.org/">R</a> has the <a href="http://cran.r-project.org/web/packages/minpack.lm/index.html"">minpack.lm</a> package.</li>
</ul>

<h2>History</h2>
<ul>
  <li>1.3.0 (09/06/2012): Optionally use LAPACK and CBLAS in lmpar, qrfac, and qrsolv. Added "make lapack" to build the LAPACK-based cminpack and "make checklapack" to test it (results of the test may depend on the underlying LAPACK and BLAS implementations).</li>
  <li>1.2.2 (16/05/2012): Update Makefiles and documentation (see "Using CMinpack" above) for easier building and testing.</li>
  <li>1.2.1 (15/05/2012): The library can now be built as double, float or half versions. Standard tests in the "examples" directory can now be lauched using "make check" (to run common tests, including against the float version), "make checkhalf" (to test the half version) and "make checkfail" (to run all the tests, even those that fail).</li>
  <li>1.2.0 (14/05/2012): Added original FORTRAN sources for better testing (type "make" in directory fortran, then "make" in examples and follow the instructions). Added driver tests lmsdrv, chkdrv, hyjdrv, hybdrv. Typing "make alltest" in the examples directory will run all possible test combinations (make sure you have gfortran installed).</li>
  <li>1.1.5 (04/05/2012): cminpack now works in CUDA, thanks to Jordi Bataller Mascarell, type "make" in the "cuda" subdir (be careful, though: this is a straightforward port from C, and each problem is solved using a single thread). cminpack can now also be compiled with single-precision floating point computation (define __cminpack_real__ to float when compiling and using the library). Fix cmake support for CMINPACK_LIB_INSTALL_DIR. Update the reference files for tests.</li>
  <li>1.1.4 (30/10/2011): Translated all the Levenberg-Marquardt code (lmder, lmdif, lmstr, lmder1, lmdif1, lmstr1, lmpar, qrfac, qrsolv, fdjac2, chkder) to use C-style indices.</li>
  <li>1.1.3 (16/03/2011): Minor fix: Change non-standard strnstr() to strstr() in genf77tests.c.</li>
  <li>1.1.2 (07/01/2011): Fix Windows DLL building (David Graeff) and document covar in cminpack.h.</li>
  <li>1.1.1 (04/12/2010): Complete rewrite of the C functions (without trailing underscore in the function name). Using the original FORTRAN code, the original algorithms structure was recovered, and many goto's were converted to if...then...else. The code should now be both more readable and easier to optimize, both for humans and for compilers. Added lmddrv and lmfdrv test drivers, which test a lot of difficult functions (these functions are explained in <a href="http://scholar.google.fr/scholar?q=10.1145%2F355934.355936">Testing Unconstrained Optimization Software</a> by Mor&eacute; et al.). Also added the pkg-config files to the cmake build, as well as an "uninstall" target, contributed by Geoffrey Biggs.</li>
  <li>1.0.4 (18/10/2010): Support for shared library building using CMake, thanks to Goeffrey Biggs from AIST and Radu Bogdan Rusu from Willow Garage. Shared libraries can be enabled using cmake options, as in: <code>cmake -DUSE_FPIC=ON -DSHARED_LIBS=ON -DBUILD_EXAMPLES=OFF path_to_sources</code></li>
  <li>1.0.3 (18/03/2010): Added CMake support. XCode build is now Universal (i386+ppc). Added tfdjac2_ and tfdjac2c examples, which test the accuracy of a finite-differences approximation of the Jacobian. Bug fix in tlmstr1 (signaled by Thomas Capricelli).</li>
  <li>1.0.2 (27/02/2009): Added Xcode and Visual Studio project files</li>
  <li>1.0.1 (17/12/2007): bug fix in covar() and covar_(), the computation of tolr caused a segfault (signaled by Timo Hartmann).</li>
  <li>1.0.0 (24/04/2007): Initial revision.</li>
</ul>


<!-- <p>Please <a href="/email.html">contact me</a> for any suggestion or request.</p>

<address>
<a href="/email.html">Fr&eacute;d&eacute;ric Devernay</a></address>
-->
     
<hr />

<p> <a href="http://validator.w3.org/check/referer"> <img class="borderless"
src="/images/vxhtml11.png" alt="Valid XHTML 1.1!" height="31"
width="88" /></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img class="borderless"  height="31"
width="88"
       src="/images/vcss.png" 
       alt="Valid CSS!" />
</a>
<a href="http://www.w3.org/WAI/WCAG1AA-Conformance"
      title="Explanation of Level Double-A Conformance">
  <img class="borderless" height="32" width="88" 
          src="/images/wcag1AA.png"
          alt="Level Double-A conformance icon, 
          W3C-WAI Web Content Accessibility Guidelines 1.0" /></a>
      </p>
</body>
</html>