[cminpack] 17/19: Upstream version 1.3.3

Ole Streicher olebole-guest at moszumanska.debian.org
Tue May 13 10:34:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

olebole-guest pushed a commit to branch debian
in repository cminpack.

commit 9976a4a0c8e11fac3067c0c7f82f31022518d70f
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Tue May 13 11:07:55 2014 +0200

    Upstream version 1.3.3
---
 .cproject                          |  134 ++
 .project                           |   78 +
 .travis.yml                        |    5 +
 CMakeLists.txt                     |   73 +
 CopyrightMINPACK.txt               |   52 +
 Makefile                           |  117 ++
 README.md                          |  128 ++
 chkder.c                           |  159 ++
 chkder_.c                          |  198 ++
 cmake/CMakeLists.txt               |    7 +
 cmake/cminpack.pc.in               |   13 +
 cmake/cminpack_utils.cmake         |   41 +
 cmake/uninstall_target.cmake.in    |   19 +
 cminpack.h                         |  370 ++++
 cminpack.sln                       |   26 +
 cminpack.vcproj                    |  586 ++++++
 cminpack.vcxproj                   |  234 +++
 cminpack.vcxproj.filters           |  175 ++
 cminpack.xcodeproj/project.pbxproj | 2477 +++++++++++++++++++++++++
 cminpackP.h                        |   62 +
 cminpack_dll.vcproj                |  391 ++++
 covar.c                            |  154 ++
 covar1.c                           |  165 ++
 covar_.c                           |  209 +++
 cuda/Makefile                      |   22 +
 cuda/chkder.cu                     |    7 +
 cuda/covar.cu                      |    6 +
 cuda/covar1.cu                     |    6 +
 cuda/dogleg.cu                     |    8 +
 cuda/dpmpar.cu                     |    6 +
 cuda/enorm.cu                      |    7 +
 cuda/examples/Makefile             |   19 +
 cuda/examples/leeme.txt            |   12 +
 cuda/examples/tlmderc.cu           |  279 +++
 cuda/examples/tlmdif1c.cu          |  208 +++
 cuda/examples/tlmdifc.cu           |  318 ++++
 cuda/fdjac1.cu                     |    7 +
 cuda/fdjac2.cu                     |    7 +
 cuda/hybrd.cu                      |   14 +
 cuda/hybrd1.cu                     |    7 +
 cuda/hybrj.cu                      |   13 +
 cuda/hybrj1.cu                     |    7 +
 cuda/lmder.cu                      |   10 +
 cuda/lmder1.cu                     |    7 +
 cuda/lmdif.cu                      |   11 +
 cuda/lmdif1.cu                     |    7 +
 cuda/lmpar.cu                      |    9 +
 cuda/lmstr.cu                      |   11 +
 cuda/lmstr1.cu                     |    7 +
 cuda/qform.cu                      |    6 +
 cuda/qrfac.cu                      |    8 +
 cuda/qrsolv.cu                     |    6 +
 cuda/r1mpyq.cu                     |    6 +
 cuda/r1updt.cu                     |    7 +
 cuda/rwupdt.cu                     |    6 +
 dist-exclude                       |   71 +
 doc/hybrd1_.3                      |    1 +
 doc/hybrd_.3                       |  292 +++
 doc/hybrd_.html                    |  391 ++++
 doc/hybrj1_.3                      |    1 +
 doc/hybrj_.3                       |  282 +++
 doc/hybrj_.html                    |  381 ++++
 doc/index.html                     |  236 +++
 doc/lmder1_.3                      |    1 +
 doc/lmder_.3                       |  340 ++++
 doc/lmder_.html                    |  460 +++++
 doc/lmdif1_.3                      |    1 +
 doc/lmdif_.3                       |  319 ++++
 doc/lmdif_.html                    |  421 +++++
 doc/lmstr1_.3                      |    1 +
 doc/lmstr_.3                       |  340 ++++
 doc/lmstr_.html                    |  458 +++++
 doc/man.html                       |   25 +
 doc/minpack-documentation.txt      | 3528 ++++++++++++++++++++++++++++++++++++
 dogleg.c                           |  219 +++
 dogleg_.c                          |  253 +++
 dpmpar.c                           |  201 ++
 dpmpar_.c                          |  207 +++
 enorm.c                            |  157 ++
 enorm_.c                           |  186 ++
 examples/CMakeLists.txt            |   71 +
 examples/Makefile                  |  321 ++++
 examples/chkdrv.c                  |  132 ++
 examples/chkdrv.f                  |   87 +
 examples/chkdrv_                   |  Bin 0 -> 29968 bytes
 examples/chkdrv_.c                 |  133 ++
 examples/cmpfiles.c                |   55 +
 examples/errjac.c                  |  442 +++++
 examples/errjac.f                  |  333 ++++
 examples/fcn.mpl                   |   18 +
 examples/genf77tests.c             |  100 +
 examples/grdfcn.f                  |  438 +++++
 examples/hesfcn.f                  |  651 +++++++
 examples/hybdrv.c                  |  186 ++
 examples/hybdrv.f                  |  112 ++
 examples/hybdrv_                   |  Bin 0 -> 34728 bytes
 examples/hybdrv_.c                 |  185 ++
 examples/hybipt.c                  |  150 ++
 examples/hybipt.f                  |  167 ++
 examples/hyjdrv.c                  |  192 ++
 examples/hyjdrv.f                  |  120 ++
 examples/hyjdrv_                   |  Bin 0 -> 44304 bytes
 examples/hyjdrv_.c                 |  191 ++
 examples/ibmdpdr.c                 |   94 +
 examples/ibmdpdr.f                 |   72 +
 examples/ibmdpdr_                  |  Bin 0 -> 13564 bytes
 examples/ibmdpdr_.c                |   95 +
 examples/ibmdpdrc                  |  Bin 0 -> 13556 bytes
 examples/lhesfcn.f                 |  663 +++++++
 examples/lmddrv.c                  |  228 +++
 examples/lmddrv.f                  |  124 ++
 examples/lmddrv_                   |  Bin 0 -> 42040 bytes
 examples/lmddrv_.c                 |  227 +++
 examples/lmdipt.c                  |  214 +++
 examples/lmdipt.f                  |  214 +++
 examples/lmfdrv.c                  |  223 +++
 examples/lmfdrv.f                  |  121 ++
 examples/lmfdrv_                   |  Bin 0 -> 33816 bytes
 examples/lmfdrv_.c                 |  222 +++
 examples/lmsdrv.c                  |  240 +++
 examples/lmsdrv.f                  |  135 ++
 examples/lmsdrv_                   |  Bin 0 -> 42360 bytes
 examples/lmsdrv_.c                 |  240 +++
 examples/machar.c                  |  338 ++++
 examples/machar.f                  |  258 +++
 examples/objfcn.f                  |  342 ++++
 examples/ocpipt.f                  |  223 +++
 examples/ref/chkdrv.ref            |  311 ++++
 examples/ref/chkdrvc.ref           |  311 ++++
 examples/ref/hchkdrvc.ref          |  311 ++++
 examples/ref/hhybdrvc.ref          | 1204 ++++++++++++
 examples/ref/hhyjdrvc.ref          | 1204 ++++++++++++
 examples/ref/hibmdpdrc.ref         |   42 +
 examples/ref/hlmddrvc.ref          | 1151 ++++++++++++
 examples/ref/hlmfdrvc.ref          | 1151 ++++++++++++
 examples/ref/hlmsdrvc.ref          | 1148 ++++++++++++
 examples/ref/htchkderc.ref         |   22 +
 examples/ref/htfdjac2c.ref         |   29 +
 examples/ref/hthybrd1c.ref         |    7 +
 examples/ref/hthybrdc.ref          |   11 +
 examples/ref/hthybrj1c.ref         |    9 +
 examples/ref/hthybrjc.ref          |   14 +
 examples/ref/htlmder1c.ref         |    7 +
 examples/ref/htlmderc.ref          |   16 +
 examples/ref/htlmdif1c.ref         |    7 +
 examples/ref/htlmdifc.ref          |   14 +
 examples/ref/htlmstr1c.ref         |    7 +
 examples/ref/htlmstrc.ref          |   16 +
 examples/ref/hybdrv.ref            | 1094 +++++++++++
 examples/ref/hybdrvc.ref           | 1204 ++++++++++++
 examples/ref/hyjdrv.ref            | 1204 ++++++++++++
 examples/ref/hyjdrvc.ref           | 1204 ++++++++++++
 examples/ref/ibmdpdr.ref           |   42 +
 examples/ref/ibmdpdrc.ref          |   42 +
 examples/ref/lchkdrvc.ref          |  311 ++++
 examples/ref/lhybdrvc.ref          | 1204 ++++++++++++
 examples/ref/lhyjdrvc.ref          | 1204 ++++++++++++
 examples/ref/libmdpdrc.ref         |   42 +
 examples/ref/llmddrvc.ref          | 1151 ++++++++++++
 examples/ref/llmfdrvc.ref          | 1151 ++++++++++++
 examples/ref/llmsdrvc.ref          | 1148 ++++++++++++
 examples/ref/lmddrv.ref            | 1149 ++++++++++++
 examples/ref/lmddrvc.ref           | 1151 ++++++++++++
 examples/ref/lmfdrv.ref            | 1149 ++++++++++++
 examples/ref/lmfdrvc.ref           | 1151 ++++++++++++
 examples/ref/lmsdrv.ref            | 1149 ++++++++++++
 examples/ref/lmsdrvc.ref           | 1148 ++++++++++++
 examples/ref/ltchkderc.ref         |   22 +
 examples/ref/ltfdjac2c.ref         |   29 +
 examples/ref/lthybrd1c.ref         |    7 +
 examples/ref/lthybrdc.ref          |   11 +
 examples/ref/lthybrj1c.ref         |    9 +
 examples/ref/lthybrjc.ref          |   14 +
 examples/ref/ltlmder1c.ref         |    7 +
 examples/ref/ltlmderc.ref          |   16 +
 examples/ref/ltlmdif1c.ref         |    7 +
 examples/ref/ltlmdifc.ref          |   14 +
 examples/ref/ltlmstr1c.ref         |    7 +
 examples/ref/ltlmstrc.ref          |   16 +
 examples/ref/schkdrvc.ref          |  311 ++++
 examples/ref/shybdrvc.ref          | 1204 ++++++++++++
 examples/ref/shyjdrvc.ref          | 1204 ++++++++++++
 examples/ref/sibmdpdrc.ref         |   42 +
 examples/ref/slmddrvc.ref          | 1151 ++++++++++++
 examples/ref/slmfdrvc.ref          | 1151 ++++++++++++
 examples/ref/slmsdrvc.ref          | 1148 ++++++++++++
 examples/ref/stchkderc.ref         |   22 +
 examples/ref/stfdjac2c.ref         |   29 +
 examples/ref/sthybrd1c.ref         |    7 +
 examples/ref/sthybrdc.ref          |   11 +
 examples/ref/sthybrj1c.ref         |    9 +
 examples/ref/sthybrjc.ref          |   14 +
 examples/ref/stlmder1c.ref         |    7 +
 examples/ref/stlmderc.ref          |   16 +
 examples/ref/stlmdif1c.ref         |    7 +
 examples/ref/stlmdifc.ref          |   14 +
 examples/ref/stlmstr1c.ref         |    7 +
 examples/ref/stlmstrc.ref          |   16 +
 examples/ref/tchkder.ref           |   24 +
 examples/ref/tchkderc.ref          |   22 +
 examples/ref/tchkderc_box.ref      |   22 +
 examples/ref/tfdjac2c.ref          |   29 +
 examples/ref/thybrd.ref            |   11 +
 examples/ref/thybrd1.ref           |    9 +
 examples/ref/thybrd1c.ref          |    7 +
 examples/ref/thybrdc.ref           |   11 +
 examples/ref/thybrj.ref            |   13 +
 examples/ref/thybrj1.ref           |    9 +
 examples/ref/thybrj1c.ref          |    9 +
 examples/ref/thybrjc.ref           |   14 +
 examples/ref/thybrjc_box.ref       |   14 +
 examples/ref/tlmder.ref            |   11 +
 examples/ref/tlmder1.ref           |    7 +
 examples/ref/tlmder1c.ref          |    7 +
 examples/ref/tlmderc.ref           |   16 +
 examples/ref/tlmderc_box.ref       |   16 +
 examples/ref/tlmdif.ref            |    9 +
 examples/ref/tlmdif1.ref           |    7 +
 examples/ref/tlmdif1c.ref          |    7 +
 examples/ref/tlmdifc.ref           |   14 +
 examples/ref/tlmstr.ref            |   11 +
 examples/ref/tlmstr1.ref           |    7 +
 examples/ref/tlmstr1c.ref          |    7 +
 examples/ref/tlmstrc.ref           |   16 +
 examples/runtest.cmake             |   34 +
 examples/ssq.h                     |   19 +
 examples/ssqfcn.c                  |  345 ++++
 examples/ssqfcn.f                  |  340 ++++
 examples/ssqjac.c                  |  390 ++++
 examples/ssqjac.f                  |  347 ++++
 examples/tchkder_.c                |   92 +
 examples/tchkderc.c                |  151 ++
 examples/testdata/chkder.data      |   15 +
 examples/testdata/hybrd.data       |   23 +
 examples/testdata/lm.data          |   29 +
 examples/tfdjac2_.c                |  107 ++
 examples/tfdjac2c.c                |  127 ++
 examples/thybrd1_.c                |   63 +
 examples/thybrd1c.c                |   62 +
 examples/thybrd_.c                 |   87 +
 examples/thybrdc.c                 |   86 +
 examples/thybrj1_.c                |   83 +
 examples/thybrj1c.c                |   82 +
 examples/thybrj_.c                 |  104 ++
 examples/thybrjc.c                 |  152 ++
 examples/tlmder1_                  |  Bin 0 -> 23284 bytes
 examples/tlmder1_.c                |   86 +
 examples/tlmder1c                  |  Bin 0 -> 19156 bytes
 examples/tlmder1c.c                |   94 +
 examples/tlmder_.c                 |  112 ++
 examples/tlmderc.c                 |  197 ++
 examples/tlmdif1_.c                |   62 +
 examples/tlmdif1c.c                |   72 +
 examples/tlmdif_.c                 |   93 +
 examples/tlmdifc.c                 |  118 ++
 examples/tlmstr1_.c                |   80 +
 examples/tlmstr1c.c                |   89 +
 examples/tlmstr_.c                 |  110 ++
 examples/tlmstrc.c                 |  131 ++
 examples/ucodrv.f                  |  122 ++
 examples/vec.h                     |   21 +
 examples/vecfcn.c                  |  389 ++++
 examples/vecfcn.f                  |  273 +++
 examples/vecjac.c                  |  430 +++++
 examples/vecjac.f                  |  321 ++++
 fdjac1.c                           |  188 ++
 fdjac1_.c                          |  211 +++
 fdjac2.c                           |  121 ++
 fdjac2_.c                          |  146 ++
 fortran/Makefile                   |   37 +
 fortran/README.txt                 |   12 +
 fortran/chkder.f                   |  140 ++
 fortran/covar.f                    |  145 ++
 fortran/dogleg.f                   |  177 ++
 fortran/dpmpar.f                   |  181 ++
 fortran/enorm.f                    |  108 ++
 fortran/fdjac1.f                   |  151 ++
 fortran/fdjac2.f                   |  107 ++
 fortran/hybrd.f                    |  459 +++++
 fortran/hybrd1.f                   |  123 ++
 fortran/hybrj.f                    |  440 +++++
 fortran/hybrj1.f                   |  127 ++
 fortran/lmder.f                    |  452 +++++
 fortran/lmder1.f                   |  156 ++
 fortran/lmdif.f                    |  454 +++++
 fortran/lmdif1.f                   |  135 ++
 fortran/lmpar.f                    |  264 +++
 fortran/lmstr.f                    |  466 +++++
 fortran/lmstr1.f                   |  156 ++
 fortran/minpack.f90                |  450 +++++
 fortran/qform.f                    |   95 +
 fortran/qrfac.f                    |  164 ++
 fortran/qrsolv.f                   |  193 ++
 fortran/r1mpyq.f                   |   92 +
 fortran/r1updt.f                   |  207 +++
 fortran/rwupdt.f                   |  113 ++
 hybrd.c                            |  570 ++++++
 hybrd1.c                           |  148 ++
 hybrd1_.c                          |  156 ++
 hybrd_.c                           |  636 +++++++
 hybrj.c                            |  549 ++++++
 hybrj1.c                           |  158 ++
 hybrj1_.c                          |  162 ++
 hybrj_.c                           |  612 +++++++
 lmder.c                            |  526 ++++++
 lmder1.c                           |  167 ++
 lmder1_.c                          |  189 ++
 lmder_.c                           |  626 +++++++
 lmdif.c                            |  530 ++++++
 lmdif1.c                           |  147 ++
 lmdif1_.c                          |  162 ++
 lmdif_.c                           |  630 +++++++
 lmpar.c                            |  338 ++++
 lmpar_.c                           |  376 ++++
 lmstr.c                            |  544 ++++++
 lmstr1.c                           |  167 ++
 lmstr1_.c                          |  189 ++
 lmstr_.c                           |  653 +++++++
 minpack.h                          |  301 +++
 qform.c                            |  116 ++
 qform_.c                           |  145 ++
 qrfac.c                            |  285 +++
 qrfac_.c                           |  245 +++
 qrsolv.c                           |  218 +++
 qrsolv_.c                          |  274 +++
 r1mpyq.c                           |  122 ++
 r1mpyq_.c                          |  155 ++
 r1updt.c                           |  236 +++
 r1updt_.c                          |  283 +++
 readme.txt                         |   15 +
 rwupdt.c                           |  141 ++
 rwupdt_.c                          |  162 ++
 332 files changed, 78545 insertions(+)

diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..1fbe365
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.494735696">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.494735696" moduleId="org.eclipse.cdt.core.settings" name="Default">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="scannerConfiguration">
+				<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+				<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="makefileGenerator">
+						<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+				<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+					<buildOutputProvider>
+						<openAction enabled="true" filePath=""/>
+						<parser enabled="true"/>
+					</buildOutputProvider>
+					<scannerInfoProvider id="specsFile">
+						<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/>
+						<parser enabled="true"/>
+					</scannerInfoProvider>
+				</profile>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.494735696" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+					<folderInfo id="cdt.managedbuild.toolchain.gnu.base.494735696.1682941871" name="/" resourcePath="">
+						<toolChain id="cdt.managedbuild.toolchain.gnu.base.600287472" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1757593327" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
+							<builder id="cdt.managedbuild.target.gnu.builder.base.1973736104" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.archiver.base.1552506477" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.2093757556" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+								<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.72510406" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1488988602" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.765450746" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1922499348" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+							<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1115271157" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+								<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1023073138" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+									<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+									<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+								</inputType>
+							</tool>
+							<tool id="cdt.managedbuild.tool.gnu.assembler.base.1650451262" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+								<inputType id="cdt.managedbuild.tool.gnu.assembler.input.741667878" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+							</tool>
+						</toolChain>
+					</folderInfo>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="cminpack.null.144097993" name="cminpack"/>
+	</storageModule>
+</cproject>
diff --git a/.project b/.project
new file mode 100644
index 0000000..63aac07
--- /dev/null
+++ b/.project
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>cminpack</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+				<dictionary>
+					<key>?name?</key>
+					<value></value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.append_environment</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+					<value>all</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.buildArguments</key>
+					<value></value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.buildCommand</key>
+					<value>make</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+					<value>clean</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.contents</key>
+					<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+					<value>false</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+					<value>all</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.stopOnError</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+					<value>true</value>
+				</dictionary>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.core.ccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7af4789
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+language: c
+compiler:
+  - gcc
+  - clang
+script: make double float && make -C examples checkdoublec checkfloatc
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..1184703
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,73 @@
+# The name of our project is "CMINPACK". CMakeLists files in this project can
+# refer to the root source directory of the project as ${CMINPACK_SOURCE_DIR} and
+# to the root binary directory of the project as ${CMINPACK_BINARY_DIR}.
+cmake_minimum_required (VERSION 2.6)
+project (CMINPACK)
+string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
+
+include(${PROJECT_SOURCE_DIR}/cmake/cminpack_utils.cmake)
+# Set version and OS-specific settings
+set(CMINPACK_VERSION 1.3.2 CACHE STRING "CMinpack version")
+set(CMINPACK_SOVERSION 1 CACHE STRING "CMinpack API version")
+DISSECT_VERSION()
+GET_OS_INFO()
+
+# Add an "uninstall" target
+CONFIGURE_FILE ("${PROJECT_SOURCE_DIR}/cmake/uninstall_target.cmake.in"
+    "${PROJECT_BINARY_DIR}/uninstall_target.cmake" IMMEDIATE @ONLY)
+ADD_CUSTOM_TARGET (uninstall "${CMAKE_COMMAND}" -P
+    "${PROJECT_BINARY_DIR}/uninstall_target.cmake")
+
+enable_testing()
+
+if (OS_LINUX)
+  option (USE_FPIC "Use the -fPIC compiler flag." ON)
+else (OS_LINUX)
+  option (USE_FPIC "Use the -fPIC compiler flag." OFF)
+endif (OS_LINUX)
+
+option (SHARED_LIBS "Build shared libraries instead of static." OFF)
+if (SHARED_LIBS)
+  message (STATUS "Building shared libraries.")
+  set (LIB_TYPE SHARED)
+else (SHARED_LIBS)
+  message (STATUS "Building static libraries.")
+  set (LIB_TYPE STATIC)
+  if(WIN32)
+    add_definitions(-DCMINPACK_NO_DLL)
+  endif(WIN32)
+endif (SHARED_LIBS)
+
+#set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/../build)
+
+add_subdirectory (cmake)
+add_subdirectory (examples)
+
+set (cminpack_srcs
+  cminpack.h cminpackP.h
+  chkder.c  enorm.c   hybrd1.c  hybrj.c   lmdif1.c  lmstr1.c  qrfac.c   r1updt.c
+  dogleg.c  fdjac1.c  hybrd.c   lmder1.c  lmdif.c   lmstr.c   qrsolv.c  rwupdt.c
+  dpmpar.c  fdjac2.c  hybrj1.c  lmder.c   lmpar.c   qform.c   r1mpyq.c  covar.c covar1.c
+  minpack.h
+  chkder_.c enorm_.c  hybrd1_.c hybrj_.c  lmdif1_.c lmstr1_.c qrfac_.c  r1updt_.c
+  dogleg_.c fdjac1_.c hybrd_.c  lmder1_.c lmdif_.c  lmstr_.c  qrsolv_.c rwupdt_.c
+  dpmpar_.c fdjac2_.c hybrj1_.c lmder_.c  lmpar_.c  qform_.c  r1mpyq_.c covar_.c
+  )
+set (cminpack_hdrs
+    cminpack.h minpack.h)
+
+add_library (cminpack ${LIB_TYPE} ${cminpack_srcs})
+
+install (TARGETS cminpack 
+   LIBRARY DESTINATION ${CMINPACK_LIB_INSTALL_DIR} COMPONENT library
+   ARCHIVE DESTINATION ${CMINPACK_LIB_INSTALL_DIR} COMPONENT library
+   RUNTIME DESTINATION ${CMINPACK_LIB_INSTALL_DIR} COMPONENT library)
+install (FILES ${cminpack_hdrs} DESTINATION ${CMINPACK_INCLUDE_INSTALL_DIR}
+    COMPONENT cminpack_hdrs)
+
+if (USE_FPIC AND NOT SHARED_LIBS)
+  set_target_properties (cminpack PROPERTIES COMPILE_FLAGS -fPIC)
+endif (USE_FPIC AND NOT SHARED_LIBS)
+
+set_target_properties(cminpack PROPERTIES VERSION ${CMINPACK_VERSION} SOVERSION ${CMINPACK_SOVERSION})
+
diff --git a/CopyrightMINPACK.txt b/CopyrightMINPACK.txt
new file mode 100644
index 0000000..ae7984d
--- /dev/null
+++ b/CopyrightMINPACK.txt
@@ -0,0 +1,52 @@
+Minpack Copyright Notice (1999) University of Chicago.  All rights reserved
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+1. Redistributions of source code must retain the above
+copyright notice, this list of conditions and the following
+disclaimer.
+
+2. Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following
+disclaimer in the documentation and/or other materials
+provided with the distribution.
+
+3. The end-user documentation included with the
+redistribution, if any, must include the following
+acknowledgment:
+
+   "This product includes software developed by the
+   University of Chicago, as Operator of Argonne National
+   Laboratory.
+
+Alternately, this acknowledgment may appear in the software
+itself, if and wherever such third-party acknowledgments
+normally appear.
+
+4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
+WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
+UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
+THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
+OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
+OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
+USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
+THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
+DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
+UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
+BE CORRECTED.
+
+5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
+HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
+ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
+INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
+ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
+PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
+SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
+(INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
+EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
+POSSIBILITY OF SUCH LOSS OR DAMAGES.
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1cec801
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,117 @@
+PACKAGE=cminpack
+VERSION=1.3.3
+
+CC=gcc
+CFLAGS= -O3 -g -Wall -Wextra
+
+### The default configuration is to compile the double precision version
+
+### configuration for the LAPACK/BLAS (double precision) version:
+## make LIBSUFFIX= CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__"
+#LIBSUFFIX=s
+#CFLAGS="-O3 -g -Wall -Wextra -DUSE_CBLAS -DUSE_LAPACK"
+CFLAGS_L=$(CFLAGS) -DUSE_CBLAS -DUSE_LAPACK
+LDADD_L=-framework Accelerate
+
+### configuration for the float (single precision) version:
+## make LIBSUFFIX=s CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__"
+#LIBSUFFIX=s
+#CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__"
+CFLAGS_F=$(CFLAGS) -D__cminpack_float__
+
+### configuration for the half (half precision) version:
+## make LIBSUFFIX=h CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__" LDADD="-L/opt/local/lib -lHalf" CC=g++
+#LIBSUFFIX=h
+#CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__"
+#LDADD="-L/opt/local/lib -lHalf"
+#CC=g++
+CFLAGS_H=$(CFLAGS) -I/opt/local/include -D__cminpack_half__
+LDADD_H=-L/opt/local/lib -lHalf
+CC_H=$(CXX)
+
+OBJS = \
+$(LIBSUFFIX)chkder.o  $(LIBSUFFIX)enorm.o   $(LIBSUFFIX)hybrd1.o  $(LIBSUFFIX)hybrj.o  \
+$(LIBSUFFIX)lmdif1.o  $(LIBSUFFIX)lmstr1.o  $(LIBSUFFIX)qrfac.o   $(LIBSUFFIX)r1updt.o \
+$(LIBSUFFIX)dogleg.o  $(LIBSUFFIX)fdjac1.o  $(LIBSUFFIX)hybrd.o   $(LIBSUFFIX)lmder1.o \
+$(LIBSUFFIX)lmdif.o   $(LIBSUFFIX)lmstr.o   $(LIBSUFFIX)qrsolv.o  $(LIBSUFFIX)rwupdt.o \
+$(LIBSUFFIX)dpmpar.o  $(LIBSUFFIX)fdjac2.o  $(LIBSUFFIX)hybrj1.o  $(LIBSUFFIX)lmder.o \
+$(LIBSUFFIX)lmpar.o   $(LIBSUFFIX)qform.o   $(LIBSUFFIX)r1mpyq.o  $(LIBSUFFIX)covar.o $(LIBSUFFIX)covar1.o \
+$(LIBSUFFIX)chkder_.o $(LIBSUFFIX)enorm_.o  $(LIBSUFFIX)hybrd1_.o $(LIBSUFFIX)hybrj_.o \
+$(LIBSUFFIX)lmdif1_.o $(LIBSUFFIX)lmstr1_.o $(LIBSUFFIX)qrfac_.o  $(LIBSUFFIX)r1updt_.o \
+$(LIBSUFFIX)dogleg_.o $(LIBSUFFIX)fdjac1_.o $(LIBSUFFIX)hybrd_.o  $(LIBSUFFIX)lmder1_.o \
+$(LIBSUFFIX)lmdif_.o  $(LIBSUFFIX)lmstr_.o  $(LIBSUFFIX)qrsolv_.o $(LIBSUFFIX)rwupdt_.o \
+$(LIBSUFFIX)dpmpar_.o $(LIBSUFFIX)fdjac2_.o $(LIBSUFFIX)hybrj1_.o $(LIBSUFFIX)lmder_.o \
+$(LIBSUFFIX)lmpar_.o  $(LIBSUFFIX)qform_.o  $(LIBSUFFIX)r1mpyq_.o $(LIBSUFFIX)covar_.o
+
+# target dir for install
+DESTDIR=/usr/local
+#
+#  Static library target
+#
+
+all: libcminpack$(LIBSUFFIX).a
+
+double:
+	$(MAKE) LIBSUFFIX=
+
+lapack:
+	$(MAKE) LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)"
+
+float:
+	$(MAKE) LIBSUFFIX=s CFLAGS="$(CFLAGS_F)"
+
+half:
+	$(MAKE) LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)"
+
+fortran:
+	$(MAKE) -C fortran
+
+cuda:
+	$(MAKE) -C cuda
+
+check:
+	$(MAKE) -C examples check
+
+checkdouble:
+	$(MAKE) -C examples checkdouble
+
+checklapack:
+	$(MAKE) -C examples checklapack
+
+checkfloat:
+	$(MAKE) -C examples checkfloat
+
+checkhalf:
+	$(MAKE) -C examples checkhalf
+
+checkfail:
+	$(MAKE) -C examples checkfail
+
+
+libcminpack$(LIBSUFFIX).a:  $(OBJS)
+	ar r $@ $(OBJS); ranlib $@
+
+$(LIBSUFFIX)%.o: %.c
+	${CC} ${CFLAGS} -c -o $@ $<
+
+install: libcminpack$(LIBSUFFIX).a
+	cp libcminpack$(LIBSUFFIX).a ${DESTDIR}/lib
+	chmod 644 ${DESTDIR}/lib/libcminpack$(LIBSUFFIX).a
+	ranlib -t ${DESTDIR}/lib/libcminpack$(LIBSUFFIX).a # might be unnecessary
+	cp minpack.h ${DESTDIR}/include
+	chmod 644 ${DESTDIR}/include/minpack.h
+	cp cminpack.h ${DESTDIR}/include
+	chmod 644 ${DESTDIR}/include/cminpack.h
+
+clean:
+	rm -f *.o libcminpack*.a *~ #*#
+
+.PHONY: dist all double lapack float half fortran cuda check checkhalf checkfail
+
+# COPYFILE_DISABLE=true and COPY_EXTENDED_ATTRIBUTES_DISABLE=true are used to disable inclusion
+# of file attributes (._* files) in the tar file on MacOSX
+dist:
+	mkdir $(PACKAGE)-$(VERSION)
+	env COPYFILE_DISABLE=true COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar --exclude-from dist-exclude --exclude $(PACKAGE)-$(VERSION) -cf - . | (cd $(PACKAGE)-$(VERSION); tar xf -)
+	tar zcvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
+	rm -rf $(PACKAGE)-$(VERSION)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..66bbc6f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,128 @@
+C/C++ Minpack [![Build Status](https://api.travis-ci.org/devernay/cminpack.png?branch=master)](https://travis-ci.org/devernay/cminpack)
+==========
+
+This is a C version of the minpack minimization package.
+It has been derived from the fortran code using f2c and
+some limited manual editing. Note that you need to link
+against libf2c to use this version of minpack. Extern "C"
+linkage permits the package routines to be called from C++.
+Check ftp://netlib.bell-labs.com/netlib/f2c for the latest
+f2c version. For general minpack info and test programs, see
+the accompanying readme.txt and http://www.netlib.org/minpack/.
+
+Type `make` to compile and `make install` to install in /usr/local
+or modify the makefile to suit your needs.
+
+This software has been tested on a RedHat 7.3 Linux machine -
+usual 'use at your own risk' warnings apply.
+
+Manolis Lourakis -- lourakis at ics forth gr, July 2002
+	Institute of Computer Science,
+	Foundation for Research and Technology - Hellas
+	Heraklion, Crete, Greece
+
+Repackaging by Frederic Devernay -- frederic dot devernay at m4x dot org
+
+The project home page is at http://devernay.free.fr/hacks/cminpack/
+
+History
+------
+
+* version 1.3.3 (04/02/2014)::
+ - Add documentation and examples abouts how to add box constraints to the variables.
+ - continuous integration https://travis-ci.org/devernay/cminpack
+
+* version 1.3.2 (27/10/2013):
+ - Minor change in the CMake build: also set SOVERSION.
+
+* version 1.3.1 (02/10/2013):
+ - Fix CUDA examples compilation, and remove non-free files.
+
+* version 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).
+  On 64-bits architectures, the preprocessor symbol __LP64__ must be
+  defined (see cminpackP.h) if the LAPACK library uses the LP64
+  interface (i.e. 32-bits integer, vhereas the ILP interface uses 64
+  bits integers).
+
+* version 1.2.2 (16/05/2012):
+ - Update Makefiles and documentation (see "Using CMinpack" above) for
+  easier building and testing.
+
+* version 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).
+
+* version 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).
+
+* version 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.
+
+* version 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.
+
+* version 1.1.3 (16/03/2011):
+  - Minor fix: Change non-standard strnstr() to strstr() in
+     genf77tests.c.
+
+* version 1.1.2 (07/01/2011):
+   - Fix Windows DLL building (David Graeff) and document covar in
+     cminpack.h.
+
+* version 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 Testing Unconstrained Optimization
+   Software by Moré et al.). Also added the pkg-config files to the
+   cmake build, as well as an "uninstall" target, contributed by
+   Geoffrey Biggs.
+
+* version 1.0.4 (18/10/2010):
+ - Support for shared library building using CMake, thanks to Goeffrey
+   Biggs and Radu Bogdan Rusu from Willow Garage. Shared libraries can be
+   enabled using cmake options, as in;
+ cmake -DUSE_FPIC=ON -DSHARED_LIBS=ON -DBUILD_EXAMPLES=OFF path_to_sources
+
+* version 1.0.3 (18/03/2010):
+ - Added CMake support.
+ - XCode build is now Universal.
+ - 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).
+
+* version 1.0.2 (27/02/2009):
+ - Added Xcode and Visual Studio project files
+
+* version 1.0.1 (17/12/2007):
+ - bug fix in covar() and covar_(), the computation of tolr caused a
+   segfault (signaled by Timo Hartmann).
+
+* version 1.0.0 (24/04/2007):
+ - Added fortran and C examples
+ - Added documentation from Debian man pages
+ - Wrote pure C version
+ - Added covar() and covar_(), and use it in tlmdef/tlmdif
diff --git a/chkder.c b/chkder.c
new file mode 100644
index 0000000..9a39741
--- /dev/null
+++ b/chkder.c
@@ -0,0 +1,159 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+#define log10e 0.43429448190325182765
+#define factor 100.
+
+/* Table of constant values */
+
+__cminpack_attr__
+void __cminpack_func__(chkder)(int m, int n, const real *x, 
+	real *fvec, real *fjac, int ldfjac, real *xp, 
+	real *fvecp, int mode, real *err)
+{
+    /* Local variables */
+    int i, j;
+    real eps, epsf, temp, epsmch;
+    real epslog;
+
+/*     ********** */
+
+/*     subroutine chkder */
+
+/*     this subroutine checks the gradients of m nonlinear functions */
+/*     in n variables, evaluated at a point x, for consistency with */
+/*     the functions themselves. the user must call chkder twice, */
+/*     first with mode = 1 and then with mode = 2. */
+
+/*     mode = 1. on input, x must contain the point of evaluation. */
+/*               on output, xp is set to a neighboring point. */
+
+/*     mode = 2. on input, fvec must contain the functions and the */
+/*                         rows of fjac must contain the gradients */
+/*                         of the respective functions each evaluated */
+/*                         at x, and fvecp must contain the functions */
+/*                         evaluated at xp. */
+/*               on output, err contains measures of correctness of */
+/*                          the respective gradients. */
+
+/*     the subroutine does not perform reliably if cancellation or */
+/*     rounding errors cause a severe loss of significance in the */
+/*     evaluation of a function. therefore, none of the components */
+/*     of x should be unusually small (in particular, zero) or any */
+/*     other value which may cause loss of significance. */
+
+/*     the subroutine statement is */
+
+/*       subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an array of length m. on input when mode = 2, */
+/*         fvec must contain the functions evaluated at x. */
+
+/*       fjac is an m by n array. on input when mode = 2, */
+/*         the rows of fjac must contain the gradients of */
+/*         the respective functions evaluated at x. */
+
+/*       ldfjac is a positive integer input parameter not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       xp is an array of length n. on output when mode = 1, */
+/*         xp is set to a neighboring point of x. */
+
+/*       fvecp is an array of length m. on input when mode = 2, */
+/*         fvecp must contain the functions evaluated at xp. */
+
+/*       mode is an integer input variable set to 1 on the first call */
+/*         and 2 on the second. other values of mode are equivalent */
+/*         to mode = 1. */
+
+/*       err is an array of length m. on output when mode = 2, */
+/*         err contains measures of correctness of the respective */
+/*         gradients. if there is no severe loss of significance, */
+/*         then if err(i) is 1.0 the i-th gradient is correct, */
+/*         while if err(i) is 0.0 the i-th gradient is incorrect. */
+/*         for values of err between 0.0 and 1.0, the categorization */
+/*         is less certain. in general, a value of err(i) greater */
+/*         than 0.5 indicates that the i-th gradient is probably */
+/*         correct, while a value of err(i) less than 0.5 indicates */
+/*         that the i-th gradient is probably incorrect. */
+
+/*     subprograms called */
+
+/*       minpack supplied ... dpmpar */
+
+/*       fortran supplied ... dabs,dlog10,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    eps = sqrt(epsmch);
+
+    if (mode != 2) {
+
+/*        mode = 1. */
+
+        for (j = 0; j < n; ++j) {
+            temp = eps * fabs(x[j]);
+            if (temp == 0.) {
+                temp = eps;
+            }
+            xp[j] = x[j] + temp;
+        }
+        return;
+    }
+
+/*        mode = 2. */
+
+    epsf = factor * epsmch;
+    epslog = log10e * log(eps);
+    for (i = 0; i < m; ++i) {
+	err[i] = 0.;
+    }
+    for (j = 0; j < n; ++j) {
+	temp = fabs(x[j]);
+	if (temp == 0.) {
+	    temp = 1.;
+	}
+	for (i = 0; i < m; ++i) {
+	    err[i] += temp * fjac[i + j * ldfjac];
+	}
+    }
+    for (i = 0; i < m; ++i) {
+	temp = 1.;
+	if (fvec[i] != 0. && fvecp[i] != 0. &&
+            fabs(fvecp[i] - fvec[i]) >= epsf * fabs(fvec[i]))
+		 {
+	    temp = eps * fabs((fvecp[i] - fvec[i]) / eps - err[i]) 
+		    / (fabs(fvec[i]) +
+                       fabs(fvecp[i]));
+	}
+	err[i] = 1.;
+	if (temp > epsmch && temp < eps) {
+	    err[i] = (log10e * log(temp) - epslog) / epslog;
+	}
+	if (temp >= eps) {
+	    err[i] = 0.;
+	}
+    }
+
+/*     last card of subroutine chkder. */
+
+} /* chkder_ */
+
diff --git a/chkder_.c b/chkder_.c
new file mode 100644
index 0000000..a8799fc
--- /dev/null
+++ b/chkder_.c
@@ -0,0 +1,198 @@
+/* chkder.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define log10e 0.43429448190325182765
+#define factor 100.
+
+/* Table of constant values */
+
+__minpack_attr__
+void __minpack_func__(chkder)(const int *m, const int *n, const real *x, 
+	real *fvec, real *fjac, const int *ldfjac, real *xp, 
+	real *fvecp, const int *mode, real *err)
+{
+    /* Initialized data */
+
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+
+    /* Local variables */
+    int i__, j;
+    real eps, epsf, temp, epsmch;
+    real epslog;
+
+/*     ********** */
+
+/*     subroutine chkder */
+
+/*     this subroutine checks the gradients of m nonlinear functions */
+/*     in n variables, evaluated at a point x, for consistency with */
+/*     the functions themselves. the user must call chkder twice, */
+/*     first with mode = 1 and then with mode = 2. */
+
+/*     mode = 1. on input, x must contain the point of evaluation. */
+/*               on output, xp is set to a neighboring point. */
+
+/*     mode = 2. on input, fvec must contain the functions and the */
+/*                         rows of fjac must contain the gradients */
+/*                         of the respective functions each evaluated */
+/*                         at x, and fvecp must contain the functions */
+/*                         evaluated at xp. */
+/*               on output, err contains measures of correctness of */
+/*                          the respective gradients. */
+
+/*     the subroutine does not perform reliably if cancellation or */
+/*     rounding errors cause a severe loss of significance in the */
+/*     evaluation of a function. therefore, none of the components */
+/*     of x should be unusually small (in particular, zero) or any */
+/*     other value which may cause loss of significance. */
+
+/*     the subroutine statement is */
+
+/*       subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an array of length m. on input when mode = 2, */
+/*         fvec must contain the functions evaluated at x. */
+
+/*       fjac is an m by n array. on input when mode = 2, */
+/*         the rows of fjac must contain the gradients of */
+/*         the respective functions evaluated at x. */
+
+/*       ldfjac is a positive integer input parameter not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       xp is an array of length n. on output when mode = 1, */
+/*         xp is set to a neighboring point of x. */
+
+/*       fvecp is an array of length m. on input when mode = 2, */
+/*         fvecp must contain the functions evaluated at xp. */
+
+/*       mode is an integer input variable set to 1 on the first call */
+/*         and 2 on the second. other values of mode are equivalent */
+/*         to mode = 1. */
+
+/*       err is an array of length m. on output when mode = 2, */
+/*         err contains measures of correctness of the respective */
+/*         gradients. if there is no severe loss of significance, */
+/*         then if err(i) is 1.0 the i-th gradient is correct, */
+/*         while if err(i) is 0.0 the i-th gradient is incorrect. */
+/*         for values of err between 0.0 and 1.0, the categorization */
+/*         is less certain. in general, a value of err(i) greater */
+/*         than 0.5 indicates that the i-th gradient is probably */
+/*         correct, while a value of err(i) less than 0.5 indicates */
+/*         that the i-th gradient is probably incorrect. */
+
+/*     subprograms called */
+
+/*       minpack supplied ... dpmpar */
+
+/*       fortran supplied ... dabs,dlog10,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --err;
+    --fvecp;
+    --fvec;
+    --xp;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    eps = sqrt(epsmch);
+
+    if (*mode == 2) {
+	goto L20;
+    }
+
+/*        mode = 1. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	temp = eps * fabs(x[j]);
+	if (temp == 0.) {
+	    temp = eps;
+	}
+	xp[j] = x[j] + temp;
+/* L10: */
+    }
+    /* goto L70; */
+    return;
+L20:
+
+/*        mode = 2. */
+
+    epsf = factor * epsmch;
+    epslog = log10e * log(eps);
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	err[i__] = 0.;
+/* L30: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	temp = fabs(x[j]);
+	if (temp == 0.) {
+	    temp = 1.;
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    err[i__] += temp * fjac[i__ + j * fjac_dim1];
+/* L40: */
+	}
+/* L50: */
+    }
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	temp = 1.;
+	if (fvec[i__] != 0. && fvecp[i__] != 0. && fabs(fvecp[i__] - 
+		fvec[i__]) >= epsf * fabs(fvec[i__]))
+		 {
+	    temp = eps * fabs((fvecp[i__] - fvec[i__]) / eps - err[i__]) 
+		    / (fabs(fvec[i__]) +
+                       fabs(fvecp[i__]));
+	}
+	err[i__] = 1.;
+	if (temp > epsmch && temp < eps) {
+	    err[i__] = (log10e * log(temp) - epslog) / epslog;
+	}
+	if (temp >= eps) {
+	    err[i__] = 0.;
+	}
+/* L60: */
+    }
+/* L70: */
+
+    /* return 0; */
+
+/*     last card of subroutine chkder. */
+
+} /* chkder_ */
+
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
new file mode 100644
index 0000000..650d709
--- /dev/null
+++ b/cmake/CMakeLists.txt
@@ -0,0 +1,7 @@
+set(PKG_DESC "CMinPack")
+set(PKG_EXTERNAL_DEPS "")
+set(pkg_conf_file ${CMAKE_CURRENT_BINARY_DIR}/cminpack.pc)
+configure_file(cminpack.pc.in ${pkg_conf_file} @ONLY)
+install(FILES ${pkg_conf_file}
+    DESTINATION ${CMINPACK_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT pkgconfig)
+
diff --git a/cmake/cminpack.pc.in b/cmake/cminpack.pc.in
new file mode 100644
index 0000000..c0515da
--- /dev/null
+++ b/cmake/cminpack.pc.in
@@ -0,0 +1,13 @@
+# This file was generated by CMake for @PROJECT_NAME@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/@CMINPACK_LIB_INSTALL_DIR@
+includedir=${prefix}/@CMINPACK_INCLUDE_INSTALL_DIR@
+
+Name: @PROJECT_NAME@
+Description: @PKG_DESC@
+Version: @CMINPACK_VERSION@
+Requires: @PKG_EXTERNAL_DEPS@
+Libs: -L${libdir} -lcminpack -lm
+Cflags: -I${includedir}
+
diff --git a/cmake/cminpack_utils.cmake b/cmake/cminpack_utils.cmake
new file mode 100644
index 0000000..e380d5c
--- /dev/null
+++ b/cmake/cminpack_utils.cmake
@@ -0,0 +1,41 @@
+macro(GET_OS_INFO)
+    string(REGEX MATCH "Linux" OS_LINUX ${CMAKE_SYSTEM_NAME})
+    string(REGEX MATCH "BSD" OS_BSD ${CMAKE_SYSTEM_NAME})
+    if(WIN32)
+        set(OS_WIN TRUE)
+    endif(WIN32)
+
+    if(NOT DEFINED CMINPACK_LIB_INSTALL_DIR)
+    set(CMINPACK_LIB_INSTALL_DIR "lib")
+    if(OS_LINUX)
+        if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+            set(CMINPACK_LIB_INSTALL_DIR "lib64")
+        else(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+            set(CMINPACK_LIB_INSTALL_DIR "lib")
+        endif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+        message (STATUS "Operating system is Linux")
+    elseif(OS_BSD)
+        message (STATUS "Operating system is BSD")
+    elseif(OS_WIN)
+        message (STATUS "Operating system is Windows")
+    else(OS_LINUX)
+        message (STATUS "Operating system is generic Unix")
+    endif(OS_LINUX)
+    endif(NOT DEFINED CMINPACK_LIB_INSTALL_DIR)
+    set(CMINPACK_INCLUDE_INSTALL_DIR
+        "include/${PROJECT_NAME_LOWER}-${CMINPACK_MAJOR_VERSION}")
+endmacro(GET_OS_INFO)
+
+
+macro(DISSECT_VERSION)
+    # Find version components
+    string(REGEX REPLACE "^([0-9]+).*" "\\1"
+        CMINPACK_MAJOR_VERSION "${CMINPACK_VERSION}")
+    string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1"
+        CMINPACK_MINOR_VERSION "${CMINPACK_VERSION}")
+    string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1"
+        CMINPACK_REVISION_VERSION ${CMINPACK_VERSION})
+    string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1"
+        CMINPACK_CANDIDATE_VERSION ${CMINPACK_VERSION})
+endmacro(DISSECT_VERSION)
+
diff --git a/cmake/uninstall_target.cmake.in b/cmake/uninstall_target.cmake.in
new file mode 100644
index 0000000..e3db04e
--- /dev/null
+++ b/cmake/uninstall_target.cmake.in
@@ -0,0 +1,19 @@
+if(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
+    message(FATAL_ERROR "Cannot find install manifest: \"@PROJECT_BINARY_DIR@/install_manifest.txt\"")
+endif(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@PROJECT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+    message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+    if(EXISTS "$ENV{DESTDIR}${file}")
+        exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+            OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval)
+        if(NOT "${rm_retval}" STREQUAL 0)
+            message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+        endif(NOT "${rm_retval}" STREQUAL 0)
+    else(EXISTS "$ENV{DESTDIR}${file}")
+        message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+    endif(EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
+
diff --git a/cminpack.h b/cminpack.h
new file mode 100644
index 0000000..6d3f757
--- /dev/null
+++ b/cminpack.h
@@ -0,0 +1,370 @@
+/* Header file for cminpack, by Frederic Devernay.
+   The documentation for all functions can be found in the file
+   minpack-documentation.txt from the distribution, or in the source
+   code of each function. */
+
+#ifndef __CMINPACK_H__
+#define __CMINPACK_H__
+
+/* The default floating-point type is "double" for C/C++ and "float" for CUDA,
+   but you can change this by defining one of the following symbols when
+   compiling the library, and before including cminpack.h when using it:
+   __cminpack_double__ for double
+   __cminpack_float__ for float
+   __cminpack_half__ for half from the OpenEXR library (in this case, you must
+                     compile cminpack with a C++ compiler)
+*/
+#ifdef __cminpack_double__
+#define __cminpack_real__ double
+#endif
+
+#ifdef __cminpack_float__
+#define __cminpack_real__ float
+#endif
+
+#ifdef __cminpack_half__
+#include <OpenEXR/half.h>
+#define __cminpack_real__ half
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Cmake will define cminpack_EXPORTS on Windows when it
+configures to build a shared library. If you are going to use
+another build system on windows or create the visual studio
+projects by hand you need to define cminpack_EXPORTS when
+building a DLL on windows.
+*/
+#if defined (__GNUC__)
+#define CMINPACK_DECLSPEC_EXPORT  __declspec(__dllexport__)
+#define CMINPACK_DECLSPEC_IMPORT  __declspec(__dllimport__)
+#endif
+#if defined (_MSC_VER) || defined (__BORLANDC__)
+#define CMINPACK_DECLSPEC_EXPORT  __declspec(dllexport)
+#define CMINPACK_DECLSPEC_IMPORT  __declspec(dllimport)
+#endif
+#ifdef __WATCOMC__
+#define CMINPACK_DECLSPEC_EXPORT  __export
+#define CMINPACK_DECLSPEC_IMPORT  __import
+#endif
+#ifdef __IBMC__
+#define CMINPACK_DECLSPEC_EXPORT  _Export
+#define CMINPACK_DECLSPEC_IMPORT  _Import
+#endif
+
+#if !defined(CMINPACK_NO_DLL) && (defined(__WIN32__) || defined(WIN32) || defined (_WIN32))
+#if defined(cminpack_EXPORTS) || defined(CMINPACK_EXPORTS) || defined(CMINPACK_DLL_EXPORTS)
+    #define  CMINPACK_EXPORT CMINPACK_DECLSPEC_EXPORT
+  #else
+    #define  CMINPACK_EXPORT CMINPACK_DECLSPEC_IMPORT
+  #endif /* cminpack_EXPORTS */
+#else /* defined (_WIN32) */
+ #define CMINPACK_EXPORT
+#endif
+
+#if defined(__CUDA_ARCH__) || defined(__CUDACC__)
+#define __cminpack_attr__ __device__
+#ifndef __cminpack_real__
+#define __cminpack_float__
+#define __cminpack_real__ float
+#endif
+#define __cminpack_type_fcn_nn__        __cminpack_attr__ int fcn_nn
+#define __cminpack_type_fcnder_nn__     __cminpack_attr__ int fcnder_nn
+#define __cminpack_type_fcn_mn__        __cminpack_attr__ int fcn_mn
+#define __cminpack_type_fcnder_mn__     __cminpack_attr__ int fcnder_mn
+#define __cminpack_type_fcnderstr_mn__  __cminpack_attr__ int fcnderstr_mn
+#define __cminpack_decl_fcn_nn__
+#define __cminpack_decl_fcnder_nn__
+#define __cminpack_decl_fcn_mn__
+#define __cminpack_decl_fcnder_mn__
+#define __cminpack_decl_fcnderstr_mn__
+#define __cminpack_param_fcn_nn__
+#define __cminpack_param_fcnder_nn__
+#define __cminpack_param_fcn_mn__
+#define __cminpack_param_fcnder_mn__
+#define __cminpack_param_fcnderstr_mn__
+#else
+#define __cminpack_attr__
+#ifndef __cminpack_real__
+#define __cminpack_double__
+#define __cminpack_real__ double
+#endif
+#define __cminpack_type_fcn_nn__        typedef int (*cminpack_func_nn)
+#define __cminpack_type_fcnder_nn__     typedef int (*cminpack_funcder_nn)
+#define __cminpack_type_fcn_mn__        typedef int (*cminpack_func_mn)
+#define __cminpack_type_fcnder_mn__     typedef int (*cminpack_funcder_mn)
+#define __cminpack_type_fcnderstr_mn__  typedef int (*cminpack_funcderstr_mn)
+#define __cminpack_decl_fcn_nn__        cminpack_func_nn fcn_nn,
+#define __cminpack_decl_fcnder_nn__     cminpack_funcder_nn fcnder_nn,
+#define __cminpack_decl_fcn_mn__        cminpack_func_mn fcn_mn,
+#define __cminpack_decl_fcnder_mn__     cminpack_funcder_mn fcnder_mn,
+#define __cminpack_decl_fcnderstr_mn__  cminpack_funcderstr_mn fcnderstr_mn,
+#define __cminpack_param_fcn_nn__       fcn_nn,
+#define __cminpack_param_fcnder_nn__    fcnder_nn,
+#define __cminpack_param_fcn_mn__       fcn_mn,
+#define __cminpack_param_fcnder_mn__    fcnder_mn,
+#define __cminpack_param_fcnderstr_mn__ fcnderstr_mn,
+#endif
+
+#ifdef __cminpack_double__
+#define __cminpack_func__(func) func
+#endif
+
+#ifdef __cminpack_float__
+#define __cminpack_func__(func) s ## func
+#endif
+
+#ifdef __cminpack_half__
+#define __cminpack_func__(func) h ## func
+#endif
+
+/* Declarations for minpack */
+
+/* Function types: */
+/* The first argument can be used to store extra function parameters, thus */
+/* avoiding the use of global variables. */
+/* the iflag parameter is input-only (with respect to the FORTRAN */
+/*  version), the output iflag value is the return value of the function. */
+/* If iflag=0, the function shoulkd just print the current values (see */
+/* the nprint parameters below). */
+  
+/* for hybrd1 and hybrd: */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/* return a negative value to terminate hybrd1/hybrd */
+__cminpack_type_fcn_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int iflag );
+
+/* for hybrj1 and hybrj */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate hybrj1/hybrj */
+__cminpack_type_fcnder_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+                                  int ldfjac, int iflag );
+
+/* for lmdif1 and lmdif */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = 1 the result is used to compute the residuals. */
+/*         if iflag = 2 the result is used to compute the Jacobian by finite differences. */
+/*         Jacobian computation requires exactly n function calls with iflag = 2. */
+/* return a negative value to terminate lmdif1/lmdif */
+__cminpack_type_fcn_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
+                               int iflag );
+
+/* for lmder1 and lmder */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate lmder1/lmder */
+__cminpack_type_fcnder_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
+                                  __cminpack_real__ *fjac, int ldfjac, int iflag );
+
+/* for lmstr1 and lmstr */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/* return a negative value to terminate lmstr1/lmstr */
+__cminpack_type_fcnderstr_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
+                                     __cminpack_real__ *fjrow, int iflag );
+
+
+
+
+
+
+/* MINPACK functions: */
+/* the info parameter was removed from most functions: the return */
+/* value of the function is used instead. */
+/* The argument 'p' can be used to store extra function parameters, thus */
+/* avoiding the use of global variables. You can also think of it as a */
+/* 'this' pointer a la C++. */
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrd1)( __cminpack_decl_fcn_nn__ 
+	       void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol,
+	       __cminpack_real__ *wa, int lwa );
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation, more general). */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrd)( __cminpack_decl_fcn_nn__
+	      void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ xtol, int maxfev,
+	      int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *diag, int mode,
+	      __cminpack_real__ factor, int nprint, int *nfev,
+	      __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ *r, int lr, __cminpack_real__ *qtf,
+	      __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4);
+  
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrj1)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x,
+	       __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ tol,
+	       __cminpack_real__ *wa, int lwa );
+          
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian,
+   more general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrj)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x,
+	      __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ xtol,
+	      int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
+	      int nprint, int *nfev, int *njev, __cminpack_real__ *r,
+	      int lr, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2,
+	      __cminpack_real__ *wa3, __cminpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmdif1)( __cminpack_decl_fcn_mn__
+	       void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol,
+	       int *iwa, __cminpack_real__ *wa, int lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation, more
+   general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmdif)( __cminpack_decl_fcn_mn__
+	      void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ ftol,
+	      __cminpack_real__ xtol, __cminpack_real__ gtol, int maxfev, __cminpack_real__ epsfcn,
+	      __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint,
+	      int *nfev, __cminpack_real__ *fjac, int ldfjac, int *ipvt,
+	      __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
+	      __cminpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmder1)( __cminpack_decl_fcnder_mn__
+	       void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	       int ldfjac, __cminpack_real__ tol, int *ipvt,
+	       __cminpack_real__ *wa, int lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, more general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmder)( __cminpack_decl_fcnder_mn__
+	      void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	      int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol,
+	      int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
+	      int nprint, int *nfev, int *njev, int *ipvt,
+	      __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
+	      __cminpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmstr1)( __cminpack_decl_fcnderstr_mn__ void *p, int m, int n,
+	       __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac,
+	       __cminpack_real__ tol, int *ipvt, __cminpack_real__ *wa, int lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage, more general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmstr)(  __cminpack_decl_fcnderstr_mn__ void *p, int m,
+	      int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	      int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol,
+	      int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
+	      int nprint, int *nfev, int *njev, int *ipvt,
+	      __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
+	      __cminpack_real__ *wa4 );
+ 
+__cminpack_attr__
+void CMINPACK_EXPORT __cminpack_func__(chkder)( int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	       int ldfjac, __cminpack_real__ *xp, __cminpack_real__ *fvecp, int mode,
+	       __cminpack_real__ *err  );
+
+__cminpack_attr__
+__cminpack_real__ CMINPACK_EXPORT __cminpack_func__(dpmpar)( int i );
+
+__cminpack_attr__
+__cminpack_real__ CMINPACK_EXPORT __cminpack_func__(enorm)( int n, const __cminpack_real__ *x );
+
+/* compute a forward-difference approximation to the m by n jacobian
+   matrix associated with a specified problem of m functions in n
+   variables. */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(fdjac2)(__cminpack_decl_fcn_mn__
+	     void *p, int m, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	     int ldfjac, __cminpack_real__ epsfcn, __cminpack_real__ *wa);
+
+/* compute a forward-difference approximation to the n by n jacobian
+   matrix associated with a specified problem of n functions in n
+   variables. if the jacobian has a banded form, then function
+   evaluations are saved by only approximating the nonzero terms. */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(fdjac1)(__cminpack_decl_fcn_nn__
+	     void *p, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac,
+	     int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *wa1,
+	     __cminpack_real__ *wa2);
+
+/* compute inverse(JtJ) after a run of lmdif or lmder. The covariance matrix is obtained
+   by scaling the result by enorm(y)**2/(m-n). If JtJ is singular and k = rank(J), the
+   pseudo-inverse is computed, and the result has to be scaled by enorm(y)**2/(m-k). */
+__cminpack_attr__
+void CMINPACK_EXPORT __cminpack_func__(covar)(int n, __cminpack_real__ *r, int ldr, 
+           const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa);
+
+/* covar1 estimates the variance-covariance matrix:
+   C = sigma**2 (JtJ)**+
+   where (JtJ)**+ is the inverse of JtJ or the pseudo-inverse of JtJ (in case J does not have full rank),
+   and sigma**2 = fsumsq / (m - k)
+   where fsumsq is the residual sum of squares and k is the rank of J.
+   The function returns 0 if J has full rank, else the rank of J.
+*/
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(covar1)(int m, int n, __cminpack_real__ fsumsq, __cminpack_real__ *r, int ldr, 
+                           const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa);
+
+/* internal MINPACK subroutines */
+__cminpack_attr__
+void __cminpack_func__(dogleg)(int n, const __cminpack_real__ *r, int lr, 
+             const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, __cminpack_real__ *x, 
+             __cminpack_real__ *wa1, __cminpack_real__ *wa2);
+__cminpack_attr__
+void __cminpack_func__(qrfac)(int m, int n, __cminpack_real__ *a, int
+            lda, int pivot, int *ipvt, int lipvt, __cminpack_real__ *rdiag,
+            __cminpack_real__ *acnorm, __cminpack_real__ *wa);
+__cminpack_attr__
+void __cminpack_func__(qrsolv)(int n, __cminpack_real__ *r, int ldr, 
+             const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ *x, 
+             __cminpack_real__ *sdiag, __cminpack_real__ *wa);
+__cminpack_attr__
+void __cminpack_func__(qform)(int m, int n, __cminpack_real__ *q, int
+            ldq, __cminpack_real__ *wa);
+__cminpack_attr__
+void __cminpack_func__(r1updt)(int m, int n, __cminpack_real__ *s, int
+             ls, const __cminpack_real__ *u, __cminpack_real__ *v, __cminpack_real__ *w, int *sing);
+__cminpack_attr__
+void __cminpack_func__(r1mpyq)(int m, int n, __cminpack_real__ *a, int
+             lda, const __cminpack_real__ *v, const __cminpack_real__ *w);
+__cminpack_attr__
+void __cminpack_func__(lmpar)(int n, __cminpack_real__ *r, int ldr, 
+            const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, 
+            __cminpack_real__ *par, __cminpack_real__ *x, __cminpack_real__ *sdiag, __cminpack_real__ *wa1, 
+            __cminpack_real__ *wa2);
+__cminpack_attr__
+void __cminpack_func__(rwupdt)(int n, __cminpack_real__ *r, int ldr, 
+             const __cminpack_real__ *w, __cminpack_real__ *b, __cminpack_real__ *alpha, __cminpack_real__ *cos, 
+             __cminpack_real__ *sin);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __CMINPACK_H__ */
diff --git a/cminpack.sln b/cminpack.sln
new file mode 100644
index 0000000..ac50122
--- /dev/null
+++ b/cminpack.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cminpack", "cminpack.vcproj", "{DFCA12EC-B869-49B9-920D-F14FFB48529F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cminpack_dll", "cminpack_dll.vcproj", "{7A715393-C1E6-41D2-9A47-DA8501440F71}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{DFCA12EC-B869-49B9-920D-F14FFB48529F}.Debug|Win32.ActiveCfg = Debug|Win32
+		{DFCA12EC-B869-49B9-920D-F14FFB48529F}.Debug|Win32.Build.0 = Debug|Win32
+		{DFCA12EC-B869-49B9-920D-F14FFB48529F}.Release|Win32.ActiveCfg = Release|Win32
+		{DFCA12EC-B869-49B9-920D-F14FFB48529F}.Release|Win32.Build.0 = Release|Win32
+		{7A715393-C1E6-41D2-9A47-DA8501440F71}.Debug|Win32.ActiveCfg = Debug|Win32
+		{7A715393-C1E6-41D2-9A47-DA8501440F71}.Debug|Win32.Build.0 = Debug|Win32
+		{7A715393-C1E6-41D2-9A47-DA8501440F71}.Release|Win32.ActiveCfg = Release|Win32
+		{7A715393-C1E6-41D2-9A47-DA8501440F71}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
diff --git a/cminpack.vcproj b/cminpack.vcproj
new file mode 100644
index 0000000..974319d
--- /dev/null
+++ b/cminpack.vcproj
@@ -0,0 +1,586 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="cminpack"
+	ProjectGUID="{DFCA12EC-B869-49B9-920D-F14FFB48529F}"
+	RootNamespace="cminpack"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;CMINPACK_NO_DLL"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/$(ProjectName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;CMINPACK_NO_DLL"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/$(ProjectName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release (no sbw)|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;CMINPACK_NO_DLL"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/$(ProjectName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug DLL|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;cminpack_EXPORTS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/$(ProjectName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release DLL|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories=""
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;cminpack_EXPORTS"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/$(ProjectName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\chkder.c"
+				>
+			</File>
+			<File
+				RelativePath=".\chkder_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\covar.c"
+				>
+			</File>
+			<File
+				RelativePath=".\covar1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\covar_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dogleg.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dogleg_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dpmpar.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dpmpar_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\enorm.c"
+				>
+			</File>
+			<File
+				RelativePath=".\enorm_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac2.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac2_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmpar.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmpar_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qform.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qform_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrfac.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrfac_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrsolv.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrsolv_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1mpyq.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1mpyq_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1updt.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1updt_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\rwupdt.c"
+				>
+			</File>
+			<File
+				RelativePath=".\rwupdt_.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\cminpack.h"
+				>
+			</File>
+			<File
+				RelativePath=".\minpack.h"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath=".\CopyrightMINPACK.txt"
+			>
+		</File>
+		<File
+			RelativePath=".\readme.txt"
+			>
+		</File>
+		<File
+			RelativePath=".\README.md"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/cminpack.vcxproj b/cminpack.vcxproj
new file mode 100644
index 0000000..d76bdf9
--- /dev/null
+++ b/cminpack.vcxproj
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug DLL|Win32">
+      <Configuration>Debug DLL</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release (no sbw)|Win32">
+      <Configuration>Release (no sbw)</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release DLL|Win32">
+      <Configuration>Release DLL</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{DFCA12EC-B869-49B9-920D-F14FFB48529F}</ProjectGuid>
+    <RootNamespace>cminpack</RootNamespace>
+    <Keyword>Win32Proj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>Dynamic</UseOfMfc>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>Dynamic</UseOfMfc>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release (no sbw)|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>Dynamic</UseOfMfc>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>Dynamic</UseOfMfc>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>Dynamic</UseOfMfc>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release (no sbw)|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release (no sbw)|Win32'">$(Configuration)\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">$(Configuration)\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">$(Configuration)\</IntDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release (no sbw)|Win32'">$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;CMINPACK_NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;CMINPACK_NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release (no sbw)|Win32'">
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;CMINPACK_NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;cminpack_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;cminpack_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="chkder.c" />
+    <ClCompile Include="chkder_.c" />
+    <ClCompile Include="covar.c" />
+    <ClCompile Include="covar1.c" />
+    <ClCompile Include="covar_.c" />
+    <ClCompile Include="dogleg.c" />
+    <ClCompile Include="dogleg_.c" />
+    <ClCompile Include="dpmpar.c" />
+    <ClCompile Include="dpmpar_.c" />
+    <ClCompile Include="enorm.c" />
+    <ClCompile Include="enorm_.c" />
+    <ClCompile Include="fdjac1.c" />
+    <ClCompile Include="fdjac1_.c" />
+    <ClCompile Include="fdjac2.c" />
+    <ClCompile Include="fdjac2_.c" />
+    <ClCompile Include="hybrd.c" />
+    <ClCompile Include="hybrd1.c" />
+    <ClCompile Include="hybrd1_.c" />
+    <ClCompile Include="hybrd_.c" />
+    <ClCompile Include="hybrj.c" />
+    <ClCompile Include="hybrj1.c" />
+    <ClCompile Include="hybrj1_.c" />
+    <ClCompile Include="hybrj_.c" />
+    <ClCompile Include="lmder.c" />
+    <ClCompile Include="lmder1.c" />
+    <ClCompile Include="lmder1_.c" />
+    <ClCompile Include="lmder_.c" />
+    <ClCompile Include="lmdif.c" />
+    <ClCompile Include="lmdif1.c" />
+    <ClCompile Include="lmdif1_.c" />
+    <ClCompile Include="lmdif_.c" />
+    <ClCompile Include="lmpar.c" />
+    <ClCompile Include="lmpar_.c" />
+    <ClCompile Include="lmstr.c" />
+    <ClCompile Include="lmstr1.c" />
+    <ClCompile Include="lmstr1_.c" />
+    <ClCompile Include="lmstr_.c" />
+    <ClCompile Include="qform.c" />
+    <ClCompile Include="qform_.c" />
+    <ClCompile Include="qrfac.c" />
+    <ClCompile Include="qrfac_.c" />
+    <ClCompile Include="qrsolv.c" />
+    <ClCompile Include="qrsolv_.c" />
+    <ClCompile Include="r1mpyq.c" />
+    <ClCompile Include="r1mpyq_.c" />
+    <ClCompile Include="r1updt.c" />
+    <ClCompile Include="r1updt_.c" />
+    <ClCompile Include="rwupdt.c" />
+    <ClCompile Include="rwupdt_.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="cminpack.h" />
+    <ClInclude Include="minpack.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="CopyrightMINPACK.txt" />
+    <None Include="readme.txt" />
+    <None Include="README.md" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
diff --git a/cminpack.vcxproj.filters b/cminpack.vcxproj.filters
new file mode 100644
index 0000000..ce793e0
--- /dev/null
+++ b/cminpack.vcxproj.filters
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="chkder.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="chkder_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="covar.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="covar1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="covar_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="dogleg.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="dogleg_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="dpmpar.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="dpmpar_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="enorm.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="enorm_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="fdjac1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="fdjac1_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="fdjac2.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="fdjac2_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrd.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrd1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrd1_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrd_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrj.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrj1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrj1_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="hybrj_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmder.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmder1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmder1_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmder_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmdif.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmdif1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmdif1_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmdif_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmpar.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmpar_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmstr.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmstr1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmstr1_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="lmstr_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="qform.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="qform_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="qrfac.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="qrfac_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="qrsolv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="qrsolv_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="r1mpyq.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="r1mpyq_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="r1updt.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="r1updt_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="rwupdt.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="rwupdt_.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="cminpack.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="minpack.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="CopyrightMINPACK.txt" />
+    <None Include="readme.txt" />
+    <None Include="README.md" />
+  </ItemGroup>
+</Project>
diff --git a/cminpack.xcodeproj/project.pbxproj b/cminpack.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..bbdf568
--- /dev/null
+++ b/cminpack.xcodeproj/project.pbxproj
@@ -0,0 +1,2477 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXAggregateTarget section */
+		1E548EEC0F83E3F10015F022 /* all */ = {
+			isa = PBXAggregateTarget;
+			buildConfigurationList = 1E548F0D0F83E42D0015F022 /* Build configuration list for PBXAggregateTarget "all" */;
+			buildPhases = (
+			);
+			dependencies = (
+				1E548EF10F83E3F90015F022 /* PBXTargetDependency */,
+				1EA5C2D015877BB000F5CFF7 /* PBXTargetDependency */,
+				1EA5C2D215877BB000F5CFF7 /* PBXTargetDependency */,
+				1EA5C2D415877BB000F5CFF7 /* PBXTargetDependency */,
+				1EA5C2D615877BB000F5CFF7 /* PBXTargetDependency */,
+				1EA5C2D815877BB000F5CFF7 /* PBXTargetDependency */,
+				1EA5C2DA15877BB000F5CFF7 /* PBXTargetDependency */,
+				1EA5C2DC15877BB000F5CFF7 /* PBXTargetDependency */,
+				1E548EF70F83E3F90015F022 /* PBXTargetDependency */,
+				1E548EF90F83E3F90015F022 /* PBXTargetDependency */,
+				1E548EFB0F83E3F90015F022 /* PBXTargetDependency */,
+				1E548EFD0F83E3F90015F022 /* PBXTargetDependency */,
+				1E548EFF0F83E3F90015F022 /* PBXTargetDependency */,
+				1E548F010F83E3F90015F022 /* PBXTargetDependency */,
+				1E548F070F83E3F90015F022 /* PBXTargetDependency */,
+				1E548EF30F83E3F90015F022 /* PBXTargetDependency */,
+				1E548EF50F83E3F90015F022 /* PBXTargetDependency */,
+				1E548F030F83E3F90015F022 /* PBXTargetDependency */,
+				1E548F050F83E3F90015F022 /* PBXTargetDependency */,
+			);
+			name = all;
+			productName = cminpack;
+		};
+/* End PBXAggregateTarget section */
+
+/* Begin PBXBuildFile section */
+		1E20CA5214486BB40084559B /* covar1.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E20CA5114486BB40084559B /* covar1.c */; };
+		1E47DDC6181A6A8000CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDCB181A73B000CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD1181A73B400CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD2181A73B900CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD3181A73BA00CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD4181A73BA00CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD5181A73BB00CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD6181A73BC00CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD7181A73BD00CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD8181A73BD00CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDD9181A745900CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDDA181A746100CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDDB181A746200CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDDC181A746200CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDDD181A746300CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDDE181A746400CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDDF181A746500CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDE0181A746500CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E47DDE1181A746600CBDA54 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */; };
+		1E548DCD0F83DF710015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E0A0F83E1C10015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E1C0F83E2050015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E510F83E2DF0015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E650F83E2F90015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E780F83E3130015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E8A0F83E32D0015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548E9B0F83E3440015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548EBA0F83E3810015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548ECA0F83E38C0015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1E548ED90F83E3A10015F022 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C26015877A0900F5CFF7 /* ibmdpdr.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C25F15877A0900F5CFF7 /* ibmdpdr.c */; };
+		1EA5C2BE15877B2B00F5CFF7 /* tchkderc.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63941148F51A0013EA0C /* tchkderc.c */; };
+		1EA5C2BF15877B3700F5CFF7 /* thybrdc.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F639A1148F51A0013EA0C /* thybrdc.c */; };
+		1EA5C2C015877B4600F5CFF7 /* thybrd1c.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63981148F51A0013EA0C /* thybrd1c.c */; };
+		1EA5C2C115877B4C00F5CFF7 /* thybrjc.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F639E1148F51A0013EA0C /* thybrjc.c */; };
+		1EA5C2C215877B5000F5CFF7 /* thybrj1c.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F639C1148F51A0013EA0C /* thybrj1c.c */; };
+		1EA5C2C315877B5500F5CFF7 /* tlmderc.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63A21148F51A0013EA0C /* tlmderc.c */; };
+		1EA5C2C415877B5800F5CFF7 /* tlmder1c.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63A01148F51A0013EA0C /* tlmder1c.c */; };
+		1EA5C2C515877B5E00F5CFF7 /* tlmdifc.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63A61148F51A0013EA0C /* tlmdifc.c */; };
+		1EA5C2C615877B6100F5CFF7 /* tlmdif1c.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63A41148F51A0013EA0C /* tlmdif1c.c */; };
+		1EA5C2C715877B6500F5CFF7 /* tlmstrc.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63AA1148F51A0013EA0C /* tlmstrc.c */; };
+		1EA5C2C815877B6900F5CFF7 /* tlmstr1c.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F8F63A81148F51A0013EA0C /* tlmstr1c.c */; };
+		1EA5C2C915877B8B00F5CFF7 /* lmddrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36B145DA8F100F4FFF4 /* lmddrv.c */; };
+		1EA5C2CA15877B8E00F5CFF7 /* lmfdrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36D145DA8F100F4FFF4 /* lmfdrv.c */; };
+		1EA5C2CB15877B9200F5CFF7 /* lmsdrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2BB15877B0100F5CFF7 /* lmsdrv.c */; };
+		1EA5C2CC15877B9700F5CFF7 /* hyjdrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B915877B0100F5CFF7 /* hyjdrv.c */; };
+		1EA5C2CD15877B9A00F5CFF7 /* hybipt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B815877B0100F5CFF7 /* hybipt.c */; };
+		1EA5C2CE15877B9F00F5CFF7 /* chkdrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B515877B0100F5CFF7 /* chkdrv.c */; };
+		1EA5C2E615877C2100F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2E715877C2200F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2E815877C2400F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2E915877C2400F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2EA15877C2500F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2EB15877C2500F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2EC15877C2500F5CFF7 /* libcminpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC046055464E500DB518D /* libcminpack.a */; };
+		1EA5C2EE15877C2F00F5CFF7 /* machar.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2ED15877C2F00F5CFF7 /* machar.c */; };
+		1EA5C2EF15877C6800F5CFF7 /* lmdipt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36C145DA8F100F4FFF4 /* lmdipt.c */; };
+		1EA5C2F015877C6800F5CFF7 /* ssqfcn.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36F145DA8F100F4FFF4 /* ssqfcn.c */; };
+		1EA5C2F115877C6800F5CFF7 /* ssqjac.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E370145DA8F100F4FFF4 /* ssqjac.c */; };
+		1EA5C2F215877C7B00F5CFF7 /* lmdipt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36C145DA8F100F4FFF4 /* lmdipt.c */; };
+		1EA5C2F315877C7B00F5CFF7 /* ssqfcn.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36F145DA8F100F4FFF4 /* ssqfcn.c */; };
+		1EA5C2F415877C7B00F5CFF7 /* ssqjac.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E370145DA8F100F4FFF4 /* ssqjac.c */; };
+		1EA5C2F515877C8D00F5CFF7 /* lmdipt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36C145DA8F100F4FFF4 /* lmdipt.c */; };
+		1EA5C2F615877C8D00F5CFF7 /* ssqfcn.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5E36F145DA8F100F4FFF4 /* ssqfcn.c */; };
+		1EA5C2F715877CA400F5CFF7 /* hybipt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B815877B0100F5CFF7 /* hybipt.c */; };
+		1EA5C2F815877CA400F5CFF7 /* vecfcn.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2BC15877B0100F5CFF7 /* vecfcn.c */; };
+		1EA5C2F915877CA400F5CFF7 /* vecjac.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2BD15877B0100F5CFF7 /* vecjac.c */; };
+		1EA5C2FA15877CC800F5CFF7 /* hybdrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B715877B0100F5CFF7 /* hybdrv.c */; };
+		1EA5C2FB15877CE500F5CFF7 /* errjac.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B615877B0100F5CFF7 /* errjac.c */; };
+		1EA5C2FC15877CE500F5CFF7 /* hybipt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2B815877B0100F5CFF7 /* hybipt.c */; };
+		1EA5C2FD15877CE500F5CFF7 /* vecfcn.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2BC15877B0100F5CFF7 /* vecfcn.c */; };
+		1EA5C2FE15877CF600F5CFF7 /* vecfcn.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5C2BC15877B0100F5CFF7 /* vecfcn.c */; };
+		35C3D6DF0DB79E4800A4BB4B /* lmdif.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6BC0DB79E4800A4BB4B /* lmdif.c */; };
+		35C3D6E00DB79E4800A4BB4B /* chkder.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6BD0DB79E4800A4BB4B /* chkder.c */; };
+		35C3D6E10DB79E4800A4BB4B /* covar.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6BE0DB79E4800A4BB4B /* covar.c */; };
+		35C3D6E20DB79E4800A4BB4B /* dogleg.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6BF0DB79E4800A4BB4B /* dogleg.c */; };
+		35C3D6E30DB79E4800A4BB4B /* dpmpar.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C00DB79E4800A4BB4B /* dpmpar.c */; };
+		35C3D6E40DB79E4800A4BB4B /* enorm.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C10DB79E4800A4BB4B /* enorm.c */; };
+		35C3D6E50DB79E4800A4BB4B /* fdjac1.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C20DB79E4800A4BB4B /* fdjac1.c */; };
+		35C3D6E60DB79E4800A4BB4B /* fdjac2.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C30DB79E4800A4BB4B /* fdjac2.c */; };
+		35C3D6E70DB79E4800A4BB4B /* hybrd.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C40DB79E4800A4BB4B /* hybrd.c */; };
+		35C3D6E80DB79E4800A4BB4B /* hybrd1.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C50DB79E4800A4BB4B /* hybrd1.c */; };
+		35C3D6E90DB79E4800A4BB4B /* hybrj.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C60DB79E4800A4BB4B /* hybrj.c */; };
+		35C3D6EA0DB79E4800A4BB4B /* hybrj1.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C70DB79E4800A4BB4B /* hybrj1.c */; };
+		35C3D6EB0DB79E4800A4BB4B /* lmder.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C80DB79E4800A4BB4B /* lmder.c */; };
+		35C3D6EC0DB79E4800A4BB4B /* lmder1.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6C90DB79E4800A4BB4B /* lmder1.c */; };
+		35C3D6ED0DB79E4800A4BB4B /* lmdif1.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6CA0DB79E4800A4BB4B /* lmdif1.c */; };
+		35C3D6EE0DB79E4800A4BB4B /* lmpar.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6CB0DB79E4800A4BB4B /* lmpar.c */; };
+		35C3D6EF0DB79E4800A4BB4B /* lmstr.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6CC0DB79E4800A4BB4B /* lmstr.c */; };
+		35C3D6F00DB79E4800A4BB4B /* lmstr1.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6CD0DB79E4800A4BB4B /* lmstr1.c */; };
+		35C3D6F10DB79E4800A4BB4B /* qform.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6CE0DB79E4800A4BB4B /* qform.c */; };
+		35C3D6F20DB79E4800A4BB4B /* qrfac.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6CF0DB79E4800A4BB4B /* qrfac.c */; };
+		35C3D6F30DB79E4800A4BB4B /* qrsolv.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6D00DB79E4800A4BB4B /* qrsolv.c */; };
+		35C3D6F40DB79E4800A4BB4B /* r1mpyq.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6D10DB79E4800A4BB4B /* r1mpyq.c */; };
+		35C3D6F50DB79E4800A4BB4B /* r1updt.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6D20DB79E4800A4BB4B /* r1updt.c */; };
+		35C3D6F60DB79E4800A4BB4B /* rwupdt.c in Sources */ = {isa = PBXBuildFile; fileRef = 35C3D6D30DB79E4800A4BB4B /* rwupdt.c */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+		1E548EF00F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548EF20F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548DC50F83DF460015F022;
+			remoteInfo = tlmdif;
+		};
+		1E548EF40F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E060F83E1C10015F022;
+			remoteInfo = tlmdif1;
+		};
+		1E548EF60F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E180F83E2050015F022;
+			remoteInfo = tchkder;
+		};
+		1E548EF80F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E450F83E2DF0015F022;
+			remoteInfo = thybrd;
+		};
+		1E548EFA0F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E5A0F83E2F90015F022;
+			remoteInfo = thybrd1;
+		};
+		1E548EFC0F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E6E0F83E3130015F022;
+			remoteInfo = thybrj;
+		};
+		1E548EFE0F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E810F83E32D0015F022;
+			remoteInfo = thybrj1;
+		};
+		1E548F000F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548E930F83E3440015F022;
+			remoteInfo = tlmder;
+		};
+		1E548F020F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548EB30F83E3810015F022;
+			remoteInfo = tlmstr;
+		};
+		1E548F040F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548EC30F83E38C0015F022;
+			remoteInfo = tlmstr1;
+		};
+		1E548F060F83E3F90015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1E548ED30F83E3A10015F022;
+			remoteInfo = tlmder1;
+		};
+		1E548F100F83E4590015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F120F83E4620015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F140F83E4710015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F160F83E4740015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F180F83E4770015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F1A0F83E47E0015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F1C0F83E4820015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F1E0F83E4880015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F200F83E48B0015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F220F83E4920015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1E548F240F83E4950015F022 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minmack;
+		};
+		1EA5C2CF15877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C254158779BA00F5CFF7;
+			remoteInfo = ibmdpdrc;
+		};
+		1EA5C2D115877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C26415877A8B00F5CFF7;
+			remoteInfo = lmddrvc;
+		};
+		1EA5C2D315877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C27215877A9500F5CFF7;
+			remoteInfo = lmfdrvc;
+		};
+		1EA5C2D515877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C28015877AA100F5CFF7;
+			remoteInfo = lmsdrvc;
+		};
+		1EA5C2D715877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C28E15877AAF00F5CFF7;
+			remoteInfo = hyjdrvc;
+		};
+		1EA5C2D915877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C29C15877ABA00F5CFF7;
+			remoteInfo = hybdrvc;
+		};
+		1EA5C2DB15877BB000F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 1EA5C2AA15877AC900F5CFF7;
+			remoteInfo = chkdrvc;
+		};
+		1EA5C2DD15877C0400F5CFF7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = D2AAC045055464E500DB518D;
+			remoteInfo = minpack;
+		};
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		1EA5C253158779BA00F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		1EA5C26315877A8B00F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		1EA5C27115877A9500F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		1EA5C27F15877AA100F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		1EA5C28D15877AAF00F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		1EA5C29B15877ABA00F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+		1EA5C2A915877AC900F5CFF7 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+		1E20CA5114486BB40084559B /* covar1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = covar1.c; sourceTree = "<group>"; };
+		1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
+		1E548DC60F83DF460015F022 /* tlmdif */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tlmdif; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548DDC0F83E0960015F022 /* hybrd_.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = hybrd_.html; path = doc/hybrd_.html; sourceTree = "<group>"; };
+		1E548DDD0F83E0960015F022 /* hybrj_.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = hybrj_.html; path = doc/hybrj_.html; sourceTree = "<group>"; };
+		1E548DDE0F83E0960015F022 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = index.html; path = doc/index.html; sourceTree = "<group>"; };
+		1E548DDF0F83E0960015F022 /* lmder_.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = lmder_.html; path = doc/lmder_.html; sourceTree = "<group>"; };
+		1E548DE00F83E0960015F022 /* lmdif_.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = lmdif_.html; path = doc/lmdif_.html; sourceTree = "<group>"; };
+		1E548DE10F83E0960015F022 /* lmstr_.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = lmstr_.html; path = doc/lmstr_.html; sourceTree = "<group>"; };
+		1E548DE20F83E0960015F022 /* minpack-documentation.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "minpack-documentation.txt"; path = "doc/minpack-documentation.txt"; sourceTree = "<group>"; };
+		1E548E0E0F83E1C10015F022 /* tlmdif1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tlmdif1; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548E200F83E2050015F022 /* tchkder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tchkder; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548E550F83E2DF0015F022 /* thybrd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = thybrd; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548E690F83E2F90015F022 /* thybrd1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = thybrd1; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548E7C0F83E3130015F022 /* thybrj */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = thybrj; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548E8E0F83E32D0015F022 /* thybrj1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = thybrj1; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548E9F0F83E3440015F022 /* tlmder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tlmder; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548EBE0F83E3810015F022 /* tlmstr */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tlmstr; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548ECE0F83E38C0015F022 /* tlmstr1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tlmstr1; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E548EDD0F83E3A10015F022 /* tlmder1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = tlmder1; sourceTree = BUILT_PRODUCTS_DIR; };
+		1E8894CE158261E000FD154D /* cminpackP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cminpackP.h; sourceTree = "<group>"; };
+		1EA5C255158779BA00F5CFF7 /* ibmdpdrc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ibmdpdrc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C25F15877A0900F5CFF7 /* ibmdpdr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ibmdpdr.c; path = examples/ibmdpdr.c; sourceTree = "<group>"; };
+		1EA5C26515877A8B00F5CFF7 /* lmddrvc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lmddrvc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C27315877A9500F5CFF7 /* lmfdrvc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lmfdrvc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C28115877AA100F5CFF7 /* lmsdrvc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lmsdrvc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C28F15877AAF00F5CFF7 /* hyjdrvc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = hyjdrvc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C29D15877ABA00F5CFF7 /* hybdrvc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = hybdrvc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C2AB15877AC900F5CFF7 /* chkdrvc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = chkdrvc; sourceTree = BUILT_PRODUCTS_DIR; };
+		1EA5C2B515877B0100F5CFF7 /* chkdrv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = chkdrv.c; path = examples/chkdrv.c; sourceTree = "<group>"; };
+		1EA5C2B615877B0100F5CFF7 /* errjac.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = errjac.c; path = examples/errjac.c; sourceTree = "<group>"; };
+		1EA5C2B715877B0100F5CFF7 /* hybdrv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = hybdrv.c; path = examples/hybdrv.c; sourceTree = "<group>"; };
+		1EA5C2B815877B0100F5CFF7 /* hybipt.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = hybipt.c; path = examples/hybipt.c; sourceTree = "<group>"; };
+		1EA5C2B915877B0100F5CFF7 /* hyjdrv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = hyjdrv.c; path = examples/hyjdrv.c; sourceTree = "<group>"; };
+		1EA5C2BA15877B0100F5CFF7 /* lmfdrv_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = lmfdrv_.c; path = examples/lmfdrv_.c; sourceTree = "<group>"; };
+		1EA5C2BB15877B0100F5CFF7 /* lmsdrv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = lmsdrv.c; path = examples/lmsdrv.c; sourceTree = "<group>"; };
+		1EA5C2BC15877B0100F5CFF7 /* vecfcn.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = vecfcn.c; path = examples/vecfcn.c; sourceTree = "<group>"; };
+		1EA5C2BD15877B0100F5CFF7 /* vecjac.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = vecjac.c; path = examples/vecjac.c; sourceTree = "<group>"; };
+		1EA5C2ED15877C2F00F5CFF7 /* machar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = machar.c; path = examples/machar.c; sourceTree = "<group>"; };
+		1EE5E35E145DA88300F4FFF4 /* cminpack.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = cminpack.html; path = doc/cminpack.html; sourceTree = "<group>"; };
+		1EE5E35F145DA88300F4FFF4 /* hybrd_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = hybrd_.3; path = doc/hybrd_.3; sourceTree = "<group>"; };
+		1EE5E360145DA88300F4FFF4 /* hybrd1_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = hybrd1_.3; path = doc/hybrd1_.3; sourceTree = "<group>"; };
+		1EE5E361145DA88300F4FFF4 /* hybrj_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = hybrj_.3; path = doc/hybrj_.3; sourceTree = "<group>"; };
+		1EE5E362145DA88300F4FFF4 /* hybrj1_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = hybrj1_.3; path = doc/hybrj1_.3; sourceTree = "<group>"; };
+		1EE5E363145DA88300F4FFF4 /* lmder_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = lmder_.3; path = doc/lmder_.3; sourceTree = "<group>"; };
+		1EE5E364145DA88300F4FFF4 /* lmder1_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = lmder1_.3; path = doc/lmder1_.3; sourceTree = "<group>"; };
+		1EE5E365145DA88300F4FFF4 /* lmdif_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = lmdif_.3; path = doc/lmdif_.3; sourceTree = "<group>"; };
+		1EE5E366145DA88300F4FFF4 /* lmdif1_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = lmdif1_.3; path = doc/lmdif1_.3; sourceTree = "<group>"; };
+		1EE5E367145DA88300F4FFF4 /* lmstr_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = lmstr_.3; path = doc/lmstr_.3; sourceTree = "<group>"; };
+		1EE5E368145DA88300F4FFF4 /* lmstr1_.3 */ = {isa = PBXFileReference; lastKnownFileType = text; name = lmstr1_.3; path = doc/lmstr1_.3; sourceTree = "<group>"; };
+		1EE5E369145DA8F100F4FFF4 /* cmpfiles.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = cmpfiles.c; path = examples/cmpfiles.c; sourceTree = "<group>"; };
+		1EE5E36A145DA8F100F4FFF4 /* genf77tests.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = genf77tests.c; path = examples/genf77tests.c; sourceTree = "<group>"; };
+		1EE5E36B145DA8F100F4FFF4 /* lmddrv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = lmddrv.c; path = examples/lmddrv.c; sourceTree = "<group>"; };
+		1EE5E36C145DA8F100F4FFF4 /* lmdipt.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = lmdipt.c; path = examples/lmdipt.c; sourceTree = "<group>"; };
+		1EE5E36D145DA8F100F4FFF4 /* lmfdrv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = lmfdrv.c; path = examples/lmfdrv.c; sourceTree = "<group>"; };
+		1EE5E36E145DA8F100F4FFF4 /* ssq.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ssq.h; path = examples/ssq.h; sourceTree = "<group>"; };
+		1EE5E36F145DA8F100F4FFF4 /* ssqfcn.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = ssqfcn.c; path = examples/ssqfcn.c; sourceTree = "<group>"; };
+		1EE5E370145DA8F100F4FFF4 /* ssqjac.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = ssqjac.c; path = examples/ssqjac.c; sourceTree = "<group>"; };
+		1EE5E373145DA96C00F4FFF4 /* chkdrv.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = chkdrv.ref; sourceTree = "<group>"; };
+		1EE5E374145DA96C00F4FFF4 /* hybdrv.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = hybdrv.ref; sourceTree = "<group>"; };
+		1EE5E375145DA96C00F4FFF4 /* hyjdrv.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = hyjdrv.ref; sourceTree = "<group>"; };
+		1EE5E376145DA96C00F4FFF4 /* lmddrv.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = lmddrv.ref; sourceTree = "<group>"; };
+		1EE5E377145DA96C00F4FFF4 /* lmddrvc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = lmddrvc.ref; sourceTree = "<group>"; };
+		1EE5E378145DA96C00F4FFF4 /* lmfdrv.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = lmfdrv.ref; sourceTree = "<group>"; };
+		1EE5E379145DA96C00F4FFF4 /* lmfdrvc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = lmfdrvc.ref; sourceTree = "<group>"; };
+		1EE5E37A145DA96C00F4FFF4 /* lmsdrv.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = lmsdrv.ref; sourceTree = "<group>"; };
+		1EE5E37B145DA96C00F4FFF4 /* tchkder.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tchkder.ref; sourceTree = "<group>"; };
+		1EE5E37C145DA96C00F4FFF4 /* tchkderc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tchkderc.ref; sourceTree = "<group>"; };
+		1EE5E37D145DA96C00F4FFF4 /* tfdjac2c.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tfdjac2c.ref; sourceTree = "<group>"; };
+		1EE5E37E145DA96C00F4FFF4 /* thybrd.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrd.ref; sourceTree = "<group>"; };
+		1EE5E37F145DA96C00F4FFF4 /* thybrd1.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrd1.ref; sourceTree = "<group>"; };
+		1EE5E380145DA96C00F4FFF4 /* thybrd1c.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrd1c.ref; sourceTree = "<group>"; };
+		1EE5E381145DA96C00F4FFF4 /* thybrdc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrdc.ref; sourceTree = "<group>"; };
+		1EE5E382145DA96C00F4FFF4 /* thybrj.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrj.ref; sourceTree = "<group>"; };
+		1EE5E383145DA96C00F4FFF4 /* thybrj1.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrj1.ref; sourceTree = "<group>"; };
+		1EE5E384145DA96C00F4FFF4 /* thybrj1c.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrj1c.ref; sourceTree = "<group>"; };
+		1EE5E385145DA96C00F4FFF4 /* thybrjc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = thybrjc.ref; sourceTree = "<group>"; };
+		1EE5E386145DA96C00F4FFF4 /* tlmder.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmder.ref; sourceTree = "<group>"; };
+		1EE5E387145DA96C00F4FFF4 /* tlmder1.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmder1.ref; sourceTree = "<group>"; };
+		1EE5E388145DA96C00F4FFF4 /* tlmder1c.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmder1c.ref; sourceTree = "<group>"; };
+		1EE5E389145DA96C00F4FFF4 /* tlmderc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmderc.ref; sourceTree = "<group>"; };
+		1EE5E38A145DA96C00F4FFF4 /* tlmdif.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmdif.ref; sourceTree = "<group>"; };
+		1EE5E38B145DA96C00F4FFF4 /* tlmdif1.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmdif1.ref; sourceTree = "<group>"; };
+		1EE5E38C145DA96C00F4FFF4 /* tlmdif1c.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmdif1c.ref; sourceTree = "<group>"; };
+		1EE5E38D145DA96C00F4FFF4 /* tlmdifc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmdifc.ref; sourceTree = "<group>"; };
+		1EE5E38E145DA96C00F4FFF4 /* tlmstr.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmstr.ref; sourceTree = "<group>"; };
+		1EE5E38F145DA96C00F4FFF4 /* tlmstr1.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmstr1.ref; sourceTree = "<group>"; };
+		1EE5E390145DA96C00F4FFF4 /* tlmstr1c.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmstr1c.ref; sourceTree = "<group>"; };
+		1EE5E391145DA96C00F4FFF4 /* tlmstrc.ref */ = {isa = PBXFileReference; lastKnownFileType = text; path = tlmstrc.ref; sourceTree = "<group>"; };
+		1EE5E396145DA9AC00F4FFF4 /* chkder.data */ = {isa = PBXFileReference; lastKnownFileType = text; path = chkder.data; sourceTree = "<group>"; };
+		1EE5E397145DA9AC00F4FFF4 /* hybrd.data */ = {isa = PBXFileReference; lastKnownFileType = text; path = hybrd.data; sourceTree = "<group>"; };
+		1EE5E398145DA9AC00F4FFF4 /* lm.data */ = {isa = PBXFileReference; lastKnownFileType = text; path = lm.data; sourceTree = "<group>"; };
+		1EE5E39A145DAA2400F4FFF4 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
+		1EE5E39B145DAA2400F4FFF4 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
+		1EE5E39D145DAA5300F4FFF4 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
+		1EE5E39E145DAA5300F4FFF4 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
+		1EE5E39F145DAA5300F4FFF4 /* runtest.cmake */ = {isa = PBXFileReference; lastKnownFileType = text; path = runtest.cmake; sourceTree = "<group>"; };
+		1EE5E3A0145DAA8C00F4FFF4 /* CopyrightMINPACK.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CopyrightMINPACK.txt; sourceTree = "<group>"; };
+		1EE5E3A1145DAA8C00F4FFF4 /* readme.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.txt; sourceTree = "<group>"; };
+		1EE5E3A2145DAA8C00F4FFF4 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
+		1EE5E3A4145DAB0A00F4FFF4 /* chkder_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = chkder_.c; sourceTree = "<group>"; };
+		1EE5E3A5145DAB0A00F4FFF4 /* covar_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = covar_.c; sourceTree = "<group>"; };
+		1EE5E3A6145DAB0A00F4FFF4 /* dogleg_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = dogleg_.c; sourceTree = "<group>"; };
+		1EE5E3A7145DAB0A00F4FFF4 /* dpmpar_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = dpmpar_.c; sourceTree = "<group>"; };
+		1EE5E3A8145DAB0A00F4FFF4 /* enorm_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = enorm_.c; sourceTree = "<group>"; };
+		1EE5E3A9145DAB0A00F4FFF4 /* fdjac1_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = fdjac1_.c; sourceTree = "<group>"; };
+		1EE5E3AA145DAB0A00F4FFF4 /* fdjac2_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = fdjac2_.c; sourceTree = "<group>"; };
+		1EE5E3AB145DAB0A00F4FFF4 /* hybrd_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = hybrd_.c; sourceTree = "<group>"; };
+		1EE5E3AC145DAB0A00F4FFF4 /* hybrd1_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = hybrd1_.c; sourceTree = "<group>"; };
+		1EE5E3AD145DAB0A00F4FFF4 /* hybrj_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = hybrj_.c; sourceTree = "<group>"; };
+		1EE5E3AE145DAB0A00F4FFF4 /* hybrj1_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = hybrj1_.c; sourceTree = "<group>"; };
+		1EE5E3AF145DAB0A00F4FFF4 /* lmder_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmder_.c; sourceTree = "<group>"; };
+		1EE5E3B0145DAB0A00F4FFF4 /* lmder1_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmder1_.c; sourceTree = "<group>"; };
+		1EE5E3B1145DAB0A00F4FFF4 /* lmdif_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmdif_.c; sourceTree = "<group>"; };
+		1EE5E3B2145DAB0A00F4FFF4 /* lmdif1_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmdif1_.c; sourceTree = "<group>"; };
+		1EE5E3B3145DAB0A00F4FFF4 /* lmpar_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmpar_.c; sourceTree = "<group>"; };
+		1EE5E3B4145DAB0A00F4FFF4 /* lmstr_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmstr_.c; sourceTree = "<group>"; };
+		1EE5E3B5145DAB0A00F4FFF4 /* lmstr1_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lmstr1_.c; sourceTree = "<group>"; };
+		1EE5E3B6145DAB0A00F4FFF4 /* qform_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = qform_.c; sourceTree = "<group>"; };
+		1EE5E3B7145DAB0A00F4FFF4 /* qrfac_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = qrfac_.c; sourceTree = "<group>"; };
+		1EE5E3B8145DAB0A00F4FFF4 /* qrsolv_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = qrsolv_.c; sourceTree = "<group>"; };
+		1EE5E3B9145DAB0A00F4FFF4 /* r1mpyq_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = r1mpyq_.c; sourceTree = "<group>"; };
+		1EE5E3BA145DAB0A00F4FFF4 /* r1updt_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = r1updt_.c; sourceTree = "<group>"; };
+		1EE5E3BB145DAB0A00F4FFF4 /* rwupdt_.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = rwupdt_.c; sourceTree = "<group>"; };
+		1EE5E3BC145DAB4C00F4FFF4 /* cminpack_dll.vcproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = cminpack_dll.vcproj; sourceTree = "<group>"; };
+		1EE5E3BD145DAB4C00F4FFF4 /* cminpack.sln */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cminpack.sln; sourceTree = "<group>"; };
+		1EE5E3BE145DAB4C00F4FFF4 /* cminpack.vcproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = cminpack.vcproj; sourceTree = "<group>"; };
+		1EE5E3BF145DAB4C00F4FFF4 /* dist-exclude */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "dist-exclude"; sourceTree = "<group>"; };
+		35C3D6BC0DB79E4800A4BB4B /* lmdif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmdif.c; sourceTree = "<group>"; };
+		35C3D6BD0DB79E4800A4BB4B /* chkder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = chkder.c; sourceTree = "<group>"; };
+		35C3D6BE0DB79E4800A4BB4B /* covar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = covar.c; sourceTree = "<group>"; };
+		35C3D6BF0DB79E4800A4BB4B /* dogleg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dogleg.c; sourceTree = "<group>"; };
+		35C3D6C00DB79E4800A4BB4B /* dpmpar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dpmpar.c; sourceTree = "<group>"; };
+		35C3D6C10DB79E4800A4BB4B /* enorm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = enorm.c; sourceTree = "<group>"; };
+		35C3D6C20DB79E4800A4BB4B /* fdjac1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fdjac1.c; sourceTree = "<group>"; };
+		35C3D6C30DB79E4800A4BB4B /* fdjac2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fdjac2.c; sourceTree = "<group>"; };
+		35C3D6C40DB79E4800A4BB4B /* hybrd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hybrd.c; sourceTree = "<group>"; };
+		35C3D6C50DB79E4800A4BB4B /* hybrd1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hybrd1.c; sourceTree = "<group>"; };
+		35C3D6C60DB79E4800A4BB4B /* hybrj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hybrj.c; sourceTree = "<group>"; };
+		35C3D6C70DB79E4800A4BB4B /* hybrj1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hybrj1.c; sourceTree = "<group>"; };
+		35C3D6C80DB79E4800A4BB4B /* lmder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmder.c; sourceTree = "<group>"; };
+		35C3D6C90DB79E4800A4BB4B /* lmder1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmder1.c; sourceTree = "<group>"; };
+		35C3D6CA0DB79E4800A4BB4B /* lmdif1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmdif1.c; sourceTree = "<group>"; };
+		35C3D6CB0DB79E4800A4BB4B /* lmpar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmpar.c; sourceTree = "<group>"; };
+		35C3D6CC0DB79E4800A4BB4B /* lmstr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmstr.c; sourceTree = "<group>"; };
+		35C3D6CD0DB79E4800A4BB4B /* lmstr1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmstr1.c; sourceTree = "<group>"; };
+		35C3D6CE0DB79E4800A4BB4B /* qform.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = qform.c; sourceTree = "<group>"; };
+		35C3D6CF0DB79E4800A4BB4B /* qrfac.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = qrfac.c; sourceTree = "<group>"; };
+		35C3D6D00DB79E4800A4BB4B /* qrsolv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = qrsolv.c; sourceTree = "<group>"; };
+		35C3D6D10DB79E4800A4BB4B /* r1mpyq.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = r1mpyq.c; sourceTree = "<group>"; };
+		35C3D6D20DB79E4800A4BB4B /* r1updt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = r1updt.c; sourceTree = "<group>"; };
+		35C3D6D30DB79E4800A4BB4B /* rwupdt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rwupdt.c; sourceTree = "<group>"; };
+		35C3D7020DB79E5600A4BB4B /* cminpack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cminpack.h; sourceTree = "<group>"; };
+		35C3D7030DB79E5600A4BB4B /* minpack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = minpack.h; sourceTree = "<group>"; };
+		7F8F63941148F51A0013EA0C /* tchkderc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tchkderc.c; path = examples/tchkderc.c; sourceTree = "<group>"; };
+		7F8F63961148F51A0013EA0C /* tfdjac2c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tfdjac2c.c; path = examples/tfdjac2c.c; sourceTree = "<group>"; };
+		7F8F63981148F51A0013EA0C /* thybrd1c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thybrd1c.c; path = examples/thybrd1c.c; sourceTree = "<group>"; };
+		7F8F639A1148F51A0013EA0C /* thybrdc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thybrdc.c; path = examples/thybrdc.c; sourceTree = "<group>"; };
+		7F8F639C1148F51A0013EA0C /* thybrj1c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thybrj1c.c; path = examples/thybrj1c.c; sourceTree = "<group>"; };
+		7F8F639E1148F51A0013EA0C /* thybrjc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thybrjc.c; path = examples/thybrjc.c; sourceTree = "<group>"; };
+		7F8F63A01148F51A0013EA0C /* tlmder1c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tlmder1c.c; path = examples/tlmder1c.c; sourceTree = "<group>"; };
+		7F8F63A21148F51A0013EA0C /* tlmderc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tlmderc.c; path = examples/tlmderc.c; sourceTree = "<group>"; };
+		7F8F63A41148F51A0013EA0C /* tlmdif1c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tlmdif1c.c; path = examples/tlmdif1c.c; sourceTree = "<group>"; };
+		7F8F63A61148F51A0013EA0C /* tlmdifc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tlmdifc.c; path = examples/tlmdifc.c; sourceTree = "<group>"; };
+		7F8F63A81148F51A0013EA0C /* tlmstr1c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tlmstr1c.c; path = examples/tlmstr1c.c; sourceTree = "<group>"; };
+		7F8F63AA1148F51A0013EA0C /* tlmstrc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tlmstrc.c; path = examples/tlmstrc.c; sourceTree = "<group>"; };
+		D2AAC046055464E500DB518D /* libcminpack.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcminpack.a; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		1E548DC40F83DF460015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548DCD0F83DF710015F022 /* libcminpack.a in Frameworks */,
+				1E47DDDF181A746500CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E090F83E1C10015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E0A0F83E1C10015F022 /* libcminpack.a in Frameworks */,
+				1E47DDE0181A746500CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E1B0F83E2050015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E1C0F83E2050015F022 /* libcminpack.a in Frameworks */,
+				1E47DDDB181A746200CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E500F83E2DF0015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E510F83E2DF0015F022 /* libcminpack.a in Frameworks */,
+				1E47DDDC181A746200CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E640F83E2F90015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E650F83E2F90015F022 /* libcminpack.a in Frameworks */,
+				1E47DDDD181A746300CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E770F83E3130015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E780F83E3130015F022 /* libcminpack.a in Frameworks */,
+				1E47DDCB181A73B000CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E890F83E32D0015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E8A0F83E32D0015F022 /* libcminpack.a in Frameworks */,
+				1E47DDD9181A745900CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E9A0F83E3440015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548E9B0F83E3440015F022 /* libcminpack.a in Frameworks */,
+				1E47DDDA181A746100CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548EB90F83E3810015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548EBA0F83E3810015F022 /* libcminpack.a in Frameworks */,
+				1E47DDE1181A746600CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548EC90F83E38C0015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548ECA0F83E38C0015F022 /* libcminpack.a in Frameworks */,
+				1E47DDD1181A73B400CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548ED80F83E3A10015F022 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E548ED90F83E3A10015F022 /* libcminpack.a in Frameworks */,
+				1E47DDDE181A746400CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C252158779BA00F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2E615877C2100F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD2181A73B900CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C26215877A8B00F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2E715877C2200F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD3181A73BA00CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C27015877A9500F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2E815877C2400F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD4181A73BA00CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C27E15877AA100F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2E915877C2400F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD5181A73BB00CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C28C15877AAF00F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2EA15877C2500F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD6181A73BC00CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C29A15877ABA00F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2EB15877C2500F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD7181A73BD00CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C2A815877AC900F5CFF7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2EC15877C2500F5CFF7 /* libcminpack.a in Frameworks */,
+				1E47DDD8181A73BD00CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		D289987405E68DCB004EDB86 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1E47DDC6181A6A8000CBDA54 /* Accelerate.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		08FB7794FE84155DC02AAC07 /* libfnt */ = {
+			isa = PBXGroup;
+			children = (
+				1EA5C24F158778BF00F5CFF7 /* Frameworks */,
+				1EE5E399145DA9D700F4FFF4 /* Makefiles */,
+				1EE5E371145DA91200F4FFF4 /* Data */,
+				08FB7795FE84155DC02AAC07 /* Source */,
+				C6A0FF2B0290797F04C91782 /* Documentation */,
+				1AB674ADFE9D54B511CA2CBB /* Products */,
+			);
+			name = libfnt;
+			sourceTree = "<group>";
+		};
+		08FB7795FE84155DC02AAC07 /* Source */ = {
+			isa = PBXGroup;
+			children = (
+				35C3D6BD0DB79E4800A4BB4B /* chkder.c */,
+				35C3D6BE0DB79E4800A4BB4B /* covar.c */,
+				1E20CA5114486BB40084559B /* covar1.c */,
+				35C3D6BF0DB79E4800A4BB4B /* dogleg.c */,
+				35C3D6C00DB79E4800A4BB4B /* dpmpar.c */,
+				35C3D6C10DB79E4800A4BB4B /* enorm.c */,
+				35C3D6C20DB79E4800A4BB4B /* fdjac1.c */,
+				35C3D6C30DB79E4800A4BB4B /* fdjac2.c */,
+				35C3D6C40DB79E4800A4BB4B /* hybrd.c */,
+				35C3D6C50DB79E4800A4BB4B /* hybrd1.c */,
+				35C3D6C60DB79E4800A4BB4B /* hybrj.c */,
+				35C3D6C70DB79E4800A4BB4B /* hybrj1.c */,
+				35C3D6C80DB79E4800A4BB4B /* lmder.c */,
+				35C3D6C90DB79E4800A4BB4B /* lmder1.c */,
+				35C3D6BC0DB79E4800A4BB4B /* lmdif.c */,
+				35C3D6CA0DB79E4800A4BB4B /* lmdif1.c */,
+				35C3D6CB0DB79E4800A4BB4B /* lmpar.c */,
+				35C3D6CC0DB79E4800A4BB4B /* lmstr.c */,
+				35C3D6CD0DB79E4800A4BB4B /* lmstr1.c */,
+				35C3D6CE0DB79E4800A4BB4B /* qform.c */,
+				35C3D6CF0DB79E4800A4BB4B /* qrfac.c */,
+				35C3D6D00DB79E4800A4BB4B /* qrsolv.c */,
+				35C3D6D10DB79E4800A4BB4B /* r1mpyq.c */,
+				35C3D6D20DB79E4800A4BB4B /* r1updt.c */,
+				35C3D6D30DB79E4800A4BB4B /* rwupdt.c */,
+				35C3D7020DB79E5600A4BB4B /* cminpack.h */,
+				1E8894CE158261E000FD154D /* cminpackP.h */,
+				35C3D7030DB79E5600A4BB4B /* minpack.h */,
+				1E548DD10F83DFAA0015F022 /* examples */,
+				1EE5E3A3145DAAAF00F4FFF4 /* Fortran API */,
+			);
+			name = Source;
+			sourceTree = "<group>";
+		};
+		1AB674ADFE9D54B511CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				D2AAC046055464E500DB518D /* libcminpack.a */,
+				1E548DC60F83DF460015F022 /* tlmdif */,
+				1E548E0E0F83E1C10015F022 /* tlmdif1 */,
+				1E548E200F83E2050015F022 /* tchkder */,
+				1E548E550F83E2DF0015F022 /* thybrd */,
+				1E548E690F83E2F90015F022 /* thybrd1 */,
+				1E548E7C0F83E3130015F022 /* thybrj */,
+				1E548E8E0F83E32D0015F022 /* thybrj1 */,
+				1E548E9F0F83E3440015F022 /* tlmder */,
+				1E548EBE0F83E3810015F022 /* tlmstr */,
+				1E548ECE0F83E38C0015F022 /* tlmstr1 */,
+				1E548EDD0F83E3A10015F022 /* tlmder1 */,
+				1EA5C255158779BA00F5CFF7 /* ibmdpdrc */,
+				1EA5C26515877A8B00F5CFF7 /* lmddrvc */,
+				1EA5C27315877A9500F5CFF7 /* lmfdrvc */,
+				1EA5C28115877AA100F5CFF7 /* lmsdrvc */,
+				1EA5C28F15877AAF00F5CFF7 /* hyjdrvc */,
+				1EA5C29D15877ABA00F5CFF7 /* hybdrvc */,
+				1EA5C2AB15877AC900F5CFF7 /* chkdrvc */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		1E548DD10F83DFAA0015F022 /* examples */ = {
+			isa = PBXGroup;
+			children = (
+				1EA5C2B515877B0100F5CFF7 /* chkdrv.c */,
+				1EE5E369145DA8F100F4FFF4 /* cmpfiles.c */,
+				1EA5C2B615877B0100F5CFF7 /* errjac.c */,
+				1EE5E36A145DA8F100F4FFF4 /* genf77tests.c */,
+				1EA5C2B715877B0100F5CFF7 /* hybdrv.c */,
+				1EA5C2B815877B0100F5CFF7 /* hybipt.c */,
+				1EA5C2B915877B0100F5CFF7 /* hyjdrv.c */,
+				1EA5C25F15877A0900F5CFF7 /* ibmdpdr.c */,
+				1EE5E36B145DA8F100F4FFF4 /* lmddrv.c */,
+				1EE5E36C145DA8F100F4FFF4 /* lmdipt.c */,
+				1EE5E36D145DA8F100F4FFF4 /* lmfdrv.c */,
+				1EA5C2BA15877B0100F5CFF7 /* lmfdrv_.c */,
+				1EA5C2BB15877B0100F5CFF7 /* lmsdrv.c */,
+				1EA5C2ED15877C2F00F5CFF7 /* machar.c */,
+				1EE5E36E145DA8F100F4FFF4 /* ssq.h */,
+				1EE5E36F145DA8F100F4FFF4 /* ssqfcn.c */,
+				1EE5E370145DA8F100F4FFF4 /* ssqjac.c */,
+				7F8F63941148F51A0013EA0C /* tchkderc.c */,
+				7F8F63961148F51A0013EA0C /* tfdjac2c.c */,
+				7F8F63981148F51A0013EA0C /* thybrd1c.c */,
+				7F8F639A1148F51A0013EA0C /* thybrdc.c */,
+				7F8F639C1148F51A0013EA0C /* thybrj1c.c */,
+				7F8F639E1148F51A0013EA0C /* thybrjc.c */,
+				7F8F63A01148F51A0013EA0C /* tlmder1c.c */,
+				7F8F63A21148F51A0013EA0C /* tlmderc.c */,
+				7F8F63A41148F51A0013EA0C /* tlmdif1c.c */,
+				7F8F63A61148F51A0013EA0C /* tlmdifc.c */,
+				7F8F63A81148F51A0013EA0C /* tlmstr1c.c */,
+				7F8F63AA1148F51A0013EA0C /* tlmstrc.c */,
+				1EA5C2BC15877B0100F5CFF7 /* vecfcn.c */,
+				1EA5C2BD15877B0100F5CFF7 /* vecjac.c */,
+			);
+			name = examples;
+			sourceTree = "<group>";
+		};
+		1EA5C24F158778BF00F5CFF7 /* Frameworks */ = {
+			isa = PBXGroup;
+			children = (
+				1E47DDC5181A6A8000CBDA54 /* Accelerate.framework */,
+			);
+			name = Frameworks;
+			sourceTree = "<group>";
+		};
+		1EE5E371145DA91200F4FFF4 /* Data */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E392145DA97800F4FFF4 /* testdata */,
+				1EE5E372145DA94500F4FFF4 /* ref */,
+			);
+			name = Data;
+			path = examples;
+			sourceTree = "<group>";
+		};
+		1EE5E372145DA94500F4FFF4 /* ref */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E373145DA96C00F4FFF4 /* chkdrv.ref */,
+				1EE5E374145DA96C00F4FFF4 /* hybdrv.ref */,
+				1EE5E375145DA96C00F4FFF4 /* hyjdrv.ref */,
+				1EE5E376145DA96C00F4FFF4 /* lmddrv.ref */,
+				1EE5E377145DA96C00F4FFF4 /* lmddrvc.ref */,
+				1EE5E378145DA96C00F4FFF4 /* lmfdrv.ref */,
+				1EE5E379145DA96C00F4FFF4 /* lmfdrvc.ref */,
+				1EE5E37A145DA96C00F4FFF4 /* lmsdrv.ref */,
+				1EE5E37B145DA96C00F4FFF4 /* tchkder.ref */,
+				1EE5E37C145DA96C00F4FFF4 /* tchkderc.ref */,
+				1EE5E37D145DA96C00F4FFF4 /* tfdjac2c.ref */,
+				1EE5E37E145DA96C00F4FFF4 /* thybrd.ref */,
+				1EE5E37F145DA96C00F4FFF4 /* thybrd1.ref */,
+				1EE5E380145DA96C00F4FFF4 /* thybrd1c.ref */,
+				1EE5E381145DA96C00F4FFF4 /* thybrdc.ref */,
+				1EE5E382145DA96C00F4FFF4 /* thybrj.ref */,
+				1EE5E383145DA96C00F4FFF4 /* thybrj1.ref */,
+				1EE5E384145DA96C00F4FFF4 /* thybrj1c.ref */,
+				1EE5E385145DA96C00F4FFF4 /* thybrjc.ref */,
+				1EE5E386145DA96C00F4FFF4 /* tlmder.ref */,
+				1EE5E387145DA96C00F4FFF4 /* tlmder1.ref */,
+				1EE5E388145DA96C00F4FFF4 /* tlmder1c.ref */,
+				1EE5E389145DA96C00F4FFF4 /* tlmderc.ref */,
+				1EE5E38A145DA96C00F4FFF4 /* tlmdif.ref */,
+				1EE5E38B145DA96C00F4FFF4 /* tlmdif1.ref */,
+				1EE5E38C145DA96C00F4FFF4 /* tlmdif1c.ref */,
+				1EE5E38D145DA96C00F4FFF4 /* tlmdifc.ref */,
+				1EE5E38E145DA96C00F4FFF4 /* tlmstr.ref */,
+				1EE5E38F145DA96C00F4FFF4 /* tlmstr1.ref */,
+				1EE5E390145DA96C00F4FFF4 /* tlmstr1c.ref */,
+				1EE5E391145DA96C00F4FFF4 /* tlmstrc.ref */,
+			);
+			path = ref;
+			sourceTree = "<group>";
+		};
+		1EE5E392145DA97800F4FFF4 /* testdata */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E396145DA9AC00F4FFF4 /* chkder.data */,
+				1EE5E397145DA9AC00F4FFF4 /* hybrd.data */,
+				1EE5E398145DA9AC00F4FFF4 /* lm.data */,
+			);
+			path = testdata;
+			sourceTree = "<group>";
+		};
+		1EE5E399145DA9D700F4FFF4 /* Makefiles */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E3BC145DAB4C00F4FFF4 /* cminpack_dll.vcproj */,
+				1EE5E3BD145DAB4C00F4FFF4 /* cminpack.sln */,
+				1EE5E3BE145DAB4C00F4FFF4 /* cminpack.vcproj */,
+				1EE5E3BF145DAB4C00F4FFF4 /* dist-exclude */,
+				1EE5E39C145DAA2900F4FFF4 /* examples */,
+				1EE5E39A145DAA2400F4FFF4 /* CMakeLists.txt */,
+				1EE5E39B145DAA2400F4FFF4 /* Makefile */,
+			);
+			name = Makefiles;
+			sourceTree = "<group>";
+		};
+		1EE5E39C145DAA2900F4FFF4 /* examples */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E39D145DAA5300F4FFF4 /* CMakeLists.txt */,
+				1EE5E39E145DAA5300F4FFF4 /* Makefile */,
+				1EE5E39F145DAA5300F4FFF4 /* runtest.cmake */,
+			);
+			path = examples;
+			sourceTree = "<group>";
+		};
+		1EE5E3A3145DAAAF00F4FFF4 /* Fortran API */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E3A4145DAB0A00F4FFF4 /* chkder_.c */,
+				1EE5E3A5145DAB0A00F4FFF4 /* covar_.c */,
+				1EE5E3A6145DAB0A00F4FFF4 /* dogleg_.c */,
+				1EE5E3A7145DAB0A00F4FFF4 /* dpmpar_.c */,
+				1EE5E3A8145DAB0A00F4FFF4 /* enorm_.c */,
+				1EE5E3A9145DAB0A00F4FFF4 /* fdjac1_.c */,
+				1EE5E3AA145DAB0A00F4FFF4 /* fdjac2_.c */,
+				1EE5E3AB145DAB0A00F4FFF4 /* hybrd_.c */,
+				1EE5E3AC145DAB0A00F4FFF4 /* hybrd1_.c */,
+				1EE5E3AD145DAB0A00F4FFF4 /* hybrj_.c */,
+				1EE5E3AE145DAB0A00F4FFF4 /* hybrj1_.c */,
+				1EE5E3AF145DAB0A00F4FFF4 /* lmder_.c */,
+				1EE5E3B0145DAB0A00F4FFF4 /* lmder1_.c */,
+				1EE5E3B1145DAB0A00F4FFF4 /* lmdif_.c */,
+				1EE5E3B2145DAB0A00F4FFF4 /* lmdif1_.c */,
+				1EE5E3B3145DAB0A00F4FFF4 /* lmpar_.c */,
+				1EE5E3B4145DAB0A00F4FFF4 /* lmstr_.c */,
+				1EE5E3B5145DAB0A00F4FFF4 /* lmstr1_.c */,
+				1EE5E3B6145DAB0A00F4FFF4 /* qform_.c */,
+				1EE5E3B7145DAB0A00F4FFF4 /* qrfac_.c */,
+				1EE5E3B8145DAB0A00F4FFF4 /* qrsolv_.c */,
+				1EE5E3B9145DAB0A00F4FFF4 /* r1mpyq_.c */,
+				1EE5E3BA145DAB0A00F4FFF4 /* r1updt_.c */,
+				1EE5E3BB145DAB0A00F4FFF4 /* rwupdt_.c */,
+			);
+			name = "Fortran API";
+			sourceTree = "<group>";
+		};
+		C6A0FF2B0290797F04C91782 /* Documentation */ = {
+			isa = PBXGroup;
+			children = (
+				1EE5E35E145DA88300F4FFF4 /* cminpack.html */,
+				1EE5E3A0145DAA8C00F4FFF4 /* CopyrightMINPACK.txt */,
+				1EE5E360145DA88300F4FFF4 /* hybrd1_.3 */,
+				1EE5E35F145DA88300F4FFF4 /* hybrd_.3 */,
+				1E548DDC0F83E0960015F022 /* hybrd_.html */,
+				1EE5E362145DA88300F4FFF4 /* hybrj1_.3 */,
+				1EE5E361145DA88300F4FFF4 /* hybrj_.3 */,
+				1E548DDD0F83E0960015F022 /* hybrj_.html */,
+				1E548DDE0F83E0960015F022 /* index.html */,
+				1EE5E364145DA88300F4FFF4 /* lmder1_.3 */,
+				1EE5E363145DA88300F4FFF4 /* lmder_.3 */,
+				1E548DDF0F83E0960015F022 /* lmder_.html */,
+				1EE5E366145DA88300F4FFF4 /* lmdif1_.3 */,
+				1EE5E365145DA88300F4FFF4 /* lmdif_.3 */,
+				1E548DE00F83E0960015F022 /* lmdif_.html */,
+				1EE5E368145DA88300F4FFF4 /* lmstr1_.3 */,
+				1EE5E367145DA88300F4FFF4 /* lmstr_.3 */,
+				1E548DE10F83E0960015F022 /* lmstr_.html */,
+				1E548DE20F83E0960015F022 /* minpack-documentation.txt */,
+				1EE5E3A1145DAA8C00F4FFF4 /* readme.txt */,
+				1EE5E3A2145DAA8C00F4FFF4 /* README.md */,
+			);
+			name = Documentation;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		1E548DC50F83DF460015F022 /* tlmdifc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548DCE0F83DF8F0015F022 /* Build configuration list for PBXNativeTarget "tlmdifc" */;
+			buildPhases = (
+				1E548DC30F83DF460015F022 /* Sources */,
+				1E548DC40F83DF460015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F1F0F83E4880015F022 /* PBXTargetDependency */,
+			);
+			name = tlmdifc;
+			productName = tlmdif;
+			productReference = 1E548DC60F83DF460015F022 /* tlmdif */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E060F83E1C10015F022 /* tlmdif1c */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E0B0F83E1C10015F022 /* Build configuration list for PBXNativeTarget "tlmdif1c" */;
+			buildPhases = (
+				1E548E070F83E1C10015F022 /* Sources */,
+				1E548E090F83E1C10015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F210F83E48B0015F022 /* PBXTargetDependency */,
+			);
+			name = tlmdif1c;
+			productName = tlmdif;
+			productReference = 1E548E0E0F83E1C10015F022 /* tlmdif1 */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E180F83E2050015F022 /* tchkderc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E1D0F83E2050015F022 /* Build configuration list for PBXNativeTarget "tchkderc" */;
+			buildPhases = (
+				1E548E190F83E2050015F022 /* Sources */,
+				1E548E1B0F83E2050015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F110F83E4590015F022 /* PBXTargetDependency */,
+			);
+			name = tchkderc;
+			productName = tlmdif;
+			productReference = 1E548E200F83E2050015F022 /* tchkder */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E450F83E2DF0015F022 /* thybrdc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E520F83E2DF0015F022 /* Build configuration list for PBXNativeTarget "thybrdc" */;
+			buildPhases = (
+				1E548E460F83E2DF0015F022 /* Sources */,
+				1E548E500F83E2DF0015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F130F83E4620015F022 /* PBXTargetDependency */,
+			);
+			name = thybrdc;
+			productName = tlmdif;
+			productReference = 1E548E550F83E2DF0015F022 /* thybrd */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E5A0F83E2F90015F022 /* thybrd1c */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E660F83E2F90015F022 /* Build configuration list for PBXNativeTarget "thybrd1c" */;
+			buildPhases = (
+				1E548E5B0F83E2F90015F022 /* Sources */,
+				1E548E640F83E2F90015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F150F83E4710015F022 /* PBXTargetDependency */,
+			);
+			name = thybrd1c;
+			productName = tlmdif;
+			productReference = 1E548E690F83E2F90015F022 /* thybrd1 */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E6E0F83E3130015F022 /* thybrjc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E790F83E3130015F022 /* Build configuration list for PBXNativeTarget "thybrjc" */;
+			buildPhases = (
+				1E548E6F0F83E3130015F022 /* Sources */,
+				1E548E770F83E3130015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F170F83E4740015F022 /* PBXTargetDependency */,
+			);
+			name = thybrjc;
+			productName = tlmdif;
+			productReference = 1E548E7C0F83E3130015F022 /* thybrj */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E810F83E32D0015F022 /* thybrj1c */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E8B0F83E32D0015F022 /* Build configuration list for PBXNativeTarget "thybrj1c" */;
+			buildPhases = (
+				1E548E820F83E32D0015F022 /* Sources */,
+				1E548E890F83E32D0015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F190F83E4770015F022 /* PBXTargetDependency */,
+			);
+			name = thybrj1c;
+			productName = tlmdif;
+			productReference = 1E548E8E0F83E32D0015F022 /* thybrj1 */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548E930F83E3440015F022 /* tlmderc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548E9C0F83E3440015F022 /* Build configuration list for PBXNativeTarget "tlmderc" */;
+			buildPhases = (
+				1E548E940F83E3440015F022 /* Sources */,
+				1E548E9A0F83E3440015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F1B0F83E47E0015F022 /* PBXTargetDependency */,
+			);
+			name = tlmderc;
+			productName = tlmdif;
+			productReference = 1E548E9F0F83E3440015F022 /* tlmder */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548EB30F83E3810015F022 /* tlmstrc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548EBB0F83E3810015F022 /* Build configuration list for PBXNativeTarget "tlmstrc" */;
+			buildPhases = (
+				1E548EB40F83E3810015F022 /* Sources */,
+				1E548EB90F83E3810015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F230F83E4920015F022 /* PBXTargetDependency */,
+			);
+			name = tlmstrc;
+			productName = tlmdif;
+			productReference = 1E548EBE0F83E3810015F022 /* tlmstr */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548EC30F83E38C0015F022 /* tlmstr1c */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548ECB0F83E38C0015F022 /* Build configuration list for PBXNativeTarget "tlmstr1c" */;
+			buildPhases = (
+				1E548EC40F83E38C0015F022 /* Sources */,
+				1E548EC90F83E38C0015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F250F83E4950015F022 /* PBXTargetDependency */,
+			);
+			name = tlmstr1c;
+			productName = tlmdif;
+			productReference = 1E548ECE0F83E38C0015F022 /* tlmstr1 */;
+			productType = "com.apple.product-type.tool";
+		};
+		1E548ED30F83E3A10015F022 /* tlmder1c */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1E548EDA0F83E3A10015F022 /* Build configuration list for PBXNativeTarget "tlmder1c" */;
+			buildPhases = (
+				1E548ED40F83E3A10015F022 /* Sources */,
+				1E548ED80F83E3A10015F022 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1E548F1D0F83E4820015F022 /* PBXTargetDependency */,
+			);
+			name = tlmder1c;
+			productName = tlmdif;
+			productReference = 1E548EDD0F83E3A10015F022 /* tlmder1 */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C254158779BA00F5CFF7 /* ibmdpdrc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C25C158779BA00F5CFF7 /* Build configuration list for PBXNativeTarget "ibmdpdrc" */;
+			buildPhases = (
+				1EA5C251158779BA00F5CFF7 /* Sources */,
+				1EA5C252158779BA00F5CFF7 /* Frameworks */,
+				1EA5C253158779BA00F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				1EA5C2DE15877C0400F5CFF7 /* PBXTargetDependency */,
+			);
+			name = ibmdpdrc;
+			productName = ibmdpdr;
+			productReference = 1EA5C255158779BA00F5CFF7 /* ibmdpdrc */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C26415877A8B00F5CFF7 /* lmddrvc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C26C15877A8B00F5CFF7 /* Build configuration list for PBXNativeTarget "lmddrvc" */;
+			buildPhases = (
+				1EA5C26115877A8B00F5CFF7 /* Sources */,
+				1EA5C26215877A8B00F5CFF7 /* Frameworks */,
+				1EA5C26315877A8B00F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = lmddrvc;
+			productName = lmddrvc;
+			productReference = 1EA5C26515877A8B00F5CFF7 /* lmddrvc */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C27215877A9500F5CFF7 /* lmfdrvc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C27A15877A9500F5CFF7 /* Build configuration list for PBXNativeTarget "lmfdrvc" */;
+			buildPhases = (
+				1EA5C26F15877A9500F5CFF7 /* Sources */,
+				1EA5C27015877A9500F5CFF7 /* Frameworks */,
+				1EA5C27115877A9500F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = lmfdrvc;
+			productName = lmfdrvc;
+			productReference = 1EA5C27315877A9500F5CFF7 /* lmfdrvc */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C28015877AA100F5CFF7 /* lmsdrvc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C28815877AA100F5CFF7 /* Build configuration list for PBXNativeTarget "lmsdrvc" */;
+			buildPhases = (
+				1EA5C27D15877AA100F5CFF7 /* Sources */,
+				1EA5C27E15877AA100F5CFF7 /* Frameworks */,
+				1EA5C27F15877AA100F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = lmsdrvc;
+			productName = lmsdrvc;
+			productReference = 1EA5C28115877AA100F5CFF7 /* lmsdrvc */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C28E15877AAF00F5CFF7 /* hyjdrvc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C29615877AAF00F5CFF7 /* Build configuration list for PBXNativeTarget "hyjdrvc" */;
+			buildPhases = (
+				1EA5C28B15877AAF00F5CFF7 /* Sources */,
+				1EA5C28C15877AAF00F5CFF7 /* Frameworks */,
+				1EA5C28D15877AAF00F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = hyjdrvc;
+			productName = hyjdrvc;
+			productReference = 1EA5C28F15877AAF00F5CFF7 /* hyjdrvc */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C29C15877ABA00F5CFF7 /* hybdrvc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C2A415877ABA00F5CFF7 /* Build configuration list for PBXNativeTarget "hybdrvc" */;
+			buildPhases = (
+				1EA5C29915877ABA00F5CFF7 /* Sources */,
+				1EA5C29A15877ABA00F5CFF7 /* Frameworks */,
+				1EA5C29B15877ABA00F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = hybdrvc;
+			productName = hybdrvc;
+			productReference = 1EA5C29D15877ABA00F5CFF7 /* hybdrvc */;
+			productType = "com.apple.product-type.tool";
+		};
+		1EA5C2AA15877AC900F5CFF7 /* chkdrvc */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1EA5C2B215877AC900F5CFF7 /* Build configuration list for PBXNativeTarget "chkdrvc" */;
+			buildPhases = (
+				1EA5C2A715877AC900F5CFF7 /* Sources */,
+				1EA5C2A815877AC900F5CFF7 /* Frameworks */,
+				1EA5C2A915877AC900F5CFF7 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = chkdrvc;
+			productName = chkdrvc;
+			productReference = 1EA5C2AB15877AC900F5CFF7 /* chkdrvc */;
+			productType = "com.apple.product-type.tool";
+		};
+		D2AAC045055464E500DB518D /* cminpack */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "cminpack" */;
+			buildPhases = (
+				D2AAC044055464E500DB518D /* Sources */,
+				D289987405E68DCB004EDB86 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = cminpack;
+			productName = libfnt;
+			productReference = D2AAC046055464E500DB518D /* libcminpack.a */;
+			productType = "com.apple.product-type.library.static";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		08FB7793FE84155DC02AAC07 /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0420;
+			};
+			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "cminpack" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 1;
+			knownRegions = (
+				English,
+				Japanese,
+				French,
+				German,
+			);
+			mainGroup = 08FB7794FE84155DC02AAC07 /* libfnt */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				1E548EEC0F83E3F10015F022 /* all */,
+				D2AAC045055464E500DB518D /* cminpack */,
+				1E548E180F83E2050015F022 /* tchkderc */,
+				1E548E450F83E2DF0015F022 /* thybrdc */,
+				1E548E5A0F83E2F90015F022 /* thybrd1c */,
+				1E548E6E0F83E3130015F022 /* thybrjc */,
+				1E548E810F83E32D0015F022 /* thybrj1c */,
+				1E548E930F83E3440015F022 /* tlmderc */,
+				1E548ED30F83E3A10015F022 /* tlmder1c */,
+				1E548DC50F83DF460015F022 /* tlmdifc */,
+				1E548E060F83E1C10015F022 /* tlmdif1c */,
+				1E548EB30F83E3810015F022 /* tlmstrc */,
+				1E548EC30F83E38C0015F022 /* tlmstr1c */,
+				1EA5C254158779BA00F5CFF7 /* ibmdpdrc */,
+				1EA5C26415877A8B00F5CFF7 /* lmddrvc */,
+				1EA5C27215877A9500F5CFF7 /* lmfdrvc */,
+				1EA5C28015877AA100F5CFF7 /* lmsdrvc */,
+				1EA5C28E15877AAF00F5CFF7 /* hyjdrvc */,
+				1EA5C29C15877ABA00F5CFF7 /* hybdrvc */,
+				1EA5C2AA15877AC900F5CFF7 /* chkdrvc */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+		1E548DC30F83DF460015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C515877B5E00F5CFF7 /* tlmdifc.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E070F83E1C10015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C615877B6100F5CFF7 /* tlmdif1c.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E190F83E2050015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2BE15877B2B00F5CFF7 /* tchkderc.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E460F83E2DF0015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2BF15877B3700F5CFF7 /* thybrdc.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E5B0F83E2F90015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C015877B4600F5CFF7 /* thybrd1c.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E6F0F83E3130015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C115877B4C00F5CFF7 /* thybrjc.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E820F83E32D0015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C215877B5000F5CFF7 /* thybrj1c.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548E940F83E3440015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C315877B5500F5CFF7 /* tlmderc.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548EB40F83E3810015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C715877B6500F5CFF7 /* tlmstrc.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548EC40F83E38C0015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C815877B6900F5CFF7 /* tlmstr1c.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1E548ED40F83E3A10015F022 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2C415877B5800F5CFF7 /* tlmder1c.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C251158779BA00F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C26015877A0900F5CFF7 /* ibmdpdr.c in Sources */,
+				1EA5C2EE15877C2F00F5CFF7 /* machar.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C26115877A8B00F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2EF15877C6800F5CFF7 /* lmdipt.c in Sources */,
+				1EA5C2F015877C6800F5CFF7 /* ssqfcn.c in Sources */,
+				1EA5C2F115877C6800F5CFF7 /* ssqjac.c in Sources */,
+				1EA5C2C915877B8B00F5CFF7 /* lmddrv.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C26F15877A9500F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2F515877C8D00F5CFF7 /* lmdipt.c in Sources */,
+				1EA5C2F615877C8D00F5CFF7 /* ssqfcn.c in Sources */,
+				1EA5C2CA15877B8E00F5CFF7 /* lmfdrv.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C27D15877AA100F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2F215877C7B00F5CFF7 /* lmdipt.c in Sources */,
+				1EA5C2F315877C7B00F5CFF7 /* ssqfcn.c in Sources */,
+				1EA5C2F415877C7B00F5CFF7 /* ssqjac.c in Sources */,
+				1EA5C2CB15877B9200F5CFF7 /* lmsdrv.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C28B15877AAF00F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2F715877CA400F5CFF7 /* hybipt.c in Sources */,
+				1EA5C2F815877CA400F5CFF7 /* vecfcn.c in Sources */,
+				1EA5C2F915877CA400F5CFF7 /* vecjac.c in Sources */,
+				1EA5C2CC15877B9700F5CFF7 /* hyjdrv.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C29915877ABA00F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2FE15877CF600F5CFF7 /* vecfcn.c in Sources */,
+				1EA5C2FA15877CC800F5CFF7 /* hybdrv.c in Sources */,
+				1EA5C2CD15877B9A00F5CFF7 /* hybipt.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		1EA5C2A715877AC900F5CFF7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				1EA5C2FB15877CE500F5CFF7 /* errjac.c in Sources */,
+				1EA5C2FC15877CE500F5CFF7 /* hybipt.c in Sources */,
+				1EA5C2FD15877CE500F5CFF7 /* vecfcn.c in Sources */,
+				1EA5C2CE15877B9F00F5CFF7 /* chkdrv.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		D2AAC044055464E500DB518D /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				35C3D6DF0DB79E4800A4BB4B /* lmdif.c in Sources */,
+				35C3D6E00DB79E4800A4BB4B /* chkder.c in Sources */,
+				35C3D6E10DB79E4800A4BB4B /* covar.c in Sources */,
+				35C3D6E20DB79E4800A4BB4B /* dogleg.c in Sources */,
+				35C3D6E30DB79E4800A4BB4B /* dpmpar.c in Sources */,
+				35C3D6E40DB79E4800A4BB4B /* enorm.c in Sources */,
+				35C3D6E50DB79E4800A4BB4B /* fdjac1.c in Sources */,
+				35C3D6E60DB79E4800A4BB4B /* fdjac2.c in Sources */,
+				35C3D6E70DB79E4800A4BB4B /* hybrd.c in Sources */,
+				35C3D6E80DB79E4800A4BB4B /* hybrd1.c in Sources */,
+				35C3D6E90DB79E4800A4BB4B /* hybrj.c in Sources */,
+				35C3D6EA0DB79E4800A4BB4B /* hybrj1.c in Sources */,
+				35C3D6EB0DB79E4800A4BB4B /* lmder.c in Sources */,
+				35C3D6EC0DB79E4800A4BB4B /* lmder1.c in Sources */,
+				35C3D6ED0DB79E4800A4BB4B /* lmdif1.c in Sources */,
+				35C3D6EE0DB79E4800A4BB4B /* lmpar.c in Sources */,
+				35C3D6EF0DB79E4800A4BB4B /* lmstr.c in Sources */,
+				35C3D6F00DB79E4800A4BB4B /* lmstr1.c in Sources */,
+				35C3D6F10DB79E4800A4BB4B /* qform.c in Sources */,
+				35C3D6F20DB79E4800A4BB4B /* qrfac.c in Sources */,
+				35C3D6F30DB79E4800A4BB4B /* qrsolv.c in Sources */,
+				35C3D6F40DB79E4800A4BB4B /* r1mpyq.c in Sources */,
+				35C3D6F50DB79E4800A4BB4B /* r1updt.c in Sources */,
+				35C3D6F60DB79E4800A4BB4B /* rwupdt.c in Sources */,
+				1E20CA5214486BB40084559B /* covar1.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+		1E548EF10F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548EF00F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EF30F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548DC50F83DF460015F022 /* tlmdifc */;
+			targetProxy = 1E548EF20F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EF50F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E060F83E1C10015F022 /* tlmdif1c */;
+			targetProxy = 1E548EF40F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EF70F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E180F83E2050015F022 /* tchkderc */;
+			targetProxy = 1E548EF60F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EF90F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E450F83E2DF0015F022 /* thybrdc */;
+			targetProxy = 1E548EF80F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EFB0F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E5A0F83E2F90015F022 /* thybrd1c */;
+			targetProxy = 1E548EFA0F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EFD0F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E6E0F83E3130015F022 /* thybrjc */;
+			targetProxy = 1E548EFC0F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548EFF0F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E810F83E32D0015F022 /* thybrj1c */;
+			targetProxy = 1E548EFE0F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F010F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548E930F83E3440015F022 /* tlmderc */;
+			targetProxy = 1E548F000F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F030F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548EB30F83E3810015F022 /* tlmstrc */;
+			targetProxy = 1E548F020F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F050F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548EC30F83E38C0015F022 /* tlmstr1c */;
+			targetProxy = 1E548F040F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F070F83E3F90015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1E548ED30F83E3A10015F022 /* tlmder1c */;
+			targetProxy = 1E548F060F83E3F90015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F110F83E4590015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F100F83E4590015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F130F83E4620015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F120F83E4620015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F150F83E4710015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F140F83E4710015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F170F83E4740015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F160F83E4740015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F190F83E4770015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F180F83E4770015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F1B0F83E47E0015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F1A0F83E47E0015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F1D0F83E4820015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F1C0F83E4820015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F1F0F83E4880015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F1E0F83E4880015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F210F83E48B0015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F200F83E48B0015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F230F83E4920015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F220F83E4920015F022 /* PBXContainerItemProxy */;
+		};
+		1E548F250F83E4950015F022 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1E548F240F83E4950015F022 /* PBXContainerItemProxy */;
+		};
+		1EA5C2D015877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C254158779BA00F5CFF7 /* ibmdpdrc */;
+			targetProxy = 1EA5C2CF15877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2D215877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C26415877A8B00F5CFF7 /* lmddrvc */;
+			targetProxy = 1EA5C2D115877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2D415877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C27215877A9500F5CFF7 /* lmfdrvc */;
+			targetProxy = 1EA5C2D315877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2D615877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C28015877AA100F5CFF7 /* lmsdrvc */;
+			targetProxy = 1EA5C2D515877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2D815877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C28E15877AAF00F5CFF7 /* hyjdrvc */;
+			targetProxy = 1EA5C2D715877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2DA15877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C29C15877ABA00F5CFF7 /* hybdrvc */;
+			targetProxy = 1EA5C2D915877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2DC15877BB000F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 1EA5C2AA15877AC900F5CFF7 /* chkdrvc */;
+			targetProxy = 1EA5C2DB15877BB000F5CFF7 /* PBXContainerItemProxy */;
+		};
+		1EA5C2DE15877C0400F5CFF7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = D2AAC045055464E500DB518D /* cminpack */;
+			targetProxy = 1EA5C2DD15877C0400F5CFF7 /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+		1DEB91EC08733DB70010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				HEADER_SEARCH_PATHS = (
+					"$(BOOST_PATH)",
+					../CImg,
+					../,
+				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../local/lib\"",
+				);
+				ONLY_ACTIVE_ARCH = NO;
+				PRODUCT_NAME = cminpack;
+			};
+			name = Debug;
+		};
+		1DEB91ED08733DB70010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				HEADER_SEARCH_PATHS = (
+					"$(BOOST_PATH)",
+					../CImg,
+					../,
+				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../local/lib\"",
+				);
+				PRODUCT_NAME = cminpack;
+			};
+			name = Release;
+		};
+		1DEB91F008733DB70010E9CD /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				GCC_ENABLE_SSE3_EXTENSIONS = YES;
+				GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = YES;
+				GCC_FAST_MATH = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					DEBUG,
+					USE_CBLAS,
+					USE_LAPACK,
+				);
+				ONLY_ACTIVE_ARCH = YES;
+				PRODUCT_NAME = cminpack;
+				WARNING_CFLAGS = "-Wall";
+			};
+			name = Debug;
+		};
+		1DEB91F108733DB70010E9CD /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				GCC_ENABLE_SSE3_EXTENSIONS = YES;
+				GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = YES;
+				GCC_FAST_MATH = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_OPTIMIZATION_LEVEL = 3;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					NDEBUG,
+					USE_CBLAS,
+					USE_LAPACK,
+				);
+				PRODUCT_NAME = cminpack;
+				WARNING_CFLAGS = "-Wall";
+			};
+			name = Release;
+		};
+		1E548DC80F83DF460015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmdif;
+			};
+			name = Debug;
+		};
+		1E548DC90F83DF460015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmdif;
+			};
+			name = Release;
+		};
+		1E548E0C0F83E1C10015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmdif1;
+			};
+			name = Debug;
+		};
+		1E548E0D0F83E1C10015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmdif1;
+			};
+			name = Release;
+		};
+		1E548E1E0F83E2050015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tchkder;
+			};
+			name = Debug;
+		};
+		1E548E1F0F83E2050015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tchkder;
+			};
+			name = Release;
+		};
+		1E548E530F83E2DF0015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrd;
+			};
+			name = Debug;
+		};
+		1E548E540F83E2DF0015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrd;
+			};
+			name = Release;
+		};
+		1E548E670F83E2F90015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrd1;
+			};
+			name = Debug;
+		};
+		1E548E680F83E2F90015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrd1;
+			};
+			name = Release;
+		};
+		1E548E7A0F83E3130015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrj;
+			};
+			name = Debug;
+		};
+		1E548E7B0F83E3130015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrj;
+			};
+			name = Release;
+		};
+		1E548E8C0F83E32D0015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrj1;
+			};
+			name = Debug;
+		};
+		1E548E8D0F83E32D0015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = thybrj1;
+			};
+			name = Release;
+		};
+		1E548E9D0F83E3440015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmder;
+			};
+			name = Debug;
+		};
+		1E548E9E0F83E3440015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmder;
+			};
+			name = Release;
+		};
+		1E548EBC0F83E3810015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmstr;
+			};
+			name = Debug;
+		};
+		1E548EBD0F83E3810015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmstr;
+			};
+			name = Release;
+		};
+		1E548ECC0F83E38C0015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmstr1;
+			};
+			name = Debug;
+		};
+		1E548ECD0F83E38C0015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmstr1;
+			};
+			name = Release;
+		};
+		1E548EDB0F83E3A10015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmder1;
+			};
+			name = Debug;
+		};
+		1E548EDC0F83E3A10015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = tlmder1;
+			};
+			name = Release;
+		};
+		1E548EED0F83E3F10015F022 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+			};
+			name = Debug;
+		};
+		1E548EEE0F83E3F10015F022 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+			};
+			name = Release;
+		};
+		1EA5C25D158779BA00F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		1EA5C25E158779BA00F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
+		1EA5C26D15877A8B00F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		1EA5C26E15877A8B00F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		1EA5C27B15877A9500F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		1EA5C27C15877A9500F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		1EA5C28915877AA100F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		1EA5C28A15877AA100F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		1EA5C29715877AAF00F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		1EA5C29815877AAF00F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		1EA5C2A515877ABA00F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		1EA5C2A615877ABA00F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		1EA5C2B315877AC900F5CFF7 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		1EA5C2B415877AC900F5CFF7 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "cminpack" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB91EC08733DB70010E9CD /* Debug */,
+				1DEB91ED08733DB70010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "cminpack" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1DEB91F008733DB70010E9CD /* Debug */,
+				1DEB91F108733DB70010E9CD /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548DCE0F83DF8F0015F022 /* Build configuration list for PBXNativeTarget "tlmdifc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548DC80F83DF460015F022 /* Debug */,
+				1E548DC90F83DF460015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E0B0F83E1C10015F022 /* Build configuration list for PBXNativeTarget "tlmdif1c" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E0C0F83E1C10015F022 /* Debug */,
+				1E548E0D0F83E1C10015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E1D0F83E2050015F022 /* Build configuration list for PBXNativeTarget "tchkderc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E1E0F83E2050015F022 /* Debug */,
+				1E548E1F0F83E2050015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E520F83E2DF0015F022 /* Build configuration list for PBXNativeTarget "thybrdc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E530F83E2DF0015F022 /* Debug */,
+				1E548E540F83E2DF0015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E660F83E2F90015F022 /* Build configuration list for PBXNativeTarget "thybrd1c" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E670F83E2F90015F022 /* Debug */,
+				1E548E680F83E2F90015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E790F83E3130015F022 /* Build configuration list for PBXNativeTarget "thybrjc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E7A0F83E3130015F022 /* Debug */,
+				1E548E7B0F83E3130015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E8B0F83E32D0015F022 /* Build configuration list for PBXNativeTarget "thybrj1c" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E8C0F83E32D0015F022 /* Debug */,
+				1E548E8D0F83E32D0015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548E9C0F83E3440015F022 /* Build configuration list for PBXNativeTarget "tlmderc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548E9D0F83E3440015F022 /* Debug */,
+				1E548E9E0F83E3440015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548EBB0F83E3810015F022 /* Build configuration list for PBXNativeTarget "tlmstrc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548EBC0F83E3810015F022 /* Debug */,
+				1E548EBD0F83E3810015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548ECB0F83E38C0015F022 /* Build configuration list for PBXNativeTarget "tlmstr1c" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548ECC0F83E38C0015F022 /* Debug */,
+				1E548ECD0F83E38C0015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548EDA0F83E3A10015F022 /* Build configuration list for PBXNativeTarget "tlmder1c" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548EDB0F83E3A10015F022 /* Debug */,
+				1E548EDC0F83E3A10015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1E548F0D0F83E42D0015F022 /* Build configuration list for PBXAggregateTarget "all" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1E548EED0F83E3F10015F022 /* Debug */,
+				1E548EEE0F83E3F10015F022 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C25C158779BA00F5CFF7 /* Build configuration list for PBXNativeTarget "ibmdpdrc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C25D158779BA00F5CFF7 /* Debug */,
+				1EA5C25E158779BA00F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C26C15877A8B00F5CFF7 /* Build configuration list for PBXNativeTarget "lmddrvc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C26D15877A8B00F5CFF7 /* Debug */,
+				1EA5C26E15877A8B00F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C27A15877A9500F5CFF7 /* Build configuration list for PBXNativeTarget "lmfdrvc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C27B15877A9500F5CFF7 /* Debug */,
+				1EA5C27C15877A9500F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C28815877AA100F5CFF7 /* Build configuration list for PBXNativeTarget "lmsdrvc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C28915877AA100F5CFF7 /* Debug */,
+				1EA5C28A15877AA100F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C29615877AAF00F5CFF7 /* Build configuration list for PBXNativeTarget "hyjdrvc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C29715877AAF00F5CFF7 /* Debug */,
+				1EA5C29815877AAF00F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C2A415877ABA00F5CFF7 /* Build configuration list for PBXNativeTarget "hybdrvc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C2A515877ABA00F5CFF7 /* Debug */,
+				1EA5C2A615877ABA00F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		1EA5C2B215877AC900F5CFF7 /* Build configuration list for PBXNativeTarget "chkdrvc" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				1EA5C2B315877AC900F5CFF7 /* Debug */,
+				1EA5C2B415877AC900F5CFF7 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
diff --git a/cminpackP.h b/cminpackP.h
new file mode 100644
index 0000000..4e8ba7b
--- /dev/null
+++ b/cminpackP.h
@@ -0,0 +1,62 @@
+/* Internal header file for cminpack, by Frederic Devernay. */
+#ifndef __CMINPACKP_H__
+#define __CMINPACKP_H__
+
+#ifndef __CMINPACK_H__
+#error "cminpackP.h in an internal cminpack header, and must be included after all other headers (including cminpack.h)"
+#endif
+
+#if (defined (USE_CBLAS) || defined (USE_LAPACK)) && !defined (__cminpack_double__)
+#error "cminpack can use cblas and lapack only in double precision mode"
+#endif
+
+#ifdef USE_CBLAS
+#ifdef __APPLE__
+#include <Accelerate/Accelerate.h>
+#else
+#include <cblas.h>
+#endif
+#define __cminpack_enorm__(n,x) cblas_dnrm2(n,x,1)
+#else
+#define __cminpack_enorm__(n,x) __cminpack_func__(enorm)(n,x)
+#endif
+
+#ifdef USE_LAPACK
+#ifdef __APPLE__
+#include <Accelerate/Accelerate.h>
+#else
+#if defined(__LP64__) /* In LP64 match sizes with the 32 bit ABI */
+typedef int 		__CLPK_integer;
+typedef int 		__CLPK_logical;
+typedef float 		__CLPK_real;
+typedef double 		__CLPK_doublereal;
+typedef __CLPK_logical 	(*__CLPK_L_fp)();
+typedef int 		__CLPK_ftnlen;
+#else
+typedef long int 	__CLPK_integer;
+typedef long int 	__CLPK_logical;
+typedef float 		__CLPK_real;
+typedef double 		__CLPK_doublereal;
+typedef __CLPK_logical 	(*__CLPK_L_fp)();
+typedef long int 	__CLPK_ftnlen;
+#endif
+//extern void dlartg_(double *f, double *g, double *cs, double *sn, double *r__);
+int dlartg_(__CLPK_doublereal *f, __CLPK_doublereal *g, __CLPK_doublereal *cs,
+            __CLPK_doublereal *sn, __CLPK_doublereal *r__)
+//extern void dgeqp3_(int *m, int *n, double *a, int *lda, int *jpvt, double *tau, double *work, int *lwork, int *info);
+int dgeqp3_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_doublereal *a, __CLPK_integer *
+            lda, __CLPK_integer *jpvt, __CLPK_doublereal *tau, __CLPK_doublereal *work, __CLPK_integer *lwork,
+            __CLPK_integer *info)
+//extern void dgeqrf_(int *m, int *n, double *a, int *lda, double *tau, double *work, int *lwork, int *info);
+int dgeqrf_(__CLPK_integer *m, __CLPK_integer *n, __CLPK_doublereal *a, __CLPK_integer *
+            lda, __CLPK_doublereal *tau, __CLPK_doublereal *work, __CLPK_integer *lwork, __CLPK_integer *info)
+#endif
+#endif
+
+#define real __cminpack_real__
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+#endif /* !__CMINPACKP_H__ */
diff --git a/cminpack_dll.vcproj b/cminpack_dll.vcproj
new file mode 100644
index 0000000..d549386
--- /dev/null
+++ b/cminpack_dll.vcproj
@@ -0,0 +1,391 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="cminpack_dll"
+	ProjectGUID="{7A715393-C1E6-41D2-9A47-DA8501440F71}"
+	RootNamespace="cminpack_dll"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CMINPACK_DLL_EXPORTS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CMINPACK_DLL_EXPORTS"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\chkder.c"
+				>
+			</File>
+			<File
+				RelativePath=".\chkder_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\covar.c"
+				>
+			</File>
+			<File
+				RelativePath=".\covar1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\covar_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dogleg.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dogleg_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dpmpar.c"
+				>
+			</File>
+			<File
+				RelativePath=".\dpmpar_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\enorm.c"
+				>
+			</File>
+			<File
+				RelativePath=".\enorm_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac2.c"
+				>
+			</File>
+			<File
+				RelativePath=".\fdjac2_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrd_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\hybrj_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmder_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmdif_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmpar.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmpar_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr1.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr1_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\lmstr_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qform.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qform_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrfac.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrfac_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrsolv.c"
+				>
+			</File>
+			<File
+				RelativePath=".\qrsolv_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1mpyq.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1mpyq_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1updt.c"
+				>
+			</File>
+			<File
+				RelativePath=".\r1updt_.c"
+				>
+			</File>
+			<File
+				RelativePath=".\rwupdt.c"
+				>
+			</File>
+			<File
+				RelativePath=".\rwupdt_.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\cminpack.h"
+				>
+			</File>
+			<File
+				RelativePath=".\minpack.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/covar.c b/covar.c
new file mode 100644
index 0000000..2859392
--- /dev/null
+++ b/covar.c
@@ -0,0 +1,154 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(covar)(int n, real *r, int ldr, 
+	const int *ipvt, real tol, real *wa)
+{
+    /* Local variables */
+    int i, j, k, l, ii, jj;
+    int sing;
+    real temp, tolr;
+
+/*     ********** */
+
+/*     subroutine covar */
+
+/*     given an m by n matrix a, the problem is to determine */
+/*     the covariance matrix corresponding to a, defined as */
+
+/*                    t */
+/*           inverse(a *a) . */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then covar expects */
+/*     the full upper triangle of r and the permutation matrix p. */
+/*     the covariance matrix is then computed as */
+
+/*                      t     t */
+/*           p*inverse(r *r)*p  . */
+
+/*     if a is nearly rank deficient, it may be desirable to compute */
+/*     the covariance matrix corresponding to the linearly independent */
+/*     columns of a. to define the numerical rank of a, covar uses */
+/*     the tolerance tol. if l is the largest integer such that */
+
+/*           abs(r(l,l)) .gt. tol*abs(r(1,1)) , */
+
+/*     then covar computes the covariance matrix corresponding to */
+/*     the first l columns of r. for k greater than l, column */
+/*     and row ipvt(k) of the covariance matrix are set to zero. */
+
+/*     the subroutine statement is */
+
+/*       subroutine covar(n,r,ldr,ipvt,tol,wa) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle must */
+/*         contain the full upper triangle of the matrix r. on output */
+/*         r contains the square symmetric covariance matrix. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       tol is a nonnegative input variable used to define the */
+/*         numerical rank of a in the manner described above. */
+
+/*       wa is a work array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs */
+
+/*     argonne national laboratory. minpack project. august 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    tolr = tol * fabs(r[0]);
+
+/*     form the inverse of r in the full upper triangle of r. */
+
+    l = -1;
+    for (k = 0; k < n; ++k) {
+	if (fabs(r[k + k * ldr]) <= tolr) {
+	    break;
+	}
+	r[k + k * ldr] = 1. / r[k + k * ldr];
+	if (k > 0) {
+            for (j = 0; j < k; ++j) {
+                temp = r[k + k * ldr] * r[j + k * ldr];
+                r[j + k * ldr] = 0.;
+                for (i = 0; i <= j; ++i) {
+                    r[i + k * ldr] -= temp * r[i + j * ldr];
+                }
+            }
+        }
+	l = k;
+    }
+
+/*     form the full upper triangle of the inverse of (r transpose)*r */
+/*     in the full upper triangle of r. */
+
+    if (l >= 0) {
+        for (k = 0; k <= l; ++k) {
+            if (k > 0) {
+                for (j = 0; j < k; ++j) {
+                    temp = r[j + k * ldr];
+                    for (i = 0; i <= j; ++i) {
+                        r[i + j * ldr] += temp * r[i + k * ldr];
+                    }
+                }
+            }
+            temp = r[k + k * ldr];
+            for (i = 0; i <= k; ++i) {
+                r[i + k * ldr] *= temp;
+            }
+        }
+    }
+
+/*     form the full lower triangle of the covariance matrix */
+/*     in the strict lower triangle of r and in wa. */
+
+    for (j = 0; j < n; ++j) {
+	jj = ipvt[j]-1;
+	sing = j > l;
+	for (i = 0; i <= j; ++i) {
+	    if (sing) {
+		r[i + j * ldr] = 0.;
+	    }
+	    ii = ipvt[i]-1;
+	    if (ii > jj) {
+		r[ii + jj * ldr] = r[i + j * ldr];
+	    }
+	    else if (ii < jj) {
+		r[jj + ii * ldr] = r[i + j * ldr];
+	    }
+	}
+	wa[jj] = r[j + j * ldr];
+    }
+
+/*     symmetrize the covariance matrix in r. */
+
+    for (j = 0; j < n; ++j) {
+	for (i = 0; i < j; ++i) {
+	    r[i + j * ldr] = r[j + i * ldr];
+	}
+	r[j + j * ldr] = wa[j];
+    }
+
+/*     last card of subroutine covar. */
+
+} /* covar_ */
+
diff --git a/covar1.c b/covar1.c
new file mode 100644
index 0000000..df1be66
--- /dev/null
+++ b/covar1.c
@@ -0,0 +1,165 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+/* covar1 estimates the variance-covariance matrix:
+   C = sigma**2 (JtJ)**+
+   where (JtJ)**+ is the inverse of JtJ or the pseudo-inverse of JtJ (in case J does not have full rank),
+   and sigma**2 = fsumsq / (m - k)
+   where fsumsq is the residual sum of squares and k is the rank of J.
+*/
+__cminpack_attr__
+int __cminpack_func__(covar1)(int m, int n, real fsumsq, real *r, int ldr, 
+	const int *ipvt, real tol, real *wa)
+{
+    /* Local variables */
+    int i, j, k, l, ii, jj;
+    int sing;
+    real temp, tolr;
+
+/*     ********** */
+
+/*     subroutine covar */
+
+/*     given an m by n matrix a, the problem is to determine */
+/*     the covariance matrix corresponding to a, defined as */
+
+/*                    t */
+/*           inverse(a *a) . */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then covar expects */
+/*     the full upper triangle of r and the permutation matrix p. */
+/*     the covariance matrix is then computed as */
+
+/*                      t     t */
+/*           p*inverse(r *r)*p  . */
+
+/*     if a is nearly rank deficient, it may be desirable to compute */
+/*     the covariance matrix corresponding to the linearly independent */
+/*     columns of a. to define the numerical rank of a, covar uses */
+/*     the tolerance tol. if l is the largest integer such that */
+
+/*           abs(r(l,l)) .gt. tol*abs(r(1,1)) , */
+
+/*     then covar computes the covariance matrix corresponding to */
+/*     the first l columns of r. for k greater than l, column */
+/*     and row ipvt(k) of the covariance matrix are set to zero. */
+
+/*     the subroutine statement is */
+
+/*       subroutine covar(n,r,ldr,ipvt,tol,wa) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle must */
+/*         contain the full upper triangle of the matrix r. on output */
+/*         r contains the square symmetric covariance matrix. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       tol is a nonnegative input variable used to define the */
+/*         numerical rank of a in the manner described above. */
+
+/*       wa is a work array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs */
+
+/*     argonne national laboratory. minpack project. august 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    tolr = tol * fabs(r[0]);
+
+/*     form the inverse of r in the full upper triangle of r. */
+
+    l = -1;
+    for (k = 0; k < n; ++k) {
+	if (fabs(r[k + k * ldr]) <= tolr) {
+	    break;
+	}
+	r[k + k * ldr] = 1. / r[k + k * ldr];
+	if (k > 0) {
+            for (j = 0; j < k; ++j) {
+                temp = r[k + k * ldr] * r[j + k * ldr];
+                r[j + k * ldr] = 0.;
+                for (i = 0; i <= j; ++i) {
+                    r[i + k * ldr] -= temp * r[i + j * ldr];
+                }
+            }
+        }
+	l = k;
+    }
+
+/*     form the full upper triangle of the inverse of (r transpose)*r */
+/*     in the full upper triangle of r. */
+
+    if (l >= 0) {
+        for (k = 0; k <= l; ++k) {
+            if (k > 0) {
+                for (j = 0; j < k; ++j) {
+                    temp = r[j + k * ldr];
+                    for (i = 0; i <= j; ++i) {
+                        r[i + j * ldr] += temp * r[i + k * ldr];
+                    }
+                }
+            }
+            temp = r[k + k * ldr];
+            for (i = 0; i <= k; ++i) {
+                r[i + k * ldr] *= temp;
+            }
+        }
+    }
+
+/*     form the full lower triangle of the covariance matrix */
+/*     in the strict lower triangle of r and in wa. */
+
+    for (j = 0; j < n; ++j) {
+	jj = ipvt[j]-1;
+	sing = j > l;
+	for (i = 0; i <= j; ++i) {
+	    if (sing) {
+		r[i + j * ldr] = 0.;
+	    }
+	    ii = ipvt[i]-1;
+	    if (ii > jj) {
+		r[ii + jj * ldr] = r[i + j * ldr];
+	    }
+	    else if (ii < jj) {
+		r[jj + ii * ldr] = r[i + j * ldr];
+	    }
+	}
+	wa[jj] = r[j + j * ldr];
+    }
+
+/*     symmetrize the covariance matrix in r. */
+
+    temp = fsumsq / (m - (l + 1));
+    for (j = 0; j < n; ++j) {
+	for (i = 0; i < j; ++i) {
+            r[j + i * ldr] *= temp;
+	    r[i + j * ldr] = r[j + i * ldr];
+	}
+	r[j + j * ldr] = temp * wa[j];
+    }
+
+/*     last card of subroutine covar. */
+    if (l == (n - 1)) {
+        return 0;
+    }
+    return l + 1;
+} /* covar_ */
+
diff --git a/covar_.c b/covar_.c
new file mode 100644
index 0000000..188ccc4
--- /dev/null
+++ b/covar_.c
@@ -0,0 +1,209 @@
+/* covar.f -- translated by f2c (version 20100827).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+__minpack_attr__
+void __minpack_func__(covar)(const int *n, real *r__, const int *ldr, 
+	const int *ipvt, const real *tol, real *wa)
+{
+    /* System generated locals */
+    int r_dim1, r_offset, i__1, i__2, i__3;
+
+    /* Local variables */
+    int i__, j, k, l, ii, jj, km1;
+    int sing;
+    real temp, tolr;
+
+/*     ********** */
+
+/*     subroutine covar */
+
+/*     given an m by n matrix a, the problem is to determine */
+/*     the covariance matrix corresponding to a, defined as */
+
+/*                    t */
+/*           inverse(a *a) . */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then covar expects */
+/*     the full upper triangle of r and the permutation matrix p. */
+/*     the covariance matrix is then computed as */
+
+/*                      t     t */
+/*           p*inverse(r *r)*p  . */
+
+/*     if a is nearly rank deficient, it may be desirable to compute */
+/*     the covariance matrix corresponding to the linearly independent */
+/*     columns of a. to define the numerical rank of a, covar uses */
+/*     the tolerance tol. if l is the largest integer such that */
+
+/*           abs(r(l,l)) .gt. tol*abs(r(1,1)) , */
+
+/*     then covar computes the covariance matrix corresponding to */
+/*     the first l columns of r. for k greater than l, column */
+/*     and row ipvt(k) of the covariance matrix are set to zero. */
+
+/*     the subroutine statement is */
+
+/*       subroutine covar(n,r,ldr,ipvt,tol,wa) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle must */
+/*         contain the full upper triangle of the matrix r. on output */
+/*         r contains the square symmetric covariance matrix. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       tol is a nonnegative input variable used to define the */
+/*         numerical rank of a in the manner described above. */
+
+/*       wa is a work array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs */
+
+/*     argonne national laboratory. minpack project. august 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    --ipvt;
+    tolr = *tol * fabs(r__[0]);
+    r_dim1 = *ldr;
+    r_offset = 1 + r_dim1;
+    r__ -= r_offset;
+
+    /* Function Body */
+
+/*     form the inverse of r in the full upper triangle of r. */
+
+    l = 0;
+    i__1 = *n;
+    for (k = 1; k <= i__1; ++k) {
+	if (fabs(r__[k + k * r_dim1]) <= tolr) {
+	    goto L50;
+	}
+	r__[k + k * r_dim1] = 1. / r__[k + k * r_dim1];
+	km1 = k - 1;
+	if (km1 < 1) {
+	    goto L30;
+	}
+	i__2 = km1;
+	for (j = 1; j <= i__2; ++j) {
+	    temp = r__[k + k * r_dim1] * r__[j + k * r_dim1];
+	    r__[j + k * r_dim1] = 0.;
+	    i__3 = j;
+	    for (i__ = 1; i__ <= i__3; ++i__) {
+		r__[i__ + k * r_dim1] -= temp * r__[i__ + j * r_dim1];
+/* L10: */
+	    }
+/* L20: */
+	}
+L30:
+	l = k;
+/* L40: */
+    }
+L50:
+
+/*     form the full upper triangle of the inverse of (r transpose)*r */
+/*     in the full upper triangle of r. */
+
+    if (l < 1) {
+	goto L110;
+    }
+    i__1 = l;
+    for (k = 1; k <= i__1; ++k) {
+	km1 = k - 1;
+	if (km1 < 1) {
+	    goto L80;
+	}
+	i__2 = km1;
+	for (j = 1; j <= i__2; ++j) {
+	    temp = r__[j + k * r_dim1];
+	    i__3 = j;
+	    for (i__ = 1; i__ <= i__3; ++i__) {
+		r__[i__ + j * r_dim1] += temp * r__[i__ + k * r_dim1];
+/* L60: */
+	    }
+/* L70: */
+	}
+L80:
+	temp = r__[k + k * r_dim1];
+	i__2 = k;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    r__[i__ + k * r_dim1] = temp * r__[i__ + k * r_dim1];
+/* L90: */
+	}
+/* L100: */
+    }
+L110:
+
+/*     form the full lower triangle of the covariance matrix */
+/*     in the strict lower triangle of r and in wa. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	jj = ipvt[j];
+	sing = j > l;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    if (sing) {
+		r__[i__ + j * r_dim1] = 0.;
+	    }
+	    ii = ipvt[i__];
+	    if (ii > jj) {
+		r__[ii + jj * r_dim1] = r__[i__ + j * r_dim1];
+	    }
+	    if (ii < jj) {
+		r__[jj + ii * r_dim1] = r__[i__ + j * r_dim1];
+	    }
+/* L120: */
+	}
+	wa[jj] = r__[j + j * r_dim1];
+/* L130: */
+    }
+
+/*     symmetrize the covariance matrix in r. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    r__[i__ + j * r_dim1] = r__[j + i__ * r_dim1];
+/* L140: */
+	}
+	r__[j + j * r_dim1] = wa[j];
+/* L150: */
+    }
+    /*return 0;*/
+
+/*     last card of subroutine covar. */
+
+} /* covar_ */
+
diff --git a/cuda/Makefile b/cuda/Makefile
new file mode 100644
index 0000000..999a817
--- /dev/null
+++ b/cuda/Makefile
@@ -0,0 +1,22 @@
+CC=nvcc
+CFLAGS= --compile  -I..
+
+SOURCES = $(wildcard *.cu)
+OBJECTS = $(SOURCES:.cu=.o)
+
+all: libcuminpack.a
+
+libcuminpack.a:  $(OBJECTS)
+	@echo " **************************** "
+	@echo " making compiling and library for testing "
+	@echo " (cuda needs __device__ source code compiled inline with kernel) "
+	@echo " **************************** "
+	ar r $@ $(OBJECTS); ranlib $@
+
+%.o: %.cu
+	@echo " compiling for testing "
+	${CC} ${CFLAGS}  -o $@ $<
+
+clean:
+	rm -f *.o libcuminpack.a *~ #*#
+
diff --git a/cuda/chkder.cu b/cuda/chkder.cu
new file mode 100644
index 0000000..a714186
--- /dev/null
+++ b/cuda/chkder.cu
@@ -0,0 +1,7 @@
+#ifndef CHKDER_CU_INCLUDED
+#define CHKDER_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include <chkder.c>
+
+#endif
diff --git a/cuda/covar.cu b/cuda/covar.cu
new file mode 100644
index 0000000..879b936
--- /dev/null
+++ b/cuda/covar.cu
@@ -0,0 +1,6 @@
+#ifndef COVAR_CU_INCLUDED
+#define COVAR_CU_INCLUDED
+
+#include <covar.c>
+
+#endif
diff --git a/cuda/covar1.cu b/cuda/covar1.cu
new file mode 100644
index 0000000..a3306ef
--- /dev/null
+++ b/cuda/covar1.cu
@@ -0,0 +1,6 @@
+#ifndef COVAR1_CU_INCLUDED
+#define COVAR1_CU_INCLUDED
+
+#include <covar1.c>
+
+#endif
diff --git a/cuda/dogleg.cu b/cuda/dogleg.cu
new file mode 100644
index 0000000..8f524dd
--- /dev/null
+++ b/cuda/dogleg.cu
@@ -0,0 +1,8 @@
+#ifndef DOGLEG_CU_INCLUDED
+#define DOGLEG_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include <dogleg.c>
+
+#endif
diff --git a/cuda/dpmpar.cu b/cuda/dpmpar.cu
new file mode 100644
index 0000000..fb246b3
--- /dev/null
+++ b/cuda/dpmpar.cu
@@ -0,0 +1,6 @@
+#ifndef DPMPAR_CU_INCLUDED
+#define DPMPAR_CU_INCLUDED
+
+#include <dpmpar.c>
+
+#endif
diff --git a/cuda/enorm.cu b/cuda/enorm.cu
new file mode 100644
index 0000000..ee2411a
--- /dev/null
+++ b/cuda/enorm.cu
@@ -0,0 +1,7 @@
+#ifndef ENORM_CU_INCLUDED
+#define ENORM_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include <enorm.c>
+
+#endif
diff --git a/cuda/examples/Makefile b/cuda/examples/Makefile
new file mode 100755
index 0000000..22a1714
--- /dev/null
+++ b/cuda/examples/Makefile
@@ -0,0 +1,19 @@
+
+SOURCES = $(wildcard t*.cu)
+TEST_PROGRAMS = $(SOURCES:.cu=)
+
+CC=nvcc
+CFLAGS=  -I.. -I../..
+
+all:
+	@echo    make cudatest, make clean
+	@echo $(TEST_PROGRAMS)
+
+
+cudatest: clean $(TEST_PROGRAMS)
+
+%:%.cu
+	$(CC) $(CFLAGS) -o $@ $<
+
+clean:
+	rm -f *.o run.* $(TEST_PROGRAMS)
diff --git a/cuda/examples/leeme.txt b/cuda/examples/leeme.txt
new file mode 100755
index 0000000..0ac51a8
--- /dev/null
+++ b/cuda/examples/leeme.txt
@@ -0,0 +1,12 @@
+
+man nvcc
+	 --gpu-name 
+
+	  __CUDACC__ and __CUDA_ARCH__. (http://forums.nvidia.com/index.php?showtopic=149501)
+
+http://developer.download.nvidia.com/compute/cuda/4_0/toolkit/docs/CUDA_C_Programming_Guide.pdf
+
+		Function Pointers
+		Function pointers to __global__ functions are supported in host code, but not in device code.
+		Function pointers to __device__ functions are only supported in device code compiled for devices of compute capability 2.x.
+		It is not allowed to take the address of a __device__ function in host code.
diff --git a/cuda/examples/tlmderc.cu b/cuda/examples/tlmderc.cu
new file mode 100755
index 0000000..ded0ece
--- /dev/null
+++ b/cuda/examples/tlmderc.cu
@@ -0,0 +1,279 @@
+/* -*- mode: c++ -*- */
+/* ------------------------------ */
+/*  driver for lmder example.     */
+/* ------------------------------ */
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <cminpack.h>
+
+#include <lmder.cu>
+#include <covar1.cu>
+#define real __cminpack_real__
+
+#define cutilSafeCall(err)           __cudaSafeCall      (err, __FILE__, __LINE__)
+inline void __cudaSafeCall( cudaError err, const char *file, const int line )
+{
+    if( cudaSuccess != err) {
+        fprintf(stderr, "cudaSafeCall() Runtime API error in file <%s>, line %i : %s.\n",
+                file, line, cudaGetErrorString( err) );
+        exit(-1);
+    }
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+const unsigned int NUM_OBSERVATIONS = 15; // m
+const unsigned int NUM_PARAMS = 3; // 3 = n
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// 
+//  fixed arrangement of threads to be run 
+// 
+const unsigned int NUM_THREADS = 2048;
+const unsigned int NUM_THREADS_PER_BLOCK = 128;
+const unsigned int NUM_BLOCKS = NUM_THREADS / NUM_THREADS_PER_BLOCK;
+
+//--------------------------------------------------------------------------
+//
+// the struct for returning results from the GPU
+//
+
+typedef struct    
+{
+    real fnorm;
+    int nfev;
+    int njev;
+    int info;
+    int rankJ;
+    real solution[NUM_PARAMS];
+    real covar[NUM_PARAMS][NUM_PARAMS];
+} ResultType;
+
+//--------------------------------------------------------------------------
+// the cost function
+//--------------------------------------------------------------------------
+__cminpack_attr__ /* __device__ */
+int fcnder_mn(
+    void *p, int m, int n, const real *x, 
+    real *fvec, real *fjac, 
+    int ldfjac, int iflag)
+{
+
+    /*      subroutine fcn for lmder example. */
+
+    int i;
+    real tmp1, tmp2, tmp3, tmp4;
+    real y[NUM_OBSERVATIONS]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 
+                              2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1, 3.7e-1, 
+                              5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+    if (iflag == 0) {
+        /*      insert print statements here when nprint is positive. */
+        return 0;
+    }
+
+    if (iflag != 2) {
+
+	for (i = 1; i <= NUM_OBSERVATIONS; i++) {
+            tmp1 = i;
+            tmp2 = (NUM_OBSERVATIONS+1) - i;
+            tmp3 = tmp1;
+            if (i > 8) tmp3 = tmp2;
+            fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+        } // for
+
+    } else { 
+
+        for (i=1; i<=NUM_OBSERVATIONS; i++) {
+            tmp1 = i;
+            tmp2 = (NUM_OBSERVATIONS+1) - i;
+            tmp3 = tmp1;
+            if (i > 8) tmp3 = tmp2;
+            tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4;
+            fjac[i-1 + ldfjac*(1-1)] = -1.;
+            fjac[i-1 + ldfjac*(2-1)] = tmp1*tmp2/tmp4;
+            fjac[i-1 + ldfjac*(3-1)] = tmp1*tmp3/tmp4;
+        } // for
+    } // if
+
+    return 0;
+}
+
+//--------------------------------------------------------------------------
+// the kernel in the GPU
+//--------------------------------------------------------------------------
+__global__ void mainKernel(ResultType  pResults[])
+{
+    int ldfjac, maxfev, mode, nprint, info, nfev, njev;
+    int ipvt[NUM_PARAMS];
+    real ftol, xtol, gtol, factor, fnorm;
+    real x[NUM_PARAMS], fvec[NUM_OBSERVATIONS], 
+            diag[NUM_PARAMS], fjac[NUM_OBSERVATIONS*NUM_PARAMS], qtf[NUM_PARAMS], 
+            wa1[NUM_PARAMS], wa2[NUM_PARAMS], wa3[NUM_PARAMS], wa4[NUM_OBSERVATIONS];
+    int k;
+
+    // m = NUM_OBSERVATIONS;
+    // n = NUM_PARAMS;
+
+    /*      the following starting values provide a rough fit. */
+
+    x[1-1] = 1.; 
+    x[2-1] = 1.; 
+    x[3-1] = 1.;
+
+    ldfjac = NUM_OBSERVATIONS;
+
+    /*      set ftol and xtol to the square root of the machine */
+    /*      and gtol to zero. unless high solutions are */
+    /*      required, these are the recommended settings. */
+
+    ftol = sqrt(__cminpack_func__(dpmpar)(1));
+    xtol = sqrt(__cminpack_func__(dpmpar)(1));
+    gtol = 0.;
+
+    maxfev = 400;
+    mode = 1;
+    factor = 1.e2;
+    nprint = 0;
+
+    // -------------------------------
+    // call lmder, enorm, and covar1
+    // -------------------------------
+    info = __cminpack_func__(lmder)(__cminpack_param_fcnder_mn__ 0, NUM_OBSERVATIONS, NUM_PARAMS, 
+                 x, fvec, fjac, ldfjac, ftol, xtol, gtol, 
+                 maxfev, diag, mode, factor, nprint, &nfev, &njev, 
+                 ipvt, qtf, wa1, wa2, wa3, wa4);
+
+    fnorm = __cminpack_func__(enorm)(NUM_OBSERVATIONS, fvec);
+
+    // NOTE: REMOVED THE TEST OF ORIGINAL MINPACK covar routine
+
+    /* test covar1, which also estimates the rank of the Jacobian */
+    ftol = __cminpack_func__(dpmpar)(1);
+    k = __cminpack_func__(covar1)(NUM_OBSERVATIONS, NUM_PARAMS, 
+               fnorm*fnorm, fjac, ldfjac, ipvt, ftol, wa1);
+
+    // ----------------------------------
+    // save the results in global memory
+    // ----------------------------------
+    int threadId = (blockIdx.x * blockDim.x) + threadIdx.x;
+
+    pResults[threadId].fnorm = fnorm;
+    pResults[threadId].nfev = nfev;
+    pResults[threadId].njev = njev;
+    pResults[threadId].info = info;
+
+    for (int j=1; j<=NUM_PARAMS; j++) {
+        pResults[threadId].solution[j-1] = x[j-1];
+    }
+
+    for (int i=1; i<=NUM_PARAMS; i++) {
+        for (int j=1; j<=NUM_PARAMS; j++) {
+            pResults[threadId].covar[i-1][j-1] = fjac[(i-1)*ldfjac+j-1];
+	} // for
+    } // for
+
+    pResults[threadId].rankJ =  (k != 0 ? k : NUM_PARAMS); 
+
+} // ()
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+int main (int argc, char** argv)
+{
+
+    fprintf (stderr, "\ntlmder starts ! \n");
+    //  ...............................................................
+    // choose the fastest GPU device
+    //  ...............................................................
+    unsigned int GPU_ID = 1; 
+    // unsigned int GPU_ID =  cutGetMaxGflopsDeviceId() ;
+    cudaSetDevice(GPU_ID); 
+    fprintf (stderr, " CUDA device chosen = %d \n", GPU_ID);
+
+    // ....................................................... 
+    //  get memory in the GPU to store the results 
+    // ....................................................... 
+    ResultType * results_GPU = 0;
+    cutilSafeCall(cudaMalloc( &results_GPU,  NUM_THREADS * sizeof(ResultType) ));
+
+    // ....................................................... 
+    //  get memory in the CPU to store the results 
+    // ....................................................... 
+    ResultType * results_CPU = 0;
+    cutilSafeCall(cudaMallocHost( &results_CPU, NUM_THREADS * sizeof(ResultType) ));
+
+    // ....................................................... 
+    //  launch the kernel
+    // ....................................................... 
+    fprintf (stderr, " \nlaunching the kernel num. blocks = %d, threads per block = %d\n total threads = %d\n\n",
+             NUM_BLOCKS, NUM_THREADS_PER_BLOCK, NUM_THREADS);
+
+    mainKernel<<<NUM_BLOCKS,NUM_THREADS_PER_BLOCK>>> ( results_GPU );
+
+    // ....................................................... 
+    // wait for termination
+    // ....................................................... 
+    cudaThreadSynchronize(); 
+    fprintf (stderr, " GPU processing done \n\n");
+
+    // ....................................................... 
+    // copy back to CPU the results
+    // ....................................................... 
+    cutilSafeCall(cudaMemcpy( results_CPU, results_GPU,
+                              NUM_THREADS * sizeof(ResultType),
+                              cudaMemcpyDeviceToHost
+                              ));
+
+    // ....................................................... 
+    // check all the threads computed the same results
+    // ....................................................... 
+    bool ok = true;
+    for (unsigned int i = 1; i<NUM_THREADS; i++) {
+	if ( memcmp (&results_CPU[0], &results_CPU[i], sizeof(ResultType)) != 0) {
+            // warning: may the padding bytes be different ?
+            ok = false;
+	}
+    } // for
+
+    if (ok) {
+	fprintf (stderr, " !!! all threads computed the same results !!! \n\n");
+    } else {
+	fprintf (stderr, "ERROR in results of threads \n");
+    }
+
+    // ....................................................... 
+    // show the results !
+    // ....................................................... 
+
+    printf("      final l2 norm of the residuals%15.7g\n\n", results_CPU[0].fnorm);
+    printf("      number of function evaluations%10i\n\n", results_CPU[0].nfev);
+    printf("      number of Jacobian evaluations%10i\n\n", results_CPU[0].njev);
+    printf("      exit parameter                %10i\n\n", results_CPU[0].info);
+    printf("      final approximate solution\n");
+
+    for (int j=0; j<NUM_PARAMS; j++)  {
+        printf("%15.7g", results_CPU[0].solution[j]);
+    }
+    printf("\n");
+
+    printf("      covariance\n");
+ 
+    for (unsigned int i=0; i<NUM_PARAMS; i++) {
+        for (unsigned int j=0; j<NUM_PARAMS; j++) {
+            printf("%15.7g", results_CPU[0].covar[i][j]);
+	} // for
+	printf ("\n");
+    } // for
+  
+    printf("\n");
+    printf(" rank(J) = %d\n", results_CPU[0].rankJ );
+
+    cutilSafeCall(cudaFree(results_GPU));
+    cutilSafeCall(cudaFreeHost(results_CPU));
+    cudaThreadExit();
+    //cutilExit(argc, argv);
+} // ()
diff --git a/cuda/examples/tlmdif1c.cu b/cuda/examples/tlmdif1c.cu
new file mode 100755
index 0000000..1699af3
--- /dev/null
+++ b/cuda/examples/tlmdif1c.cu
@@ -0,0 +1,208 @@
+/* -*- mode: c++ -*- */
+/* ------------------------------ */
+/*  driver for lmdif1 example.     */
+/* ------------------------------ */
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <cminpack.h>
+
+#include <lmdif1.cu>
+#define real __cminpack_real__
+
+#define cutilSafeCall(err)           __cudaSafeCall      (err, __FILE__, __LINE__)
+inline void __cudaSafeCall( cudaError err, const char *file, const int line )
+{
+    if( cudaSuccess != err) {
+        fprintf(stderr, "cudaSafeCall() Runtime API error in file <%s>, line %i : %s.\n",
+                file, line, cudaGetErrorString( err) );
+        exit(-1);
+    }
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+const unsigned int NUM_OBSERVATIONS = 15; // m
+const unsigned int NUM_PARAMS = 3; // 3 = n
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// 
+//  fixed arrangement of threads to be run 
+// 
+const unsigned int NUM_THREADS = 2048;
+const unsigned int NUM_THREADS_PER_BLOCK = 128;
+const unsigned int NUM_BLOCKS = NUM_THREADS / NUM_THREADS_PER_BLOCK;
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//
+// the struct for returning results from the GPU
+//
+
+typedef struct    
+{
+    real fnorm;
+    int info;
+    real solution[NUM_PARAMS];
+} ResultType;
+
+
+//--------------------------------------------------------------------------
+// the cost function
+//--------------------------------------------------------------------------
+__cminpack_attr__ /* __device__ */
+int fcn_mn(void *p, int m, int n, const real *x, real *fvec, int iflag)
+{
+
+    /*      subroutine fcn for lmdif example. */
+
+    int i;
+    real tmp1, tmp2, tmp3;
+    real y[NUM_OBSERVATIONS]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                              3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+    for (i = 0; i < NUM_OBSERVATIONS; i++) {
+        tmp1 = i+1;
+        tmp2 = NUM_OBSERVATIONS - i;
+        tmp3 = tmp1;
+	  
+        if (i >= 8) tmp3 = tmp2;
+        fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+    } // for
+    return 0;
+}
+
+//--------------------------------------------------------------------------
+// the kernel in the GPU
+//--------------------------------------------------------------------------
+__global__ void mainKernel(ResultType  pResults[])
+{
+
+    int info, lwa, iwa[NUM_PARAMS];
+    real tol, fnorm, x[NUM_PARAMS], fvec[NUM_OBSERVATIONS], wa[75];
+
+    // m = 15 = NUM_OBSERVATIONS;
+    // n = 3 = NUM_PARAMS;
+
+    /*   the following starting values provide a rough fit. */
+    x[0] = 1.; 
+    x[1] = 1.; 
+    x[2] = 1.;
+
+    lwa = 75;
+
+    /* set tol to the square root of the machine precision.  unless high
+       precision solutions are required, this is the recommended
+       setting. */
+
+    tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+    // -------------------------------
+    // call lmdif, and enorm
+    // -------------------------------
+    info = __cminpack_func__(lmdif1)(__cminpack_param_fcn_mn__ 0, NUM_OBSERVATIONS, NUM_PARAMS, x, fvec, tol, iwa, wa, lwa);
+  
+    fnorm = __cminpack_func__(enorm)(NUM_OBSERVATIONS, fvec);
+
+    // ----------------------------------
+    // save the results in global memory
+    // ----------------------------------
+    int threadId = (blockIdx.x * blockDim.x) + threadIdx.x;
+
+    pResults[threadId].fnorm = fnorm;
+    pResults[threadId].info = info;
+
+    for (int j=0; j<NUM_PARAMS; j++) {
+        pResults[threadId].solution[j] = x[j];
+    }
+
+} // ()
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+int main (int argc, char** argv)
+{
+
+    fprintf (stderr, "\ntlmdif1c starts ! \n");
+
+    //  ...............................................................
+    // choose the fastest GPU device
+    //  ...............................................................
+    unsigned int GPU_ID = 1;  // not actually :-)
+    // unsigned int GPU_ID =  cutGetMaxGflopsDeviceId() ;
+    cudaSetDevice(GPU_ID); 
+    fprintf (stderr, " CUDA device chosen = %d \n", GPU_ID);
+
+    // ....................................................... 
+    //  get memory in the GPU to store the results 
+    // ....................................................... 
+    ResultType * results_GPU = 0;
+    cutilSafeCall( cudaMalloc( &results_GPU,  NUM_THREADS * sizeof(ResultType)) );
+
+    // ....................................................... 
+    //  get memory in the CPU to store the results 
+    // ....................................................... 
+    ResultType * results_CPU = 0;
+    cutilSafeCall( cudaMallocHost( &results_CPU, NUM_THREADS * sizeof(ResultType)) );
+
+    // ....................................................... 
+    //  launch the kernel
+    // ....................................................... 
+    fprintf (stderr, " \nlaunching the kernel num. blocks = %d, threads per block = %d\n total threads = %d\n\n",
+             NUM_BLOCKS, NUM_THREADS_PER_BLOCK, NUM_THREADS);
+
+    mainKernel<<<NUM_BLOCKS,NUM_THREADS_PER_BLOCK>>> ( results_GPU );
+
+    // ....................................................... 
+    // wait for termination
+    // ....................................................... 
+    cudaThreadSynchronize(); 
+    fprintf (stderr, " GPU processing done \n\n");
+
+    // ....................................................... 
+    // copy back to CPU the results
+    // ....................................................... 
+    cutilSafeCall( cudaMemcpy( results_CPU, results_GPU, 
+                               NUM_THREADS * sizeof(ResultType),
+                               cudaMemcpyDeviceToHost
+                               ) );
+
+    // ....................................................... 
+    // check all the threads computed the same results
+    // ....................................................... 
+    bool ok = true;
+    for (unsigned int i = 1; i<NUM_THREADS; i++) {
+	if ( memcmp (&results_CPU[0], &results_CPU[i], sizeof(ResultType)) != 0) {
+            // warning: may the padding bytes be different ?
+            ok = false;
+	}
+    } // for
+		 
+
+    if (ok) {
+	fprintf (stderr, " !!! all threads computed the same results !!! \n\n");
+    } else {
+	fprintf (stderr, "ERROR in results of threads \n");
+    }
+
+    // ....................................................... 
+    // show the results !
+    // ....................................................... 
+
+    printf("      final l2 norm of the residuals%15.7g\n\n", results_CPU[0].fnorm);
+    printf("      exit parameter                %10i\n\n", results_CPU[0].info);
+    printf("      final approximate solution\n");
+
+    for (int j=0; j<NUM_PARAMS; j++)  {
+        printf("%15.7g", results_CPU[0].solution[j]);
+    }
+    printf("\n");
+
+    cutilSafeCall(cudaFree(results_GPU));
+    cutilSafeCall(cudaFreeHost(results_CPU));
+    cudaThreadExit();
+    //cutilExit(argc, argv);
+} // ()
+
diff --git a/cuda/examples/tlmdifc.cu b/cuda/examples/tlmdifc.cu
new file mode 100755
index 0000000..585ac88
--- /dev/null
+++ b/cuda/examples/tlmdifc.cu
@@ -0,0 +1,318 @@
+/* -*- mode: c++ -*- */
+/* ------------------------------ */
+/*  driver for lmdif example.     */
+/* ------------------------------ */
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <cminpack.h>
+
+#include <lmdif.cu>
+#include <covar1.cu>
+#define real __cminpack_real__
+
+#define cutilSafeCall(err)           __cudaSafeCall      (err, __FILE__, __LINE__)
+inline void __cudaSafeCall( cudaError err, const char *file, const int line )
+{
+    if( cudaSuccess != err) {
+        fprintf(stderr, "cudaSafeCall() Runtime API error in file <%s>, line %i : %s.\n",
+                file, line, cudaGetErrorString( err) );
+        exit(-1);
+    }
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+const unsigned int NUM_OBSERVATIONS = 15; // m
+const unsigned int NUM_PARAMS = 3; // 3 = n
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// 
+//  fixed arrangement of threads to be run 
+// 
+const unsigned int NUM_THREADS = 2048;
+const unsigned int NUM_THREADS_PER_BLOCK = 128;
+const unsigned int NUM_BLOCKS = NUM_THREADS / NUM_THREADS_PER_BLOCK;
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//
+// the struct for returning results from the GPU
+//
+//   #define ALIGN 16
+// #pragma pack(16)
+// float rankJ;
+// __align__(2*sizeof(float))
+// __align__(ALIGN) 
+// float covar[NUM_PARAMS][NUM_PARAMS];
+
+
+typedef struct    
+{
+    real fnorm;
+    int nfev;
+    int info;
+    int rankJ;
+    real solution[NUM_PARAMS];
+    real covar[NUM_PARAMS][NUM_PARAMS];
+} ResultType;
+
+//--------------------------------------------------------------------------
+// the cost function
+//--------------------------------------------------------------------------
+__cminpack_attr__ /* __device__ */
+int fcn_mn(void *p, int m, int n, const real *x, real *fvec, int iflag)
+{
+
+    /*      subroutine fcn for lmdif example. */
+
+    int i;
+    real tmp1, tmp2, tmp3;
+    real y[NUM_OBSERVATIONS]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                              3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+    if (iflag == 0)
+    {
+        /*      insert print statements here when nprint is positive. */
+        return 0;
+    }
+    for (i = 1; i <= NUM_OBSERVATIONS; i++)
+    {
+        tmp1 = i;
+        tmp2 = (NUM_OBSERVATIONS+1) - i;
+        tmp3 = tmp1;
+        if (i > 8) tmp3 = tmp2;
+        fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+    }
+    return 0;
+}
+
+//--------------------------------------------------------------------------
+// a test kernel for cheking the return of results
+//--------------------------------------------------------------------------
+__global__ void test_mainKernel(ResultType * pResults)
+{
+
+    int threadId = (blockIdx.x * blockDim.x) + threadIdx.x;
+
+    pResults[threadId].fnorm = 13.13;
+    pResults[threadId].nfev = 144;
+    pResults[threadId].info = -1234;
+
+    for (int j=0; j<NUM_PARAMS; j++) {
+	pResults[threadId].solution[j] = 200+sqrt((real) (j*j));
+    }
+
+    for (unsigned int i=0; i<NUM_PARAMS; i++) {
+        for (unsigned int j=0; j<NUM_PARAMS; j++) {
+            pResults[threadId].covar[i][j] = 100+i+j;
+	} // for
+    } // for
+
+    pResults[threadId].rankJ =   NUM_PARAMS; 
+
+} // ()
+
+//--------------------------------------------------------------------------
+// the kernel in the GPU
+//--------------------------------------------------------------------------
+__global__ void mainKernel(ResultType  pResults[])
+{
+    int  maxfev, mode, nprint, info, nfev, ldfjac;
+    int ipvt[NUM_PARAMS];
+    real ftol, xtol, gtol, epsfcn, factor, fnorm;
+    real x[NUM_PARAMS], fvec[NUM_OBSERVATIONS], 
+            diag[NUM_PARAMS], fjac[NUM_OBSERVATIONS*NUM_PARAMS], qtf[NUM_PARAMS], 
+            wa1[NUM_PARAMS], wa2[NUM_PARAMS], wa3[NUM_PARAMS], wa4[NUM_OBSERVATIONS];
+    int k;
+
+    // m = NUM_OBSERVATIONS;
+    // n = NUM_PARAMS;
+
+    /*      the following starting values provide a rough fit. */
+
+    x[1-1] = 1.; 
+    x[2-1] = 1.; 
+    x[3-1] = 1.;
+
+    ldfjac = NUM_OBSERVATIONS;
+
+    /*      set ftol and xtol to the square root of the machine */
+    /*      and gtol to zero. unless high solutions are */
+    /*      required, these are the recommended settings. */
+
+    ftol = sqrt(__cminpack_func__(dpmpar)(1));
+    xtol = sqrt(__cminpack_func__(dpmpar)(1));
+    gtol = 0.;
+
+    maxfev = 800;
+    epsfcn = 0.;
+    mode = 1;
+    factor = 1.e2;
+    nprint = 0;
+
+    /* NOTE: lmdif for pointer to cost function
+       Error: Function pointers and function template parameters are not supported in sm_1x.
+       info = lmdif(COST_FUNCTION, 0, m, n, x, fvec, ftol, xtol, gtol, maxfev, epsfcn, 
+       diag, mode, factor, nprint, &nfev, fjac, ldfjac, 
+       ipvt, qtf, wa1, wa2, wa3, wa4);
+    */
+
+    // -------------------------------
+    // call lmdif, enorm, and covar1
+    // -------------------------------
+    info = __cminpack_func__(lmdif)(__cminpack_param_fcn_mn__ 0, NUM_OBSERVATIONS, NUM_PARAMS, 
+                 x, fvec, ftol, xtol, gtol, maxfev, epsfcn, 
+                 diag, mode, factor, nprint, &nfev, fjac, ldfjac, 
+                 ipvt, qtf, wa1, wa2, wa3, wa4);
+
+    fnorm = __cminpack_func__(enorm)(NUM_OBSERVATIONS, fvec);
+
+    // NOTE: REMOVED THE TEST OF ORIGINAL MINPACK covar routine
+
+    /* test covar1, which also estimates the rank of the Jacobian */
+    ftol = __cminpack_func__(dpmpar)(1);
+    k = __cminpack_func__(covar1)(NUM_OBSERVATIONS, NUM_PARAMS, 
+               fnorm*fnorm, fjac, ldfjac, ipvt, ftol, wa1);
+
+    // ----------------------------------
+    // save the results in global memory
+    // ----------------------------------
+    int threadId = (blockIdx.x * blockDim.x) + threadIdx.x;
+
+    pResults[threadId].fnorm = fnorm;
+    pResults[threadId].nfev = nfev;
+    pResults[threadId].info = info;
+
+    for (int j=1; j<=NUM_PARAMS; j++) {
+        pResults[threadId].solution[j-1] = x[j-1];
+    }
+
+    for (int i=1; i<=NUM_PARAMS; i++) {
+        for (int j=1; j<=NUM_PARAMS; j++) {
+            pResults[threadId].covar[i-1][j-1] = fjac[(i-1)*ldfjac+j-1];
+	} // for
+    } // for
+
+    /*
+      for (unsigned int i=0; i<NUM_PARAMS; i++) {
+      for (unsigned int j=0; j<NUM_PARAMS; j++) {
+      pResults[threadId].covar[i][j] = 100+i+j;
+      } // for
+      } // for
+    */
+
+    pResults[threadId].rankJ =  (k != 0 ? k : NUM_PARAMS); 
+
+} // ()
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+int main (int argc, char** argv)
+{
+
+    fprintf (stderr, "\ntlmdif starts ! \n");
+    //  ...............................................................
+    // choose the fastest GPU device
+    //  ...............................................................
+    unsigned int GPU_ID = 1; 
+    //unsigned int GPU_ID =  cutGetMaxGflopsDeviceId() ;
+    cudaSetDevice(GPU_ID); 
+    fprintf (stderr, " CUDA device chosen = %d \n", GPU_ID);
+
+    // ....................................................... 
+    //  get memory in the GPU to store the results 
+    // ....................................................... 
+    ResultType * results_GPU = 0;
+    cutilSafeCall( cudaMalloc( &results_GPU,  NUM_THREADS * sizeof(ResultType) ) );
+
+    // ....................................................... 
+    //  get memory in the CPU to store the results 
+    // ....................................................... 
+    ResultType * results_CPU = 0;
+    cutilSafeCall( cudaMallocHost( &results_CPU, NUM_THREADS * sizeof(ResultType) ) );
+
+    // ....................................................... 
+    //  launch the kernel
+    // ....................................................... 
+    fprintf (stderr, " \nlaunching the kernel num. blocks = %d, threads per block = %d\n total threads = %d\n\n",
+             NUM_BLOCKS, NUM_THREADS_PER_BLOCK, NUM_THREADS);
+
+    mainKernel<<<NUM_BLOCKS,NUM_THREADS_PER_BLOCK>>> ( results_GPU );
+
+    // ....................................................... 
+    // wait for termination
+    // ....................................................... 
+    cudaThreadSynchronize(); 
+    fprintf (stderr, " GPU processing done \n\n");
+
+    // ....................................................... 
+    // copy back to CPU the results
+    // ....................................................... 
+    cutilSafeCall( cudaMemcpy( results_CPU, results_GPU, 
+                               NUM_THREADS * sizeof(ResultType),
+                               cudaMemcpyDeviceToHost
+                               ) );
+
+    // ....................................................... 
+    // check all the threads computed the same results
+    // ....................................................... 
+    bool ok = true;
+    for (unsigned int i = 1; i<NUM_THREADS; i++) {
+	if ( memcmp (&results_CPU[0], &results_CPU[i], sizeof(ResultType)) != 0) {
+            // warning: may the padding bytes be different ?
+            ok = false;
+	}
+	/*
+          if ( results_CPU[0].fnorm != results_CPU[i].fnorm
+          || results_CPU[0].nfev != results_CPU[i].nfev
+          || results_CPU[0].info != results_CPU[i].info
+          || results_CPU[0].rankJ != results_CPU[i].rankJ
+          )
+	  {
+          ok = false;
+	  }
+	*/
+    } // for
+		 
+
+    if (ok) {
+	fprintf (stderr, " !!! all threads computed the same results !!! \n\n");
+    } else {
+	fprintf (stderr, "ERROR in results of threads \n");
+    }
+
+    // ....................................................... 
+    // show the results !
+    // ....................................................... 
+
+    printf("      final l2 norm of the residuals%15.7g\n\n", results_CPU[0].fnorm);
+    printf("      number of function evaluations%10i\n\n", results_CPU[0].nfev);
+    printf("      exit parameter                %10i\n\n", results_CPU[0].info);
+    printf("      final approximate solution\n");
+
+    for (int j=0; j<NUM_PARAMS; j++)  {
+        printf("%15.7g", results_CPU[0].solution[j]);
+    }
+    printf("\n");
+
+    printf("      covariance\n");
+
+ 
+    for (unsigned int i=0; i<NUM_PARAMS; i++) {
+        for (unsigned int j=0; j<NUM_PARAMS; j++) {
+            printf("%15.7g", results_CPU[0].covar[i][j]);
+	} // for
+	printf ("\n");
+    } // for
+  
+    printf("\n");
+    printf(" rank(J) = %d\n", results_CPU[0].rankJ );
+    cutilSafeCall(cudaFree(results_GPU));
+    cutilSafeCall(cudaFreeHost(results_CPU));
+    cudaThreadExit();
+    //cutilExit(argc, argv);
+
+} // ()
diff --git a/cuda/fdjac1.cu b/cuda/fdjac1.cu
new file mode 100644
index 0000000..48c0b8f
--- /dev/null
+++ b/cuda/fdjac1.cu
@@ -0,0 +1,7 @@
+#ifndef FDJAC1_CU_INCLUDED
+#define FDJAC1_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include <fdjac1.c>
+
+#endif
diff --git a/cuda/fdjac2.cu b/cuda/fdjac2.cu
new file mode 100644
index 0000000..fd2bf5d
--- /dev/null
+++ b/cuda/fdjac2.cu
@@ -0,0 +1,7 @@
+#ifndef FDJAC2_CU_INCLUDED
+#define FDJAC2_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include <fdjac2.c>
+
+#endif
diff --git a/cuda/hybrd.cu b/cuda/hybrd.cu
new file mode 100644
index 0000000..4e8843b
--- /dev/null
+++ b/cuda/hybrd.cu
@@ -0,0 +1,14 @@
+#ifndef HYBRD_CU_INCLUDED
+#define HYBRD_CU_INCLUDED
+
+#include "dogleg.cu"
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include "fdjac1.cu"
+#include "qform.cu"
+#include "qrfac.cu"
+#include "r1mpyq.cu"
+#include "r1updt.cu"
+#include <hybrd.c>
+
+#endif
diff --git a/cuda/hybrd1.cu b/cuda/hybrd1.cu
new file mode 100644
index 0000000..7a7d973
--- /dev/null
+++ b/cuda/hybrd1.cu
@@ -0,0 +1,7 @@
+#ifndef HYBRD1_CU_INCLUDED
+#define HYBRD1_CU_INCLUDED
+
+#include "hybrd.cu"
+#include <hybrd1.c>
+
+#endif
diff --git a/cuda/hybrj.cu b/cuda/hybrj.cu
new file mode 100644
index 0000000..8ce4a7f
--- /dev/null
+++ b/cuda/hybrj.cu
@@ -0,0 +1,13 @@
+#ifndef HYBRJ_CU_INCLUDED
+#define HYBRJ_CU_INCLUDED
+
+#include "dogleg.cu"
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include "qform.cu"
+#include "qrfac.cu"
+#include "r1mpyq.cu"
+#include "r1updt.cu"
+#include <hybrj.c>
+
+#endif
diff --git a/cuda/hybrj1.cu b/cuda/hybrj1.cu
new file mode 100644
index 0000000..f05ae68
--- /dev/null
+++ b/cuda/hybrj1.cu
@@ -0,0 +1,7 @@
+#ifndef HYBRJ1_CU_INCLUDED
+#define HYBRJ1_CU_INCLUDED
+
+#include "hybrj.cu"
+#include <hybrj1.c>
+
+#endif
diff --git a/cuda/lmder.cu b/cuda/lmder.cu
new file mode 100644
index 0000000..c62cb74
--- /dev/null
+++ b/cuda/lmder.cu
@@ -0,0 +1,10 @@
+#ifndef LMDER_CU_INCLUDED
+#define LMDER_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include "lmpar.cu"
+#include "qrfac.cu"
+#include <lmder.c>
+
+#endif
diff --git a/cuda/lmder1.cu b/cuda/lmder1.cu
new file mode 100644
index 0000000..9279303
--- /dev/null
+++ b/cuda/lmder1.cu
@@ -0,0 +1,7 @@
+#ifndef LMDER1_CU_INCLUDED
+#define LMDER1_CU_INCLUDED
+
+#include "lmder.cu"
+#include <lmder1.c>
+
+#endif
diff --git a/cuda/lmdif.cu b/cuda/lmdif.cu
new file mode 100644
index 0000000..03ba9e1
--- /dev/null
+++ b/cuda/lmdif.cu
@@ -0,0 +1,11 @@
+#ifndef LMDIF_CU_INCLUDED
+#define LMDIF_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include "fdjac2.cu"
+#include "lmpar.cu"
+#include "qrfac.cu"
+#include <lmdif.c>
+
+#endif
diff --git a/cuda/lmdif1.cu b/cuda/lmdif1.cu
new file mode 100644
index 0000000..82ae542
--- /dev/null
+++ b/cuda/lmdif1.cu
@@ -0,0 +1,7 @@
+#ifndef LMDIF1_CU_INCLUDED
+#define LMDIF1_CU_INCLUDED
+
+#include "lmdif.cu"
+#include <lmdif1.c>
+
+#endif
diff --git a/cuda/lmpar.cu b/cuda/lmpar.cu
new file mode 100644
index 0000000..72b4fee
--- /dev/null
+++ b/cuda/lmpar.cu
@@ -0,0 +1,9 @@
+#ifndef LMPAR_CU_INCLUDED
+#define LMPAR_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include "qrsolv.cu"
+#include <lmpar.c>
+
+#endif
diff --git a/cuda/lmstr.cu b/cuda/lmstr.cu
new file mode 100644
index 0000000..2c2c0b6
--- /dev/null
+++ b/cuda/lmstr.cu
@@ -0,0 +1,11 @@
+#ifndef LMSTR_CU_INCLUDED
+#define LMSTR_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include "lmpar.cu"
+#include "qrfac.cu"
+#include "rwupdt.cu"
+#include <lmstr.c>
+
+#endif
diff --git a/cuda/lmstr1.cu b/cuda/lmstr1.cu
new file mode 100644
index 0000000..4f2b969
--- /dev/null
+++ b/cuda/lmstr1.cu
@@ -0,0 +1,7 @@
+#ifndef LMSTR1_CU_INCLUDED
+#define LMSTR1_CU_INCLUDED
+
+#include "lmstr.cu"
+#include <lmstr1.c>
+
+#endif
diff --git a/cuda/qform.cu b/cuda/qform.cu
new file mode 100644
index 0000000..094ca5b
--- /dev/null
+++ b/cuda/qform.cu
@@ -0,0 +1,6 @@
+#ifndef QFORM_CU_INCLUDED
+#define QFORM_CU_INCLUDED
+
+#include <qform.c>
+
+#endif
diff --git a/cuda/qrfac.cu b/cuda/qrfac.cu
new file mode 100644
index 0000000..a6799e7
--- /dev/null
+++ b/cuda/qrfac.cu
@@ -0,0 +1,8 @@
+#ifndef QRFAC_CU_INCLUDED
+#define QRFAC_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include "enorm.cu"
+#include <qrfac.c>
+
+#endif
diff --git a/cuda/qrsolv.cu b/cuda/qrsolv.cu
new file mode 100644
index 0000000..dba15f5
--- /dev/null
+++ b/cuda/qrsolv.cu
@@ -0,0 +1,6 @@
+#ifndef QRSOLV_CU_INCLUDED
+#define QRSOLV_CU_INCLUDED
+
+#include <qrsolv.c>
+
+#endif
diff --git a/cuda/r1mpyq.cu b/cuda/r1mpyq.cu
new file mode 100644
index 0000000..c10704c
--- /dev/null
+++ b/cuda/r1mpyq.cu
@@ -0,0 +1,6 @@
+#ifndef R1MPYQ_CU_INCLUDED
+#define R1MPYQ_CU_INCLUDED
+
+#include <r1mpyq.c>
+
+#endif
diff --git a/cuda/r1updt.cu b/cuda/r1updt.cu
new file mode 100644
index 0000000..5e9768e
--- /dev/null
+++ b/cuda/r1updt.cu
@@ -0,0 +1,7 @@
+#ifndef R1UPDT_CU_INCLUDED
+#define R1UPDT_CU_INCLUDED
+
+#include "dpmpar.cu"
+#include <r1updt.c>
+
+#endif
diff --git a/cuda/rwupdt.cu b/cuda/rwupdt.cu
new file mode 100644
index 0000000..6d30a0c
--- /dev/null
+++ b/cuda/rwupdt.cu
@@ -0,0 +1,6 @@
+#ifndef RWUPDT_CU_INCLUDED
+#define RWUPDT_CU_INCLUDED
+
+#include <rwupdt.c>
+
+#endif
diff --git a/dist-exclude b/dist-exclude
new file mode 100644
index 0000000..0216cc5
--- /dev/null
+++ b/dist-exclude
@@ -0,0 +1,71 @@
+.DS_Store
+*.out
+lib*.a
+*.dSYM
+.gitattributes
+.gitignore
+.git
+.svn
+CVS
+*.o
+*~
+#*#
+.#*
+cminpack-*.tar.gz
+build*
+CMakeFiles
+*.pbxuser
+*.perspectivev3
+DerivedData/*
+*.xcworkspacedata
+*.xcworkspace
+xcuserdata
+*.patch
+tchkderc
+tfdjac2c
+thybrd1c
+thybrdc
+thybrj1c
+thybrjc
+tlmderc
+tlmdif1c
+tlmdifc
+tlmstr1c
+tlmstrc
+tchkder_
+tfdjac2_
+thybrd1_
+thybrd_
+thybrj1_
+thybrj_
+tlmder_
+tlmdif1_
+tlmdif_
+tlmstr1_
+tlmstr_
+tchkder
+tfdjac2
+thybrd1
+thybrd
+thybrj1
+thybrj
+tlmder
+tlmdif1
+tlmdif
+tlmstr1
+tlmstr
+chkdrv
+chkdrvc
+hybdrv
+hybdrvc
+hyjdrv
+hyjdrvc
+lmddrv
+lmddrvc
+lmfdrv
+lmfdrvc
+lmsdrv
+lmsdrvc
+tchkderc_box
+thybrjc_box
+tlmderc_box
diff --git a/doc/hybrd1_.3 b/doc/hybrd1_.3
new file mode 100644
index 0000000..4ba1d32
--- /dev/null
+++ b/doc/hybrd1_.3
@@ -0,0 +1 @@
+.so man3/hybrd_.3
diff --git a/doc/hybrd_.3 b/doc/hybrd_.3
new file mode 100644
index 0000000..b3c98a7
--- /dev/null
+++ b/doc/hybrd_.3
@@ -0,0 +1,292 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH HYBRD_ 3 "March 8, 2002" Minpack
+.\" Please adjust this date whenever revising the manpage.
+.SH NAME
+hybrd_, hybrd1_ \- find a zero of a system of nonlinear function
+.SH SYNOPSIS
+.B #include <minpack.h>
+.sp
+.nh
+.ad l
+.HP 28
+.BI "void hybrd1_ ( "
+.BI "void (*" fcn ")("
+.BI "int *" n ,
+.BI "double *" x ,
+.br
+.BI "double *" fvec , 
+.BI "int *" iflag  ), 
+.RS 15
+.BI "int *" n , 
+.BI "double *" x , 
+.BI "double *" fvec , 
+.br
+.BI "double *" tol , 
+.BI "int *" info , 
+.BI "double *" wa , 
+.br
+.BI "int *" lwa );
+.RE
+.HP 27
+.BI "void hybrd_" 
+.BI "( void (*" fcn ")("
+.BI "int * " n , 
+.BI "double *" x , 
+.br
+.BI "double *" fvec , 
+.BI "int *" iflag ), 
+.RS 14
+.BI "int *" n , 
+.BI "double *" x , 
+.BI "double *" fvec , 
+.br
+.BI "double *" xtol , 
+.BI "int *" maxfev ,
+.BI "int *" ml , 
+.BI "int *" mu , 
+.br
+.BI "double *" epsfcn , 
+.BI "double *" diag , 
+.BI "int *" mode ,
+.BI "double *" factor , 
+.BI "int *" nprint , 
+.BI "int *" info , 
+.br
+.BI "int *" nfev ,
+.BI "double *" fjac , 
+.BI "int *" ldfjac , 
+.br
+.BI "double *" r , 
+.BI "int *" lr , 
+.BI "double *" qtf ,
+.br
+.BI "double *" wa1 , 
+.BI "double *" wa2 , 
+.BI "double *" wa3 , 
+.BI "double *" wa4 );
+.RE
+.hy
+.ad b
+.br
+.SH DESCRIPTION
+The purpose of \fBhybrd_\fP is to find a zero of a system of
+\fIn\fP nonlinear functions in \fIn\fP variables by a modification
+of the Powell hybrid method. The user must provide a
+subroutine which calculates the functions. The Jacobian is
+then calculated by a forward-difference approximation.
+.PP
+\fBhybrd1_\fP serves the same function but has a simplified calling
+sequence.
+.br
+.SS Language notes
+\fBhybrd_\fP and \fBhybrd1_\fP are written in FORTRAN. If calling from
+C, keep these points in mind:
+.TP
+Name mangling.
+With \fBg77\fP version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of \fBg77\fP.
+.TP
+Compile with \fBg77\fP.
+Even if your program is all C code, you should link with \fBg77\fP
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use \fBg77\fP to do all the compiling.  (It handles C just fine.)
+.TP
+Call by reference.
+All function parameters must be pointers.
+.TP
+Column-major arrays.
+Suppose a function returns an array with 5 rows and 3 columns in an
+array \fIz\fP and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+.sp
+.nf
+	z(1,1)		z[0]
+	z(2,1)		z[1]
+	z(5,1)		z[4]
+	z(1,2)		z[7]
+	z(1,3)		z[14]
+	z(i,j)		z[(i-1) + (j-1)*7]
+.fi
+.SS Parameters for both functions
+\fIfcn\fP is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, \fIfcn\fP must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+.sp
+.nf
+subroutine fcn(n,x,fvec,iflag)
+integer n,iflag
+double precision x(n),fvec(n)
+----------
+calculate the functions at x and
+return this vector in fvec.
+---------
+return
+end
+.fi
+.sp
+.sp
+In C, \fIfcn\fP should be written as follows:
+.sp
+.nf
+  void fcn(int n, double *x, double *fvec, int *iflag)
+  {
+    /* calculate the functions at x and
+       return this vector in fvec. */
+  }
+.fi
+.sp
+The value of \fIiflag\fP should not be changed by \fIfcn\fP unless
+the user wants to terminate execution of \fBhybrd_\fP.
+In this case set \fIiflag\fP to a negative integer.
+
+\fIn\fP is a positive integer input variable set to the number
+of functions and variables.
+
+\fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain
+an initial estimate of the solution vector. On output \fIx\fP
+contains the final estimate of the solution vector.
+
+\fIfvec\fP is an output array of length \fIn\fP which contains
+the functions evaluated at the output \fIx\fP.
+.br
+.SS Parameters for \fBhybrd1_\fP
+
+\fItol\fP is a nonnegative input variable. Termination occurs
+when the algorithm estimates that the relative error
+between \fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise,
+\fIinfo\fP is set as follows.
+
+\fIinfo\fP = 0   improper input parameters.
+
+\fIinfo\fP = 1   algorithm estimates that the relative error
+           between \fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP = 2   number of calls to fcn has reached or exceeded
+           200*(\fIn\fP+1).
+
+\fIinfo\fP = 3   \fItol\fP is too small. No further improvement in
+           the approximate solution \fIx\fP is possible.
+
+\fIinfo\fP = 4   iteration is not making good progress.
+
+\fIwa\fP is a work array of length \fIlwa\fP.
+
+\fIlwa\fP is a positive integer input variable not less than
+(\fIn\fP*(3*\fIn\fP+13))/2.
+.br
+.SS Parameters for \fBhybrd_\fP
+
+\fIxtol\fP is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most \fIxtol\fP.
+
+\fImaxfev\fP is a positive integer input variable. Termination
+occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP
+by the end of an iteration.
+
+\fIml\fP is a nonnegative integer input variable which specifies
+the number of subdiagonals within the band of the
+jacobian matrix. If the Jacobian is not banded, set
+\fIml\fP to at least \fIn\fP - 1.
+
+\fImu\fP is a nonnegative integer input variable which specifies
+the number of superdiagonals within the band of the
+jacobian matrix. If the jacobian is not banded, set
+mu to at least \fIn\fP - 1.
+
+\fIepsfcn\fP is an input variable used in determining a suitable
+step length for the forward-difference approximation. This
+approximation assumes that the relative errors in the
+functions are of the order of \fIepsfcn\fP. If \fIepsfcn\fP is less
+than the machine precision, it is assumed that the relative
+errors in the functions are of the order of the machine
+precision.
+
+\fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see
+below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+
+\fImode\fP is an integer input variable. If \fImode\fP = 1, the
+variables will be scaled internally. If \fImode\fP = 2,
+the scaling is specified by the input \fIdiag\fP. Other
+values of mode are equivalent to \fImode\fP = 1.
+
+\fIfactor\fP is a positive input variable used in determining the
+initial step bound. This bound is set to the product of
+\fIfactor\fP and the euclidean norm of diag*x if nonzero, or else
+to \fIfactor\fP itself. In most cases factor should lie in the
+interval (.1,100.). 100. Is a generally recommended value.
+
+\fInprint\fP is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case,
+\fIfcn\fP is called with \fIiflag\fP = 0 at the beginning of the first
+iteration and every nprint iterations thereafter and
+immediately prior to return, with \fIx\fP and \fIfvec\fP available
+for printing. If \fInprint\fP is not positive, no special calls
+of \fIfcn\fP with \fIiflag\fP = 0 are made.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise,
+\fIinfo\fP is set as follows.
+
+\fIinfo\fP = 0   improper input parameters.
+
+\fIinfo\fP = 1   relative error between two consecutive iterates
+           is at most \fIxtol\fP.
+
+\fIinfo\fP = 2   number of calls to \fIfcn\fP has reached or exceeded
+           \fImaxfev\fP.
+
+\fIinfo\fP = 3   \fIxtol\fP is too small. No further improvement in
+           the approximate solution \fIx\fP is possible.
+
+\fIinfo\fP = 4   iteration is not making good progress, as
+           measured by the improvement from the last
+           five jacobian evaluations.
+
+\fIinfo\fP = 5   iteration is not making good progress, as
+           measured by the improvement from the last
+           ten iterations.
+
+\fInfev\fP is an integer output variable set to the number of
+calls to \fIfcn\fP.
+
+\fIfjac\fP is an output \fIn\fP by \fIn\fP array which contains the
+orthogonal matrix \fIq\fP produced by the \fIqr\fP factorization
+of the final approximate jacobian.
+
+\fIldfjac\fP is a positive integer input variable not less than \fIn\fP
+which specifies the leading dimension of the array \fIfjac\fP.
+
+\fIr\fP is an output array of length \fIlr\fP which contains the
+upper triangular matrix produced by the \fIqr\fP factorization
+of the final approximate Jacobian, stored rowwise.
+
+\fIlr\fP is a positive integer input variable not less than
+(\fIn\fP*(\fIn\fP+1))/2.
+
+\fIqtf\fP is an output array of length \fIn\fP which contains
+the vector (q transpose)*\fIfvec\fP.
+
+\fIwa1\fP, \fIwa2\fP, \fIwa3\fP, and \fIwa4\fP are work arrays of length \fIn\fP.
+
+.SH SEE ALSO
+.BR hybrj (3),
+.BR hybrj1 (3).
+.br
+
+.SH AUTHORS
+Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More.
+.br
+This manual page was written by Jim Van Zandt <jrv at debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
diff --git a/doc/hybrd_.html b/doc/hybrd_.html
new file mode 100644
index 0000000..7bf09b2
--- /dev/null
+++ b/doc/hybrd_.html
@@ -0,0 +1,391 @@
+<HTML><HEAD><TITLE>Manpage of HYBRD_</TITLE>
+</HEAD><BODY>
+<H1>HYBRD_</H1>
+Section: C Library Functions (3)<BR>Updated: March 8, 2002<BR><A HREF="#index">Index</A>
+<A HREF="index.html">Return to Main Contents</A><HR>
+
+
+<A NAME="lbAB"> </A>
+<H2>NAME</H2>
+
+hybrd_, hybrd1_ - find a zero of a system of nonlinear function
+<A NAME="lbAC"> </A>
+<H2>SYNOPSIS</H2>
+
+<B>#include <<A HREF="file:/usr/include/minpack.h">minpack.h</A>></B>
+
+<P>
+
+
+<DL COMPACT>
+<DT>
+<B>void hybrd1_ ( </B>
+
+<B>void (*</B><I>fcn</I><B>)(</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<DD>
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<DD>
+<B>double *</B><I>tol</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>double *</B><I>wa</I><B>,</B>
+
+<DD>
+<B>int *</B><I>lwa</I><B>);</B>
+
+</DL>
+
+<DT>
+<B>void hybrd_</B>
+
+<B>( void (*</B><I>fcn</I><B>)(</B>
+
+<B>int * </B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<DD>
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<DD>
+<B>double *</B><I>xtol</I><B>,</B>
+
+<B>int *</B><I>maxfev</I><B>,</B>
+
+<B>int *</B><I>ml</I><B>,</B>
+
+<B>int *</B><I>mu</I><B>,</B>
+
+<DD>
+<B>double *</B><I>epsfcn</I><B>,</B>
+
+<B>double *</B><I>diag</I><B>,</B>
+
+<B>int *</B><I>mode</I><B>,</B>
+
+<B>double *</B><I>factor</I><B>,</B>
+
+<B>int *</B><I>nprint</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<DD>
+<B>int *</B><I>nfev</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>r</I><B>,</B>
+
+<B>int *</B><I>lr</I><B>,</B>
+
+<B>double *</B><I>qtf</I><B>,</B>
+
+<DD>
+<B>double *</B><I>wa1</I><B>,</B>
+
+<B>double *</B><I>wa2</I><B>,</B>
+
+<B>double *</B><I>wa3</I><B>,</B>
+
+<B>double *</B><I>wa4</I><B>);</B>
+
+</DL>
+
+
+
+<DD>
+</DL>
+<A NAME="lbAD"> </A>
+<H2>DESCRIPTION</H2>
+
+<DD>The purpose of <B>hybrd_</B> is to find a zero of a system of
+<I>n</I> nonlinear functions in <I>n</I> variables by a modification
+of the Powell hybrid method. The user must provide a
+subroutine which calculates the functions. The Jacobian is
+then calculated by a forward-difference approximation.
+<P>
+
+<B>hybrd1_</B> serves the same function but has a simplified calling
+sequence.
+<BR>
+
+<A NAME="lbAE"> </A>
+<H3>Language notes</H3>
+
+<B>hybrd_</B> and <B>hybrd1_</B> are written in FORTRAN. If calling from
+C, keep these points in mind:
+<DL COMPACT>
+<DT>Name mangling.<DD>
+With <B>g77</B> version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of <B>g77</B>.
+<DT>Compile with <B>g77</B>.<DD>
+Even if your program is all C code, you should link with <B>g77</B>
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use <B>g77</B> to do all the compiling.  (It handles C just fine.)
+<DT>Call by reference.<DD>
+All function parameters must be pointers.
+<DT>Column-major arrays.<DD>
+Suppose a function returns an array with 5 rows and 3 columns in an
+array <I>z</I> and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+<P>
+<PRE>
+        z(1,1)          z[0]
+        z(2,1)          z[1]
+        z(5,1)          z[4]
+        z(1,2)          z[7]
+        z(1,3)          z[14]
+        z(i,j)          z[(i-1) + (j-1)*7]
+</PRE>
+
+</DL>
+<A NAME="lbAF"> </A>
+<H3>Parameters for both functions</H3>
+
+<I>fcn</I> is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, <I>fcn</I> must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+<P>
+<PRE>
+subroutine fcn(n,x,fvec,iflag)
+integer n,iflag
+double precision x(n),fvec(n)
+----------
+calculate the functions at x and
+return this vector in fvec.
+---------
+return
+end
+</PRE>
+
+<P>
+<P>
+In C, <I>fcn</I> should be written as follows:
+<P>
+<PRE>
+  void fcn(int n, double *x, double *fvec, int *iflag)
+  {
+    /* calculate the functions at x and
+       return this vector in fvec. */
+  }
+</PRE>
+
+<P>
+The value of <I>iflag</I> should not be changed by <I>fcn</I> unless
+the user wants to terminate execution of <B>hybrd_</B>.
+In this case set <I>iflag</I> to a negative integer.
+<P>
+<I>n</I> is a positive integer input variable set to the number
+of functions and variables.
+<P>
+<I>x</I> is an array of length <I>n</I>. On input <I>x</I> must contain
+an initial estimate of the solution vector. On output <I>x</I>
+contains the final estimate of the solution vector.
+<P>
+<I>fvec</I> is an output array of length <I>n</I> which contains
+the functions evaluated at the output <I>x</I>.
+<BR>
+
+<A NAME="lbAG"> </A>
+<H3>Parameters for <B>hybrd1_</B></H3>
+
+<P>
+<I>tol</I> is a nonnegative input variable. Termination occurs
+when the algorithm estimates that the relative error
+between <I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of <I>iflag</I>. See description of <I>fcn</I>. Otherwise,
+<I>info</I> is set as follows.
+<P>
+<I>info</I> = 0   improper input parameters.
+<P>
+<I>info</I> = 1   algorithm estimates that the relative error
+<BR>           between <I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> = 2   number of calls to fcn has reached or exceeded
+<BR>           200*(<I>n</I>+1).
+<P>
+<I>info</I> = 3   <I>tol</I> is too small. No further improvement in
+<BR>           the approximate solution <I>x</I> is possible.
+<P>
+<I>info</I> = 4   iteration is not making good progress.
+<P>
+<I>wa</I> is a work array of length <I>lwa</I>.
+<P>
+<I>lwa</I> is a positive integer input variable not less than
+(<I>n</I>*(3*<I>n</I>+13))/2.
+<BR>
+
+<A NAME="lbAH"> </A>
+<H3>Parameters for <B>hybrd_</B></H3>
+
+<P>
+<I>xtol</I> is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most <I>xtol</I>.
+<P>
+<I>maxfev</I> is a positive integer input variable. Termination
+occurs when the number of calls to <I>fcn</I> is at least <I>maxfev</I>
+by the end of an iteration.
+<P>
+<I>ml</I> is a nonnegative integer input variable which specifies
+the number of subdiagonals within the band of the
+jacobian matrix. If the Jacobian is not banded, set
+<I>ml</I> to at least <I>n</I> - 1.
+<P>
+<I>mu</I> is a nonnegative integer input variable which specifies
+the number of superdiagonals within the band of the
+jacobian matrix. If the jacobian is not banded, set
+mu to at least <I>n</I> - 1.
+<P>
+<I>epsfcn</I> is an input variable used in determining a suitable
+step length for the forward-difference approximation. This
+approximation assumes that the relative errors in the
+functions are of the order of <I>epsfcn</I>. If <I>epsfcn</I> is less
+than the machine precision, it is assumed that the relative
+errors in the functions are of the order of the machine
+precision.
+<P>
+<I>diag</I> is an array of length <I>n</I>. If <I>mode</I> = 1 (see
+below), <I>diag</I> is internally set. If <I>mode</I> = 2, <I>diag</I>
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+<P>
+<I>mode</I> is an integer input variable. If <I>mode</I> = 1, the
+variables will be scaled internally. If <I>mode</I> = 2,
+the scaling is specified by the input <I>diag</I>. Other
+values of mode are equivalent to <I>mode</I> = 1.
+<P>
+<I>factor</I> is a positive input variable used in determining the
+initial step bound. This bound is set to the product of
+<I>factor</I> and the euclidean norm of diag*x if nonzero, or else
+to <I>factor</I> itself. In most cases factor should lie in the
+interval (.1,100.). 100. Is a generally recommended value.
+<P>
+<I>nprint</I> is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case,
+<I>fcn</I> is called with <I>iflag</I> = 0 at the beginning of the first
+iteration and every nprint iterations thereafter and
+immediately prior to return, with <I>x</I> and <I>fvec</I> available
+for printing. If <I>nprint</I> is not positive, no special calls
+of <I>fcn</I> with <I>iflag</I> = 0 are made.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of <I>iflag</I>. See description of <I>fcn</I>. Otherwise,
+<I>info</I> is set as follows.
+<P>
+<I>info</I> = 0   improper input parameters.
+<P>
+<I>info</I> = 1   relative error between two consecutive iterates
+<BR>           is at most <I>xtol</I>.
+<P>
+<I>info</I> = 2   number of calls to <I>fcn</I> has reached or exceeded
+<BR>           <I>maxfev</I>.
+<P>
+<I>info</I> = 3   <I>xtol</I> is too small. No further improvement in
+<BR>           the approximate solution <I>x</I> is possible.
+<P>
+<I>info</I> = 4   iteration is not making good progress, as
+<BR>           measured by the improvement from the last
+<BR>           five jacobian evaluations.
+<P>
+<I>info</I> = 5   iteration is not making good progress, as
+<BR>           measured by the improvement from the last
+<BR>           ten iterations.
+<P>
+<I>nfev</I> is an integer output variable set to the number of
+calls to <I>fcn</I>.
+<P>
+<I>fjac</I> is an output <I>n</I> by <I>n</I> array which contains the
+orthogonal matrix <I>q</I> produced by the <I>qr</I> factorization
+of the final approximate jacobian.
+<P>
+<I>ldfjac</I> is a positive integer input variable not less than <I>n</I>
+which specifies the leading dimension of the array <I>fjac</I>.
+<P>
+<I>r</I> is an output array of length <I>lr</I> which contains the
+upper triangular matrix produced by the <I>qr</I> factorization
+of the final approximate Jacobian, stored rowwise.
+<P>
+<I>lr</I> is a positive integer input variable not less than
+(<I>n</I>*(<I>n</I>+1))/2.
+<P>
+<I>qtf</I> is an output array of length <I>n</I> which contains
+the vector (q transpose)*<I>fvec</I>.
+<P>
+<I>wa1</I>, <I>wa2</I>, <I>wa3</I>, and <I>wa4</I> are work arrays of length <I>n</I>.
+<P>
+<A NAME="lbAI"> </A>
+<H2>SEE ALSO</H2>
+
+<B><A HREF="hybrj_.html">hybrj</A></B>(3),
+
+<B><A HREF="hybrj_.html">hybrj1</A></B>(3).
+
+<BR>
+
+<P>
+<A NAME="lbAJ"> </A>
+<H2>AUTHORS</H2>
+
+Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More.
+<BR>
+
+This manual page was written by Jim Van Zandt <<A HREF="mailto:jrv at debian.org">jrv at debian.org</A>>,
+for the Debian GNU/Linux system (but may be used by others).
+<P>
+
+<HR>
+<A NAME="index"> </A><H2>Index</H2>
+<DL>
+<DT><A HREF="#lbAB">NAME</A><DD>
+<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
+<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
+<DL>
+<DT><A HREF="#lbAE">Language notes</A><DD>
+<DT><A HREF="#lbAF">Parameters for both functions</A><DD>
+<DT><A HREF="#lbAG">Parameters for <B>hybrd1_</B></A><DD>
+<DT><A HREF="#lbAH">Parameters for <B>hybrd_</B></A><DD>
+</DL>
+<DT><A HREF="#lbAI">SEE ALSO</A><DD>
+<DT><A HREF="#lbAJ">AUTHORS</A><DD>
+</DL>
+<HR>
+This document was created by
+<A HREF="index.html">man2html</A>,
+using the manual pages.<BR>
+Time: 10:19:50 GMT, April 20, 2007
+</BODY>
+</HTML>
diff --git a/doc/hybrj1_.3 b/doc/hybrj1_.3
new file mode 100644
index 0000000..398001c
--- /dev/null
+++ b/doc/hybrj1_.3
@@ -0,0 +1 @@
+.so man3/hybrj_.3
diff --git a/doc/hybrj_.3 b/doc/hybrj_.3
new file mode 100644
index 0000000..4c9c82f
--- /dev/null
+++ b/doc/hybrj_.3
@@ -0,0 +1,282 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH HYBRJ_ 3 "March 8, 2002" Minpack
+.\" Please adjust this date whenever revising the manpage.
+.SH NAME
+hybrj_, hybrj1_ \- find a zero of a system of nonlinear function
+.SH SYNOPSIS
+.B #include <minpack.h>
+.nh
+.ad l
+.HP 14
+.BI "void hybrj1_ (void (*" fcn ")(int *" n  , 
+.BI "double *" x , 
+.BI "double *" fvec , 
+.BI "double *" fjec , 
+.BI "int *" ldfjac , 
+.BI "int *" iflag ), 
+.RS 4
+.BI "int *" n , 
+.BI "double *" x , 
+.BI "double *" fvec , 
+.BI "double *" fjac , 
+.br
+.BI "int *" ldfjac , 
+.br
+.BI "double *" tol , 
+.BI "int *" info , 
+.BI "double *" wa , 
+.BI "int *" lwa );
+.RE          
+
+.HP 13
+.BI "void hybrj_ (void (*" fcn ")(int *" n , 
+.BI "double *" x , 
+.BI "double *" fvec , 
+.BI "double *" fjec ,
+.BI "int *" ldfjac , 
+.BI "int *" iflag ), 
+.RS 4
+.BI "int *" n , 
+.BI "double *" x ,
+.BI "double *" fvec , 
+.BI "double *" fjac , 
+.br
+.BI "int *" ldfjac , 
+.br
+.BI "double *" xtol ,
+.BI "int *" maxfev , 
+.BI "double *" diag , 
+.BI "int *" mode , 
+.BI "double *" factor ,
+.BI "int *" nprint , 
+.BI "int *" info , 
+.BI "int *" nfev , 
+.br
+.BI "int *" njev , 
+.BI "double *" r ,
+.BI "int *" lr , 
+.BI "double *" qtf , 
+.br
+.BI "double *" wa1 , 
+.BI "double *" wa2 ,
+.BI "double *" wa3 , 
+.BI "double *" wa4 );
+.RE
+.hy
+.ad b
+.br
+.SH DESCRIPTION
+The purpose of \fBhybrj_\fP is to find a zero of a system of
+\fIn\fP nonlinear functions in \fIn\fP variables by a modification
+of the Powell hybrid method. The user must provide a
+subroutine which calculates the functions and the Jacobian.
+.PP
+\fBhybrj1_\fP serves the same function but has a simplified calling
+sequence.
+.br
+.SS Language notes
+\fBhybrj_\fP and \fBhybrj1_\fP are written in FORTRAN. If calling from
+C, keep these points in mind:
+.TP
+Name mangling.
+With \fBg77\fP version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of \fBg77\fP.
+.TP
+Compile with \fBg77\fP.
+Even if your program is all C code, you should link with \fBg77\fP
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use \fBg77\fP to do all the compiling.  (It handles C just fine.)
+.TP
+Call by reference.
+All function parameters must be pointers.
+.TP
+Column-major arrays.
+Suppose a function returns an array with 5 rows and 3 columns in an
+array \fIz\fP and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+.sp
+.nf
+	z(1,1)		z[0]
+	z(2,1)		z[1]
+	z(5,1)		z[4]
+	z(1,2)		z[7]
+	z(1,3)		z[14]
+	z(i,j)		z[(i-1) + (j-1)*7]
+.fi
+.SS Parameters for both functions
+\fIfcn\fP is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, \fIfcn\fP must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+.sp
+.nf
+subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+integer n,ldfjac,iflag
+double precision x(n),fvec(n),fjac(ldfjac,n)
+----------
+if iflag = 1 calculate the functions at x and
+return this vector in fvec. do not alter fjac.
+if iflag = 2 calculate the jacobian at x and
+return this matrix in fjac. do not alter fvec.
+---------
+return
+end
+.fi
+.sp
+.sp
+In C, \fIfcn\fP should be written as follows:
+.sp
+.nf
+  void fcn(int n, double *x, double *fvec, double *fjac, 
+           int *ldfjac, int *iflag)
+  {
+  /* if iflag = 1 calculate the functions at x and
+     return this vector in fvec. do not alter fjac.
+     if iflag = 2 calculate the jacobian at x and
+     return this matrix in fjac. do not alter fvec. */
+  }
+.fi
+.sp
+The value of \fIiflag\fP should not be changed by \fIfcn\fP unless
+the user wants to terminate execution of hybrj_.
+In this case set \fIiflag\fP to a negative integer.
+
+\fIn\fP is a positive integer input variable set to the number
+of functions and variables.
+
+\fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain
+an initial estimate of the solution vector. On output \fIx\fP
+contains the final estimate of the solution vector.
+
+\fIfjac\fP is an output \fIn\fP by \fIn\fP array which contains the
+orthogonal matrix q produced by the qr factorization
+of the final approximate jacobian.
+
+\fIldfjac\fP is a positive integer input variable not less than \fIn\fP
+which specifies the leading dimension of the array \fIfjac\fP.
+
+\fIfvec\fP is an output array of length \fIn\fP which contains
+the functions evaluated at the output \fIx\fP.
+.br
+.SS Parameters for \fBhybrj1_\fP
+
+\fItol\fP is a nonnegative input variable. Termination occurs
+when the algorithm estimates that the relative error
+between \fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise,
+\fIinfo\fP is set as follows.
+
+\fIinfo\fP = 0   improper input parameters.
+
+\fIinfo\fP = 1   algorithm estimates that the relative error
+           between \fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP = 2   number of calls to fcn has reached or exceeded
+           200*(\fIn\fP+1).
+
+\fIinfo\fP = 3   \fItol\fP is too small. No further improvement in
+           the approximate solution \fIx\fP is possible.
+
+\fIinfo\fP = 4   iteration is not making good progress.
+
+\fIwa\fP is a work array of length \fIlwa\fP.
+
+\fIlwa\fP is a positive integer input variable not less than
+(\fIn\fP*(3*\fIn\fP+13))/2.
+.br
+.SS Parameters for \fBhybrj_\fP
+
+\fIxtol\fP is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most \fIxtol\fP.
+
+\fImaxfev\fP is a positive integer input variable. Termination
+occurs when the number of calls to \fIfcn\fP is at least \fImaxfev\fP
+by the end of an iteration.
+
+\fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see
+below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+
+\fImode\fP is an integer input variable. If \fImode\fP = 1, the
+variables will be scaled internally. If \fImode\fP = 2,
+the scaling is specified by the input \fIdiag\fP. Other
+values of mode are equivalent to \fImode\fP = 1.
+
+\fIfactor\fP is a positive input variable used in determining the
+initial step bound. This bound is set to the product of
+\fIfactor\fP and the euclidean norm of diag*x if nonzero, or else
+to \fIfactor\fP itself. In most cases factor should lie in the
+interval (.1,100.). 100. Is a generally recommended value.
+
+\fInprint\fP is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case,
+\fIfcn\fP is called with \fIiflag\fP = 0 at the beginning of the first
+iteration and every nprint iterations thereafter and
+immediately prior to return, with \fIx\fP and \fIfvec\fP available
+for printing. If \fInprint\fP is not positive, no special calls
+of \fIfcn\fP with \fIiflag\fP = 0 are made.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of \fIiflag\fP. See description of \fIfcn\fP. Otherwise,
+\fIinfo\fP is set as follows.
+
+\fIinfo\fP = 0   improper input parameters.
+
+\fIinfo\fP = 1   relative error between two consecutive iterates
+           is at most \fIxtol\fP.
+
+\fIinfo\fP = 2   number of calls to \fIfcn\fP has reached or exceeded
+           \fImaxfev\fP.
+
+\fIinfo\fP = 3   \fIxtol\fP is too small. No further improvement in
+           the approximate solution \fIx\fP is possible.
+
+\fIinfo\fP = 4   iteration is not making good progress, as
+           measured by the improvement from the last
+           five jacobian evaluations.
+
+\fIinfo\fP = 5   iteration is not making good progress, as
+           measured by the improvement from the last
+           ten iterations.
+
+\fInfev\fP is an integer output variable set to the number of
+calls to \fIfcn\fP.
+
+\fIfjac\fP is an output \fIn\fP by \fIn\fP array which contains the
+orthogonal matrix \fIq\fP produced by the \fIqr\fP factorization
+of the final approximate jacobian.
+
+\fIldfjac\fP is a positive integer input variable not less than \fIn\fP
+which specifies the leading dimension of the array \fIfjac\fP.
+
+\fIr\fP is an output array of length \fIlr\fP which contains the
+upper triangular matrix produced by the \fIqr\fP factorization
+of the final approximate Jacobian, stored rowwise.
+
+\fIlr\fP is a positive integer input variable not less than
+(\fIn\fP*(\fIn\fP+1))/2.
+
+\fIqtf\fP is an output array of length \fIn\fP which contains
+the vector (q transpose)*\fIfvec\fP.
+
+\fIwa1\fP, \fIwa2\fP, \fIwa3\fP, and \fIwa4\fP are work arrays of length \fIn\fP.
+
+.SH SEE ALSO
+.BR hybrd (3),
+.BR hybrd1 (3).
+.br
+
+.SH AUTHORS
+Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More.
+.br
+This manual page was written by Jim Van Zandt <jrv at debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
diff --git a/doc/hybrj_.html b/doc/hybrj_.html
new file mode 100644
index 0000000..14451a5
--- /dev/null
+++ b/doc/hybrj_.html
@@ -0,0 +1,381 @@
+<HTML><HEAD><TITLE>Manpage of HYBRJ_</TITLE>
+</HEAD><BODY>
+<H1>HYBRJ_</H1>
+Section: C Library Functions (3)<BR>Updated: March 8, 2002<BR><A HREF="#index">Index</A>
+<A HREF="index.html">Return to Main Contents</A><HR>
+
+
+<A NAME="lbAB"> </A>
+<H2>NAME</H2>
+
+hybrj_, hybrj1_ - find a zero of a system of nonlinear function
+<A NAME="lbAC"> </A>
+<H2>SYNOPSIS</H2>
+
+<B>#include <<A HREF="file:/usr/include/minpack.h">minpack.h</A>></B>
+
+
+
+<DL COMPACT>
+<DT>
+<B>void hybrj1_ (void (*</B><I>fcn</I><B>)(int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjec</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<DD>
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>tol</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>double *</B><I>wa</I><B>,</B>
+
+<B>int *</B><I>lwa</I><B>);</B>
+
+</DL>
+
+<P>
+<DT>
+<B>void hybrj_ (void (*</B><I>fcn</I><B>)(int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjec</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<DD>
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>xtol</I><B>,</B>
+
+<B>int *</B><I>maxfev</I><B>,</B>
+
+<B>double *</B><I>diag</I><B>,</B>
+
+<B>int *</B><I>mode</I><B>,</B>
+
+<B>double *</B><I>factor</I><B>,</B>
+
+<B>int *</B><I>nprint</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>int *</B><I>nfev</I><B>,</B>
+
+<DD>
+<B>int *</B><I>njev</I><B>,</B>
+
+<B>double *</B><I>r</I><B>,</B>
+
+<B>int *</B><I>lr</I><B>,</B>
+
+<B>double *</B><I>qtf</I><B>,</B>
+
+<DD>
+<B>double *</B><I>wa1</I><B>,</B>
+
+<B>double *</B><I>wa2</I><B>,</B>
+
+<B>double *</B><I>wa3</I><B>,</B>
+
+<B>double *</B><I>wa4</I><B>);</B>
+
+</DL>
+
+
+
+<DD>
+</DL>
+<A NAME="lbAD"> </A>
+<H2>DESCRIPTION</H2>
+
+<DD>The purpose of <B>hybrj_</B> is to find a zero of a system of
+<I>n</I> nonlinear functions in <I>n</I> variables by a modification
+of the Powell hybrid method. The user must provide a
+subroutine which calculates the functions and the Jacobian.
+<P>
+
+<B>hybrj1_</B> serves the same function but has a simplified calling
+sequence.
+<BR>
+
+<A NAME="lbAE"> </A>
+<H3>Language notes</H3>
+
+<B>hybrj_</B> and <B>hybrj1_</B> are written in FORTRAN. If calling from
+C, keep these points in mind:
+<DL COMPACT>
+<DT>Name mangling.<DD>
+With <B>g77</B> version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of <B>g77</B>.
+<DT>Compile with <B>g77</B>.<DD>
+Even if your program is all C code, you should link with <B>g77</B>
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use <B>g77</B> to do all the compiling.  (It handles C just fine.)
+<DT>Call by reference.<DD>
+All function parameters must be pointers.
+<DT>Column-major arrays.<DD>
+Suppose a function returns an array with 5 rows and 3 columns in an
+array <I>z</I> and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+<P>
+<PRE>
+        z(1,1)          z[0]
+        z(2,1)          z[1]
+        z(5,1)          z[4]
+        z(1,2)          z[7]
+        z(1,3)          z[14]
+        z(i,j)          z[(i-1) + (j-1)*7]
+</PRE>
+
+</DL>
+<A NAME="lbAF"> </A>
+<H3>Parameters for both functions</H3>
+
+<I>fcn</I> is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, <I>fcn</I> must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+<P>
+<PRE>
+subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+integer n,ldfjac,iflag
+double precision x(n),fvec(n),fjac(ldfjac,n)
+----------
+if iflag = 1 calculate the functions at x and
+return this vector in fvec. do not alter fjac.
+if iflag = 2 calculate the jacobian at x and
+return this matrix in fjac. do not alter fvec.
+---------
+return
+end
+</PRE>
+
+<P>
+<P>
+In C, <I>fcn</I> should be written as follows:
+<P>
+<PRE>
+  void fcn(int n, double *x, double *fvec, double *fjac, 
+           int *ldfjac, int *iflag)
+  {
+  /* if iflag = 1 calculate the functions at x and
+     return this vector in fvec. do not alter fjac.
+     if iflag = 2 calculate the jacobian at x and
+     return this matrix in fjac. do not alter fvec. */
+  }
+</PRE>
+
+<P>
+The value of <I>iflag</I> should not be changed by <I>fcn</I> unless
+the user wants to terminate execution of hybrj_.
+In this case set <I>iflag</I> to a negative integer.
+<P>
+<I>n</I> is a positive integer input variable set to the number
+of functions and variables.
+<P>
+<I>x</I> is an array of length <I>n</I>. On input <I>x</I> must contain
+an initial estimate of the solution vector. On output <I>x</I>
+contains the final estimate of the solution vector.
+<P>
+<I>fjac</I> is an output <I>n</I> by <I>n</I> array which contains the
+orthogonal matrix q produced by the qr factorization
+of the final approximate jacobian.
+<P>
+<I>ldfjac</I> is a positive integer input variable not less than <I>n</I>
+which specifies the leading dimension of the array <I>fjac</I>.
+<P>
+<I>fvec</I> is an output array of length <I>n</I> which contains
+the functions evaluated at the output <I>x</I>.
+<BR>
+
+<A NAME="lbAG"> </A>
+<H3>Parameters for <B>hybrj1_</B></H3>
+
+<P>
+<I>tol</I> is a nonnegative input variable. Termination occurs
+when the algorithm estimates that the relative error
+between <I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of <I>iflag</I>. See description of <I>fcn</I>. Otherwise,
+<I>info</I> is set as follows.
+<P>
+<I>info</I> = 0   improper input parameters.
+<P>
+<I>info</I> = 1   algorithm estimates that the relative error
+<BR>           between <I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> = 2   number of calls to fcn has reached or exceeded
+<BR>           200*(<I>n</I>+1).
+<P>
+<I>info</I> = 3   <I>tol</I> is too small. No further improvement in
+<BR>           the approximate solution <I>x</I> is possible.
+<P>
+<I>info</I> = 4   iteration is not making good progress.
+<P>
+<I>wa</I> is a work array of length <I>lwa</I>.
+<P>
+<I>lwa</I> is a positive integer input variable not less than
+(<I>n</I>*(3*<I>n</I>+13))/2.
+<BR>
+
+<A NAME="lbAH"> </A>
+<H3>Parameters for <B>hybrj_</B></H3>
+
+<P>
+<I>xtol</I> is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most <I>xtol</I>.
+<P>
+<I>maxfev</I> is a positive integer input variable. Termination
+occurs when the number of calls to <I>fcn</I> is at least <I>maxfev</I>
+by the end of an iteration.
+<P>
+<I>diag</I> is an array of length <I>n</I>. If <I>mode</I> = 1 (see
+below), <I>diag</I> is internally set. If <I>mode</I> = 2, <I>diag</I>
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+<P>
+<I>mode</I> is an integer input variable. If <I>mode</I> = 1, the
+variables will be scaled internally. If <I>mode</I> = 2,
+the scaling is specified by the input <I>diag</I>. Other
+values of mode are equivalent to <I>mode</I> = 1.
+<P>
+<I>factor</I> is a positive input variable used in determining the
+initial step bound. This bound is set to the product of
+<I>factor</I> and the euclidean norm of diag*x if nonzero, or else
+to <I>factor</I> itself. In most cases factor should lie in the
+interval (.1,100.). 100. Is a generally recommended value.
+<P>
+<I>nprint</I> is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case,
+<I>fcn</I> is called with <I>iflag</I> = 0 at the beginning of the first
+iteration and every nprint iterations thereafter and
+immediately prior to return, with <I>x</I> and <I>fvec</I> available
+for printing. If <I>nprint</I> is not positive, no special calls
+of <I>fcn</I> with <I>iflag</I> = 0 are made.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of <I>iflag</I>. See description of <I>fcn</I>. Otherwise,
+<I>info</I> is set as follows.
+<P>
+<I>info</I> = 0   improper input parameters.
+<P>
+<I>info</I> = 1   relative error between two consecutive iterates
+<BR>           is at most <I>xtol</I>.
+<P>
+<I>info</I> = 2   number of calls to <I>fcn</I> has reached or exceeded
+<BR>           <I>maxfev</I>.
+<P>
+<I>info</I> = 3   <I>xtol</I> is too small. No further improvement in
+<BR>           the approximate solution <I>x</I> is possible.
+<P>
+<I>info</I> = 4   iteration is not making good progress, as
+<BR>           measured by the improvement from the last
+<BR>           five jacobian evaluations.
+<P>
+<I>info</I> = 5   iteration is not making good progress, as
+<BR>           measured by the improvement from the last
+<BR>           ten iterations.
+<P>
+<I>nfev</I> is an integer output variable set to the number of
+calls to <I>fcn</I>.
+<P>
+<I>fjac</I> is an output <I>n</I> by <I>n</I> array which contains the
+orthogonal matrix <I>q</I> produced by the <I>qr</I> factorization
+of the final approximate jacobian.
+<P>
+<I>ldfjac</I> is a positive integer input variable not less than <I>n</I>
+which specifies the leading dimension of the array <I>fjac</I>.
+<P>
+<I>r</I> is an output array of length <I>lr</I> which contains the
+upper triangular matrix produced by the <I>qr</I> factorization
+of the final approximate Jacobian, stored rowwise.
+<P>
+<I>lr</I> is a positive integer input variable not less than
+(<I>n</I>*(<I>n</I>+1))/2.
+<P>
+<I>qtf</I> is an output array of length <I>n</I> which contains
+the vector (q transpose)*<I>fvec</I>.
+<P>
+<I>wa1</I>, <I>wa2</I>, <I>wa3</I>, and <I>wa4</I> are work arrays of length <I>n</I>.
+<P>
+<A NAME="lbAI"> </A>
+<H2>SEE ALSO</H2>
+
+<B><A HREF="hybrd_.html">hybrd</A></B>(3),
+
+<B><A HREF="hybrd_.html">hybrd1</A></B>(3).
+
+<BR>
+
+<P>
+<A NAME="lbAJ"> </A>
+<H2>AUTHORS</H2>
+
+Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More.
+<BR>
+
+This manual page was written by Jim Van Zandt <<A HREF="mailto:jrv at debian.org">jrv at debian.org</A>>,
+for the Debian GNU/Linux system (but may be used by others).
+<P>
+
+<HR>
+<A NAME="index"> </A><H2>Index</H2>
+<DL>
+<DT><A HREF="#lbAB">NAME</A><DD>
+<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
+<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
+<DL>
+<DT><A HREF="#lbAE">Language notes</A><DD>
+<DT><A HREF="#lbAF">Parameters for both functions</A><DD>
+<DT><A HREF="#lbAG">Parameters for <B>hybrj1_</B></A><DD>
+<DT><A HREF="#lbAH">Parameters for <B>hybrj_</B></A><DD>
+</DL>
+<DT><A HREF="#lbAI">SEE ALSO</A><DD>
+<DT><A HREF="#lbAJ">AUTHORS</A><DD>
+</DL>
+<HR>
+This document was created by
+<A HREF="index.html">man2html</A>,
+using the manual pages.<BR>
+Time: 10:19:50 GMT, April 20, 2007
+</BODY>
+</HTML>
diff --git a/doc/index.html b/doc/index.html
new file mode 100644
index 0000000..5b29c0c
--- /dev/null
+++ b/doc/index.html
@@ -0,0 +1,236 @@
+<?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 [...]
+<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>
+
+<p>If you use C/C++ Minpack for a publication, you should cite it as:</p>
+<pre>
+ at misc{cminpack,
+  title={C/C++ Minpack},
+  author={Devernay, Fr{\'e}d{\'e}ric},
+  year={2007},
+  howpublished = "\url{http://devernay.free.fr/hacks/cminpack/}",
+}
+</pre>
+
+<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 <a href="http://www.nag.co.uk/">NAG</a> function <a href="http://www.nag.co.uk/numeric/fl/manual/xhtml/E04/e04ycf.xml">E04YCF</a> 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.3.tar.gz">cminpack-1.3.3.tar.gz</a> (latest version)</li> 
+  <li><a href="cminpack-1.3.2.tar.gz">cminpack-1.3.2.tar.gz</a></li> 
+  <li><a href="cminpack-1.3.1.tar.gz">cminpack-1.3.1.tar.gz</a></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>
+
+
+<p>GitHub repository: <a href="https://github.com/devernay/cminpack">https://github.com/devernay/cminpack</a></p> 
+
+<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 <code>__cminpack_func__()</code> 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, and you should prefer calling directly <code>slmder(...)</code> or <code>slmder(...)</code>.</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>Simulating box constraints</h2>
+
+<p>Note that box constraints can easily be simulated in C++ Minpack, using a change of variables in the function (that hint was found in the <a href="http://apps.jcns.fz-juelich.de/doku/sc/lmfit:constraints">lmfit documentation</a>).</p>
+
+<p>For example, say you want <code>xmin[j] < x[j] < xmax[j]</code>, just apply the following change of variable at the beginning of <code>fcn</code> on the variables vector, and also on the computed solution after the optimization was performed:</p>
+<pre>
+  for (j = 0; j < 3; ++j) {
+    real xmiddle = (xmin[j]+xmax[j])/2.;
+    real xwidth = (xmax[j]-xmin[j])/2.;
+    real th =  tanh((x[j]-xmiddle)/xwidth);
+    x[j] = xmiddle + th * xwidth;
+    jacfac[j] = 1. - th * th;
+  }
+</pre>
+
+<p>This change of variables preserves the variables scaling, and is almost the identity near the middle of the interval.</p>
+
+<p>Of course, if you use <code>lmder</code>, <code>lmder1</code>, <code>hybrj</code> or <code>hybrj1</code>, the Jacobian must be also consistent with that new function, so the column of the original Jacobian corresponding to <code>x1</code> must be multiplied by the derivative of the change of variable, i.e <code>jacfac[j]</code>.</p>
+
+<p>Similarly, each element of the covariance matrix must be multiplied by <code>jacfac[i]*jacfac[j]</code>.</p>
+
+<p>Examples of optimization with a box constraint is available in the following examples: <code>tlmderc.c</code>, <code>thybrj.c</code>, <code>tchkderc.c</code>.</p>
+
+<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>
+  <li><a href="http://eigen.tuxfamily.org/">Eigen</a> has an unsupported <a href="http://eigen.tuxfamily.org/dox/unsupported/group__NonLinearOptimization__Module.html">nonlinear optimization</a> module based on cminpack.</li>
+  <li><a href="http://code.google.com/p/ceres-solver/">Ceres Solver</a> is not derived from MINPACK, but is probably the best available alternative, with lots of features (New BSD License).</li>
+</ul>
+
+<h2>History</h2>
+<ul>
+  <li>1.3.3 (04/02/2014): Add documentation and examples abouts how to add box constraints to the variables. <a href="https://travis-ci.org/devernay/cminpack">Continuous integration using Travis CI</a></li>
+  <li>1.3.2 (27/10/2013): Minor change in the CMake build: also set SOVERSION.</li>
+  <li>1.3.1 (02/10/2013): Fix CUDA examples compilation, and remove non-free files.</li>
+  <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). On 64-bits architectures, the preprocessor symbol __LP64__ must be defined (see cminpackP.h) if the LAPACK library uses the LP64 interface (i.e. 32-bits integer, vhereas the ILP interface uses 64 bits integers).</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. [...]
+  <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>
+
+<h2>Future work</h2>
+
+<p>There is now a very powerful alternative to MINPACK, which is the <a href="http://code.google.com/p/ceres-solver/">Ceres Solver</a>. You may want to consider using Ceres for any new project.</p>
+
+<p>The main feature that's missing on cminpack is the possibility to add constraints on variables. Simple boundary constraints should be enough, as implemented in <a href="http://www.alglib.net/optimization/levenbergmarquardt.php">ALGLIB</a> or <a href="http://www.physics.wisc.edu/~craigm/idl/cmpfit.html">MPFIT</a>.<p>
+
+<p><a href="http://www.ics.forth.gr/~lourakis/levmar/">levmar</a> also has linear constraints, but they shouldn't be necessary since linear constraints can be changed to box constraints by a simple change of variables. If you really need nonlinear constraints, and no reparameterization of variables (which may be able to linearize these constraints), you should consider using <a href="http://ab-initio.mit.edu/wiki/index.php/NLopt">NLopt</a> instead of cminpack.</p>
+
+<p>Please <a href="/email.html">contact me</a> for any suggestion or request.</p>
+
+<address>
+<a href="/email.html">Frédé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>
+
diff --git a/doc/lmder1_.3 b/doc/lmder1_.3
new file mode 100644
index 0000000..070a03f
--- /dev/null
+++ b/doc/lmder1_.3
@@ -0,0 +1 @@
+.so man3/lmder_.3
diff --git a/doc/lmder_.3 b/doc/lmder_.3
new file mode 100644
index 0000000..f9b00de
--- /dev/null
+++ b/doc/lmder_.3
@@ -0,0 +1,340 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.TH LMDER_ 3 "March 8, 2002" Minpack
+.\" Please adjust this date whenever revising the manpage.
+.SH NAME
+lmder_, lmder1_ \- minimize the sum of squares of m nonlinear functions, with user supplied Jacobian 
+.SH SYNOPSIS
+.B include <minpack.h>
+.nh
+.ad l
+.HP 28
+.BI "void lmder1_ ( "
+.BI "void (*" fcn         )
+.BI "(int *"     m        , 
+.BI "int *"      n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.BI "double *"   fjac     ,
+.br
+.BI "int *"      ldfjac   ,
+.BI "int *"      iflag    ),
+.RS 15
+.BI "int *"      m        ,
+.BI "int * "     n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.BI "double *"   fjac     ,
+.BI "int *"      ldfjac   ,
+.br
+.BI "double *"   tol      , 
+.BI "int *"      info     ,
+.BI "int *"      iwa      ,
+.BI "double *"   wa       ,
+.BI "int *"      lwa      );
+.RE
+.HP 27
+.BI "void lmder_"
+.BI "( void (*" fcn )(
+.BI "int *"      m        , 
+.BI "int *"      n        ,
+.BI "double *"   x        , 
+.BI "double *"   fvec     , 
+.BI "double *"   fjac     ,
+.br
+.BI "int *"      ldfjac   ,
+.BI "int *"      iflag    ),
+.RS 14
+.BI "int *"      m        ,
+.BI "int *"      n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.BI "double *"   fjac     ,
+.BI "int *"      ldfjac   ,
+.br
+.BI "double *"   ftol     ,
+.BI "double *"   xtol     ,
+.BI "double *"   gtol     ,
+.BI "int *"      maxfev   ,
+.BI "double *"   diag     ,
+.BI "int *"      mode     ,
+.br
+.BI "double *"   factor   ,
+.BI "int *"      nprint   ,
+.BI "int *"      info     ,
+.br
+.BI "int *"      nfev     ,
+.BI "int *"      njev     ,
+.BI "int *"      ipvt     ,
+.br
+.BI "double *"   qtf      ,
+.BI "double *"   wa1      ,
+.BI "double *"   wa2      ,
+.BI "double *"   wa3      ,
+.BI "double *"   wa4      " );"
+.RE
+.hy
+.ad b
+.br
+.SH DESCRIPTION
+
+The purpose of \fBlmder_\fP is to minimize the sum of the squares of
+\fIm\fP nonlinear functions in \fIn\fP variables by a modification of
+the Levenberg-Marquardt algorithm. The user must provide a function 
+which calculates the functions and the Jacobian.
+.PP
+\fBlmder1_\fP performs the same function
+as \fBlmder_\fP but has a simplified calling sequence.  
+.PP
+\fBlmstr\fP and \fBlmstr1\fP also perform the same function but use
+minimal storage.
+.br
+.SS Language notes
+These functions are written in FORTRAN. If calling from
+C, keep these points in mind:
+.TP
+Name mangling.
+With \fBg77\fP version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of \fBg77\fP.
+.TP
+Compile with \fBg77\fP.
+Even if your program is all C code, you should link with \fBg77\fP
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use \fBg77\fP to do all the compiling.  (It handles C just fine.)
+.TP
+Call by reference.
+All function parameters must be pointers.
+.TP
+Column-major arrays.
+Suppose a function returns an array with 5 rows and 3 columns in an
+array \fIz\fP and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+.sp
+.nf
+	z(1,1)		z[0]
+	z(2,1)		z[1]
+	z(5,1)		z[4]
+	z(1,2)		z[7]
+	z(1,3)		z[14]
+	z(i,j)		z[(i-1) + (j-1)*7]
+.fi
+.br
+.SS User-supplied Function
+
+\fIfcn\fP is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, \fIfcn\fP must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+.sp
+.nf
+  subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+  integer m,n,iflag
+  double precision x(n),fvec(m),fjac(ldfjac,n)
+  ----------
+  if iflag = 1 calculate the functions at x and
+  return this vector in fvec. do not alter fjac.
+  if iflag = 2 calculate the jacobian at x and
+  return this matrix in fjac. do not alter fvec.
+  ----------
+  return
+  end
+.fi
+.sp
+In C, \fIfcn\fP should be written as follows:
+.sp
+.nf
+  void fcn(int m, int n, double *x, double *fvec, double *fjac,
+           int *ldfjac, int *iflag)
+  {
+    /* if iflag = 1 calculate the functions at x and return this
+       vector in fvec[0] through fvec[m-1]. do not alter fjac.
+       if iflag = 2 calculate the jacobian at x and return this
+       matrix in fjac. do not alter fvec. */
+  }
+.fi
+.sp
+The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the
+user wants to terminate execution of \fBlmder_\fP (or \fBlmder1_\fP). In
+this case set \fIiflag\fP to a negative integer.
+.br
+.SS Parameters for both \fBlmder_\fP and \fBlmder1_\fP
+
+\fIm\fP is a positive integer input variable set to the number
+of functions.
+
+\fIn\fP is a positive integer input variable set to the number
+of variables. \fIn\fP must not exceed \fIm\fP.
+
+\fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain
+an initial estimate of the solution vector. On output \fIx\fP
+contains the final estimate of the solution vector.
+
+\fIfvec\fP is an output array of length \fIm\fP which contains
+the functions evaluated at the output \fIx\fP.
+
+\fIfjac\fP is an output \fIm\fP by \fIn\fP array. The upper \fIn\fP by
+\fIn\fP submatrix of \fIfjac\fP contains an upper triangular matrix
+\fIr\fP with diagonal elements of nonincreasing magnitude such that
+
+         t     t           t
+        p *(jac *jac)*p = r *r,
+
+where \fIp\fP is a permutation matrix and \fIjac\fP is the final
+calculated Jacobian. column \fBj\fP of \fIp\fP is column
+\fIipvt\fP(\fBj\fP) (see below) of the identity matrix. The lower
+trapezoidal part of \fIfjac\fP contains information generated during
+the computation of \fIr\fP.
+
+\fIldfjac\fP is a positive integer input variable not less than
+\fIm\fP which specifies the leading dimension of the array
+\fIfjac\fP.
+.br
+.SS Parameters for \fBlmder1_\fP
+
+\fItol\fP is a nonnegative input variable.  Termination occurs when
+the algorithm estimates either that the relative error in the sum of
+squares is at most \fItol\fP or that the relative error between
+\fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP is an integer output variable. if the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of iflag. see description of \fIfcn\fP. otherwise,
+\fIinfo\fP is set as follows.
+
+  \fIinfo\fP = 0  improper input parameters.
+
+  \fIinfo\fP = 1  algorithm estimates that the relative error
+in the sum of squares is at most \fItol\fP.
+
+  \fIinfo\fP = 2  algorithm estimates that the relative error
+between x and the solution is at most \fItol\fP.
+
+  \fIinfo\fP = 3  conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold.
+
+  \fIinfo\fP = 4  \fIfvec\fP is orthogonal to the columns of the
+Jacobian to machine precision.
+
+  \fIinfo\fP = 5  number of calls to \fIfcn\fP has reached or
+exceeded 200*(\fIn\fP+1).
+
+  \fIinfo\fP = 6  \fItol\fP is too small. no further reduction in
+the sum of squares is possible.
+
+  \fIinfo\fP = 7  \fItol\fP is too small. no further improvement in
+the approximate solution x is possible.
+
+\fIiwa\fP is an integer work array of length \fIn\fP.
+
+\fIwa\fP is a work array of length \fIlwa\fP.
+
+\fIlwa\fP is an integer input variable not less than \fIm\fP*\fIn\fP +
+5*\fIn\fP + \fIm\fP for \fBlmder1_\fP.
+.br
+.SS Parameters for \fBlmder_\fP
+
+\fIftol\fP is a nonnegative input variable. Termination
+occurs when both the actual and predicted relative
+reductions in the sum of squares are at most \fIftol\fP.
+Therefore, \fIftol\fP measures the relative error desired
+in the sum of squares.
+
+\fIxtol\fP is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most \fIxtol\fP. Therefore, \fIxtol\fP measures the
+relative error desired in the approximate solution.
+
+\fIgtol\fP is a nonnegative input variable. Termination
+occurs when the cosine of the angle between \fIfvec\fP and
+any column of the Jacobian is at most \fIgtol\fP in absolute
+value. Therefore, \fIgtol\fP measures the orthogonality
+desired between the function vector and the columns
+of the Jacobian.
+
+\fImaxfev\fP is a positive integer input variable. Termination
+occurs when the number of calls to \fIfcn\fP is at least
+\fImaxfev\fP by the end of an iteration.
+
+\fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see
+below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+
+\fImode\fP is an integer input variable. If \fImode\fP = 1, the
+variables will be scaled internally. If \fImode\fP = 2,
+the scaling is specified by the input \fIdiag\fP. Other
+values of mode are equivalent to \fImode\fP = 1.
+
+\fIfactor\fP is a positive input variable used in determining the
+initial step bound. This bound is set to the product of \fIfactor\fP
+and the euclidean norm of \fIdiag\fP*\fIx\fP if the latter is
+nonzero, or else to \fIfactor\fP itself. In most cases factor should
+lie in the interval (.1,100.). 100. is a generally recommended
+value.
+
+\fInprint\fP is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case, fcn is called
+with \fIiflag\fP = 0 at the beginning of the first iteration and
+every \fInprint\fP iterations thereafter and immediately prior to
+return, with \fIx\fP and \fIfvec\fP available for printing. If
+\fInprint\fP is not positive, no special calls of fcn with
+\fIiflag\fP = 0 are made.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, info is set to the (negative)
+value of iflag. See description of fcn. Otherwise,
+info is set as follows.
+
+  \fIinfo\fP = 0  improper input parameters.
+
+  \fIinfo\fP = 1  both actual and predicted relative reductions
+in the sum of squares are at most \fIftol\fP.
+
+  \fIinfo\fP = 2  relative error between two consecutive iterates
+is at most \fIxtol\fP.
+
+  \fIinfo\fP = 3  conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold.
+
+  \fIinfo\fP = 4  the cosine of the angle between fvec and any
+column of the Jacobian is at most gtol in absolute value.
+
+  \fIinfo\fP = 5  number of calls to \fIfcn\fP has reached or
+exceeded maxfev.
+
+  \fIinfo\fP = 6  \fIftol\fP is too small. No further reduction in
+the sum of squares is possible.
+
+  \fIinfo\fP = 7  \fIxtol\fP is too small. No further improvement in
+the approximate solution x is possible.
+
+  \fIinfo\fP = 8 \fIgtol\fP is too small. \fIfvec\fP is orthogonal to
+the columns of the Jacobian to machine precision.
+
+\fInfev\fP is an integer output variable set to the number of
+calls to \fIfcn\fP with \fIiflag\fP = 1.
+
+\fInjev\fP is an integer output variable set to the number of
+calls to fcn with \fIiflag\fP = 2.
+
+\fIipvt\fP is an integer output array of length \fIn\fP. \fIipvt\fP
+defines a permutation matrix \fIp\fP such that \fIjac\fP*\fIp\fP =
+\fIq\fP*\fIr\fP, where \fIjac\fP is the final calculated Jacobian,
+\fIq\fP is orthogonal (not stored), and \fIr\fP is upper triangular
+with diagonal elements of nonincreasing magnitude.  Column \fBj\fP
+of \fIp\fP is column \fIipvt\fP(\fBj\fP) of the identity matrix.
+
+\fIqtf\fP is an output array of length \fIn\fP which contains
+the first \fIn\fP elements of the vector (\fIq\fP transpose)*\fIfvec\fP.
+
+\fIwa1\fP, \fIwa2\fP, and \fIwa3\fP are work arrays of length \fIn\fP.
+
+\fIwa4\fP is a work array of length \fIm\fP.
+.br
+.SH SEE ALSO
+.BR lmdif (3),
+.BR lmdif1 (3),
+.BR lmstr (3),
+.BR lmstr1 (3).
+.br
+.SH AUTHORS
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+This manual page was written by Jim Van Zandt <jrv at debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
diff --git a/doc/lmder_.html b/doc/lmder_.html
new file mode 100644
index 0000000..20fc69d
--- /dev/null
+++ b/doc/lmder_.html
@@ -0,0 +1,460 @@
+<HTML><HEAD><TITLE>Manpage of LMDER_</TITLE>
+</HEAD><BODY>
+<H1>LMDER_</H1>
+Section: C Library Functions (3)<BR>Updated: March 8, 2002<BR><A HREF="#index">Index</A>
+<A HREF="index.html">Return to Main Contents</A><HR>
+
+
+<A NAME="lbAB"> </A>
+<H2>NAME</H2>
+
+lmder_, lmder1_ - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian 
+<A NAME="lbAC"> </A>
+<H2>SYNOPSIS</H2>
+
+<B>include <<A HREF="file:/usr/include/minpack.h">minpack.h</A>></B>
+
+
+
+<DL COMPACT>
+<DT>
+<B>void lmder1_ ( </B>
+
+<B>void (*</B><I>fcn</I><B>)</B>
+
+<B>(int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<DD>
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int * </B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>tol</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>int *</B><I>iwa</I><B>,</B>
+
+<B>double *</B><I>wa</I><B>,</B>
+
+<B>int *</B><I>lwa</I><B>);</B>
+
+</DL>
+
+<DT>
+<B>void lmder_</B>
+
+<B>( void (*</B><I>fcn</I><B>)(</B>
+
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<DD>
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>ftol</I><B>,</B>
+
+<B>double *</B><I>xtol</I><B>,</B>
+
+<B>double *</B><I>gtol</I><B>,</B>
+
+<B>int *</B><I>maxfev</I><B>,</B>
+
+<B>double *</B><I>diag</I><B>,</B>
+
+<B>int *</B><I>mode</I><B>,</B>
+
+<DD>
+<B>double *</B><I>factor</I><B>,</B>
+
+<B>int *</B><I>nprint</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<DD>
+<B>int *</B><I>nfev</I><B>,</B>
+
+<B>int *</B><I>njev</I><B>,</B>
+
+<B>int *</B><I>ipvt</I><B>,</B>
+
+<DD>
+<B>double *</B><I>qtf</I><B>,</B>
+
+<B>double *</B><I>wa1</I><B>,</B>
+
+<B>double *</B><I>wa2</I><B>,</B>
+
+<B>double *</B><I>wa3</I><B>,</B>
+
+<B>double *</B><I>wa4</I><B> );</B>
+
+</DL>
+
+
+
+<DD>
+</DL>
+<A NAME="lbAD"> </A>
+<H2>DESCRIPTION</H2>
+
+<P>
+<DD>The purpose of <B>lmder_</B> is to minimize the sum of the squares of
+<I>m</I> nonlinear functions in <I>n</I> variables by a modification of
+the Levenberg-Marquardt algorithm. The user must provide a function 
+which calculates the functions and the Jacobian.
+<P>
+
+<B>lmder1_</B> performs the same function
+as <B>lmder_</B> but has a simplified calling sequence.  
+<P>
+
+<B>lmstr</B> and <B>lmstr1</B> also perform the same function but use
+minimal storage.
+<BR>
+
+<A NAME="lbAE"> </A>
+<H3>Language notes</H3>
+
+These functions are written in FORTRAN. If calling from
+C, keep these points in mind:
+<DL COMPACT>
+<DT>Name mangling.<DD>
+With <B>g77</B> version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of <B>g77</B>.
+<DT>Compile with <B>g77</B>.<DD>
+Even if your program is all C code, you should link with <B>g77</B>
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use <B>g77</B> to do all the compiling.  (It handles C just fine.)
+<DT>Call by reference.<DD>
+All function parameters must be pointers.
+<DT>Column-major arrays.<DD>
+Suppose a function returns an array with 5 rows and 3 columns in an
+array <I>z</I> and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+<P>
+<PRE>
+        z(1,1)          z[0]
+        z(2,1)          z[1]
+        z(5,1)          z[4]
+        z(1,2)          z[7]
+        z(1,3)          z[14]
+        z(i,j)          z[(i-1) + (j-1)*7]
+</PRE>
+
+<BR>
+
+</DL>
+<A NAME="lbAF"> </A>
+<H3>User-supplied Function</H3>
+
+<P>
+<I>fcn</I> is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, <I>fcn</I> must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+<P>
+<PRE>
+  subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+  integer m,n,iflag
+  double precision x(n),fvec(m),fjac(ldfjac,n)
+  ----------
+  if iflag = 1 calculate the functions at x and
+  return this vector in fvec. do not alter fjac.
+  if iflag = 2 calculate the jacobian at x and
+  return this matrix in fjac. do not alter fvec.
+  ----------
+  return
+  end
+</PRE>
+
+<P>
+In C, <I>fcn</I> should be written as follows:
+<P>
+<PRE>
+  void fcn(int m, int n, double *x, double *fvec, double *fjac,
+           int *ldfjac, int *iflag)
+  {
+    /* if iflag = 1 calculate the functions at x and return this
+       vector in fvec[0] through fvec[m-1]. do not alter fjac.
+       if iflag = 2 calculate the jacobian at x and return this
+       matrix in fjac. do not alter fvec. */
+  }
+</PRE>
+
+<P>
+The value of <I>iflag</I> should not be changed by <I>fcn</I> unless the
+user wants to terminate execution of <B>lmder_</B> (or <B>lmder1_</B>). In
+this case set <I>iflag</I> to a negative integer.
+<BR>
+
+<A NAME="lbAG"> </A>
+<H3>Parameters for both <B>lmder_</B> and <B>lmder1_</B></H3>
+
+<P>
+<I>m</I> is a positive integer input variable set to the number
+of functions.
+<P>
+<I>n</I> is a positive integer input variable set to the number
+of variables. <I>n</I> must not exceed <I>m</I>.
+<P>
+<I>x</I> is an array of length <I>n</I>. On input <I>x</I> must contain
+an initial estimate of the solution vector. On output <I>x</I>
+contains the final estimate of the solution vector.
+<P>
+<I>fvec</I> is an output array of length <I>m</I> which contains
+the functions evaluated at the output <I>x</I>.
+<P>
+<I>fjac</I> is an output <I>m</I> by <I>n</I> array. The upper <I>n</I> by
+<I>n</I> submatrix of <I>fjac</I> contains an upper triangular matrix
+<I>r</I> with diagonal elements of nonincreasing magnitude such that
+<P>
+<BR>         t     t           t
+<BR>        p *(jac *jac)*p = r *r,
+<P>
+where <I>p</I> is a permutation matrix and <I>jac</I> is the final
+calculated Jacobian. column <B>j</B> of <I>p</I> is column
+<I>ipvt</I>(<B>j</B>) (see below) of the identity matrix. The lower
+trapezoidal part of <I>fjac</I> contains information generated during
+the computation of <I>r</I>.
+<P>
+<I>ldfjac</I> is a positive integer input variable not less than
+<I>m</I> which specifies the leading dimension of the array
+<I>fjac</I>.
+<BR>
+
+<A NAME="lbAH"> </A>
+<H3>Parameters for <B>lmder1_</B></H3>
+
+<P>
+<I>tol</I> is a nonnegative input variable.  Termination occurs when
+the algorithm estimates either that the relative error in the sum of
+squares is at most <I>tol</I> or that the relative error between
+<I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> is an integer output variable. if the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of iflag. see description of <I>fcn</I>. otherwise,
+<I>info</I> is set as follows.
+<P>
+<BR>  <I>info</I> = 0  improper input parameters.
+<P>
+<BR>  <I>info</I> = 1  algorithm estimates that the relative error
+in the sum of squares is at most <I>tol</I>.
+<P>
+<BR>  <I>info</I> = 2  algorithm estimates that the relative error
+between x and the solution is at most <I>tol</I>.
+<P>
+<BR>  <I>info</I> = 3  conditions for <I>info</I> = 1 and <I>info</I> = 2 both hold.
+<P>
+<BR>  <I>info</I> = 4  <I>fvec</I> is orthogonal to the columns of the
+Jacobian to machine precision.
+<P>
+<BR>  <I>info</I> = 5  number of calls to <I>fcn</I> has reached or
+exceeded 200*(<I>n</I>+1).
+<P>
+<BR>  <I>info</I> = 6  <I>tol</I> is too small. no further reduction in
+the sum of squares is possible.
+<P>
+<BR>  <I>info</I> = 7  <I>tol</I> is too small. no further improvement in
+the approximate solution x is possible.
+<P>
+<I>iwa</I> is an integer work array of length <I>n</I>.
+<P>
+<I>wa</I> is a work array of length <I>lwa</I>.
+<P>
+<I>lwa</I> is an integer input variable not less than <I>m</I>*<I>n</I> +
+5*<I>n</I> + <I>m</I> for <B>lmder1_</B>.
+<BR>
+
+<A NAME="lbAI"> </A>
+<H3>Parameters for <B>lmder_</B></H3>
+
+<P>
+<I>ftol</I> is a nonnegative input variable. Termination
+occurs when both the actual and predicted relative
+reductions in the sum of squares are at most <I>ftol</I>.
+Therefore, <I>ftol</I> measures the relative error desired
+in the sum of squares.
+<P>
+<I>xtol</I> is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most <I>xtol</I>. Therefore, <I>xtol</I> measures the
+relative error desired in the approximate solution.
+<P>
+<I>gtol</I> is a nonnegative input variable. Termination
+occurs when the cosine of the angle between <I>fvec</I> and
+any column of the Jacobian is at most <I>gtol</I> in absolute
+value. Therefore, <I>gtol</I> measures the orthogonality
+desired between the function vector and the columns
+of the Jacobian.
+<P>
+<I>maxfev</I> is a positive integer input variable. Termination
+occurs when the number of calls to <I>fcn</I> is at least
+<I>maxfev</I> by the end of an iteration.
+<P>
+<I>diag</I> is an array of length <I>n</I>. If <I>mode</I> = 1 (see
+below), <I>diag</I> is internally set. If <I>mode</I> = 2, <I>diag</I>
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+<P>
+<I>mode</I> is an integer input variable. If <I>mode</I> = 1, the
+variables will be scaled internally. If <I>mode</I> = 2,
+the scaling is specified by the input <I>diag</I>. Other
+values of mode are equivalent to <I>mode</I> = 1.
+<P>
+<I>factor</I> is a positive input variable used in determining the
+initial step bound. This bound is set to the product of <I>factor</I>
+and the euclidean norm of <I>diag</I>*<I>x</I> if the latter is
+nonzero, or else to <I>factor</I> itself. In most cases factor should
+lie in the interval (.1,100.). 100. is a generally recommended
+value.
+<P>
+<I>nprint</I> is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case, fcn is called
+with <I>iflag</I> = 0 at the beginning of the first iteration and
+every <I>nprint</I> iterations thereafter and immediately prior to
+return, with <I>x</I> and <I>fvec</I> available for printing. If
+<I>nprint</I> is not positive, no special calls of fcn with
+<I>iflag</I> = 0 are made.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, info is set to the (negative)
+value of iflag. See description of fcn. Otherwise,
+info is set as follows.
+<P>
+<BR>  <I>info</I> = 0  improper input parameters.
+<P>
+<BR>  <I>info</I> = 1  both actual and predicted relative reductions
+in the sum of squares are at most <I>ftol</I>.
+<P>
+<BR>  <I>info</I> = 2  relative error between two consecutive iterates
+is at most <I>xtol</I>.
+<P>
+<BR>  <I>info</I> = 3  conditions for <I>info</I> = 1 and <I>info</I> = 2 both hold.
+<P>
+<BR>  <I>info</I> = 4  the cosine of the angle between fvec and any
+column of the Jacobian is at most gtol in absolute value.
+<P>
+<BR>  <I>info</I> = 5  number of calls to <I>fcn</I> has reached or
+exceeded maxfev.
+<P>
+<BR>  <I>info</I> = 6  <I>ftol</I> is too small. No further reduction in
+the sum of squares is possible.
+<P>
+<BR>  <I>info</I> = 7  <I>xtol</I> is too small. No further improvement in
+the approximate solution x is possible.
+<P>
+<BR>  <I>info</I> = 8 <I>gtol</I> is too small. <I>fvec</I> is orthogonal to
+the columns of the Jacobian to machine precision.
+<P>
+<I>nfev</I> is an integer output variable set to the number of
+calls to <I>fcn</I> with <I>iflag</I> = 1.
+<P>
+<I>njev</I> is an integer output variable set to the number of
+calls to fcn with <I>iflag</I> = 2.
+<P>
+<I>ipvt</I> is an integer output array of length <I>n</I>. <I>ipvt</I>
+defines a permutation matrix <I>p</I> such that <I>jac</I>*<I>p</I> =
+<I>q</I>*<I>r</I>, where <I>jac</I> is the final calculated Jacobian,
+<I>q</I> is orthogonal (not stored), and <I>r</I> is upper triangular
+with diagonal elements of nonincreasing magnitude.  Column <B>j</B>
+of <I>p</I> is column <I>ipvt</I>(<B>j</B>) of the identity matrix.
+<P>
+<I>qtf</I> is an output array of length <I>n</I> which contains
+the first <I>n</I> elements of the vector (<I>q</I> transpose)*<I>fvec</I>.
+<P>
+<I>wa1</I>, <I>wa2</I>, and <I>wa3</I> are work arrays of length <I>n</I>.
+<P>
+<I>wa4</I> is a work array of length <I>m</I>.
+<BR>
+
+<A NAME="lbAJ"> </A>
+<H2>SEE ALSO</H2>
+
+<B><A HREF="lmdif_.html">lmdif</A></B>(3),
+
+<B><A HREF="lmdif_.html">lmdif1</A></B>(3),
+
+<B><A HREF="lmstr_.html">lmstr</A></B>(3),
+
+<B><A HREF="lmstr_.html">lmstr1</A></B>(3).
+
+<BR>
+
+<A NAME="lbAK"> </A>
+<H2>AUTHORS</H2>
+
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+This manual page was written by Jim Van Zandt <<A HREF="mailto:jrv at debian.org">jrv at debian.org</A>>,
+for the Debian GNU/Linux system (but may be used by others).
+<P>
+
+<HR>
+<A NAME="index"> </A><H2>Index</H2>
+<DL>
+<DT><A HREF="#lbAB">NAME</A><DD>
+<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
+<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
+<DL>
+<DT><A HREF="#lbAE">Language notes</A><DD>
+<DT><A HREF="#lbAF">User-supplied Function</A><DD>
+<DT><A HREF="#lbAG">Parameters for both <B>lmder_</B> and <B>lmder1_</B></A><DD>
+<DT><A HREF="#lbAH">Parameters for <B>lmder1_</B></A><DD>
+<DT><A HREF="#lbAI">Parameters for <B>lmder_</B></A><DD>
+</DL>
+<DT><A HREF="#lbAJ">SEE ALSO</A><DD>
+<DT><A HREF="#lbAK">AUTHORS</A><DD>
+</DL>
+<HR>
+This document was created by
+<A HREF="index.html">man2html</A>,
+using the manual pages.<BR>
+Time: 10:19:50 GMT, April 20, 2007
+</BODY>
+</HTML>
diff --git a/doc/lmdif1_.3 b/doc/lmdif1_.3
new file mode 100644
index 0000000..72a453c
--- /dev/null
+++ b/doc/lmdif1_.3
@@ -0,0 +1 @@
+.so man3/lmdif_.3
diff --git a/doc/lmdif_.3 b/doc/lmdif_.3
new file mode 100644
index 0000000..f0052fb
--- /dev/null
+++ b/doc/lmdif_.3
@@ -0,0 +1,319 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.TH LMDIF_ 3 "March 8, 2002" Minpack
+.\" Please adjust this date whenever revising the manpage.
+.SH NAME
+lmdif_, lmdif1_ \- minimize the sum of squares of m nonlinear functions 
+.SH SYNOPSIS
+.B include <minpack.h>
+.nh
+.ad l
+.HP 15
+.BI "void lmdif1_ ( "
+.BI "void (*" fcn ")(int *" m ", int *" n ", double *" x ,
+.BI "double *" fvec ", int *" iflag ),
+.RS 2
+.BI "int *"      m        ,
+.BI "int * "     n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.br
+.BI "double *"   tol      , 
+.BI "int *"      info     ,
+.BI "int *"      iwa      ,
+.BI "double *"   wa       ,
+.BI "int *"      lwa      );
+.RE
+.HP 14
+.BI "void lmdif_"
+.BI "( void (*" fcn ")(int *" m ", int *" n ", double *" x , 
+.BI "double *" fvec ", int *" iflag ),
+.RS 2
+.BI "int *"      m        ,
+.BI "int *"      n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.br
+.BI "double *"   ftol     ,
+.BI "double *"   xtol     ,
+.BI "double *"   gtol     ,
+.BI "int *"      maxfev   ,
+.BI "double *"   epsfcn   ,
+.BI "double *"   diag     ,
+.BI "int *"      mode     ,
+.BI "double *"   factor   ,
+.BI "int *"      nprint   ,
+.BI "int *"      info     ,
+.BI "int *"      nfev     ,
+.BI "double *"   fjac     ,
+.br
+.BI "int *"      ldfjac   ,
+.BI "int *"      ipvt     ,
+.BI "double *"   qtf      ,
+.br
+.BI "double *"   wa1      ,
+.BI "double *"   wa2      ,
+.BI "double *"   wa3      ,
+.BI "double *"   wa4      " );"
+.RE
+.hy
+.ad b
+.br
+.SH DESCRIPTION
+
+The purpose of \fBlmdif_\fP is to minimize the sum of the squares of
+\fIm\fP nonlinear functions in \fIn\fP variables by a modification of
+the Levenberg-Marquardt algorithm. The user must provide a subroutine
+which calculates the functions. The Jacobian is then calculated by a
+forward-difference approximation.
+
+\fBlmdif1_\fP serves the same purpose but has a simplified calling
+sequence.
+.br
+.SS Language notes
+These functions are written in FORTRAN. If calling from
+C, keep these points in mind:
+.TP
+Name mangling.
+With \fBg77\fP version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of \fBg77\fP.
+.TP
+Compile with \fBg77\fP.
+Even if your program is all C code, you should link with \fBg77\fP
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use \fBg77\fP to do all the compiling.  (It handles C just fine.)
+.TP
+Call by reference.
+All function parameters must be pointers.
+.TP
+Column-major arrays.
+Suppose a function returns an array with 5 rows and 3 columns in an
+array \fIz\fP and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+.sp
+.nf
+	z(1,1)		z[0]
+	z(2,1)		z[1]
+	z(5,1)		z[4]
+	z(1,2)		z[7]
+	z(1,3)		z[14]
+	z(i,j)		z[(i-1) + (j-1)*7]
+.fi
+.br
+\fIfcn\fP is the name of the user-supplied subroutine which
+calculates the functions. In FORTRAN, \fIfcn\fP must be declared
+in an external statement in the user calling
+program, and should be written as follows:
+.sp
+.nf
+  subroutine fcn(m,n,x,fvec,iflag)
+  integer m,n,iflag
+  double precision x(n),fvec(m)
+  ----------
+  calculate the functions at x and
+  return this vector in fvec.
+  ----------
+  return
+  end
+.fi
+.sp
+In C, \fIfcn\fP should be written as follows:
+.sp
+.nf
+  void fcn(int m, int n, double *x, double *fvec, int *iflag)
+  {
+  	  /* calculate the functions at x and return 
+  	     the values in fvec[0] through fvec[m-1] */
+  }
+.fi
+.sp
+The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the
+user wants to terminate execution of \fBlmdif_\fP (or \fBlmdif1_\fP). In
+this case set \fIiflag\fP to a negative integer.
+.br
+.SS Parameters for both \fBlmdif_\fP and \fBlmdif1_\fP
+
+\fIm\fP is a positive integer input variable set to the number
+of functions.
+
+\fIn\fP is a positive integer input variable set to the number
+of variables. \fIn\fP must not exceed \fIm\fP.
+
+\fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain
+an initial estimate of the solution vector. On output \fIx\fP
+contains the final estimate of the solution vector.
+
+\fIfvec\fP is an output array of length \fIm\fP which contains
+the functions evaluated at the output \fIx\fP.
+.br
+.SS Parameters for \fBlmdif1_\fP 
+
+\fItol\fP is a nonnegative input variable.  Termination occurs when
+the algorithm estimates either that the relative error in the sum of
+squares is at most \fItol\fP or that the relative error between
+\fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP is an integer output variable. if the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of iflag. see description of \fIfcn\fP. otherwise,
+\fIinfo\fP is set as follows.
+
+  \fIinfo\fP = 0  improper input parameters.
+
+  \fIinfo\fP = 1  algorithm estimates that the relative error
+in the sum of squares is at most \fItol\fP.
+
+  \fIinfo\fP = 2  algorithm estimates that the relative error
+between x and the solution is at most \fItol\fP.
+
+  \fIinfo\fP = 3  conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold.
+
+  \fIinfo\fP = 4  \fIfvec\fP is orthogonal to the columns of the
+Jacobian to machine precision.
+
+  \fIinfo\fP = 5  number of calls to \fIfcn\fP has reached or
+exceeded 200*(\fIn\fP+1).
+
+  \fIinfo\fP = 6  \fItol\fP is too small. no further reduction in
+the sum of squares is possible.
+
+  \fIinfo\fP = 7  \fItol\fP is too small. no further improvement in
+the approximate solution x is possible.
+
+\fIiwa\fP is an integer work array of length \fIn\fP.
+
+\fIwa\fP is a work array of length \fIlwa\fP.
+
+\fIlwa\fP is an integer input variable not less than \fIm\fP*\fIn\fP +
+5*\fIn\fP + \fIm\fP.
+.br
+.SS Parameters for \fBlmdif_\fP
+
+\fIftol\fP is a nonnegative input variable. Termination
+occurs when both the actual and predicted relative
+reductions in the sum of squares are at most \fIftol\fP.
+Therefore, \fIftol\fP measures the relative error desired
+in the sum of squares.
+
+\fIxtol\fP is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most \fIxtol\fP. Therefore, \fIxtol\fP measures the
+relative error desired in the approximate solution.
+
+\fIgtol\fP is a nonnegative input variable. Termination
+occurs when the cosine of the angle between \fIfvec\fP and
+any column of the Jacobian is at most \fIgtol\fP in absolute
+value. Therefore, \fIgtol\fP measures the orthogonality
+desired between the function vector and the columns
+of the Jacobian.
+
+\fImaxfev\fP is a positive integer input variable. Termination
+occurs when the number of calls to \fIfcn\fP is at least
+\fImaxfev\fP by the end of an iteration.
+
+\fIepsfcn\fP is an input variable used in determining a suitable
+step length for the forward-difference approximation. This
+approximation assumes that the relative errors in the
+functions are of the order of \fIepsfcn\fP. If \fIepsfcn\fP is less
+than the machine precision, it is assumed that the relative
+errors in the functions are of the order of the machine
+precision.
+
+\fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see
+below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+
+\fImode\fP is an integer input variable. If \fImode\fP = 1, the
+variables will be scaled internally. If \fImode\fP = 2,
+the scaling is specified by the input \fIdiag\fP. Other
+values of mode are equivalent to \fImode\fP = 1.
+
+\fIfactor\fP is a positive input variable used in determining the
+initial step bound. This bound is set to the product of \fIfactor\fP
+and the euclidean norm of \fIdiag\fP*\fIx\fP if the latter is
+nonzero, or else to \fIfactor\fP itself. In most cases factor should
+lie in the interval (.1,100.). 100. is a generally recommended
+value.
+
+\fInprint\fP is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case, fcn is called
+with \fIiflag\fP = 0 at the beginning of the first iteration and
+every \fInprint\fP iterations thereafter and immediately prior to
+return, with \fIx\fP and \fIfvec\fP available for printing. If
+\fInprint\fP is not positive, no special calls of fcn with
+\fIiflag\fP = 0 are made.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, info is set to the (negative)
+value of iflag. See description of fcn. Otherwise,
+info is set as follows.
+
+  \fIinfo\fP = 0  improper input parameters.
+
+  \fIinfo\fP = 1  both actual and predicted relative reductions
+in the sum of squares are at most \fIftol\fP.
+
+  \fIinfo\fP = 2  relative error between two consecutive iterates
+is at most \fIxtol\fP.
+
+  \fIinfo\fP = 3  conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold.
+
+  \fIinfo\fP = 4  the cosine of the angle between fvec and any
+column of the Jacobian is at most gtol in absolute value.
+
+  \fIinfo\fP = 5  number of calls to \fIfcn\fP has reached or
+exceeded maxfev.
+
+  \fIinfo\fP = 6  \fIftol\fP is too small. No further reduction in
+the sum of squares is possible.
+
+  \fIinfo\fP = 7  \fIxtol\fP is too small. No further improvement in
+the approximate solution x is possible.
+
+  \fIinfo\fP = 8 \fIgtol\fP is too small. \fIfvec\fP is orthogonal to
+the columns of the Jacobian to machine precision.
+
+\fInfev\fP is an integer output variable set to the number of
+calls to \fIfcn\fP.
+
+\fIfjac\fP is an output \fIm\fP by \fIn\fP array. The upper \fIn\fP by
+\fIn\fP submatrix of \fIfjac\fP contains an upper triangular matrix
+\fIr\fP with diagonal elements of nonincreasing magnitude such that
+
+         t     t           t
+        p *(jac *jac)*p = r *r,
+
+where \fIp\fP is a permutation matrix and \fIjac\fP is the final
+calculated Jacobian. column \fBj\fP of \fIp\fP is column
+\fIipvt\fP(\fBj\fP) (see below) of the identity matrix. The lower
+trapezoidal part of \fIfjac\fP contains information generated during
+the computation of \fIr\fP.
+
+\fIldfjac\fP is a positive integer input variable not less than
+\fIm\fP which specifies the leading dimension of the array
+\fIfjac\fP.
+
+\fIipvt\fP is an integer output array of length \fIn\fP. \fIipvt\fP
+defines a permutation matrix \fIp\fP such that \fIjac\fP*\fIp\fP =
+\fIq\fP*\fIr\fP, where \fIjac\fP is the final calculated Jacobian,
+\fIq\fP is orthogonal (not stored), and \fIr\fP is upper triangular
+with diagonal elements of nonincreasing magnitude.  Column \fBj\fP
+of \fIp\fP is column \fIipvt\fP(\fBj\fP) of the identity matrix.
+
+\fIqtf\fP is an output array of length \fIn\fP which contains
+the first \fIn\fP elements of the vector (\fIq\fP transpose)*\fIfvec\fP.
+
+\fIwa1\fP, \fIwa2\fP, and \fIwa3\fP are work arrays of length \fIn\fP.
+
+\fIwa4\fP is a work array of length \fIm\fP.
+.br
+.SH SEE ALSO
+.BR lmder (3),
+.BR lmder1 (3),
+.BR lmstr (3),
+.BR lmstr1 (3).
+.br
+.SH AUTHORS
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+This manual page was written by Jim Van Zandt <jrv at debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
diff --git a/doc/lmdif_.html b/doc/lmdif_.html
new file mode 100644
index 0000000..89097a0
--- /dev/null
+++ b/doc/lmdif_.html
@@ -0,0 +1,421 @@
+
+<HTML><HEAD><TITLE>Manpage of LMDIF_</TITLE>
+</HEAD><BODY>
+<H1>LMDIF_</H1>
+Section: C Library Functions (3)<BR>Updated: March 8, 2002<BR><A HREF="#index">Index</A>
+<A HREF="index.html">Return to Main Contents</A><HR>
+
+
+<A NAME="lbAB"> </A>
+<H2>NAME</H2>
+
+lmdif_, lmdif1_ - minimize the sum of squares of m nonlinear functions 
+<A NAME="lbAC"> </A>
+<H2>SYNOPSIS</H2>
+
+<B>include <<A HREF="file:/usr/include/minpack.h">minpack.h</A>></B>
+
+
+
+<DL COMPACT>
+<DT>
+<B>void lmdif1_ ( </B>
+
+<B>void (*</B><I>fcn</I><B>)(int *</B><I>m</I><B>, int *</B><I>n</I><B>, double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>, int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int * </B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<DD>
+<B>double *</B><I>tol</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>int *</B><I>iwa</I><B>,</B>
+
+<B>double *</B><I>wa</I><B>,</B>
+
+<B>int *</B><I>lwa</I><B>);</B>
+
+</DL>
+
+<DT>
+<B>void lmdif_</B>
+
+<B>( void (*</B><I>fcn</I><B>)(int *</B><I>m</I><B>, int *</B><I>n</I><B>, double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>, int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<DD>
+<B>double *</B><I>ftol</I><B>,</B>
+
+<B>double *</B><I>xtol</I><B>,</B>
+
+<B>double *</B><I>gtol</I><B>,</B>
+
+<B>int *</B><I>maxfev</I><B>,</B>
+
+<B>double *</B><I>epsfcn</I><B>,</B>
+
+<B>double *</B><I>diag</I><B>,</B>
+
+<B>int *</B><I>mode</I><B>,</B>
+
+<B>double *</B><I>factor</I><B>,</B>
+
+<B>int *</B><I>nprint</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>int *</B><I>nfev</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<DD>
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<B>int *</B><I>ipvt</I><B>,</B>
+
+<B>double *</B><I>qtf</I><B>,</B>
+
+<DD>
+<B>double *</B><I>wa1</I><B>,</B>
+
+<B>double *</B><I>wa2</I><B>,</B>
+
+<B>double *</B><I>wa3</I><B>,</B>
+
+<B>double *</B><I>wa4</I><B> );</B>
+
+</DL>
+
+
+
+<DD>
+</DL>
+<A NAME="lbAD"> </A>
+<H2>DESCRIPTION</H2>
+
+<P>
+<DD>The purpose of <B>lmdif_</B> is to minimize the sum of the squares of
+<I>m</I> nonlinear functions in <I>n</I> variables by a modification of
+the Levenberg-Marquardt algorithm. The user must provide a subroutine
+which calculates the functions. The Jacobian is then calculated by a
+forward-difference approximation.
+<P>
+<B>lmdif1_</B> serves the same purpose but has a simplified calling
+sequence.
+<BR>
+
+<A NAME="lbAE"> </A>
+<H3>Language notes</H3>
+
+These functions are written in FORTRAN. If calling from
+C, keep these points in mind:
+<DL COMPACT>
+<DT>Name mangling.<DD>
+With <B>g77</B> version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of <B>g77</B>.
+<DT>Compile with <B>g77</B>.<DD>
+Even if your program is all C code, you should link with <B>g77</B>
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use <B>g77</B> to do all the compiling.  (It handles C just fine.)
+<DT>Call by reference.<DD>
+All function parameters must be pointers.
+<DT>Column-major arrays.<DD>
+Suppose a function returns an array with 5 rows and 3 columns in an
+array <I>z</I> and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+<P>
+<PRE>
+        z(1,1)          z[0]
+        z(2,1)          z[1]
+        z(5,1)          z[4]
+        z(1,2)          z[7]
+        z(1,3)          z[14]
+        z(i,j)          z[(i-1) + (j-1)*7]
+</PRE>
+
+<BR>
+
+<I>fcn</I> is the name of the user-supplied subroutine which
+calculates the functions. In FORTRAN, <I>fcn</I> must be declared
+in an external statement in the user calling
+program, and should be written as follows:
+<P>
+<PRE>
+  subroutine fcn(m,n,x,fvec,iflag)
+  integer m,n,iflag
+  double precision x(n),fvec(m)
+  ----------
+  calculate the functions at x and
+  return this vector in fvec.
+  ----------
+  return
+  end
+</PRE>
+
+<P>
+In C, <I>fcn</I> should be written as follows:
+<P>
+<PRE>
+  void fcn(int m, int n, double *x, double *fvec, int *iflag)
+  {
+          /* calculate the functions at x and return 
+             the values in fvec[0] through fvec[m-1] */
+  }
+</PRE>
+
+<P>
+The value of <I>iflag</I> should not be changed by <I>fcn</I> unless the
+user wants to terminate execution of <B>lmdif_</B> (or <B>lmdif1_</B>). In
+this case set <I>iflag</I> to a negative integer.
+<BR>
+
+</DL>
+<A NAME="lbAF"> </A>
+<H3>Parameters for both <B>lmdif_</B> and <B>lmdif1_</B></H3>
+
+<P>
+<I>m</I> is a positive integer input variable set to the number
+of functions.
+<P>
+<I>n</I> is a positive integer input variable set to the number
+of variables. <I>n</I> must not exceed <I>m</I>.
+<P>
+<I>x</I> is an array of length <I>n</I>. On input <I>x</I> must contain
+an initial estimate of the solution vector. On output <I>x</I>
+contains the final estimate of the solution vector.
+<P>
+<I>fvec</I> is an output array of length <I>m</I> which contains
+the functions evaluated at the output <I>x</I>.
+<BR>
+
+<A NAME="lbAG"> </A>
+<H3>Parameters for <B>lmdif1_</B> </H3>
+
+<P>
+<I>tol</I> is a nonnegative input variable.  Termination occurs when
+the algorithm estimates either that the relative error in the sum of
+squares is at most <I>tol</I> or that the relative error between
+<I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> is an integer output variable. if the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of iflag. see description of <I>fcn</I>. otherwise,
+<I>info</I> is set as follows.
+<P>
+<BR>  <I>info</I> = 0  improper input parameters.
+<P>
+<BR>  <I>info</I> = 1  algorithm estimates that the relative error
+in the sum of squares is at most <I>tol</I>.
+<P>
+<BR>  <I>info</I> = 2  algorithm estimates that the relative error
+between x and the solution is at most <I>tol</I>.
+<P>
+<BR>  <I>info</I> = 3  conditions for <I>info</I> = 1 and <I>info</I> = 2 both hold.
+<P>
+<BR>  <I>info</I> = 4  <I>fvec</I> is orthogonal to the columns of the
+Jacobian to machine precision.
+<P>
+<BR>  <I>info</I> = 5  number of calls to <I>fcn</I> has reached or
+exceeded 200*(<I>n</I>+1).
+<P>
+<BR>  <I>info</I> = 6  <I>tol</I> is too small. no further reduction in
+the sum of squares is possible.
+<P>
+<BR>  <I>info</I> = 7  <I>tol</I> is too small. no further improvement in
+the approximate solution x is possible.
+<P>
+<I>iwa</I> is an integer work array of length <I>n</I>.
+<P>
+<I>wa</I> is a work array of length <I>lwa</I>.
+<P>
+<I>lwa</I> is an integer input variable not less than <I>m</I>*<I>n</I> +
+5*<I>n</I> + <I>m</I>.
+<BR>
+
+<A NAME="lbAH"> </A>
+<H3>Parameters for <B>lmdif_</B></H3>
+
+<P>
+<I>ftol</I> is a nonnegative input variable. Termination
+occurs when both the actual and predicted relative
+reductions in the sum of squares are at most <I>ftol</I>.
+Therefore, <I>ftol</I> measures the relative error desired
+in the sum of squares.
+<P>
+<I>xtol</I> is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most <I>xtol</I>. Therefore, <I>xtol</I> measures the
+relative error desired in the approximate solution.
+<P>
+<I>gtol</I> is a nonnegative input variable. Termination
+occurs when the cosine of the angle between <I>fvec</I> and
+any column of the Jacobian is at most <I>gtol</I> in absolute
+value. Therefore, <I>gtol</I> measures the orthogonality
+desired between the function vector and the columns
+of the Jacobian.
+<P>
+<I>maxfev</I> is a positive integer input variable. Termination
+occurs when the number of calls to <I>fcn</I> is at least
+<I>maxfev</I> by the end of an iteration.
+<P>
+<I>epsfcn</I> is an input variable used in determining a suitable
+step length for the forward-difference approximation. This
+approximation assumes that the relative errors in the
+functions are of the order of <I>epsfcn</I>. If <I>epsfcn</I> is less
+than the machine precision, it is assumed that the relative
+errors in the functions are of the order of the machine
+precision.
+<P>
+<I>diag</I> is an array of length <I>n</I>. If <I>mode</I> = 1 (see
+below), <I>diag</I> is internally set. If <I>mode</I> = 2, <I>diag</I>
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+<P>
+<I>mode</I> is an integer input variable. If <I>mode</I> = 1, the
+variables will be scaled internally. If <I>mode</I> = 2,
+the scaling is specified by the input <I>diag</I>. Other
+values of mode are equivalent to <I>mode</I> = 1.
+<P>
+<I>factor</I> is a positive input variable used in determining the
+initial step bound. This bound is set to the product of <I>factor</I>
+and the euclidean norm of <I>diag</I>*<I>x</I> if the latter is
+nonzero, or else to <I>factor</I> itself. In most cases factor should
+lie in the interval (.1,100.). 100. is a generally recommended
+value.
+<P>
+<I>nprint</I> is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case, fcn is called
+with <I>iflag</I> = 0 at the beginning of the first iteration and
+every <I>nprint</I> iterations thereafter and immediately prior to
+return, with <I>x</I> and <I>fvec</I> available for printing. If
+<I>nprint</I> is not positive, no special calls of fcn with
+<I>iflag</I> = 0 are made.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, info is set to the (negative)
+value of iflag. See description of fcn. Otherwise,
+info is set as follows.
+<P>
+<BR>  <I>info</I> = 0  improper input parameters.
+<P>
+<BR>  <I>info</I> = 1  both actual and predicted relative reductions
+in the sum of squares are at most <I>ftol</I>.
+<P>
+<BR>  <I>info</I> = 2  relative error between two consecutive iterates
+is at most <I>xtol</I>.
+<P>
+<BR>  <I>info</I> = 3  conditions for <I>info</I> = 1 and <I>info</I> = 2 both hold.
+<P>
+<BR>  <I>info</I> = 4  the cosine of the angle between fvec and any
+column of the Jacobian is at most gtol in absolute value.
+<P>
+<BR>  <I>info</I> = 5  number of calls to <I>fcn</I> has reached or
+exceeded maxfev.
+<P>
+<BR>  <I>info</I> = 6  <I>ftol</I> is too small. No further reduction in
+the sum of squares is possible.
+<P>
+<BR>  <I>info</I> = 7  <I>xtol</I> is too small. No further improvement in
+the approximate solution x is possible.
+<P>
+<BR>  <I>info</I> = 8 <I>gtol</I> is too small. <I>fvec</I> is orthogonal to
+the columns of the Jacobian to machine precision.
+<P>
+<I>nfev</I> is an integer output variable set to the number of
+calls to <I>fcn</I>.
+<P>
+<I>fjac</I> is an output <I>m</I> by <I>n</I> array. The upper <I>n</I> by
+<I>n</I> submatrix of <I>fjac</I> contains an upper triangular matrix
+<I>r</I> with diagonal elements of nonincreasing magnitude such that
+<P>
+<BR>         t     t           t
+<BR>        p *(jac *jac)*p = r *r,
+<P>
+where <I>p</I> is a permutation matrix and <I>jac</I> is the final
+calculated Jacobian. column <B>j</B> of <I>p</I> is column
+<I>ipvt</I>(<B>j</B>) (see below) of the identity matrix. The lower
+trapezoidal part of <I>fjac</I> contains information generated during
+the computation of <I>r</I>.
+<P>
+<I>ldfjac</I> is a positive integer input variable not less than
+<I>m</I> which specifies the leading dimension of the array
+<I>fjac</I>.
+<P>
+<I>ipvt</I> is an integer output array of length <I>n</I>. <I>ipvt</I>
+defines a permutation matrix <I>p</I> such that <I>jac</I>*<I>p</I> =
+<I>q</I>*<I>r</I>, where <I>jac</I> is the final calculated Jacobian,
+<I>q</I> is orthogonal (not stored), and <I>r</I> is upper triangular
+with diagonal elements of nonincreasing magnitude.  Column <B>j</B>
+of <I>p</I> is column <I>ipvt</I>(<B>j</B>) of the identity matrix.
+<P>
+<I>qtf</I> is an output array of length <I>n</I> which contains
+the first <I>n</I> elements of the vector (<I>q</I> transpose)*<I>fvec</I>.
+<P>
+<I>wa1</I>, <I>wa2</I>, and <I>wa3</I> are work arrays of length <I>n</I>.
+<P>
+<I>wa4</I> is a work array of length <I>m</I>.
+<BR>
+
+<A NAME="lbAI"> </A>
+<H2>SEE ALSO</H2>
+
+<B><A HREF="lmder_.html">lmder</A></B>(3),
+
+<B><A HREF="lmder_.html">lmder1</A></B>(3),
+
+<B><A HREF="lmstr_.html">lmstr</A></B>(3),
+
+<B><A HREF="lmstr_.html">lmstr1</A></B>(3).
+
+<BR>
+
+<A NAME="lbAJ"> </A>
+<H2>AUTHORS</H2>
+
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+This manual page was written by Jim Van Zandt <<A HREF="mailto:jrv at debian.org">jrv at debian.org</A>>,
+for the Debian GNU/Linux system (but may be used by others).
+<P>
+
+<HR>
+<A NAME="index"> </A><H2>Index</H2>
+<DL>
+<DT><A HREF="#lbAB">NAME</A><DD>
+<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
+<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
+<DL>
+<DT><A HREF="#lbAE">Language notes</A><DD>
+<DT><A HREF="#lbAF">Parameters for both <B>lmdif_</B> and <B>lmdif1_</B></A><DD>
+<DT><A HREF="#lbAG">Parameters for <B>lmdif1_</B> </A><DD>
+<DT><A HREF="#lbAH">Parameters for <B>lmdif_</B></A><DD>
+</DL>
+<DT><A HREF="#lbAI">SEE ALSO</A><DD>
+<DT><A HREF="#lbAJ">AUTHORS</A><DD>
+</DL>
+<HR>
+This document was created by
+<A HREF="index.html">man2html</A>,
+using the manual pages.<BR>
+Time: 10:19:50 GMT, April 20, 2007
+</BODY>
+</HTML>
diff --git a/doc/lmstr1_.3 b/doc/lmstr1_.3
new file mode 100644
index 0000000..ec294e0
--- /dev/null
+++ b/doc/lmstr1_.3
@@ -0,0 +1 @@
+.so man3/lmstr_.3
diff --git a/doc/lmstr_.3 b/doc/lmstr_.3
new file mode 100644
index 0000000..d0de9bb
--- /dev/null
+++ b/doc/lmstr_.3
@@ -0,0 +1,340 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.TH LMSTR_ 3 "March 8, 2002" Minpack
+.\" Please adjust this date whenever revising the manpage.
+.SH NAME
+lmstr_, lmstr1_ \- minimize the sum of squares of m nonlinear functions, with user supplied Jacobian and minimal storage
+.SH SYNOPSIS
+.B include <minpack.h>
+.nh
+.ad l
+.HP 28
+.BI "void lmstr1_ ( "
+.BI "void (*" fcn         )
+.BI "(int *"     m        , 
+.BI "int *"      n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.BI "double *"   fjrow    ,
+.BI "int *"      iflag    ),
+.RS 15
+.BI "int *"      m        ,
+.BI "int * "     n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.BI "double *"   fjac     ,
+.BI "int *"      ldfjac   ,
+.br
+.BI "double *"   tol      , 
+.BI "int *"      info     ,
+.BI "int *"      iwa      ,
+.br
+.BI "double *"   wa       ,
+.BI "int *"      kwa      );
+.RE
+.HP 27
+.BI "void lmstr_"
+.BI "( void (*" fcn )(
+.BI "int *"      m        , 
+.BI "int *"      n        ,
+.BI "double *"   x        , 
+.BI "double *"   fvec     , 
+.BI "double *"   fjrow    ,
+.BI "int *"      iflag    ),
+.RS 14
+.BI "int *"      m        ,
+.BI "int *"      n        ,
+.BI "double *"   x        ,
+.BI "double *"   fvec     ,
+.BI "double *"   fjac     ,
+.BI "int *"      ldfjac   ,
+.br
+.BI "double *"   ftol     ,
+.BI "double *"   xtol     ,
+.BI "double *"   gtol     ,
+.br
+.BI "int *"      maxfev   ,
+.BI "double *"   diag     ,
+.BI "int *"      mode     ,
+.BI "double *"   factor   ,
+.br
+.BI "int *"      nprint   ,
+.BI "int *"      info     ,
+.BI "int *"      nfev     ,
+.BI "int *"      njev     ,
+.br
+.BI "int *"      ipvt     ,
+.BI "double *"   qtf      ,
+.br
+.BI "double *"   wa1      ,
+.BI "double *"   wa2      ,
+.BI "double *"   wa3      ,
+.BI "double *"   wa4      " );"
+.RE
+.hy
+.ad b
+.br
+.SH DESCRIPTION
+
+The purpose of \fBlmstr_\fP is to minimize the sum of the squares of
+\fIm\fP nonlinear functions in \fIn\fP variables by a modification of
+the Levenberg-Marquardt algorithm. The user must provide a function 
+which calculates the functions and the rows of the Jacobian.
+.PP
+\fBlmstr1_\fP performs the same function but has a simplified calling sequence.
+.PP
+\fBlmder\fP(3) and \fBlmder1\fP(3) perform the same function but do
+not attempt to minimize storage.
+.br
+.SS Language notes
+These functions are written in FORTRAN. If calling from
+C, keep these points in mind:
+.TP
+Name mangling.
+With \fBg77\fP version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of \fBg77\fP.
+.TP
+Compile with \fBg77\fP.
+Even if your program is all C code, you should link with \fBg77\fP
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use \fBg77\fP to do all the compiling.  (It handles C just fine.)
+.TP
+Call by reference.
+All function parameters must be pointers.
+.TP
+Column-major arrays.
+Suppose a function returns an array with 5 rows and 3 columns in an
+array \fIz\fP and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+.sp
+.nf
+	z(1,1)		z[0]
+	z(2,1)		z[1]
+	z(5,1)		z[4]
+	z(1,2)		z[7]
+	z(1,3)		z[14]
+	z(i,j)		z[(i-1) + (j-1)*7]
+.fi
+.br
+.SS User-supplied Function
+
+\fIfcn\fP is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, \fIfcn\fP must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+.sp
+.nf
+  subroutine fcn(m,n,x,fvec,fjrow,iflag)
+  integer m,n,iflag
+  double precision x(n),fvec(m),fjrow(n)
+  ----------
+  if iflag = 1 calculate the functions at x and
+  return this vector in fvec. Do not alter fjac.
+  if iflag = i calculate row (i-1) of the
+  Jacobian at x and return this vector in fjrow.
+  ----------
+  return
+  end
+.fi
+.sp
+In C, \fIfcn\fP should be written as follows:
+.sp
+.nf
+  void fcn(int m, int n, double *x, double *fvec, double *fjrow,
+           int *iflag)
+  {
+    /* If iflag = 1 calculate the functions at x and return the
+       values in fvec[0] through fvec[m-1].  Do not alter fjac.
+       If iflag = i calculate row (i-1) of the Jacobian
+       at x and return the vector in fjrow. */
+  }
+.fi
+.sp
+\fIiflag\fP is an input integer which specifies whether a function
+value or Jacobian row is to be calculated.
+The value of \fIiflag\fP should not be changed by \fIfcn\fP unless the
+user wants to terminate execution of \fBlmstr_\fP (or \fBlmstr1_\fP). In
+this case set \fIiflag\fP to a negative integer.
+.br
+.SS Parameters for both \fBlmstr_\fP and \fBlmstr1_\fP
+
+\fIm\fP is a positive integer input variable set to the number
+of functions.
+
+\fIn\fP is a positive integer input variable set to the number
+of variables. \fIn\fP must not exceed \fIm\fP.
+
+\fIx\fP is an array of length \fIn\fP. On input \fIx\fP must contain
+an initial estimate of the solution vector. On output \fIx\fP
+contains the final estimate of the solution vector.
+
+\fIfvec\fP is an output array of length \fIm\fP which contains
+the functions evaluated at the output \fIx\fP.
+
+\fIfjrow\fP is an output array of length \fIn\fP which is set to one
+row of the Jacobian evaluated at \fIx\fP.
+
+\fIfjac\fP is an output \fIm\fP by \fIn\fP array. The upper \fIn\fP by
+\fIn\fP submatrix of \fIfjac\fP contains an upper triangular matrix
+\fBr\fP with diagonal elements of nonincreasing magnitude such that
+
+         t     t           t
+        p *(jac *jac)*p = r *r,
+
+where \fIp\fP is a permutation matrix and \fBjac\fP is the final
+calculated Jacobian. Column \fBj\fP of \fIp\fP is column
+\fIipvt\fP(\fBj\fP) (see below) of the identity matrix. The lower
+trapezoidal part of \fIfjac\fP contains information generated during
+the computation of \fBr\fP.
+
+\fIldfjac\fP is a positive integer input variable not less than
+\fIm\fP which specifies the leading dimension of the array
+\fIfjac\fP.
+.br
+.SS Parameters for \fBlmstr1_\fP
+
+\fItol\fP is a nonnegative input variable.  Termination occurs when
+the algorithm estimates either that the relative error in the sum of
+squares is at most \fItol\fP or that the relative error between
+\fIx\fP and the solution is at most \fItol\fP.
+
+\fIinfo\fP is an integer output variable. if the user has
+terminated execution, \fIinfo\fP is set to the (negative)
+value of iflag. see description of \fIfcn\fP. otherwise,
+\fIinfo\fP is set as follows.
+
+  \fIinfo\fP = 0  improper input parameters.
+
+  \fIinfo\fP = 1  algorithm estimates that the relative error
+in the sum of squares is at most \fItol\fP.
+
+  \fIinfo\fP = 2  algorithm estimates that the relative error
+between x and the solution is at most \fItol\fP.
+
+  \fIinfo\fP = 3  conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold.
+
+  \fIinfo\fP = 4  \fIfvec\fP is orthogonal to the columns of the
+Jacobian to machine precision.
+
+  \fIinfo\fP = 5  number of calls to \fIfcn\fP has reached or
+exceeded 100*(\fIn\fP+1).
+
+  \fIinfo\fP = 6  \fItol\fP is too small. no further reduction in
+the sum of squares is possible.
+
+  \fIinfo\fP = 7  \fItol\fP is too small. no further improvement in
+the approximate solution x is possible.
+
+\fIwa\fP is a work array of length \fIlwa\fP.
+
+\fIlwa\fP is an integer input variable not less than \fIm\fP*\fIn\fP +
+5*\fIn\fP + \fIm\fP for \fBlmder1\fP, or 5*\fIn\fP+\fIm\fP for \fBlmstr1_\fP.
+.br
+.SS Parameters for \fBlmstr_\fP
+
+\fIftol\fP is a nonnegative input variable. Termination
+occurs when both the actual and predicted relative
+reductions in the sum of squares are at most \fIftol\fP.
+Therefore, \fIftol\fP measures the relative error desired
+in the sum of squares.
+
+\fIxtol\fP is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most \fIxtol\fP. Therefore, \fIxtol\fP measures the
+relative error desired in the approximate solution.
+
+\fIgtol\fP is a nonnegative input variable. Termination
+occurs when the cosine of the angle between \fIfvec\fP and
+any column of the Jacobian is at most \fIgtol\fP in absolute
+value. Therefore, \fIgtol\fP measures the orthogonality
+desired between the function vector and the columns
+of the Jacobian.
+
+\fImaxfev\fP is a positive integer input variable. Termination
+occurs when the number of calls to \fIfcn\fP is at least
+\fImaxfev\fP by the end of an iteration.
+
+\fIdiag\fP is an array of length \fIn\fP. If \fImode\fP = 1 (see
+below), \fIdiag\fP is internally set. If \fImode\fP = 2, \fIdiag\fP
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+
+\fImode\fP is an integer input variable. If \fImode\fP = 1, the
+variables will be scaled internally. If \fImode\fP = 2,
+the scaling is specified by the input \fIdiag\fP. Other
+values of mode are equivalent to \fImode\fP = 1.
+
+\fIfactor\fP is a positive input variable used in determining the
+initial step bound. This bound is set to the product of \fIfactor\fP
+and the euclidean norm of \fIdiag\fP*\fIx\fP if the latter is
+nonzero, or else to \fIfactor\fP itself. In most cases factor should
+lie in the interval (.1,100.). 100. is a generally recommended
+value.
+
+\fInprint\fP is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case, fcn is called
+with \fIiflag\fP = 0 at the beginning of the first iteration and
+every \fInprint\fP iterations thereafter and immediately prior to
+return, with \fIx\fP and \fIfvec\fP available for printing. If
+\fInprint\fP is not positive, no special calls of fcn with
+\fIiflag\fP = 0 are made.
+
+\fIinfo\fP is an integer output variable. If the user has
+terminated execution, info is set to the (negative)
+value of iflag. See description of fcn. Otherwise,
+info is set as follows.
+
+  \fIinfo\fP = 0  improper input parameters.
+
+  \fIinfo\fP = 1  both actual and predicted relative reductions
+in the sum of squares are at most \fIftol\fP.
+
+  \fIinfo\fP = 2  relative error between two consecutive iterates
+is at most \fIxtol\fP.
+
+  \fIinfo\fP = 3  conditions for \fIinfo\fP = 1 and \fIinfo\fP = 2 both hold.
+
+  \fIinfo\fP = 4  the cosine of the angle between fvec and any
+column of the Jacobian is at most gtol in absolute value.
+
+  \fIinfo\fP = 5  number of calls to \fIfcn\fP has reached or
+exceeded maxfev.
+
+  \fIinfo\fP = 6  \fIftol\fP is too small. No further reduction in
+the sum of squares is possible.
+
+  \fIinfo\fP = 7  \fIxtol\fP is too small. No further improvement in
+the approximate solution x is possible.
+
+  \fIinfo\fP = 8 \fIgtol\fP is too small. \fIfvec\fP is orthogonal to
+the columns of the Jacobian to machine precision.
+
+\fInfev\fP is an integer output variable set to the number of
+calls to \fIfcn\fP with \fIiflag\fP = 1.
+
+\fInjev\fP is an integer output variable set to the number of
+calls to fcn with \fIiflag\fP = 2.
+
+\fIipvt\fP is an integer output array of length \fIn\fP. \fIipvt\fP
+defines a permutation matrix \fIp\fP such that \fIjac\fP*\fIp\fP =
+\fIq\fP*\fIr\fP, where \fIjac\fP is the final calculated Jacobian,
+\fIq\fP is orthogonal (not stored), and \fIr\fP is upper triangular
+with diagonal elements of nonincreasing magnitude.  Column \fBj\fP
+of \fIp\fP is column \fIipvt\fP(\fBj\fP) of the identity matrix.
+
+\fIqtf\fP is an output array of length \fIn\fP which contains
+the first \fIn\fP elements of the vector (\fIq\fP transpose)*\fIfvec\fP.
+
+\fIwa1\fP, \fIwa2\fP, and \fIwa3\fP are work arrays of length \fIn\fP.
+
+\fIwa4\fP is a work array of length \fIm\fP.
+.br
+.SH SEE ALSO
+.BR lmdif (3),
+.BR lmdif1 (3),
+.BR lmder (3),
+.BR lmder1 (3).
+.br
+.SH AUTHORS
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+This manual page was written by Jim Van Zandt <jrv at debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
diff --git a/doc/lmstr_.html b/doc/lmstr_.html
new file mode 100644
index 0000000..2fbc9d3
--- /dev/null
+++ b/doc/lmstr_.html
@@ -0,0 +1,458 @@
+<HTML><HEAD><TITLE>Manpage of LMSTR_</TITLE>
+</HEAD><BODY>
+<H1>LMSTR_</H1>
+Section: C Library Functions (3)<BR>Updated: March 8, 2002<BR><A HREF="#index">Index</A>
+<A HREF="index.html">Return to Main Contents</A><HR>
+
+
+<A NAME="lbAB"> </A>
+<H2>NAME</H2>
+
+lmstr_, lmstr1_ - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian and minimal storage
+<A NAME="lbAC"> </A>
+<H2>SYNOPSIS</H2>
+
+<B>include <<A HREF="file:/usr/include/minpack.h">minpack.h</A>></B>
+
+
+
+<DL COMPACT>
+<DT>
+<B>void lmstr1_ ( </B>
+
+<B>void (*</B><I>fcn</I><B>)</B>
+
+<B>(int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjrow</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int * </B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>tol</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>int *</B><I>iwa</I><B>,</B>
+
+<DD>
+<B>double *</B><I>wa</I><B>,</B>
+
+<B>int *</B><I>kwa</I><B>);</B>
+
+</DL>
+
+<DT>
+<B>void lmstr_</B>
+
+<B>( void (*</B><I>fcn</I><B>)(</B>
+
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjrow</I><B>,</B>
+
+<B>int *</B><I>iflag</I><B>),</B>
+
+<DL COMPACT><DT><DD>
+<B>int *</B><I>m</I><B>,</B>
+
+<B>int *</B><I>n</I><B>,</B>
+
+<B>double *</B><I>x</I><B>,</B>
+
+<B>double *</B><I>fvec</I><B>,</B>
+
+<B>double *</B><I>fjac</I><B>,</B>
+
+<B>int *</B><I>ldfjac</I><B>,</B>
+
+<DD>
+<B>double *</B><I>ftol</I><B>,</B>
+
+<B>double *</B><I>xtol</I><B>,</B>
+
+<B>double *</B><I>gtol</I><B>,</B>
+
+<DD>
+<B>int *</B><I>maxfev</I><B>,</B>
+
+<B>double *</B><I>diag</I><B>,</B>
+
+<B>int *</B><I>mode</I><B>,</B>
+
+<B>double *</B><I>factor</I><B>,</B>
+
+<DD>
+<B>int *</B><I>nprint</I><B>,</B>
+
+<B>int *</B><I>info</I><B>,</B>
+
+<B>int *</B><I>nfev</I><B>,</B>
+
+<B>int *</B><I>njev</I><B>,</B>
+
+<DD>
+<B>int *</B><I>ipvt</I><B>,</B>
+
+<B>double *</B><I>qtf</I><B>,</B>
+
+<DD>
+<B>double *</B><I>wa1</I><B>,</B>
+
+<B>double *</B><I>wa2</I><B>,</B>
+
+<B>double *</B><I>wa3</I><B>,</B>
+
+<B>double *</B><I>wa4</I><B> );</B>
+
+</DL>
+
+
+
+<DD>
+</DL>
+<A NAME="lbAD"> </A>
+<H2>DESCRIPTION</H2>
+
+<P>
+<DD>The purpose of <B>lmstr_</B> is to minimize the sum of the squares of
+<I>m</I> nonlinear functions in <I>n</I> variables by a modification of
+the Levenberg-Marquardt algorithm. The user must provide a function 
+which calculates the functions and the rows of the Jacobian.
+<P>
+
+<B>lmstr1_</B> performs the same function but has a simplified calling sequence.
+<P>
+
+<B><A HREF="lmder_.html">lmder</A></B>(3) and <B><A HREF="lmder_.html">lmder1</A></B>(3) perform the same function but do
+not attempt to minimize storage.
+<BR>
+
+<A NAME="lbAE"> </A>
+<H3>Language notes</H3>
+
+These functions are written in FORTRAN. If calling from
+C, keep these points in mind:
+<DL COMPACT>
+<DT>Name mangling.<DD>
+With <B>g77</B> version 2.95 or 3.0, all the function names end in an
+underscore.  This may change with future versions of <B>g77</B>.
+<DT>Compile with <B>g77</B>.<DD>
+Even if your program is all C code, you should link with <B>g77</B>
+so it will pull in the FORTRAN libraries automatically.  It's easiest
+just to use <B>g77</B> to do all the compiling.  (It handles C just fine.)
+<DT>Call by reference.<DD>
+All function parameters must be pointers.
+<DT>Column-major arrays.<DD>
+Suppose a function returns an array with 5 rows and 3 columns in an
+array <I>z</I> and in the call you have declared a leading dimension of
+7.  The FORTRAN and equivalent C references are:
+<P>
+<PRE>
+        z(1,1)          z[0]
+        z(2,1)          z[1]
+        z(5,1)          z[4]
+        z(1,2)          z[7]
+        z(1,3)          z[14]
+        z(i,j)          z[(i-1) + (j-1)*7]
+</PRE>
+
+<BR>
+
+</DL>
+<A NAME="lbAF"> </A>
+<H3>User-supplied Function</H3>
+
+<P>
+<I>fcn</I> is the name of the user-supplied subroutine which calculates
+the functions. In FORTRAN, <I>fcn</I> must be declared in an external
+statement in the user calling program, and should be written as
+follows:
+<P>
+<PRE>
+  subroutine fcn(m,n,x,fvec,fjrow,iflag)
+  integer m,n,iflag
+  double precision x(n),fvec(m),fjrow(n)
+  ----------
+  if iflag = 1 calculate the functions at x and
+  return this vector in fvec. Do not alter fjac.
+  if iflag = i calculate row (i-1) of the
+  Jacobian at x and return this vector in fjrow.
+  ----------
+  return
+  end
+</PRE>
+
+<P>
+In C, <I>fcn</I> should be written as follows:
+<P>
+<PRE>
+  void fcn(int m, int n, double *x, double *fvec, double *fjrow,
+           int *iflag)
+  {
+    /* If iflag = 1 calculate the functions at x and return the
+       values in fvec[0] through fvec[m-1].  Do not alter fjac.
+       If iflag = i calculate row (i-1) of the Jacobian
+       at x and return the vector in fjrow. */
+  }
+</PRE>
+
+<P>
+<I>iflag</I> is an input integer which specifies whether a function
+value or Jacobian row is to be calculated.
+The value of <I>iflag</I> should not be changed by <I>fcn</I> unless the
+user wants to terminate execution of <B>lmstr_</B> (or <B>lmstr1_</B>). In
+this case set <I>iflag</I> to a negative integer.
+<BR>
+
+<A NAME="lbAG"> </A>
+<H3>Parameters for both <B>lmstr_</B> and <B>lmstr1_</B></H3>
+
+<P>
+<I>m</I> is a positive integer input variable set to the number
+of functions.
+<P>
+<I>n</I> is a positive integer input variable set to the number
+of variables. <I>n</I> must not exceed <I>m</I>.
+<P>
+<I>x</I> is an array of length <I>n</I>. On input <I>x</I> must contain
+an initial estimate of the solution vector. On output <I>x</I>
+contains the final estimate of the solution vector.
+<P>
+<I>fvec</I> is an output array of length <I>m</I> which contains
+the functions evaluated at the output <I>x</I>.
+<P>
+<I>fjrow</I> is an output array of length <I>n</I> which is set to one
+row of the Jacobian evaluated at <I>x</I>.
+<P>
+<I>fjac</I> is an output <I>m</I> by <I>n</I> array. The upper <I>n</I> by
+<I>n</I> submatrix of <I>fjac</I> contains an upper triangular matrix
+<B>r</B> with diagonal elements of nonincreasing magnitude such that
+<P>
+<BR>         t     t           t
+<BR>        p *(jac *jac)*p = r *r,
+<P>
+where <I>p</I> is a permutation matrix and <B>jac</B> is the final
+calculated Jacobian. Column <B>j</B> of <I>p</I> is column
+<I>ipvt</I>(<B>j</B>) (see below) of the identity matrix. The lower
+trapezoidal part of <I>fjac</I> contains information generated during
+the computation of <B>r</B>.
+<P>
+<I>ldfjac</I> is a positive integer input variable not less than
+<I>m</I> which specifies the leading dimension of the array
+<I>fjac</I>.
+<BR>
+
+<A NAME="lbAH"> </A>
+<H3>Parameters for <B>lmstr1_</B></H3>
+
+<P>
+<I>tol</I> is a nonnegative input variable.  Termination occurs when
+the algorithm estimates either that the relative error in the sum of
+squares is at most <I>tol</I> or that the relative error between
+<I>x</I> and the solution is at most <I>tol</I>.
+<P>
+<I>info</I> is an integer output variable. if the user has
+terminated execution, <I>info</I> is set to the (negative)
+value of iflag. see description of <I>fcn</I>. otherwise,
+<I>info</I> is set as follows.
+<P>
+<BR>  <I>info</I> = 0  improper input parameters.
+<P>
+<BR>  <I>info</I> = 1  algorithm estimates that the relative error
+in the sum of squares is at most <I>tol</I>.
+<P>
+<BR>  <I>info</I> = 2  algorithm estimates that the relative error
+between x and the solution is at most <I>tol</I>.
+<P>
+<BR>  <I>info</I> = 3  conditions for <I>info</I> = 1 and <I>info</I> = 2 both hold.
+<P>
+<BR>  <I>info</I> = 4  <I>fvec</I> is orthogonal to the columns of the
+Jacobian to machine precision.
+<P>
+<BR>  <I>info</I> = 5  number of calls to <I>fcn</I> has reached or
+exceeded 100*(<I>n</I>+1).
+<P>
+<BR>  <I>info</I> = 6  <I>tol</I> is too small. no further reduction in
+the sum of squares is possible.
+<P>
+<BR>  <I>info</I> = 7  <I>tol</I> is too small. no further improvement in
+the approximate solution x is possible.
+<P>
+<I>wa</I> is a work array of length <I>lwa</I>.
+<P>
+<I>lwa</I> is an integer input variable not less than <I>m</I>*<I>n</I> +
+5*<I>n</I> + <I>m</I> for <B>lmder1</B>, or 5*<I>n</I>+<I>m</I> for <B>lmstr1_</B>.
+<BR>
+
+<A NAME="lbAI"> </A>
+<H3>Parameters for <B>lmstr_</B></H3>
+
+<P>
+<I>ftol</I> is a nonnegative input variable. Termination
+occurs when both the actual and predicted relative
+reductions in the sum of squares are at most <I>ftol</I>.
+Therefore, <I>ftol</I> measures the relative error desired
+in the sum of squares.
+<P>
+<I>xtol</I> is a nonnegative input variable. Termination
+occurs when the relative error between two consecutive
+iterates is at most <I>xtol</I>. Therefore, <I>xtol</I> measures the
+relative error desired in the approximate solution.
+<P>
+<I>gtol</I> is a nonnegative input variable. Termination
+occurs when the cosine of the angle between <I>fvec</I> and
+any column of the Jacobian is at most <I>gtol</I> in absolute
+value. Therefore, <I>gtol</I> measures the orthogonality
+desired between the function vector and the columns
+of the Jacobian.
+<P>
+<I>maxfev</I> is a positive integer input variable. Termination
+occurs when the number of calls to <I>fcn</I> is at least
+<I>maxfev</I> by the end of an iteration.
+<P>
+<I>diag</I> is an array of length <I>n</I>. If <I>mode</I> = 1 (see
+below), <I>diag</I> is internally set. If <I>mode</I> = 2, <I>diag</I>
+must contain positive entries that serve as
+multiplicative scale factors for the variables.
+<P>
+<I>mode</I> is an integer input variable. If <I>mode</I> = 1, the
+variables will be scaled internally. If <I>mode</I> = 2,
+the scaling is specified by the input <I>diag</I>. Other
+values of mode are equivalent to <I>mode</I> = 1.
+<P>
+<I>factor</I> is a positive input variable used in determining the
+initial step bound. This bound is set to the product of <I>factor</I>
+and the euclidean norm of <I>diag</I>*<I>x</I> if the latter is
+nonzero, or else to <I>factor</I> itself. In most cases factor should
+lie in the interval (.1,100.). 100. is a generally recommended
+value.
+<P>
+<I>nprint</I> is an integer input variable that enables controlled
+printing of iterates if it is positive. In this case, fcn is called
+with <I>iflag</I> = 0 at the beginning of the first iteration and
+every <I>nprint</I> iterations thereafter and immediately prior to
+return, with <I>x</I> and <I>fvec</I> available for printing. If
+<I>nprint</I> is not positive, no special calls of fcn with
+<I>iflag</I> = 0 are made.
+<P>
+<I>info</I> is an integer output variable. If the user has
+terminated execution, info is set to the (negative)
+value of iflag. See description of fcn. Otherwise,
+info is set as follows.
+<P>
+<BR>  <I>info</I> = 0  improper input parameters.
+<P>
+<BR>  <I>info</I> = 1  both actual and predicted relative reductions
+in the sum of squares are at most <I>ftol</I>.
+<P>
+<BR>  <I>info</I> = 2  relative error between two consecutive iterates
+is at most <I>xtol</I>.
+<P>
+<BR>  <I>info</I> = 3  conditions for <I>info</I> = 1 and <I>info</I> = 2 both hold.
+<P>
+<BR>  <I>info</I> = 4  the cosine of the angle between fvec and any
+column of the Jacobian is at most gtol in absolute value.
+<P>
+<BR>  <I>info</I> = 5  number of calls to <I>fcn</I> has reached or
+exceeded maxfev.
+<P>
+<BR>  <I>info</I> = 6  <I>ftol</I> is too small. No further reduction in
+the sum of squares is possible.
+<P>
+<BR>  <I>info</I> = 7  <I>xtol</I> is too small. No further improvement in
+the approximate solution x is possible.
+<P>
+<BR>  <I>info</I> = 8 <I>gtol</I> is too small. <I>fvec</I> is orthogonal to
+the columns of the Jacobian to machine precision.
+<P>
+<I>nfev</I> is an integer output variable set to the number of
+calls to <I>fcn</I> with <I>iflag</I> = 1.
+<P>
+<I>njev</I> is an integer output variable set to the number of
+calls to fcn with <I>iflag</I> = 2.
+<P>
+<I>ipvt</I> is an integer output array of length <I>n</I>. <I>ipvt</I>
+defines a permutation matrix <I>p</I> such that <I>jac</I>*<I>p</I> =
+<I>q</I>*<I>r</I>, where <I>jac</I> is the final calculated Jacobian,
+<I>q</I> is orthogonal (not stored), and <I>r</I> is upper triangular
+with diagonal elements of nonincreasing magnitude.  Column <B>j</B>
+of <I>p</I> is column <I>ipvt</I>(<B>j</B>) of the identity matrix.
+<P>
+<I>qtf</I> is an output array of length <I>n</I> which contains
+the first <I>n</I> elements of the vector (<I>q</I> transpose)*<I>fvec</I>.
+<P>
+<I>wa1</I>, <I>wa2</I>, and <I>wa3</I> are work arrays of length <I>n</I>.
+<P>
+<I>wa4</I> is a work array of length <I>m</I>.
+<BR>
+
+<A NAME="lbAJ"> </A>
+<H2>SEE ALSO</H2>
+
+<B><A HREF="lmdif_.html">lmdif</A></B>(3),
+
+<B><A HREF="lmdif_.html">lmdif1</A></B>(3),
+
+<B><A HREF="lmder_.html">lmder</A></B>(3),
+
+<B><A HREF="lmder_.html">lmder1</A></B>(3).
+
+<BR>
+
+<A NAME="lbAK"> </A>
+<H2>AUTHORS</H2>
+
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+This manual page was written by Jim Van Zandt <<A HREF="mailto:jrv at debian.org">jrv at debian.org</A>>,
+for the Debian GNU/Linux system (but may be used by others).
+<P>
+
+<HR>
+<A NAME="index"> </A><H2>Index</H2>
+<DL>
+<DT><A HREF="#lbAB">NAME</A><DD>
+<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
+<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
+<DL>
+<DT><A HREF="#lbAE">Language notes</A><DD>
+<DT><A HREF="#lbAF">User-supplied Function</A><DD>
+<DT><A HREF="#lbAG">Parameters for both <B>lmstr_</B> and <B>lmstr1_</B></A><DD>
+<DT><A HREF="#lbAH">Parameters for <B>lmstr1_</B></A><DD>
+<DT><A HREF="#lbAI">Parameters for <B>lmstr_</B></A><DD>
+</DL>
+<DT><A HREF="#lbAJ">SEE ALSO</A><DD>
+<DT><A HREF="#lbAK">AUTHORS</A><DD>
+</DL>
+<HR>
+This document was created by
+<A HREF="index.html">man2html</A>,
+using the manual pages.<BR>
+Time: 10:19:50 GMT, April 20, 2007
+</BODY>
+</HTML>
diff --git a/doc/man.html b/doc/man.html
new file mode 100644
index 0000000..500887d
--- /dev/null
+++ b/doc/man.html
@@ -0,0 +1,25 @@
+<HTML><HEAD><TITLE>MINPACK Manual</TITLE>
+</HEAD><BODY>
+<H1>MINPACK</H1>
+
+<H2>Function Index</H2>
+<UL>
+<LI><A HREF="hybrd_.html">hybrd_, hybrd1_</A> - find a zero of a system of nonlinear function
+<LI><A HREF="hybrj_.html">hybrj_, hybrj1_</A> - find a zero of a system of nonlinear function
+<LI><A HREF="lmder_.html">lmder_, lmder1_</A> - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian
+<LI><A HREF="lmdif_.html">lmdif_, lmdif1_</A> - minimize the sum of squares of m nonlinear functions 
+<LI><A HREF="lmstr_.html">lmstr_, lmstr1_</A> - minimize the sum of squares of m nonlinear functions, with user supplied Jacobian and minimal storage
+</UL>
+
+<H2>AUTHORS</H2>
+
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+These manual pages were written by Jim Van Zandt <<A HREF="mailto:jrv at debian.org">jrv at debian.org</A>>,
+for the Debian GNU/Linux system (but may be used by others).
+<P>
+
+<HR>
+This document was created by
+<A HREF="http://hydra.nac.uci.edu/indiv/ehood/man2html.html">man2html</A>.
+</BODY>
+</HTML>
diff --git a/doc/minpack-documentation.txt b/doc/minpack-documentation.txt
new file mode 100644
index 0000000..a3c63a6
--- /dev/null
+++ b/doc/minpack-documentation.txt
@@ -0,0 +1,3528 @@
+ 
+                                                                  Page
+               Documentation for MINPACK subroutine HYBRD1
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of HYBRD1 is to find a zero of a system of N non-
+        linear functions in N variables by a modification of the Powell
+        hybrid method.  This is done by using the more general nonlinear
+        equation solver HYBRD.  The user must provide a subroutine which
+        calculates the functions.  The Jacobian is then calculated by a
+        forward-difference approximation.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE HYBRD1(FCN,N,X,FVEC,TOL,INFO,WA,LWA)
+        INTEGER N,INFO,LWA
+        DOUBLE PRECISION TOL
+        DOUBLE PRECISION X(N),FVEC(N),WA(LWA)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to HYBRD1 and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from HYBRD1.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions.  FCN must be declared in an EXTERNAL statement
+          in the user calling program, and should be written as follows
+          SUBROUTINE FCN(N,X,FVEC,IFLAG)
+          INTEGER N,IFLAG
+          DOUBLE PRECISION X(N),FVEC(N)
+          ----------
+          CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.
+          ----------
+          RETURN
+          END
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of HYBRD1.  In this case set
+          IFLAG to a negative integer.
+ 
+                                                                  Page
+        N is a positive integer input variable set to the number of
+          functions and variables.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length N which contains the function
+          evaluated at the output X.
+        TOL is a nonnegative input variable.  Termination occurs when
+          the algorithm estimates that the relative error between X and
+          the solution is at most TOL.  Section 4 contains more details
+          about TOL.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Algorithm estimates that the relative error between
+                    X and the solution is at most TOL.
+          INFO = 2  Number of calls to FCN has reached or exceeded
+                    200*(N+1).
+          INFO = 3  TOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 4  Iteration is not making good progress.
+          Sections 4 and 5 contain more details about INFO.
+        WA is a work array of length LWA.
+        LWA is a positive integer input variable not less than
+          (N*(3*N+13))/2.
+ 
+  4. Successful completion.
+        The accuracy of HYBRD1 is controlled by the convergence parame-
+        ter TOL.  This parameter is used in a test which makes a compar-
+        ison between the approximation X and a solution XSOL.  HYBRD1
+        terminates when the test is satisfied.  If TOL is less than the
+        machine precision (as defined by the MINPACK function
+        DPMPAR(1)), then HYBRD1 only attempts to satisfy the test
+        defined by the machine precision.  Further progress is not usu-
+        ally possible.  Unless high precision solutions are required,
+        the recommended value for TOL is the square root of the machine
+        precision.
+        The test assumes that the functions are reasonably well behaved
+ 
+                                                                  Page
+        If this condition is not satisfied, then HYBRD1 may incorrectly
+        indicate convergence.  The validity of the answer can be
+        checked, for example, by rerunning HYBRD1 with a tighter toler-
+        ance.
+        Convergence test.  If ENORM(Z) denotes the Euclidean norm of a
+          vector Z, then this test attempts to guarantee that
+                ENORM(X-XSOL) .LE. TOL*ENORM(XSOL).
+          If this condition is satisfied with TOL = 10**(-K), then the
+          larger components of X have K significant decimal digits and
+          INFO is set to 1.  There is a danger that the smaller compo-
+          nents of X may have large relative errors, but the fast rate
+          of convergence of HYBRD1 usually avoids this possibility.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of HYBRD1 can be due to improper input
+        parameters, arithmetic interrupts, an excessive number of func-
+        tion evaluations, errors in the functions, or lack of good prog
+        ress.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          TOL .LT. 0.D0, or LWA .LT. (N*(3*N+13))/2.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by HYBRD1.  In this
+          case, it may be possible to remedy the situation by not evalu-
+          ating the functions here, but instead setting the components
+          of FVEC to numbers that exceed those in the initial FVEC,
+          thereby indirectly reducing the step length.  The step length
+          can be more directly controlled by using instead HYBRD, which
+          includes in its calling sequence the step-length- governing
+          parameter FACTOR.
+        Excessive number of function evaluations.  If the number of
+          calls to FCN reaches 200*(N+1), then this indicates that the
+          routine is converging very slowly as measured by the progress
+          of FVEC, and INFO is set to 2.  This situation should be unu-
+          sual because, as indicated below, lack of good progress is
+          usually diagnosed earlier by HYBRD1, causing termination with
+          INFO = 4.
+        Errors in the functions.  The choice of step length in the for-
+          ward-difference approximation to the Jacobian assumes that th
+          relative errors in the functions are of the order of the
+          machine precision.  If this is not the case, HYBRD1 may fail
+          (usually with INFO = 4).  The user should then use HYBRD
+          instead, or one of the programs which require the analytic
+          Jacobian (HYBRJ1 and HYBRJ).
+ 
+                                                                  Page
+        Lack of good progress.  HYBRD1 searches for a zero of the system
+          by minimizing the sum of the squares of the functions.  In so
+          doing, it can become trapped in a region where the minimum
+          does not correspond to a zero of the system and, in this situ-
+          ation, the iteration eventually fails to make good progress.
+          In particular, this will happen if the system does not have a
+          zero.  If the system has a zero, rerunning HYBRD1 from a dif-
+          ferent starting point may be helpful.
+ 
+  6. Characteristics of the algorithm.
+        HYBRD1 is a modification of the Powell hybrid method.  Two of
+        its main characteristics involve the choice of the correction a
+        a convex combination of the Newton and scaled gradient direc-
+        tions, and the updating of the Jacobian by the rank-1 method of
+        Broyden.  The choice of the correction guarantees (under reason
+        able conditions) global convergence for starting points far fro
+        the solution and a fast rate of convergence.  The Jacobian is
+        approximated by forward differences at the starting point, but
+        forward differences are not used again until the rank-1 method
+        fails to produce satisfactory progress.
+        Timing.  The time required by HYBRD1 to solve a given problem
+          depends on N, the behavior of the functions, the accuracy
+          requested, and the starting point.  The number of arithmetic
+          operations needed by HYBRD1 is about 11.5*(N**2) to process
+          each call to FCN.  Unless FCN can be evaluated quickly, the
+          timing of HYBRD1 will be strongly influenced by the time spent
+          in FCN.
+        Storage.  HYBRD1 requires (3*N**2 + 17*N)/2 double precision
+          storage locations, in addition to the storage required by the
+          program.  There are no internally declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,FDJAC1,HYBRD,
+                             QFORM,QRFAC,R1MPYQ,R1UPDT
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD
+ 
+  8. References.
+        M. J. D. Powell, A Hybrid Method for Nonlinear Equations.
+        Numerical Methods for Nonlinear Algebraic Equations,
+        P. Rabinowitz, editor. Gordon and Breach, 1970.
+ 
+  9. Example.
+ 
+                                                                  Page
+        The problem is to determine the values of x(1), x(2), ..., x(9)
+        which solve the system of tridiagonal equations
+        (3-2*x(1))*x(1)           -2*x(2)                   = -1
+                -x(i-1) + (3-2*x(i))*x(i)         -2*x(i+1) = -1, i=2-8
+                                    -x(8) + (3-2*x(9))*x(9) = -1
+  C     **********
+  C
+  C     DRIVER FOR HYBRD1 EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,N,INFO,LWA,NWRITE
+        DOUBLE PRECISION TOL,FNORM
+        DOUBLE PRECISION X(9),FVEC(9),WA(180)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        N = 9
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION.
+  C
+        DO 10 J = 1, 9
+           X(J) = -1.D0
+     10    CONTINUE
+  C
+        LWA = 180
+  C
+  C     SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        TOL = DSQRT(DPMPAR(1))
+  C
+        CALL HYBRD1(FCN,N,X,FVEC,TOL,INFO,WA,LWA)
+        FNORM = ENORM(N,FVEC)
+        WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7))
+  C
+  C     LAST CARD OF DRIVER FOR HYBRD1 EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(N,X,FVEC,IFLAG)
+        INTEGER N,IFLAG
+        DOUBLE PRECISION X(N),FVEC(N)
+  C
+ 
+                                                                  Page
+  C     SUBROUTINE FCN FOR HYBRD1 EXAMPLE.
+  C
+        INTEGER K
+        DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO
+        DATA ZERO,ONE,TWO,THREE /0.D0,1.D0,2.D0,3.D0/
+  C
+        DO 10 K = 1, N
+           TEMP = (THREE - TWO*X(K))*X(K)
+           TEMP1 = ZERO
+           IF (K .NE. 1) TEMP1 = X(K-1)
+           TEMP2 = ZERO
+           IF (K .NE. N) TEMP2 = X(K+1)
+           FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE
+     10    CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+        -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+        -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+        -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
+ 
+ 
+ 
+                                                                  Page
+                Documentation for MINPACK subroutine HYBRD
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of HYBRD is to find a zero of a system of N non-
+        linear functions in N variables by a modification of the Powell
+        hybrid method.  The user must provide a subroutine which calcu-
+        lates the functions.  The Jacobian is then calculated by a for-
+        ward-difference approximation.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE HYBRD(FCN,N,X,FVEC,XTOL,MAXFEV,ML,MU,EPSFCN,DIAG,
+       *                 MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC,
+       *                 R,LR,QTF,WA1,WA2,WA3,WA4)
+        INTEGER N,MAXFEV,ML,MU,MODE,NPRINT,INFO,NFEV,LDFJAC,LR
+        DOUBLE PRECISION XTOL,EPSFCN,FACTOR
+        DOUBLE PRECISION X(N),FVEC(N),DIAG(N),FJAC(LDFJAC,N),R(LR),QTF(
+       *                 WA1(N),WA2(N),WA3(N),WA4(N)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to HYBRD and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from HYBRD.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions.  FCN must be declared in an EXTERNAL statement
+          in the user calling program, and should be written as follows
+          SUBROUTINE FCN(N,X,FVEC,IFLAG)
+          INTEGER N,IFLAG
+          DOUBLE PRECISION X(N),FVEC(N)
+          ----------
+          CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.
+          ----------
+          RETURN
+          END
+          The value of IFLAG should not be changed by FCN unless the
+ 
+                                                                  Page
+          user wants to terminate execution of HYBRD.  In this case set
+          IFLAG to a negative integer.
+        N is a positive integer input variable set to the number of
+          functions and variables.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length N which contains the function
+          evaluated at the output X.
+        XTOL is a nonnegative input variable.  Termination occurs when
+          the relative error between two consecutive iterates is at most
+          XTOL.  Therefore, XTOL measures the relative error desired in
+          the approximate solution.  Section 4 contains more details
+          about XTOL.
+        MAXFEV is a positive integer input variable.  Termination occur
+          when the number of calls to FCN is at least MAXFEV by the end
+          of an iteration.
+        ML is a nonnegative integer input variable which specifies the
+          number of subdiagonals within the band of the Jacobian matrix
+          If the Jacobian is not banded, set ML to at least N - 1.
+        MU is a nonnegative integer input variable which specifies the
+          number of superdiagonals within the band of the Jacobian
+          matrix.  If the Jacobian is not banded, set MU to at least
+          N - 1.
+        EPSFCN is an input variable used in determining a suitable step
+          for the forward-difference approximation.  This approximation
+          assumes that the relative errors in the functions are of the
+          order of EPSFCN.  If EPSFCN is less than the machine preci-
+          sion, it is assumed that the relative errors in the functions
+          are of the order of the machine precision.
+        DIAG is an array of length N.  If MODE = 1 (see below), DIAG is
+          internally set.  If MODE = 2, DIAG must contain positive
+          entries that serve as multiplicative scale factors for the
+          variables.
+        MODE is an integer input variable.  If MODE = 1, the variables
+          will be scaled internally.  If MODE = 2, the scaling is speci-
+          fied by the input DIAG.  Other values of MODE are equivalent
+          to MODE = 1.
+        FACTOR is a positive input variable used in determining the ini-
+          tial step bound.  This bound is set to the product of FACTOR
+          and the Euclidean norm of DIAG*X if nonzero, or else to FACTO
+          itself.  In most cases FACTOR should lie in the interval
+          (.1,100.).  100. is a generally recommended value.
+ 
+                                                                  Page
+        NPRINT is an integer input variable that enables controlled
+          printing of iterates if it is positive.  In this case, FCN is
+          called with IFLAG = 0 at the beginning of the first iteration
+          and every NPRINT iterations thereafter and immediately prior
+          to return, with X and FVEC available for printing.  If NPRINT
+          is not positive, no special calls of FCN with IFLAG = 0 are
+          made.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Relative error between two consecutive iterates is
+                    at most XTOL.
+          INFO = 2  Number of calls to FCN has reached or exceeded
+                    MAXFEV.
+          INFO = 3  XTOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 4  Iteration is not making good progress, as measured
+                    by the improvement from the last five Jacobian eval-
+                    uations.
+          INFO = 5  Iteration is not making good progress, as measured
+                    by the improvement from the last ten iterations.
+          Sections 4 and 5 contain more details about INFO.
+        NFEV is an integer output variable set to the number of calls t
+          FCN.
+        FJAC is an output N by N array which contains the orthogonal
+          matrix Q produced by the QR factorization of the final approx-
+          imate Jacobian.
+        LDFJAC is a positive integer input variable not less than N
+          which specifies the leading dimension of the array FJAC.
+        R is an output array of length LR which contains the upper
+          triangular matrix produced by the QR factorization of the
+          final approximate Jacobian, stored rowwise.
+        LR is a positive integer input variable not less than
+          (N*(N+1))/2.
+        QTF is an output array of length N which contains the vector
+          (Q transpose)*FVEC.
+        WA1, WA2, WA3, and WA4 are work arrays of length N.
+ 
+                                                                  Page
+ 
+  4. Successful completion.
+        The accuracy of HYBRD is controlled by the convergence parameter
+        XTOL.  This parameter is used in a test which makes a comparison
+        between the approximation X and a solution XSOL.  HYBRD termi-
+        nates when the test is satisfied.  If the convergence parameter
+        is less than the machine precision (as defined by the MINPACK
+        function DPMPAR(1)), then HYBRD only attempts to satisfy the
+        test defined by the machine precision.  Further progress is not
+        usually possible.
+        The test assumes that the functions are reasonably well behaved
+        If this condition is not satisfied, then HYBRD may incorrectly
+        indicate convergence.  The validity of the answer can be
+        checked, for example, by rerunning HYBRD with a tighter toler-
+        ance.
+        Convergence test.  If ENORM(Z) denotes the Euclidean norm of a
+          vector Z and D is the diagonal matrix whose entries are
+          defined by the array DIAG, then this test attempts to guaran-
+          tee that
+                ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL).
+          If this condition is satisfied with XTOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 1.  There is a danger that the smaller compo-
+          nents of D*X may have large relative errors, but the fast rat
+          of convergence of HYBRD usually avoids this possibility.
+          Unless high precision solutions are required, the recommended
+          value for XTOL is the square root of the machine precision.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of HYBRD can be due to improper input
+        parameters, arithmetic interrupts, an excessive number of func-
+        tion evaluations, or lack of good progress.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          XTOL .LT. 0.D0, or MAXFEV .LE. 0, or ML .LT. 0, or MU .LT. 0,
+          or FACTOR .LE. 0.D0, or LDFJAC .LT. N, or LR .LT. (N*(N+1))/2
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by HYBRD.  In this
+          case, it may be possible to remedy the situation by rerunning
+          HYBRD with a smaller value of FACTOR.
+        Excessive number of function evaluations.  A reasonable value
+          for MAXFEV is 200*(N+1).  If the number of calls to FCN
+          reaches MAXFEV, then this indicates that the routine is con-
+          verging very slowly as measured by the progress of FVEC, and
+ 
+                                                                  Page
+          INFO is set to 2.  This situation should be unusual because,
+          as indicated below, lack of good progress is usually diagnose
+          earlier by HYBRD, causing termination with INFO = 4 or
+          INFO = 5.
+        Lack of good progress.  HYBRD searches for a zero of the system
+          by minimizing the sum of the squares of the functions.  In so
+          doing, it can become trapped in a region where the minimum
+          does not correspond to a zero of the system and, in this situ-
+          ation, the iteration eventually fails to make good progress.
+          In particular, this will happen if the system does not have a
+          zero.  If the system has a zero, rerunning HYBRD from a dif-
+          ferent starting point may be helpful.
+ 
+  6. Characteristics of the algorithm.
+        HYBRD is a modification of the Powell hybrid method.  Two of it
+        main characteristics involve the choice of the correction as a
+        convex combination of the Newton and scaled gradient directions
+        and the updating of the Jacobian by the rank-1 method of Broy-
+        den.  The choice of the correction guarantees (under reasonable
+        conditions) global convergence for starting points far from the
+        solution and a fast rate of convergence.  The Jacobian is
+        approximated by forward differences at the starting point, but
+        forward differences are not used again until the rank-1 method
+        fails to produce satisfactory progress.
+        Timing.  The time required by HYBRD to solve a given problem
+          depends on N, the behavior of the functions, the accuracy
+          requested, and the starting point.  The number of arithmetic
+          operations needed by HYBRD is about 11.5*(N**2) to process
+          each call to FCN.  Unless FCN can be evaluated quickly, the
+          timing of HYBRD will be strongly influenced by the time spent
+          in FCN.
+        Storage.  HYBRD requires (3*N**2 + 17*N)/2 double precision
+          storage locations, in addition to the storage required by the
+          program.  There are no internally declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,FDJAC1,
+                             QFORM,QRFAC,R1MPYQ,R1UPDT
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD
+ 
+  8. References.
+        M. J. D. Powell, A Hybrid Method for Nonlinear Equations.
+ 
+                                                                  Page
+        Numerical Methods for Nonlinear Algebraic Equations,
+        P. Rabinowitz, editor. Gordon and Breach, 1970.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), ..., x(9)
+        which solve the system of tridiagonal equations
+        (3-2*x(1))*x(1)           -2*x(2)                   = -1
+                -x(i-1) + (3-2*x(i))*x(i)         -2*x(i+1) = -1, i=2-8
+                                    -x(8) + (3-2*x(9))*x(9) = -1
+  C     **********
+  C
+  C     DRIVER FOR HYBRD EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,N,MAXFEV,ML,MU,MODE,NPRINT,INFO,NFEV,LDFJAC,LR,NWRITE
+        DOUBLE PRECISION XTOL,EPSFCN,FACTOR,FNORM
+        DOUBLE PRECISION X(9),FVEC(9),DIAG(9),FJAC(9,9),R(45),QTF(9),
+       *                 WA1(9),WA2(9),WA3(9),WA4(9)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        N = 9
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION.
+  C
+        DO 10 J = 1, 9
+           X(J) = -1.D0
+     10    CONTINUE
+  C
+        LDFJAC = 9
+        LR = 45
+  C
+  C     SET XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        XTOL = DSQRT(DPMPAR(1))
+  C
+        MAXFEV = 2000
+        ML = 1
+        MU = 1
+        EPSFCN = 0.D0
+        MODE = 2
+        DO 20 J = 1, 9
+           DIAG(J) = 1.D0
+ 
+                                                                  Page
+     20    CONTINUE
+        FACTOR = 1.D2
+        NPRINT = 0
+  C
+        CALL HYBRD(FCN,N,X,FVEC,XTOL,MAXFEV,ML,MU,EPSFCN,DIAG,
+       *           MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC,
+       *           R,LR,QTF,WA1,WA2,WA3,WA4)
+        FNORM = ENORM(N,FVEC)
+        WRITE (NWRITE,1000) FNORM,NFEV,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7))
+  C
+  C     LAST CARD OF DRIVER FOR HYBRD EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(N,X,FVEC,IFLAG)
+        INTEGER N,IFLAG
+        DOUBLE PRECISION X(N),FVEC(N)
+  C
+  C     SUBROUTINE FCN FOR HYBRD EXAMPLE.
+  C
+        INTEGER K
+        DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO
+        DATA ZERO,ONE,TWO,THREE /0.D0,1.D0,2.D0,3.D0/
+  C
+        IF (IFLAG .NE. 0) GO TO 5
+  C
+  C     INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE.
+  C
+        RETURN
+      5 CONTINUE
+        DO 10 K = 1, N
+           TEMP = (THREE - TWO*X(K))*X(K)
+           TEMP1 = ZERO
+           IF (K .NE. 1) TEMP1 = X(K-1)
+           TEMP2 = ZERO
+           IF (K .NE. N) TEMP2 = X(K+1)
+           FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE
+     10    CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+        NUMBER OF FUNCTION EVALUATIONS        14
+ 
+                                                                  Page
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+        -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+        -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+        -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
+ 
+ 
+ 
+                                                                  Page
+               Documentation for MINPACK subroutine HYBRJ1
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of HYBRJ1 is to find a zero of a system of N non-
+        linear functions in N variables by a modification of the Powell
+        hybrid method.  This is done by using the more general nonlinear
+        equation solver HYBRJ.  The user must provide a subroutine which
+        calculates the functions and the Jacobian.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA)
+        INTEGER N,LDFJAC,INFO,LWA
+        DOUBLE PRECISION TOL
+        DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N),WA(LWA)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to HYBRJ1 and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from HYBRJ1.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions and the Jacobian.  FCN must be declared in an
+          EXTERNAL statement in the user calling program, and should be
+          written as follows.
+          SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG)
+          INTEGER N,LDFJAC,IFLAG
+          DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N)
+          ----------
+          IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.  DO NOT ALTER FJAC.
+          IF IFLAG = 2 CALCULATE THE JACOBIAN AT X AND
+          RETURN THIS MATRIX IN FJAC.  DO NOT ALTER FVEC.
+          ----------
+          RETURN
+          END
+          The value of IFLAG should not be changed by FCN unless the
+ 
+                                                                  Page
+          user wants to terminate execution of HYBRJ1.  In this case set
+          IFLAG to a negative integer.
+        N is a positive integer input variable set to the number of
+          functions and variables.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length N which contains the function
+          evaluated at the output X.
+        FJAC is an output N by N array which contains the orthogonal
+          matrix Q produced by the QR factorization of the final approx-
+          imate Jacobian.  Section 6 contains more details about the
+          approximation to the Jacobian.
+        LDFJAC is a positive integer input variable not less than N
+          which specifies the leading dimension of the array FJAC.
+        TOL is a nonnegative input variable.  Termination occurs when
+          the algorithm estimates that the relative error between X and
+          the solution is at most TOL.  Section 4 contains more details
+          about TOL.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Algorithm estimates that the relative error between
+                    X and the solution is at most TOL.
+          INFO = 2  Number of calls to FCN with IFLAG = 1 has reached
+                    100*(N+1).
+          INFO = 3  TOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 4  Iteration is not making good progress.
+          Sections 4 and 5 contain more details about INFO.
+        WA is a work array of length LWA.
+        LWA is a positive integer input variable not less than
+          (N*(N+13))/2.
+ 
+  4. Successful completion.
+        The accuracy of HYBRJ1 is controlled by the convergence
+ 
+                                                                  Page
+        parameter TOL.  This parameter is used in a test which makes a
+        comparison between the approximation X and a solution XSOL.
+        HYBRJ1 terminates when the test is satisfied.  If TOL is less
+        than the machine precision (as defined by the MINPACK function
+        DPMPAR(1)), then HYBRJ1 only attempts to satisfy the test
+        defined by the machine precision.  Further progress is not usu-
+        ally possible.  Unless high precision solutions are required,
+        the recommended value for TOL is the square root of the machine
+        precision.
+        The test assumes that the functions and the Jacobian are coded
+        consistently, and that the functions are reasonably well
+        behaved.  If these conditions are not satisfied, then HYBRJ1 ma
+        incorrectly indicate convergence.  The coding of the Jacobian
+        can be checked by the MINPACK subroutine CHKDER.  If the Jaco-
+        bian is coded correctly, then the validity of the answer can be
+        checked, for example, by rerunning HYBRJ1 with a tighter toler-
+        ance.
+        Convergence test.  If ENORM(Z) denotes the Euclidean norm of a
+          vector Z, then this test attempts to guarantee that
+                ENORM(X-XSOL) .LE. TOL*ENORM(XSOL).
+          If this condition is satisfied with TOL = 10**(-K), then the
+          larger components of X have K significant decimal digits and
+          INFO is set to 1.  There is a danger that the smaller compo-
+          nents of X may have large relative errors, but the fast rate
+          of convergence of HYBRJ1 usually avoids this possibility.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of HYBRJ1 can be due to improper input
+        parameters, arithmetic interrupts, an excessive number of func-
+        tion evaluations, or lack of good progress.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          LDFJAC .LT. N, or TOL .LT. 0.D0, or LWA .LT. (N*(N+13))/2.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by HYBRJ1.  In this
+          case, it may be possible to remedy the situation by not evalu
+          ating the functions here, but instead setting the components
+          of FVEC to numbers that exceed those in the initial FVEC,
+          thereby indirectly reducing the step length.  The step length
+          can be more directly controlled by using instead HYBRJ, which
+          includes in its calling sequence the step-length- governing
+          parameter FACTOR.
+        Excessive number of function evaluations.  If the number of
+          calls to FCN with IFLAG = 1 reaches 100*(N+1), then this indi-
+          cates that the routine is converging very slowly as measured
+ 
+                                                                  Page
+          by the progress of FVEC, and INFO is set to 2.  This situation
+          should be unusual because, as indicated below, lack of good
+          progress is usually diagnosed earlier by HYBRJ1, causing ter-
+          mination with INFO = 4.
+        Lack of good progress.  HYBRJ1 searches for a zero of the system
+          by minimizing the sum of the squares of the functions.  In so
+          doing, it can become trapped in a region where the minimum
+          does not correspond to a zero of the system and, in this situ-
+          ation, the iteration eventually fails to make good progress.
+          In particular, this will happen if the system does not have a
+          zero.  If the system has a zero, rerunning HYBRJ1 from a dif-
+          ferent starting point may be helpful.
+ 
+  6. Characteristics of the algorithm.
+        HYBRJ1 is a modification of the Powell hybrid method.  Two of
+        its main characteristics involve the choice of the correction a
+        a convex combination of the Newton and scaled gradient direc-
+        tions, and the updating of the Jacobian by the rank-1 method of
+        Broyden.  The choice of the correction guarantees (under reason
+        able conditions) global convergence for starting points far fro
+        the solution and a fast rate of convergence.  The Jacobian is
+        calculated at the starting point, but it is not recalculated
+        until the rank-1 method fails to produce satisfactory progress.
+        Timing.  The time required by HYBRJ1 to solve a given problem
+          depends on N, the behavior of the functions, the accuracy
+          requested, and the starting point.  The number of arithmetic
+          operations needed by HYBRJ1 is about 11.5*(N**2) to process
+          each evaluation of the functions (call to FCN with IFLAG = 1)
+          and 1.3*(N**3) to process each evaluation of the Jacobian
+          (call to FCN with IFLAG = 2).  Unless FCN can be evaluated
+          quickly, the timing of HYBRJ1 will be strongly influenced by
+          the time spent in FCN.
+        Storage.  HYBRJ1 requires (3*N**2 + 17*N)/2 double precision
+          storage locations, in addition to the storage required by the
+          program.  There are no internally declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,HYBRJ,
+                             QFORM,QRFAC,R1MPYQ,R1UPDT
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD
+ 
+  8. References.
+ 
+                                                                  Page
+        M. J. D. Powell, A Hybrid Method for Nonlinear Equations.
+        Numerical Methods for Nonlinear Algebraic Equations,
+        P. Rabinowitz, editor. Gordon and Breach, 1970.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), ..., x(9)
+        which solve the system of tridiagonal equations
+        (3-2*x(1))*x(1)           -2*x(2)                   = -1
+                -x(i-1) + (3-2*x(i))*x(i)         -2*x(i+1) = -1, i=2-8
+                                    -x(8) + (3-2*x(9))*x(9) = -1
+  C     **********
+  C
+  C     DRIVER FOR HYBRJ1 EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,N,LDFJAC,INFO,LWA,NWRITE
+        DOUBLE PRECISION TOL,FNORM
+        DOUBLE PRECISION X(9),FVEC(9),FJAC(9,9),WA(99)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        N = 9
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION.
+  C
+        DO 10 J = 1, 9
+           X(J) = -1.D0
+     10    CONTINUE
+  C
+        LDFJAC = 9
+        LWA = 99
+  C
+  C     SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        TOL = DSQRT(DPMPAR(1))
+  C
+        CALL HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA)
+        FNORM = ENORM(N,FVEC)
+        WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7))
+ 
+                                                                  Page
+  C
+  C     LAST CARD OF DRIVER FOR HYBRJ1 EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG)
+        INTEGER N,LDFJAC,IFLAG
+        DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N)
+  C
+  C     SUBROUTINE FCN FOR HYBRJ1 EXAMPLE.
+  C
+        INTEGER J,K
+        DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO
+        DATA ZERO,ONE,TWO,THREE,FOUR /0.D0,1.D0,2.D0,3.D0,4.D0/
+  C
+        IF (IFLAG .EQ. 2) GO TO 20
+        DO 10 K = 1, N
+           TEMP = (THREE - TWO*X(K))*X(K)
+           TEMP1 = ZERO
+           IF (K .NE. 1) TEMP1 = X(K-1)
+           TEMP2 = ZERO
+           IF (K .NE. N) TEMP2 = X(K+1)
+           FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE
+     10    CONTINUE
+        GO TO 50
+     20 CONTINUE
+        DO 40 K = 1, N
+           DO 30 J = 1, N
+              FJAC(K,J) = ZERO
+     30       CONTINUE
+           FJAC(K,K) = THREE - FOUR*X(K)
+           IF (K .NE. 1) FJAC(K,K-1) = -ONE
+           IF (K .NE. N) FJAC(K,K+1) = -TWO
+     40    CONTINUE
+     50 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+        -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+        -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+        -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
+ 
+ 
+ 
+                                                                  Page
+                Documentation for MINPACK subroutine HYBRJ
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of HYBRJ is to find a zero of a system of N non-
+        linear functions in N variables by a modification of the Powell
+        hybrid method.  The user must provide a subroutine which calcu-
+        lates the functions and the Jacobian.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE HYBRJ(FCN,N,X,FVEC,FJAC,LDFJAC,XTOL,MAXFEV,DIAG,
+       *                 MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,R,LR,QTF,
+       *                 WA1,WA2,WA3,WA4)
+        INTEGER N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,LR
+        DOUBLE PRECISION XTOL,FACTOR
+        DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N),DIAG(N),R(LR),QTF(
+       *                 WA1(N),WA2(N),WA3(N),WA4(N)
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to HYBRJ and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from HYBRJ.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions and the Jacobian.  FCN must be declared in an
+          EXTERNAL statement in the user calling program, and should be
+          written as follows.
+          SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG)
+          INTEGER N,LDFJAC,IFLAG
+          DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N)
+          ----------
+          IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.  DO NOT ALTER FJAC.
+          IF IFLAG = 2 CALCULATE THE JACOBIAN AT X AND
+          RETURN THIS MATRIX IN FJAC.  DO NOT ALTER FVEC.
+          ----------
+          RETURN
+          END
+ 
+                                                                  Page
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of HYBRJ.  In this case set
+          IFLAG to a negative integer.
+        N is a positive integer input variable set to the number of
+          functions and variables.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length N which contains the function
+          evaluated at the output X.
+        FJAC is an output N by N array which contains the orthogonal
+          matrix Q produced by the QR factorization of the final approx-
+          imate Jacobian.  Section 6 contains more details about the
+          approximation to the Jacobian.
+        LDFJAC is a positive integer input variable not less than N
+          which specifies the leading dimension of the array FJAC.
+        XTOL is a nonnegative input variable.  Termination occurs when
+          the relative error between two consecutive iterates is at most
+          XTOL.  Therefore, XTOL measures the relative error desired in
+          the approximate solution.  Section 4 contains more details
+          about XTOL.
+        MAXFEV is a positive integer input variable.  Termination occur
+          when the number of calls to FCN with IFLAG = 1 has reached
+          MAXFEV.
+        DIAG is an array of length N.  If MODE = 1 (see below), DIAG is
+          internally set.  If MODE = 2, DIAG must contain positive
+          entries that serve as multiplicative scale factors for the
+          variables.
+        MODE is an integer input variable.  If MODE = 1, the variables
+          will be scaled internally.  If MODE = 2, the scaling is speci-
+          fied by the input DIAG.  Other values of MODE are equivalent
+          to MODE = 1.
+        FACTOR is a positive input variable used in determining the ini-
+          tial step bound.  This bound is set to the product of FACTOR
+          and the Euclidean norm of DIAG*X if nonzero, or else to FACTO
+          itself.  In most cases FACTOR should lie in the interval
+          (.1,100.).  100. is a generally recommended value.
+        NPRINT is an integer input variable that enables controlled
+          printing of iterates if it is positive.  In this case, FCN is
+          called with IFLAG = 0 at the beginning of the first iteration
+          and every NPRINT iterations thereafter and immediately prior
+          to return, with X and FVEC available for printing.  FVEC and
+          FJAC should not be altered.  If NPRINT is not positive, no
+ 
+                                                                  Page
+          special calls of FCN with IFLAG = 0 are made.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Relative error between two consecutive iterates is
+                    at most XTOL.
+          INFO = 2  Number of calls to FCN with IFLAG = 1 has reached
+                    MAXFEV.
+          INFO = 3  XTOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 4  Iteration is not making good progress, as measured
+                    by the improvement from the last five Jacobian eval-
+                    uations.
+          INFO = 5  Iteration is not making good progress, as measured
+                    by the improvement from the last ten iterations.
+          Sections 4 and 5 contain more details about INFO.
+        NFEV is an integer output variable set to the number of calls t
+          FCN with IFLAG = 1.
+        NJEV is an integer output variable set to the number of calls t
+          FCN with IFLAG = 2.
+        R is an output array of length LR which contains the upper
+          triangular matrix produced by the QR factorization of the
+          final approximate Jacobian, stored rowwise.
+        LR is a positive integer input variable not less than
+          (N*(N+1))/2.
+        QTF is an output array of length N which contains the vector
+          (Q transpose)*FVEC.
+        WA1, WA2, WA3, and WA4 are work arrays of length N.
+ 
+  4. Successful completion.
+        The accuracy of HYBRJ is controlled by the convergence parameter
+        XTOL.  This parameter is used in a test which makes a comparison
+        between the approximation X and a solution XSOL.  HYBRJ termi-
+        nates when the test is satisfied.  If the convergence parameter
+        is less than the machine precision (as defined by the MINPACK
+        function DPMPAR(1)), then HYBRJ only attempts to satisfy the
+        test defined by the machine precision.  Further progress is not
+ 
+                                                                  Page
+        usually possible.
+        The test assumes that the functions and the Jacobian are coded
+        consistently, and that the functions are reasonably well
+        behaved.  If these conditions are not satisfied, then HYBRJ may
+        incorrectly indicate convergence.  The coding of the Jacobian
+        can be checked by the MINPACK subroutine CHKDER.  If the Jaco-
+        bian is coded correctly, then the validity of the answer can be
+        checked, for example, by rerunning HYBRJ with a tighter toler-
+        ance.
+        Convergence test.  If ENORM(Z) denotes the Euclidean norm of a
+          vector Z and D is the diagonal matrix whose entries are
+          defined by the array DIAG, then this test attempts to guaran-
+          tee that
+                ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL).
+          If this condition is satisfied with XTOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 1.  There is a danger that the smaller compo-
+          nents of D*X may have large relative errors, but the fast rat
+          of convergence of HYBRJ usually avoids this possibility.
+          Unless high precision solutions are required, the recommended
+          value for XTOL is the square root of the machine precision.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of HYBRJ can be due to improper input
+        parameters, arithmetic interrupts, an excessive number of func-
+        tion evaluations, or lack of good progress.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          LDFJAC .LT. N, or XTOL .LT. 0.D0, or MAXFEV .LE. 0, or
+          FACTOR .LE. 0.D0, or LR .LT. (N*(N+1))/2.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by HYBRJ.  In this
+          case, it may be possible to remedy the situation by rerunning
+          HYBRJ with a smaller value of FACTOR.
+        Excessive number of function evaluations.  A reasonable value
+          for MAXFEV is 100*(N+1).  If the number of calls to FCN with
+          IFLAG = 1 reaches MAXFEV, then this indicates that the routine
+          is converging very slowly as measured by the progress of FVEC
+          and INFO is set to 2.  This situation should be unusual
+          because, as indicated below, lack of good progress is usually
+          diagnosed earlier by HYBRJ, causing termination with INFO = 4
+          or INFO = 5.
+        Lack of good progress.  HYBRJ searches for a zero of the system
+          by minimizing the sum of the squares of the functions.  In so
+ 
+                                                                  Page
+          doing, it can become trapped in a region where the minimum
+          does not correspond to a zero of the system and, in this situ-
+          ation, the iteration eventually fails to make good progress.
+          In particular, this will happen if the system does not have a
+          zero.  If the system has a zero, rerunning HYBRJ from a dif-
+          ferent starting point may be helpful.
+ 
+  6. Characteristics of the algorithm.
+        HYBRJ is a modification of the Powell hybrid method.  Two of it
+        main characteristics involve the choice of the correction as a
+        convex combination of the Newton and scaled gradient directions
+        and the updating of the Jacobian by the rank-1 method of Broy-
+        den.  The choice of the correction guarantees (under reasonable
+        conditions) global convergence for starting points far from the
+        solution and a fast rate of convergence.  The Jacobian is calcu
+        lated at the starting point, but it is not recalculated until
+        the rank-1 method fails to produce satisfactory progress.
+        Timing.  The time required by HYBRJ to solve a given problem
+          depends on N, the behavior of the functions, the accuracy
+          requested, and the starting point.  The number of arithmetic
+          operations needed by HYBRJ is about 11.5*(N**2) to process
+          each evaluation of the functions (call to FCN with IFLAG = 1)
+          and 1.3*(N**3) to process each evaluation of the Jacobian
+          (call to FCN with IFLAG = 2).  Unless FCN can be evaluated
+          quickly, the timing of HYBRJ will be strongly influenced by
+          the time spent in FCN.
+        Storage.  HYBRJ requires (3*N**2 + 17*N)/2 double precision
+          storage locations, in addition to the storage required by the
+          program.  There are no internally declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DOGLEG,DPMPAR,ENORM,
+                             QFORM,QRFAC,R1MPYQ,R1UPDT
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MIN0,MOD
+ 
+  8. References.
+        M. J. D. Powell, A Hybrid Method for Nonlinear Equations.
+        Numerical Methods for Nonlinear Algebraic Equations,
+        P. Rabinowitz, editor. Gordon and Breach, 1970.
+ 
+  9. Example.
+ 
+                                                                  Page
+        The problem is to determine the values of x(1), x(2), ..., x(9)
+        which solve the system of tridiagonal equations
+        (3-2*x(1))*x(1)           -2*x(2)                   = -1
+                -x(i-1) + (3-2*x(i))*x(i)         -2*x(i+1) = -1, i=2-8
+                                    -x(8) + (3-2*x(9))*x(9) = -1
+  C     **********
+  C
+  C     DRIVER FOR HYBRJ EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,LR,NWRITE
+        DOUBLE PRECISION XTOL,FACTOR,FNORM
+        DOUBLE PRECISION X(9),FVEC(9),FJAC(9,9),DIAG(9),R(45),QTF(9),
+       *                 WA1(9),WA2(9),WA3(9),WA4(9)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        N = 9
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH SOLUTION.
+  C
+        DO 10 J = 1, 9
+           X(J) = -1.D0
+     10    CONTINUE
+  C
+        LDFJAC = 9
+        LR = 45
+  C
+  C     SET XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        XTOL = DSQRT(DPMPAR(1))
+  C
+        MAXFEV = 1000
+        MODE = 2
+        DO 20 J = 1, 9
+           DIAG(J) = 1.D0
+     20    CONTINUE
+        FACTOR = 1.D2
+        NPRINT = 0
+  C
+        CALL HYBRJ(FCN,N,X,FVEC,FJAC,LDFJAC,XTOL,MAXFEV,DIAG,
+       *           MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,R,LR,QTF,
+       *           WA1,WA2,WA3,WA4)
+        FNORM = ENORM(N,FVEC)
+        WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N)
+ 
+                                                                  Page
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 //
+       *        5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // (5X,3D15.7))
+  C
+  C     LAST CARD OF DRIVER FOR HYBRJ EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG)
+        INTEGER N,LDFJAC,IFLAG
+        DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N)
+  C
+  C     SUBROUTINE FCN FOR HYBRJ EXAMPLE.
+  C
+        INTEGER J,K
+        DOUBLE PRECISION ONE,TEMP,TEMP1,TEMP2,THREE,TWO,ZERO
+        DATA ZERO,ONE,TWO,THREE,FOUR /0.D0,1.D0,2.D0,3.D0,4.D0/
+  C
+        IF (IFLAG .NE. 0) GO TO 5
+  C
+  C     INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE.
+  C
+        RETURN
+      5 CONTINUE
+        IF (IFLAG .EQ. 2) GO TO 20
+        DO 10 K = 1, N
+           TEMP = (THREE - TWO*X(K))*X(K)
+           TEMP1 = ZERO
+           IF (K .NE. 1) TEMP1 = X(K-1)
+           TEMP2 = ZERO
+           IF (K .NE. N) TEMP2 = X(K+1)
+           FVEC(K) = TEMP - TEMP1 - TWO*TEMP2 + ONE
+     10    CONTINUE
+        GO TO 50
+     20 CONTINUE
+        DO 40 K = 1, N
+           DO 30 J = 1, N
+              FJAC(K,J) = ZERO
+     30       CONTINUE
+           FJAC(K,K) = THREE - FOUR*X(K)
+           IF (K .NE. 1) FJAC(K,K-1) = -ONE
+           IF (K .NE. N) FJAC(K,K+1) = -TWO
+     40    CONTINUE
+     50 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+ 
+                                                                  Page
+        FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+        NUMBER OF FUNCTION EVALUATIONS        11
+        NUMBER OF JACOBIAN EVALUATIONS         1
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+        -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+        -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+        -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
+ 
+ 
+ 
+                                                                  Page
+               Documentation for MINPACK subroutine LMDER1
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of LMDER1 is to minimize the sum of the squares of
+        nonlinear functions in N variables by a modification of the
+        Levenberg-Marquardt algorithm.  This is done by using the more
+        general least-squares solver LMDER.  The user must provide a
+        subroutine which calculates the functions and the Jacobian.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE LMDER1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL,
+       *                  INFO,IPVT,WA,LWA)
+        INTEGER M,N,LDFJAC,INFO,LWA
+        INTEGER IPVT(N)
+        DOUBLE PRECISION TOL
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),WA(LWA)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to LMDER1 and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from LMDER1.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions and the Jacobian.  FCN must be declared in an
+          EXTERNAL statement in the user calling program, and should be
+          written as follows.
+          SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG)
+          INTEGER M,N,LDFJAC,IFLAG
+          DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N)
+          ----------
+          IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.  DO NOT ALTER FJAC.
+          IF IFLAG = 2 CALCULATE THE JACOBIAN AT X AND
+          RETURN THIS MATRIX IN FJAC.  DO NOT ALTER FVEC.
+          ----------
+          RETURN
+          END
+ 
+                                                                  Page
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of LMDER1.  In this case set
+          IFLAG to a negative integer.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.  N must not exceed M.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length M which contains the function
+          evaluated at the output X.
+        FJAC is an output M by N array.  The upper N by N submatrix of
+          FJAC contains an upper triangular matrix R with diagonal ele-
+          ments of nonincreasing magnitude such that
+                 T     T           T
+                P *(JAC *JAC)*P = R *R,
+          where P is a permutation matrix and JAC is the final calcu-
+          lated Jacobian.  Column j of P is column IPVT(j) (see below)
+          of the identity matrix.  The lower trapezoidal part of FJAC
+          contains information generated during the computation of R.
+        LDFJAC is a positive integer input variable not less than M
+          which specifies the leading dimension of the array FJAC.
+        TOL is a nonnegative input variable.  Termination occurs when
+          the algorithm estimates either that the relative error in the
+          sum of squares is at most TOL or that the relative error
+          between X and the solution is at most TOL.  Section 4 contain
+          more details about TOL.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Algorithm estimates that the relative error in the
+                    sum of squares is at most TOL.
+          INFO = 2  Algorithm estimates that the relative error between
+                    X and the solution is at most TOL.
+          INFO = 3  Conditions for INFO = 1 and INFO = 2 both hold.
+          INFO = 4  FVEC is orthogonal to the columns of the Jacobian t
+                    machine precision.
+ 
+                                                                  Page
+          INFO = 5  Number of calls to FCN with IFLAG = 1 has reached
+                    100*(N+1).
+          INFO = 6  TOL is too small.  No further reduction in the sum
+                    of squares is possible.
+          INFO = 7  TOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          Sections 4 and 5 contain more details about INFO.
+        IPVT is an integer output array of length N.  IPVT defines a
+          permutation matrix P such that JAC*P = Q*R, where JAC is the
+          final calculated Jacobian, Q is orthogonal (not stored), and
+          is upper triangular with diagonal elements of nonincreasing
+          magnitude.  Column j of P is column IPVT(j) of the identity
+          matrix.
+        WA is a work array of length LWA.
+        LWA is a positive integer input variable not less than 5*N+M.
+ 
+  4. Successful completion.
+        The accuracy of LMDER1 is controlled by the convergence parame-
+        ter TOL.  This parameter is used in tests which make three type
+        of comparisons between the approximation X and a solution XSOL.
+        LMDER1 terminates when any of the tests is satisfied.  If TOL i
+        less than the machine precision (as defined by the MINPACK func-
+        tion DPMPAR(1)), then LMDER1 only attempts to satisfy the test
+        defined by the machine precision.  Further progress is not usu-
+        ally possible.  Unless high precision solutions are required,
+        the recommended value for TOL is the square root of the machine
+        precision.
+        The tests assume that the functions and the Jacobian are coded
+        consistently, and that the functions are reasonably well
+        behaved.  If these conditions are not satisfied, then LMDER1 ma
+        incorrectly indicate convergence.  The coding of the Jacobian
+        can be checked by the MINPACK subroutine CHKDER.  If the Jaco-
+        bian is coded correctly, then the validity of the answer can be
+        checked, for example, by rerunning LMDER1 with a tighter toler-
+        ance.
+        First convergence test.  If ENORM(Z) denotes the Euclidean norm
+          of a vector Z, then this test attempts to guarantee that
+                ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS),
+          where FVECS denotes the functions evaluated at XSOL.  If this
+          condition is satisfied with TOL = 10**(-K), then the final
+          residual norm ENORM(FVEC) has K significant decimal digits an
+          INFO is set to 1 (or to 3 if the second test is also
+ 
+                                                                  Page
+          satisfied).
+        Second convergence test.  If D is a diagonal matrix (implicitly
+          generated by LMDER1) whose entries contain scale factors for
+          the variables, then this test attempts to guarantee that
+                ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL).
+          If this condition is satisfied with TOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 2 (or to 3 if the first test is also satis-
+          fied).  There is a danger that the smaller components of D*X
+          may have large relative errors, but the choice of D is such
+          that the accuracy of the components of X is usually related t
+          their sensitivity.
+        Third convergence test.  This test is satisfied when FVEC is
+          orthogonal to the columns of the Jacobian to machine preci-
+          sion.  There is no clear relationship between this test and
+          the accuracy of LMDER1, and furthermore, the test is equally
+          well satisfied at other critical points, namely maximizers an
+          saddle points.  Therefore, termination caused by this test
+          (INFO = 4) should be examined carefully.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of LMDER1 can be due to improper input
+        parameters, arithmetic interrupts, or an excessive number of
+        function evaluations.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          M .LT. N, or LDFJAC .LT. M, or TOL .LT. 0.D0, or
+          LWA .LT. 5*N+M.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by LMDER1.  In this
+          case, it may be possible to remedy the situation by not evalu-
+          ating the functions here, but instead setting the components
+          of FVEC to numbers that exceed those in the initial FVEC,
+          thereby indirectly reducing the step length.  The step length
+          can be more directly controlled by using instead LMDER, which
+          includes in its calling sequence the step-length- governing
+          parameter FACTOR.
+        Excessive number of function evaluations.  If the number of
+          calls to FCN with IFLAG = 1 reaches 100*(N+1), then this indi-
+          cates that the routine is converging very slowly as measured
+          by the progress of FVEC, and INFO is set to 5.  In this case,
+          it may be helpful to restart LMDER1, thereby forcing it to
+          disregard old (and possibly harmful) information.
+ 
+ 
+                                                                  Page
+  6. Characteristics of the algorithm.
+        LMDER1 is a modification of the Levenberg-Marquardt algorithm.
+        Two of its main characteristics involve the proper use of
+        implicitly scaled variables and an optimal choice for the cor-
+        rection.  The use of implicitly scaled variables achieves scale
+        invariance of LMDER1 and limits the size of the correction in
+        any direction where the functions are changing rapidly.  The
+        optimal choice of the correction guarantees (under reasonable
+        conditions) global convergence from starting points far from th
+        solution and a fast rate of convergence for problems with small
+        residuals.
+        Timing.  The time required by LMDER1 to solve a given problem
+          depends on M and N, the behavior of the functions, the accu-
+          racy requested, and the starting point.  The number of arith-
+          metic operations needed by LMDER1 is about N**3 to process
+          each evaluation of the functions (call to FCN with IFLAG = 1)
+          and M*(N**2) to process each evaluation of the Jacobian (call
+          to FCN with IFLAG = 2).  Unless FCN can be evaluated quickly,
+          the timing of LMDER1 will be strongly influenced by the time
+          spent in FCN.
+        Storage.  LMDER1 requires M*N + 2*M + 6*N double precision sto-
+          rage locations and N integer storage locations, in addition t
+          the storage required by the program.  There are no internally
+          declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DPMPAR,ENORM,LMDER,LMPAR,QRFAC,QRSOLV
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD
+ 
+  8. References.
+        Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation
+        and Theory. Numerical Analysis, G. A. Watson, editor.
+        Lecture Notes in Mathematics 630, Springer-Verlag, 1977.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), and x(3)
+        which provide the best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+        to the data
+ 
+                                                                  Page
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+  C     **********
+  C
+  C     DRIVER FOR LMDER1 EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,M,N,LDFJAC,INFO,LWA,NWRITE
+        INTEGER IPVT(3)
+        DOUBLE PRECISION TOL,FNORM
+        DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),WA(30)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT.
+  C
+        X(1) = 1.D0
+        X(2) = 1.D0
+        X(3) = 1.D0
+  C
+        LDFJAC = 15
+        LWA = 30
+  C
+  C     SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        TOL = DSQRT(DPMPAR(1))
+  C
+        CALL LMDER1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL,
+       *            INFO,IPVT,WA,LWA)
+        FNORM = ENORM(M,FVEC)
+        WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7)
+  C
+  C     LAST CARD OF DRIVER FOR LMDER1 EXAMPLE.
+  C
+ 
+                                                                  Page
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG)
+        INTEGER M,N,LDFJAC,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N)
+  C
+  C     SUBROUTINE FCN FOR LMDER1 EXAMPLE.
+  C
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+        IF (IFLAG .EQ. 2) GO TO 20
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        GO TO 40
+     20 CONTINUE
+        DO 30 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
+           FJAC(I,1) = -1.D0
+           FJAC(I,2) = TMP1*TMP2/TMP4
+           FJAC(I,3) = TMP1*TMP3/TMP4
+     30    CONTINUE
+     40 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+         0.8241058D-01  0.1133037D+01  0.2343695D+01
+ 
+ 
+ 
+                                                                  Page
+                Documentation for MINPACK subroutine LMDER
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of LMDER is to minimize the sum of the squares of M
+        nonlinear functions in N variables by a modification of the
+        Levenberg-Marquardt algorithm.  The user must provide a subrou-
+        tine which calculates the functions and the Jacobian.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE LMDER(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL,
+       *                 MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,
+       *                 IPVT,QTF,WA1,WA2,WA3,WA4)
+        INTEGER M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV
+        INTEGER IPVT(N)
+        DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),DIAG(N),QTF(N),
+       *                 WA1(N),WA2(N),WA3(N),WA4(M)
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to LMDER and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from LMDER.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions and the Jacobian.  FCN must be declared in an
+          EXTERNAL statement in the user calling program, and should be
+          written as follows.
+          SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG)
+          INTEGER M,N,LDFJAC,IFLAG
+          DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N)
+          ----------
+          IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.  DO NOT ALTER FJAC.
+          IF IFLAG = 2 CALCULATE THE JACOBIAN AT X AND
+          RETURN THIS MATRIX IN FJAC.  DO NOT ALTER FVEC.
+          ----------
+          RETURN
+          END
+ 
+                                                                  Page
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of LMDER.  In this case set
+          IFLAG to a negative integer.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.  N must not exceed M.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length M which contains the function
+          evaluated at the output X.
+        FJAC is an output M by N array.  The upper N by N submatrix of
+          FJAC contains an upper triangular matrix R with diagonal ele-
+          ments of nonincreasing magnitude such that
+                 T     T           T
+                P *(JAC *JAC)*P = R *R,
+          where P is a permutation matrix and JAC is the final calcu-
+          lated Jacobian.  Column j of P is column IPVT(j) (see below)
+          of the identity matrix.  The lower trapezoidal part of FJAC
+          contains information generated during the computation of R.
+        LDFJAC is a positive integer input variable not less than M
+          which specifies the leading dimension of the array FJAC.
+        FTOL is a nonnegative input variable.  Termination occurs when
+          both the actual and predicted relative reductions in the sum
+          of squares are at most FTOL.  Therefore, FTOL measures the
+          relative error desired in the sum of squares.  Section 4 con-
+          tains more details about FTOL.
+        XTOL is a nonnegative input variable.  Termination occurs when
+          the relative error between two consecutive iterates is at most
+          XTOL.  Therefore, XTOL measures the relative error desired in
+          the approximate solution.  Section 4 contains more details
+          about XTOL.
+        GTOL is a nonnegative input variable.  Termination occurs when
+          the cosine of the angle between FVEC and any column of the
+          Jacobian is at most GTOL in absolute value.  Therefore, GTOL
+          measures the orthogonality desired between the function vector
+          and the columns of the Jacobian.  Section 4 contains more
+          details about GTOL.
+        MAXFEV is a positive integer input variable.  Termination occur
+          when the number of calls to FCN with IFLAG = 1 has reached
+          MAXFEV.
+ 
+                                                                  Page
+        DIAG is an array of length N.  If MODE = 1 (see below), DIAG is
+          internally set.  If MODE = 2, DIAG must contain positive
+          entries that serve as multiplicative scale factors for the
+          variables.
+        MODE is an integer input variable.  If MODE = 1, the variables
+          will be scaled internally.  If MODE = 2, the scaling is speci-
+          fied by the input DIAG.  Other values of MODE are equivalent
+          to MODE = 1.
+        FACTOR is a positive input variable used in determining the ini-
+          tial step bound.  This bound is set to the product of FACTOR
+          and the Euclidean norm of DIAG*X if nonzero, or else to FACTO
+          itself.  In most cases FACTOR should lie in the interval
+          (.1,100.).  100. is a generally recommended value.
+        NPRINT is an integer input variable that enables controlled
+          printing of iterates if it is positive.  In this case, FCN is
+          called with IFLAG = 0 at the beginning of the first iteration
+          and every NPRINT iterations thereafter and immediately prior
+          to return, with X, FVEC, and FJAC available for printing.
+          FVEC and FJAC should not be altered.  If NPRINT is not posi-
+          tive, no special calls of FCN with IFLAG = 0 are made.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Both actual and predicted relative reductions in th
+                    sum of squares are at most FTOL.
+          INFO = 2  Relative error between two consecutive iterates is
+                    at most XTOL.
+          INFO = 3  Conditions for INFO = 1 and INFO = 2 both hold.
+          INFO = 4  The cosine of the angle between FVEC and any column
+                    of the Jacobian is at most GTOL in absolute value.
+          INFO = 5  Number of calls to FCN with IFLAG = 1 has reached
+                    MAXFEV.
+          INFO = 6  FTOL is too small.  No further reduction in the sum
+                    of squares is possible.
+          INFO = 7  XTOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 8  GTOL is too small.  FVEC is orthogonal to the
+                    columns of the Jacobian to machine precision.
+          Sections 4 and 5 contain more details about INFO.
+ 
+                                                                  Page
+        NFEV is an integer output variable set to the number of calls t
+          FCN with IFLAG = 1.
+        NJEV is an integer output variable set to the number of calls t
+          FCN with IFLAG = 2.
+        IPVT is an integer output array of length N.  IPVT defines a
+          permutation matrix P such that JAC*P = Q*R, where JAC is the
+          final calculated Jacobian, Q is orthogonal (not stored), and
+          is upper triangular with diagonal elements of nonincreasing
+          magnitude.  Column j of P is column IPVT(j) of the identity
+          matrix.
+        QTF is an output array of length N which contains the first N
+          elements of the vector (Q transpose)*FVEC.
+        WA1, WA2, and WA3 are work arrays of length N.
+        WA4 is a work array of length M.
+ 
+  4. Successful completion.
+        The accuracy of LMDER is controlled by the convergence parame-
+        ters FTOL, XTOL, and GTOL.  These parameters are used in tests
+        which make three types of comparisons between the approximation
+        X and a solution XSOL.  LMDER terminates when any of the tests
+        is satisfied.  If any of the convergence parameters is less than
+        the machine precision (as defined by the MINPACK function
+        DPMPAR(1)), then LMDER only attempts to satisfy the test define
+        by the machine precision.  Further progress is not usually pos-
+        sible.
+        The tests assume that the functions and the Jacobian are coded
+        consistently, and that the functions are reasonably well
+        behaved.  If these conditions are not satisfied, then LMDER may
+        incorrectly indicate convergence.  The coding of the Jacobian
+        can be checked by the MINPACK subroutine CHKDER.  If the Jaco-
+        bian is coded correctly, then the validity of the answer can be
+        checked, for example, by rerunning LMDER with tighter toler-
+        ances.
+        First convergence test.  If ENORM(Z) denotes the Euclidean norm
+          of a vector Z, then this test attempts to guarantee that
+                ENORM(FVEC) .LE. (1+FTOL)*ENORM(FVECS),
+          where FVECS denotes the functions evaluated at XSOL.  If this
+          condition is satisfied with FTOL = 10**(-K), then the final
+          residual norm ENORM(FVEC) has K significant decimal digits an
+          INFO is set to 1 (or to 3 if the second test is also satis-
+          fied).  Unless high precision solutions are required, the
+          recommended value for FTOL is the square root of the machine
+          precision.
+ 
+                                                                  Page
+        Second convergence test.  If D is the diagonal matrix whose
+          entries are defined by the array DIAG, then this test attempt
+          to guarantee that
+                ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL).
+          If this condition is satisfied with XTOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 2 (or to 3 if the first test is also satis-
+          fied).  There is a danger that the smaller components of D*X
+          may have large relative errors, but if MODE = 1, then the
+          accuracy of the components of X is usually related to their
+          sensitivity.  Unless high precision solutions are required,
+          the recommended value for XTOL is the square root of the
+          machine precision.
+        Third convergence test.  This test is satisfied when the cosine
+          of the angle between FVEC and any column of the Jacobian at X
+          is at most GTOL in absolute value.  There is no clear rela-
+          tionship between this test and the accuracy of LMDER, and
+          furthermore, the test is equally well satisfied at other crit-
+          ical points, namely maximizers and saddle points.  Therefore,
+          termination caused by this test (INFO = 4) should be examined
+          carefully.  The recommended value for GTOL is zero.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of LMDER can be due to improper input
+        parameters, arithmetic interrupts, or an excessive number of
+        function evaluations.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          M .LT. N, or LDFJAC .LT. M, or FTOL .LT. 0.D0, or
+          XTOL .LT. 0.D0, or GTOL .LT. 0.D0, or MAXFEV .LE. 0, or
+          FACTOR .LE. 0.D0.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by LMDER.  In this
+          case, it may be possible to remedy the situation by rerunning
+          LMDER with a smaller value of FACTOR.
+        Excessive number of function evaluations.  A reasonable value
+          for MAXFEV is 100*(N+1).  If the number of calls to FCN with
+          IFLAG = 1 reaches MAXFEV, then this indicates that the routine
+          is converging very slowly as measured by the progress of FVEC
+          and INFO is set to 5.  In this case, it may be helpful to
+          restart LMDER with MODE set to 1.
+ 
+  6. Characteristics of the algorithm.
+        LMDER is a modification of the Levenberg-Marquardt algorithm.
+ 
+                                                                  Page
+        Two of its main characteristics involve the proper use of
+        implicitly scaled variables (if MODE = 1) and an optimal choice
+        for the correction.  The use of implicitly scaled variables
+        achieves scale invariance of LMDER and limits the size of the
+        correction in any direction where the functions are changing
+        rapidly.  The optimal choice of the correction guarantees (under
+        reasonable conditions) global convergence from starting points
+        far from the solution and a fast rate of convergence for prob-
+        lems with small residuals.
+        Timing.  The time required by LMDER to solve a given problem
+          depends on M and N, the behavior of the functions, the accu-
+          racy requested, and the starting point.  The number of arith-
+          metic operations needed by LMDER is about N**3 to process each
+          evaluation of the functions (call to FCN with IFLAG = 1) and
+          M*(N**2) to process each evaluation of the Jacobian (call to
+          FCN with IFLAG = 2).  Unless FCN can be evaluated quickly, th
+          timing of LMDER will be strongly influenced by the time spent
+          in FCN.
+        Storage.  LMDER requires M*N + 2*M + 6*N double precision sto-
+          rage locations and N integer storage locations, in addition t
+          the storage required by the program.  There are no internally
+          declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DPMPAR,ENORM,LMPAR,QRFAC,QRSOLV
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD
+ 
+  8. References.
+        Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation
+        and Theory. Numerical Analysis, G. A. Watson, editor.
+        Lecture Notes in Mathematics 630, Springer-Verlag, 1977.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), and x(3)
+        which provide the best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+        to the data
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+ 
+                                                                  Page
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+  C     **********
+  C
+  C     DRIVER FOR LMDER EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,NWRITE
+        INTEGER IPVT(3)
+        DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR,FNORM
+        DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),DIAG(3),QTF(3),
+       *                 WA1(3),WA2(3),WA3(3),WA4(15)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT.
+  C
+        X(1) = 1.D0
+        X(2) = 1.D0
+        X(3) = 1.D0
+  C
+        LDFJAC = 15
+  C
+  C     SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION
+  C     AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE
+  C     REQUIRED, THESE ARE THE RECOMMENDED SETTINGS.
+  C
+        FTOL = DSQRT(DPMPAR(1))
+        XTOL = DSQRT(DPMPAR(1))
+        GTOL = 0.D0
+  C
+        MAXFEV = 400
+        MODE = 1
+        FACTOR = 1.D2
+        NPRINT = 0
+  C
+        CALL LMDER(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL,
+       *           MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,
+       *           IPVT,QTF,WA1,WA2,WA3,WA4)
+        FNORM = ENORM(M,FVEC)
+        WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+ 
+                                                                  Page
+       *        5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 //
+       *        5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7)
+  C
+  C     LAST CARD OF DRIVER FOR LMDER EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG)
+        INTEGER M,N,LDFJAC,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N)
+  C
+  C     SUBROUTINE FCN FOR LMDER EXAMPLE.
+  C
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+        IF (IFLAG .NE. 0) GO TO 5
+  C
+  C     INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE.
+  C
+        RETURN
+      5 CONTINUE
+        IF (IFLAG .EQ. 2) GO TO 20
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        GO TO 40
+     20 CONTINUE
+        DO 30 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
+           FJAC(I,1) = -1.D0
+           FJAC(I,2) = TMP1*TMP2/TMP4
+           FJAC(I,3) = TMP1*TMP3/TMP4
+     30    CONTINUE
+     40 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+ 
+                                                                  Page
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+        NUMBER OF FUNCTION EVALUATIONS         6
+        NUMBER OF JACOBIAN EVALUATIONS         5
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+         0.8241058D-01  0.1133037D+01  0.2343695D+01
+ 
+ 
+ 
+                                                                  Page
+               Documentation for MINPACK subroutine LMSTR1
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of LMSTR1 is to minimize the sum of the squares of
+        nonlinear functions in N variables by a modification of the
+        Levenberg-Marquardt algorithm which uses minimal storage.  This
+        is done by using the more general least-squares solver LMSTR.
+        The user must provide a subroutine which calculates the func-
+        tions and the rows of the Jacobian.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE LMSTR1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL,
+       *                  INFO,IPVT,WA,LWA)
+        INTEGER M,N,LDFJAC,INFO,LWA
+        INTEGER IPVT(N)
+        DOUBLE PRECISION TOL
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),WA(LWA)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to LMSTR1 and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from LMSTR1.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions and the rows of the Jacobian.  FCN must be
+          declared in an EXTERNAL statement in the user calling program
+          and should be written as follows.
+          SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG)
+          INTEGER M,N,IFLAG
+          DOUBLE PRECISION X(N),FVEC(M),FJROW(N)
+          ----------
+          IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.
+          IF IFLAG = I CALCULATE THE (I-1)-ST ROW OF THE
+          JACOBIAN AT X AND RETURN THIS VECTOR IN FJROW.
+          ----------
+          RETURN
+ 
+                                                                  Page
+          END
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of LMSTR1.  In this case set
+          IFLAG to a negative integer.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.  N must not exceed M.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length M which contains the function
+          evaluated at the output X.
+        FJAC is an output N by N array.  The upper triangle of FJAC con
+          tains an upper triangular matrix R such that
+                 T     T           T
+                P *(JAC *JAC)*P = R *R,
+          where P is a permutation matrix and JAC is the final calcu-
+          lated Jacobian.  Column j of P is column IPVT(j) (see below)
+          of the identity matrix.  The lower triangular part of FJAC
+          contains information generated during the computation of R.
+        LDFJAC is a positive integer input variable not less than N
+          which specifies the leading dimension of the array FJAC.
+        TOL is a nonnegative input variable.  Termination occurs when
+          the algorithm estimates either that the relative error in the
+          sum of squares is at most TOL or that the relative error
+          between X and the solution is at most TOL.  Section 4 contain
+          more details about TOL.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Algorithm estimates that the relative error in the
+                    sum of squares is at most TOL.
+          INFO = 2  Algorithm estimates that the relative error between
+                    X and the solution is at most TOL.
+          INFO = 3  Conditions for INFO = 1 and INFO = 2 both hold.
+          INFO = 4  FVEC is orthogonal to the columns of the Jacobian t
+ 
+                                                                  Page
+                    machine precision.
+          INFO = 5  Number of calls to FCN with IFLAG = 1 has reached
+                    100*(N+1).
+          INFO = 6  TOL is too small.  No further reduction in the sum
+                    of squares is possible.
+          INFO = 7  TOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          Sections 4 and 5 contain more details about INFO.
+        IPVT is an integer output array of length N.  IPVT defines a
+          permutation matrix P such that JAC*P = Q*R, where JAC is the
+          final calculated Jacobian, Q is orthogonal (not stored), and
+          is upper triangular.  Column j of P is column IPVT(j) of the
+          identity matrix.
+        WA is a work array of length LWA.
+        LWA is a positive integer input variable not less than 5*N+M.
+ 
+  4. Successful completion.
+        The accuracy of LMSTR1 is controlled by the convergence parame-
+        ter TOL.  This parameter is used in tests which make three type
+        of comparisons between the approximation X and a solution XSOL.
+        LMSTR1 terminates when any of the tests is satisfied.  If TOL i
+        less than the machine precision (as defined by the MINPACK func-
+        tion DPMPAR(1)), then LMSTR1 only attempts to satisfy the test
+        defined by the machine precision.  Further progress is not usu-
+        ally possible.  Unless high precision solutions are required,
+        the recommended value for TOL is the square root of the machine
+        precision.
+        The tests assume that the functions and the Jacobian are coded
+        consistently, and that the functions are reasonably well
+        behaved.  If these conditions are not satisfied, then LMSTR1 ma
+        incorrectly indicate convergence.  The coding of the Jacobian
+        can be checked by the MINPACK subroutine CHKDER.  If the Jaco-
+        bian is coded correctly, then the validity of the answer can be
+        checked, for example, by rerunning LMSTR1 with a tighter toler-
+        ance.
+        First convergence test.  If ENORM(Z) denotes the Euclidean norm
+          of a vector Z, then this test attempts to guarantee that
+                ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS),
+          where FVECS denotes the functions evaluated at XSOL.  If this
+          condition is satisfied with TOL = 10**(-K), then the final
+          residual norm ENORM(FVEC) has K significant decimal digits an
+ 
+                                                                  Page
+          INFO is set to 1 (or to 3 if the second test is also satis-
+          fied).
+        Second convergence test.  If D is a diagonal matrix (implicitly
+          generated by LMSTR1) whose entries contain scale factors for
+          the variables, then this test attempts to guarantee that
+                ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL).
+          If this condition is satisfied with TOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 2 (or to 3 if the first test is also satis-
+          fied).  There is a danger that the smaller components of D*X
+          may have large relative errors, but the choice of D is such
+          that the accuracy of the components of X is usually related t
+          their sensitivity.
+        Third convergence test.  This test is satisfied when FVEC is
+          orthogonal to the columns of the Jacobian to machine preci-
+          sion.  There is no clear relationship between this test and
+          the accuracy of LMSTR1, and furthermore, the test is equally
+          well satisfied at other critical points, namely maximizers an
+          saddle points.  Therefore, termination caused by this test
+          (INFO = 4) should be examined carefully.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of LMSTR1 can be due to improper input
+        parameters, arithmetic interrupts, or an excessive number of
+        function evaluations.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          M .LT. N, or LDFJAC .LT. N, or TOL .LT. 0.D0, or
+          LWA .LT. 5*N+M.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by LMSTR1.  In this
+          case, it may be possible to remedy the situation by not evalu-
+          ating the functions here, but instead setting the components
+          of FVEC to numbers that exceed those in the initial FVEC,
+          thereby indirectly reducing the step length.  The step length
+          can be more directly controlled by using instead LMSTR, which
+          includes in its calling sequence the step-length- governing
+          parameter FACTOR.
+        Excessive number of function evaluations.  If the number of
+          calls to FCN with IFLAG = 1 reaches 100*(N+1), then this indi-
+          cates that the routine is converging very slowly as measured
+          by the progress of FVEC, and INFO is set to 5.  In this case,
+          it may be helpful to restart LMSTR1, thereby forcing it to
+          disregard old (and possibly harmful) information.
+ 
+                                                                  Page
+ 
+  6. Characteristics of the algorithm.
+        LMSTR1 is a modification of the Levenberg-Marquardt algorithm.
+        Two of its main characteristics involve the proper use of
+        implicitly scaled variables and an optimal choice for the cor-
+        rection.  The use of implicitly scaled variables achieves scale
+        invariance of LMSTR1 and limits the size of the correction in
+        any direction where the functions are changing rapidly.  The
+        optimal choice of the correction guarantees (under reasonable
+        conditions) global convergence from starting points far from th
+        solution and a fast rate of convergence for problems with small
+        residuals.
+        Timing.  The time required by LMSTR1 to solve a given problem
+          depends on M and N, the behavior of the functions, the accu-
+          racy requested, and the starting point.  The number of arith-
+          metic operations needed by LMSTR1 is about N**3 to process
+          each evaluation of the functions (call to FCN with IFLAG = 1)
+          and 1.5*(N**2) to process each row of the Jacobian (call to
+          FCN with IFLAG .GE. 2).  Unless FCN can be evaluated quickly,
+          the timing of LMSTR1 will be strongly influenced by the time
+          spent in FCN.
+        Storage.  LMSTR1 requires N**2 + 2*M + 6*N double precision sto-
+          rage locations and N integer storage locations, in addition t
+          the storage required by the program.  There are no internally
+          declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DPMPAR,ENORM,LMSTR,LMPAR,QRFAC,QRSOLV,
+                             RWUPDT
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD
+ 
+  8. References.
+        Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation
+        and Theory. Numerical Analysis, G. A. Watson, editor.
+        Lecture Notes in Mathematics 630, Springer-Verlag, 1977.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), and x(3)
+        which provide the best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+ 
+                                                                  Page
+        to the data
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+  C     **********
+  C
+  C     DRIVER FOR LMSTR1 EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,M,N,LDFJAC,INFO,LWA,NWRITE
+        INTEGER IPVT(3)
+        DOUBLE PRECISION TOL,FNORM
+        DOUBLE PRECISION X(3),FVEC(15),FJAC(3,3),WA(30)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT.
+  C
+        X(1) = 1.D0
+        X(2) = 1.D0
+        X(3) = 1.D0
+  C
+        LDFJAC = 3
+        LWA = 30
+  C
+  C     SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        TOL = DSQRT(DPMPAR(1))
+  C
+        CALL LMSTR1(FCN,M,N,X,FVEC,FJAC,LDFJAC,TOL,
+       *            INFO,IPVT,WA,LWA)
+        FNORM = ENORM(M,FVEC)
+        WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7)
+  C
+ 
+                                                                  Page
+  C     LAST CARD OF DRIVER FOR LMSTR1 EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG)
+        INTEGER M,N,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M),FJROW(N)
+  C
+  C     SUBROUTINE FCN FOR LMSTR1 EXAMPLE.
+  C
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+        IF (IFLAG .GE. 2) GO TO 20
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        GO TO 40
+     20 CONTINUE
+        I = IFLAG - 1
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
+           FJROW(1) = -1.D0
+           FJROW(2) = TMP1*TMP2/TMP4
+           FJROW(3) = TMP1*TMP3/TMP4
+     30    CONTINUE
+     40 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+         0.8241058D-01  0.1133037D+01  0.2343695D+01
+ 
+ 
+ 
+                                                                  Page
+                Documentation for MINPACK subroutine LMSTR
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of LMSTR is to minimize the sum of the squares of M
+        nonlinear functions in N variables by a modification of the
+        Levenberg-Marquardt algorithm which uses minimal storage.  The
+        user must provide a subroutine which calculates the functions
+        and the rows of the Jacobian.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE LMSTR(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL,
+       *                 MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,
+       *                 IPVT,QTF,WA1,WA2,WA3,WA4)
+        INTEGER M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV
+        INTEGER IPVT(N)
+        DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),DIAG(N),QTF(N),
+       *                 WA1(N),WA2(N),WA3(N),WA4(M)
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to LMSTR and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from LMSTR.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions and the rows of the Jacobian.  FCN must be
+          declared in an EXTERNAL statement in the user calling program
+          and should be written as follows.
+          SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG)
+          INTEGER M,N,IFLAG
+          DOUBLE PRECISION X(N),FVEC(M),FJROW(N)
+          ----------
+          IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.
+          IF IFLAG = I CALCULATE THE (I-1)-ST ROW OF THE
+          JACOBIAN AT X AND RETURN THIS VECTOR IN FJROW.
+          ----------
+          RETURN
+ 
+                                                                  Page
+          END
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of LMSTR.  In this case set
+          IFLAG to a negative integer.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.  N must not exceed M.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length M which contains the function
+          evaluated at the output X.
+        FJAC is an output N by N array.  The upper triangle of FJAC con
+          tains an upper triangular matrix R such that
+                 T     T           T
+                P *(JAC *JAC)*P = R *R,
+          where P is a permutation matrix and JAC is the final calcu-
+          lated Jacobian.  Column j of P is column IPVT(j) (see below)
+          of the identity matrix.  The lower triangular part of FJAC
+          contains information generated during the computation of R.
+        LDFJAC is a positive integer input variable not less than N
+          which specifies the leading dimension of the array FJAC.
+        FTOL is a nonnegative input variable.  Termination occurs when
+          both the actual and predicted relative reductions in the sum
+          of squares are at most FTOL.  Therefore, FTOL measures the
+          relative error desired in the sum of squares.  Section 4 con-
+          tains more details about FTOL.
+        XTOL is a nonnegative input variable.  Termination occurs when
+          the relative error between two consecutive iterates is at most
+          XTOL.  Therefore, XTOL measures the relative error desired in
+          the approximate solution.  Section 4 contains more details
+          about XTOL.
+        GTOL is a nonnegative input variable.  Termination occurs when
+          the cosine of the angle between FVEC and any column of the
+          Jacobian is at most GTOL in absolute value.  Therefore, GTOL
+          measures the orthogonality desired between the function vector
+          and the columns of the Jacobian.  Section 4 contains more
+          details about GTOL.
+        MAXFEV is a positive integer input variable.  Termination occur
+          when the number of calls to FCN with IFLAG = 1 has reached
+ 
+                                                                  Page
+          MAXFEV.
+        DIAG is an array of length N.  If MODE = 1 (see below), DIAG is
+          internally set.  If MODE = 2, DIAG must contain positive
+          entries that serve as multiplicative scale factors for the
+          variables.
+        MODE is an integer input variable.  If MODE = 1, the variables
+          will be scaled internally.  If MODE = 2, the scaling is speci-
+          fied by the input DIAG.  Other values of MODE are equivalent
+          to MODE = 1.
+        FACTOR is a positive input variable used in determining the ini-
+          tial step bound.  This bound is set to the product of FACTOR
+          and the Euclidean norm of DIAG*X if nonzero, or else to FACTO
+          itself.  In most cases FACTOR should lie in the interval
+          (.1,100.).  100. is a generally recommended value.
+        NPRINT is an integer input variable that enables controlled
+          printing of iterates if it is positive.  In this case, FCN is
+          called with IFLAG = 0 at the beginning of the first iteration
+          and every NPRINT iterations thereafter and immediately prior
+          to return, with X and FVEC available for printing.  If NPRINT
+          is not positive, no special calls of FCN with IFLAG = 0 are
+          made.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Both actual and predicted relative reductions in th
+                    sum of squares are at most FTOL.
+          INFO = 2  Relative error between two consecutive iterates is
+                    at most XTOL.
+          INFO = 3  Conditions for INFO = 1 and INFO = 2 both hold.
+          INFO = 4  The cosine of the angle between FVEC and any column
+                    of the Jacobian is at most GTOL in absolute value.
+          INFO = 5  Number of calls to FCN with IFLAG = 1 has reached
+                    MAXFEV.
+          INFO = 6  FTOL is too small.  No further reduction in the sum
+                    of squares is possible.
+          INFO = 7  XTOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 8  GTOL is too small.  FVEC is orthogonal to the
+                    columns of the Jacobian to machine precision.
+ 
+                                                                  Page
+          Sections 4 and 5 contain more details about INFO.
+        NFEV is an integer output variable set to the number of calls t
+          FCN with IFLAG = 1.
+        NJEV is an integer output variable set to the number of calls t
+          FCN with IFLAG = 2.
+        IPVT is an integer output array of length N.  IPVT defines a
+          permutation matrix P such that JAC*P = Q*R, where JAC is the
+          final calculated Jacobian, Q is orthogonal (not stored), and
+          is upper triangular.  Column j of P is column IPVT(j) of the
+          identity matrix.
+        QTF is an output array of length N which contains the first N
+          elements of the vector (Q transpose)*FVEC.
+        WA1, WA2, and WA3 are work arrays of length N.
+        WA4 is a work array of length M.
+ 
+  4. Successful completion.
+        The accuracy of LMSTR is controlled by the convergence parame-
+        ters FTOL, XTOL, and GTOL.  These parameters are used in tests
+        which make three types of comparisons between the approximation
+        X and a solution XSOL.  LMSTR terminates when any of the tests
+        is satisfied.  If any of the convergence parameters is less than
+        the machine precision (as defined by the MINPACK function
+        DPMPAR(1)), then LMSTR only attempts to satisfy the test define
+        by the machine precision.  Further progress is not usually pos-
+        sible.
+        The tests assume that the functions and the Jacobian are coded
+        consistently, and that the functions are reasonably well
+        behaved.  If these conditions are not satisfied, then LMSTR may
+        incorrectly indicate convergence.  The coding of the Jacobian
+        can be checked by the MINPACK subroutine CHKDER.  If the Jaco-
+        bian is coded correctly, then the validity of the answer can be
+        checked, for example, by rerunning LMSTR with tighter toler-
+        ances.
+        First convergence test.  If ENORM(Z) denotes the Euclidean norm
+          of a vector Z, then this test attempts to guarantee that
+                ENORM(FVEC) .LE. (1+FTOL)*ENORM(FVECS),
+          where FVECS denotes the functions evaluated at XSOL.  If this
+          condition is satisfied with FTOL = 10**(-K), then the final
+          residual norm ENORM(FVEC) has K significant decimal digits an
+          INFO is set to 1 (or to 3 if the second test is also satis-
+          fied).  Unless high precision solutions are required, the
+          recommended value for FTOL is the square root of the machine
+ 
+                                                                  Page
+          precision.
+        Second convergence test.  If D is the diagonal matrix whose
+          entries are defined by the array DIAG, then this test attempt
+          to guarantee that
+                ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL).
+          If this condition is satisfied with XTOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 2 (or to 3 if the first test is also satis-
+          fied).  There is a danger that the smaller components of D*X
+          may have large relative errors, but if MODE = 1, then the
+          accuracy of the components of X is usually related to their
+          sensitivity.  Unless high precision solutions are required,
+          the recommended value for XTOL is the square root of the
+          machine precision.
+        Third convergence test.  This test is satisfied when the cosine
+          of the angle between FVEC and any column of the Jacobian at X
+          is at most GTOL in absolute value.  There is no clear rela-
+          tionship between this test and the accuracy of LMSTR, and
+          furthermore, the test is equally well satisfied at other crit-
+          ical points, namely maximizers and saddle points.  Therefore,
+          termination caused by this test (INFO = 4) should be examined
+          carefully.  The recommended value for GTOL is zero.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of LMSTR can be due to improper input
+        parameters, arithmetic interrupts, or an excessive number of
+        function evaluations.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          M .LT. N, or LDFJAC .LT. N, or FTOL .LT. 0.D0, or
+          XTOL .LT. 0.D0, or GTOL .LT. 0.D0, or MAXFEV .LE. 0, or
+          FACTOR .LE. 0.D0.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by LMSTR.  In this
+          case, it may be possible to remedy the situation by rerunning
+          LMSTR with a smaller value of FACTOR.
+        Excessive number of function evaluations.  A reasonable value
+          for MAXFEV is 100*(N+1).  If the number of calls to FCN with
+          IFLAG = 1 reaches MAXFEV, then this indicates that the routine
+          is converging very slowly as measured by the progress of FVEC
+          and INFO is set to 5.  In this case, it may be helpful to
+          restart LMSTR with MODE set to 1.
+ 
+  6. Characteristics of the algorithm.
+ 
+                                                                  Page
+        LMSTR is a modification of the Levenberg-Marquardt algorithm.
+        Two of its main characteristics involve the proper use of
+        implicitly scaled variables (if MODE = 1) and an optimal choice
+        for the correction.  The use of implicitly scaled variables
+        achieves scale invariance of LMSTR and limits the size of the
+        correction in any direction where the functions are changing
+        rapidly.  The optimal choice of the correction guarantees (under
+        reasonable conditions) global convergence from starting points
+        far from the solution and a fast rate of convergence for prob-
+        lems with small residuals.
+        Timing.  The time required by LMSTR to solve a given problem
+          depends on M and N, the behavior of the functions, the accu-
+          racy requested, and the starting point.  The number of arith-
+          metic operations needed by LMSTR is about N**3 to process each
+          evaluation of the functions (call to FCN with IFLAG = 1) and
+          1.5*(N**2) to process each row of the Jacobian (call to FCN
+          with IFLAG .GE. 2).  Unless FCN can be evaluated quickly, the
+          timing of LMSTR will be strongly influenced by the time spent
+          in FCN.
+        Storage.  LMSTR requires N**2 + 2*M + 6*N double precision sto-
+          rage locations and N integer storage locations, in addition t
+          the storage required by the program.  There are no internally
+          declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DPMPAR,ENORM,LMPAR,QRFAC,QRSOLV,RWUPDT
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD
+ 
+  8. References.
+        Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation
+        and Theory. Numerical Analysis, G. A. Watson, editor.
+        Lecture Notes in Mathematics 630, Springer-Verlag, 1977.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), and x(3)
+        which provide the best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+        to the data
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+ 
+                                                                  Page
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+  C     **********
+  C
+  C     DRIVER FOR LMSTR EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,M,N,LDFJAC,MAXFEV,MODE,NPRINT,INFO,NFEV,NJEV,NWRITE
+        INTEGER IPVT(3)
+        DOUBLE PRECISION FTOL,XTOL,GTOL,FACTOR,FNORM
+        DOUBLE PRECISION X(3),FVEC(15),FJAC(3,3),DIAG(3),QTF(3),
+       *                 WA1(3),WA2(3),WA3(3),WA4(15)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT.
+  C
+        X(1) = 1.D0
+        X(2) = 1.D0
+        X(3) = 1.D0
+  C
+        LDFJAC = 3
+  C
+  C     SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION
+  C     AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE
+  C     REQUIRED, THESE ARE THE RECOMMENDED SETTINGS.
+  C
+        FTOL = DSQRT(DPMPAR(1))
+        XTOL = DSQRT(DPMPAR(1))
+        GTOL = 0.D0
+  C
+        MAXFEV = 400
+        MODE = 1
+        FACTOR = 1.D2
+        NPRINT = 0
+  C
+        CALL LMSTR(FCN,M,N,X,FVEC,FJAC,LDFJAC,FTOL,XTOL,GTOL,
+       *           MAXFEV,DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,NJEV,
+       *           IPVT,QTF,WA1,WA2,WA3,WA4)
+        FNORM = ENORM(M,FVEC)
+        WRITE (NWRITE,1000) FNORM,NFEV,NJEV,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+ 
+                                                                  Page
+       *        5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 //
+       *        5X,31H NUMBER OF JACOBIAN EVALUATIONS,I10 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7)
+  C
+  C     LAST CARD OF DRIVER FOR LMSTR EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,FJROW,IFLAG)
+        INTEGER M,N,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M),FJROW(N)
+  C
+  C     SUBROUTINE FCN FOR LMSTR EXAMPLE.
+  C
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+        IF (IFLAG .NE. 0) GO TO 5
+  C
+  C     INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE.
+  C
+        RETURN
+      5 CONTINUE
+        IF (IFLAG .GE. 2) GO TO 20
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        GO TO 40
+     20 CONTINUE
+        I = IFLAG - 1
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
+           FJROW(1) = -1.D0
+           FJROW(2) = TMP1*TMP2/TMP4
+           FJROW(3) = TMP1*TMP3/TMP4
+     30    CONTINUE
+     40 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+ 
+                                                                  Page
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+        NUMBER OF FUNCTION EVALUATIONS         6
+        NUMBER OF JACOBIAN EVALUATIONS         5
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+         0.8241058D-01  0.1133037D+01  0.2343695D+01
+ 
+ 
+ 
+                                                                  Page
+               Documentation for MINPACK subroutine LMDIF1
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of LMDIF1 is to minimize the sum of the squares of
+        nonlinear functions in N variables by a modification of the
+        Levenberg-Marquardt algorithm.  This is done by using the more
+        general least-squares solver LMDIF.  The user must provide a
+        subroutine which calculates the functions.  The Jacobian is the
+        calculated by a forward-difference approximation.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE LMDIF1(FCN,M,N,X,FVEC,TOL,INFO,IWA,WA,LWA)
+        INTEGER M,N,INFO,LWA
+        INTEGER IWA(N)
+        DOUBLE PRECISION TOL
+        DOUBLE PRECISION X(N),FVEC(M),WA(LWA)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to LMDIF1 and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from LMDIF1.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions.  FCN must be declared in an EXTERNAL statement
+          in the user calling program, and should be written as follows
+          SUBROUTINE FCN(M,N,X,FVEC,IFLAG)
+          INTEGER M,N,IFLAG
+          DOUBLE PRECISION X(N),FVEC(M)
+          ----------
+          CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.
+          ----------
+          RETURN
+          END
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of LMDIF1.  In this case set
+ 
+                                                                  Page
+          IFLAG to a negative integer.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.  N must not exceed M.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length M which contains the function
+          evaluated at the output X.
+        TOL is a nonnegative input variable.  Termination occurs when
+          the algorithm estimates either that the relative error in the
+          sum of squares is at most TOL or that the relative error
+          between X and the solution is at most TOL.  Section 4 contain
+          more details about TOL.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Algorithm estimates that the relative error in the
+                    sum of squares is at most TOL.
+          INFO = 2  Algorithm estimates that the relative error between
+                    X and the solution is at most TOL.
+          INFO = 3  Conditions for INFO = 1 and INFO = 2 both hold.
+          INFO = 4  FVEC is orthogonal to the columns of the Jacobian t
+                    machine precision.
+          INFO = 5  Number of calls to FCN has reached or exceeded
+                    200*(N+1).
+          INFO = 6  TOL is too small.  No further reduction in the sum
+                    of squares is possible.
+          INFO = 7  TOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          Sections 4 and 5 contain more details about INFO.
+        IWA is an integer work array of length N.
+        WA is a work array of length LWA.
+        LWA is a positive integer input variable not less than
+ 
+                                                                  Page
+          M*N+5*N+M.
+ 
+  4. Successful completion.
+        The accuracy of LMDIF1 is controlled by the convergence parame-
+        ter TOL.  This parameter is used in tests which make three type
+        of comparisons between the approximation X and a solution XSOL.
+        LMDIF1 terminates when any of the tests is satisfied.  If TOL i
+        less than the machine precision (as defined by the MINPACK func-
+        tion DPMPAR(1)), then LMDIF1 only attempts to satisfy the test
+        defined by the machine precision.  Further progress is not usu-
+        ally possible.  Unless high precision solutions are required,
+        the recommended value for TOL is the square root of the machine
+        precision.
+        The tests assume that the functions are reasonably well behaved
+        If this condition is not satisfied, then LMDIF1 may incorrectly
+        indicate convergence.  The validity of the answer can be
+        checked, for example, by rerunning LMDIF1 with a tighter toler-
+        ance.
+        First convergence test.  If ENORM(Z) denotes the Euclidean norm
+          of a vector Z, then this test attempts to guarantee that
+                ENORM(FVEC) .LE. (1+TOL)*ENORM(FVECS),
+          where FVECS denotes the functions evaluated at XSOL.  If this
+          condition is satisfied with TOL = 10**(-K), then the final
+          residual norm ENORM(FVEC) has K significant decimal digits an
+          INFO is set to 1 (or to 3 if the second test is also satis-
+          fied).
+        Second convergence test.  If D is a diagonal matrix (implicitly
+          generated by LMDIF1) whose entries contain scale factors for
+          the variables, then this test attempts to guarantee that
+                ENORM(D*(X-XSOL)) .LE. TOL*ENORM(D*XSOL).
+          If this condition is satisfied with TOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 2 (or to 3 if the first test is also satis-
+          fied).  There is a danger that the smaller components of D*X
+          may have large relative errors, but the choice of D is such
+          that the accuracy of the components of X is usually related t
+          their sensitivity.
+        Third convergence test.  This test is satisfied when FVEC is
+          orthogonal to the columns of the Jacobian to machine preci-
+          sion.  There is no clear relationship between this test and
+          the accuracy of LMDIF1, and furthermore, the test is equally
+          well satisfied at other critical points, namely maximizers an
+          saddle points.  Also, errors in the functions (see below) may
+          result in the test being satisfied at a point not close to th
+ 
+                                                                  Page
+          minimum.  Therefore, termination caused by this test
+          (INFO = 4) should be examined carefully.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of LMDIF1 can be due to improper input
+        parameters, arithmetic interrupts, an excessive number of func-
+        tion evaluations, or errors in the functions.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          M .LT. N, or TOL .LT. 0.D0, or LWA .LT. M*N+5*N+M.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by LMDIF1.  In this
+          case, it may be possible to remedy the situation by not evalu-
+          ating the functions here, but instead setting the components
+          of FVEC to numbers that exceed those in the initial FVEC,
+          thereby indirectly reducing the step length.  The step length
+          can be more directly controlled by using instead LMDIF, which
+          includes in its calling sequence the step-length-governing
+          parameter FACTOR.
+        Excessive number of function evaluations.  If the number of
+          calls to FCN reaches 200*(N+1), then this indicates that the
+          routine is converging very slowly as measured by the progress
+          of FVEC, and INFO is set to 5.  In this case, it may be help-
+          ful to restart LMDIF1, thereby forcing it to disregard old
+          (and possibly harmful) information.
+        Errors in the functions.  The choice of step length in the for-
+          ward-difference approximation to the Jacobian assumes that th
+          relative errors in the functions are of the order of the
+          machine precision.  If this is not the case, LMDIF1 may fail
+          (usually with INFO = 4).  The user should then use LMDIF
+          instead, or one of the programs which require the analytic
+          Jacobian (LMDER1 and LMDER).
+ 
+  6. Characteristics of the algorithm.
+        LMDIF1 is a modification of the Levenberg-Marquardt algorithm.
+        Two of its main characteristics involve the proper use of
+        implicitly scaled variables and an optimal choice for the cor-
+        rection.  The use of implicitly scaled variables achieves scale
+        invariance of LMDIF1 and limits the size of the correction in
+        any direction where the functions are changing rapidly.  The
+        optimal choice of the correction guarantees (under reasonable
+        conditions) global convergence from starting points far from th
+        solution and a fast rate of convergence for problems with small
+        residuals.
+        Timing.  The time required by LMDIF1 to solve a given problem
+ 
+                                                                  Page
+          depends on M and N, the behavior of the functions, the accu-
+          racy requested, and the starting point.  The number of arith-
+          metic operations needed by LMDIF1 is about N**3 to process
+          each evaluation of the functions (one call to FCN) and
+          M*(N**2) to process each approximation to the Jacobian (N
+          calls to FCN).  Unless FCN can be evaluated quickly, the tim-
+          ing of LMDIF1 will be strongly influenced by the time spent i
+          FCN.
+        Storage.  LMDIF1 requires M*N + 2*M + 6*N double precision sto-
+          rage locations and N integer storage locations, in addition t
+          the storage required by the program.  There are no internally
+          declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DPMPAR,ENORM,FDJAC2,LMDIF,LMPAR,
+                             QRFAC,QRSOLV
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD
+ 
+  8. References.
+        Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation
+        and Theory. Numerical Analysis, G. A. Watson, editor.
+        Lecture Notes in Mathematics 630, Springer-Verlag, 1977.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), and x(3)
+        which provide the best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+        to the data
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+  C     **********
+  C
+  C     DRIVER FOR LMDIF1 EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+ 
+                                                                  Page
+  C     **********
+        INTEGER J,M,N,INFO,LWA,NWRITE
+        INTEGER IWA(3)
+        DOUBLE PRECISION TOL,FNORM
+        DOUBLE PRECISION X(3),FVEC(15),WA(75)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT.
+  C
+        X(1) = 1.D0
+        X(2) = 1.D0
+        X(3) = 1.D0
+  C
+        LWA = 75
+  C
+  C     SET TOL TO THE SQUARE ROOT OF THE MACHINE PRECISION.
+  C     UNLESS HIGH PRECISION SOLUTIONS ARE REQUIRED,
+  C     THIS IS THE RECOMMENDED SETTING.
+  C
+        TOL = DSQRT(DPMPAR(1))
+  C
+        CALL LMDIF1(FCN,M,N,X,FVEC,TOL,INFO,IWA,WA,LWA)
+        FNORM = ENORM(M,FVEC)
+        WRITE (NWRITE,1000) FNORM,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7)
+  C
+  C     LAST CARD OF DRIVER FOR LMDIF1 EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,IFLAG)
+        INTEGER M,N,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M)
+  C
+  C     SUBROUTINE FCN FOR LMDIF1 EXAMPLE.
+  C
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+ 
+                                                                  Page
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+         0.8241057D-01  0.1133037D+01  0.2343695D+01
+ 
+ 
+ 
+                                                                  Page
+                Documentation for MINPACK subroutine LMDIF
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of LMDIF is to minimize the sum of the squares of M
+        nonlinear functions in N variables by a modification of the
+        Levenberg-Marquardt algorithm.  The user must provide a subrou-
+        tine which calculates the functions.  The Jacobian is then cal-
+        culated by a forward-difference approximation.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE LMDIF(FCN,M,N,X,FVEC,FTOL,XTOL,GTOL,MAXFEV,EPSFCN,
+       *                 DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC,
+       *                 IPVT,QTF,WA1,WA2,WA3,WA4)
+        INTEGER M,N,MAXFEV,MODE,NPRINT,INFO,NFEV,LDFJAC
+        INTEGER IPVT(N)
+        DOUBLE PRECISION FTOL,XTOL,GTOL,EPSFCN,FACTOR
+        DOUBLE PRECISION X(N),FVEC(M),DIAG(N),FJAC(LDFJAC,N),QTF(N),
+       *                 WA1(N),WA2(N),WA3(N),WA4(M)
+        EXTERNAL FCN
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to LMDIF and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from LMDIF.
+        FCN is the name of the user-supplied subroutine which calculate
+          the functions.  FCN must be declared in an EXTERNAL statement
+          in the user calling program, and should be written as follows
+          SUBROUTINE FCN(M,N,X,FVEC,IFLAG)
+          INTEGER M,N,IFLAG
+          DOUBLE PRECISION X(N),FVEC(M)
+          ----------
+          CALCULATE THE FUNCTIONS AT X AND
+          RETURN THIS VECTOR IN FVEC.
+          ----------
+          RETURN
+          END
+ 
+                                                                  Page
+          The value of IFLAG should not be changed by FCN unless the
+          user wants to terminate execution of LMDIF.  In this case set
+          IFLAG to a negative integer.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.  N must not exceed M.
+        X is an array of length N.  On input X must contain an initial
+          estimate of the solution vector.  On output X contains the
+          final estimate of the solution vector.
+        FVEC is an output array of length M which contains the function
+          evaluated at the output X.
+        FTOL is a nonnegative input variable.  Termination occurs when
+          both the actual and predicted relative reductions in the sum
+          of squares are at most FTOL.  Therefore, FTOL measures the
+          relative error desired in the sum of squares.  Section 4 con-
+          tains more details about FTOL.
+        XTOL is a nonnegative input variable.  Termination occurs when
+          the relative error between two consecutive iterates is at most
+          XTOL.  Therefore, XTOL measures the relative error desired in
+          the approximate solution.  Section 4 contains more details
+          about XTOL.
+        GTOL is a nonnegative input variable.  Termination occurs when
+          the cosine of the angle between FVEC and any column of the
+          Jacobian is at most GTOL in absolute value.  Therefore, GTOL
+          measures the orthogonality desired between the function vector
+          and the columns of the Jacobian.  Section 4 contains more
+          details about GTOL.
+        MAXFEV is a positive integer input variable.  Termination occur
+          when the number of calls to FCN is at least MAXFEV by the end
+          of an iteration.
+        EPSFCN is an input variable used in determining a suitable step
+          for the forward-difference approximation.  This approximation
+          assumes that the relative errors in the functions are of the
+          order of EPSFCN.  If EPSFCN is less than the machine preci-
+          sion, it is assumed that the relative errors in the functions
+          are of the order of the machine precision.
+        DIAG is an array of length N.  If MODE = 1 (see below), DIAG is
+          internally set.  If MODE = 2, DIAG must contain positive
+          entries that serve as multiplicative scale factors for the
+          variables.
+        MODE is an integer input variable.  If MODE = 1, the variables
+          will be scaled internally.  If MODE = 2, the scaling is
+ 
+                                                                  Page
+          specified by the input DIAG.  Other values of MODE are equiva-
+          lent to MODE = 1.
+        FACTOR is a positive input variable used in determining the ini-
+          tial step bound.  This bound is set to the product of FACTOR
+          and the Euclidean norm of DIAG*X if nonzero, or else to FACTO
+          itself.  In most cases FACTOR should lie in the interval
+          (.1,100.).  100. is a generally recommended value.
+        NPRINT is an integer input variable that enables controlled
+          printing of iterates if it is positive.  In this case, FCN is
+          called with IFLAG = 0 at the beginning of the first iteration
+          and every NPRINT iterations thereafter and immediately prior
+          to return, with X and FVEC available for printing.  If NPRINT
+          is not positive, no special calls of FCN with IFLAG = 0 are
+          made.
+        INFO is an integer output variable.  If the user has terminated
+          execution, INFO is set to the (negative) value of IFLAG.  See
+          description of FCN.  Otherwise, INFO is set as follows.
+          INFO = 0  Improper input parameters.
+          INFO = 1  Both actual and predicted relative reductions in th
+                    sum of squares are at most FTOL.
+          INFO = 2  Relative error between two consecutive iterates is
+                    at most XTOL.
+          INFO = 3  Conditions for INFO = 1 and INFO = 2 both hold.
+          INFO = 4  The cosine of the angle between FVEC and any column
+                    of the Jacobian is at most GTOL in absolute value.
+          INFO = 5  Number of calls to FCN has reached or exceeded
+                    MAXFEV.
+          INFO = 6  FTOL is too small.  No further reduction in the sum
+                    of squares is possible.
+          INFO = 7  XTOL is too small.  No further improvement in the
+                    approximate solution X is possible.
+          INFO = 8  GTOL is too small.  FVEC is orthogonal to the
+                    columns of the Jacobian to machine precision.
+          Sections 4 and 5 contain more details about INFO.
+        NFEV is an integer output variable set to the number of calls t
+          FCN.
+        FJAC is an output M by N array.  The upper N by N submatrix of
+          FJAC contains an upper triangular matrix R with diagonal ele-
+          ments of nonincreasing magnitude such that
+ 
+                                                                  Page
+                 T     T           T
+                P *(JAC *JAC)*P = R *R,
+          where P is a permutation matrix and JAC is the final calcu-
+          lated Jacobian.  Column j of P is column IPVT(j) (see below)
+          of the identity matrix.  The lower trapezoidal part of FJAC
+          contains information generated during the computation of R.
+        LDFJAC is a positive integer input variable not less than M
+          which specifies the leading dimension of the array FJAC.
+        IPVT is an integer output array of length N.  IPVT defines a
+          permutation matrix P such that JAC*P = Q*R, where JAC is the
+          final calculated Jacobian, Q is orthogonal (not stored), and
+          is upper triangular with diagonal elements of nonincreasing
+          magnitude.  Column j of P is column IPVT(j) of the identity
+          matrix.
+        QTF is an output array of length N which contains the first N
+          elements of the vector (Q transpose)*FVEC.
+        WA1, WA2, and WA3 are work arrays of length N.
+        WA4 is a work array of length M.
+ 
+  4. Successful completion.
+        The accuracy of LMDIF is controlled by the convergence parame-
+        ters FTOL, XTOL, and GTOL.  These parameters are used in tests
+        which make three types of comparisons between the approximation
+        X and a solution XSOL.  LMDIF terminates when any of the tests
+        is satisfied.  If any of the convergence parameters is less than
+        the machine precision (as defined by the MINPACK function
+        DPMPAR(1)), then LMDIF only attempts to satisfy the test define
+        by the machine precision.  Further progress is not usually pos-
+        sible.
+        The tests assume that the functions are reasonably well behaved
+        If this condition is not satisfied, then LMDIF may incorrectly
+        indicate convergence.  The validity of the answer can be
+        checked, for example, by rerunning LMDIF with tighter toler-
+        ances.
+        First convergence test.  If ENORM(Z) denotes the Euclidean norm
+          of a vector Z, then this test attempts to guarantee that
+                ENORM(FVEC) .LE. (1+FTOL)*ENORM(FVECS),
+          where FVECS denotes the functions evaluated at XSOL.  If this
+          condition is satisfied with FTOL = 10**(-K), then the final
+          residual norm ENORM(FVEC) has K significant decimal digits an
+          INFO is set to 1 (or to 3 if the second test is also satis-
+          fied).  Unless high precision solutions are required, the
+ 
+                                                                  Page
+          recommended value for FTOL is the square root of the machine
+          precision.
+        Second convergence test.  If D is the diagonal matrix whose
+          entries are defined by the array DIAG, then this test attempt
+          to guarantee that
+                ENORM(D*(X-XSOL)) .LE. XTOL*ENORM(D*XSOL).
+          If this condition is satisfied with XTOL = 10**(-K), then the
+          larger components of D*X have K significant decimal digits an
+          INFO is set to 2 (or to 3 if the first test is also satis-
+          fied).  There is a danger that the smaller components of D*X
+          may have large relative errors, but if MODE = 1, then the
+          accuracy of the components of X is usually related to their
+          sensitivity.  Unless high precision solutions are required,
+          the recommended value for XTOL is the square root of the
+          machine precision.
+        Third convergence test.  This test is satisfied when the cosine
+          of the angle between FVEC and any column of the Jacobian at X
+          is at most GTOL in absolute value.  There is no clear rela-
+          tionship between this test and the accuracy of LMDIF, and
+          furthermore, the test is equally well satisfied at other crit-
+          ical points, namely maximizers and saddle points.  Therefore,
+          termination caused by this test (INFO = 4) should be examined
+          carefully.  The recommended value for GTOL is zero.
+ 
+  5. Unsuccessful completion.
+        Unsuccessful termination of LMDIF can be due to improper input
+        parameters, arithmetic interrupts, or an excessive number of
+        function evaluations.
+        Improper input parameters.  INFO is set to 0 if N .LE. 0, or
+          M .LT. N, or LDFJAC .LT. M, or FTOL .LT. 0.D0, or
+          XTOL .LT. 0.D0, or GTOL .LT. 0.D0, or MAXFEV .LE. 0, or
+          FACTOR .LE. 0.D0.
+        Arithmetic interrupts.  If these interrupts occur in the FCN
+          subroutine during an early stage of the computation, they may
+          be caused by an unacceptable choice of X by LMDIF.  In this
+          case, it may be possible to remedy the situation by rerunning
+          LMDIF with a smaller value of FACTOR.
+        Excessive number of function evaluations.  A reasonable value
+          for MAXFEV is 200*(N+1).  If the number of calls to FCN
+          reaches MAXFEV, then this indicates that the routine is con-
+          verging very slowly as measured by the progress of FVEC, and
+          INFO is set to 5.  In this case, it may be helpful to restart
+          LMDIF with MODE set to 1.
+ 
+ 
+                                                                  Page
+  6. Characteristics of the algorithm.
+        LMDIF is a modification of the Levenberg-Marquardt algorithm.
+        Two of its main characteristics involve the proper use of
+        implicitly scaled variables (if MODE = 1) and an optimal choice
+        for the correction.  The use of implicitly scaled variables
+        achieves scale invariance of LMDIF and limits the size of the
+        correction in any direction where the functions are changing
+        rapidly.  The optimal choice of the correction guarantees (under
+        reasonable conditions) global convergence from starting points
+        far from the solution and a fast rate of convergence for prob-
+        lems with small residuals.
+        Timing.  The time required by LMDIF to solve a given problem
+          depends on M and N, the behavior of the functions, the accu-
+          racy requested, and the starting point.  The number of arith-
+          metic operations needed by LMDIF is about N**3 to process each
+          evaluation of the functions (one call to FCN) and M*(N**2) to
+          process each approximation to the Jacobian (N calls to FCN).
+          Unless FCN can be evaluated quickly, the timing of LMDIF will
+          be strongly influenced by the time spent in FCN.
+        Storage.  LMDIF requires M*N + 2*M + 6*N double precision sto-
+          rage locations and N integer storage locations, in addition t
+          the storage required by the program.  There are no internally
+          declared storage arrays.
+ 
+  7. Subprograms required.
+        USER-supplied ...... FCN
+        MINPACK-supplied ... DPMPAR,ENORM,FDJAC2,LMPAR,QRFAC,QRSOLV
+        FORTRAN-supplied ... DABS,DMAX1,DMIN1,DSQRT,MOD
+ 
+  8. References.
+        Jorge J. More, The Levenberg-Marquardt Algorithm, Implementation
+        and Theory. Numerical Analysis, G. A. Watson, editor.
+        Lecture Notes in Mathematics 630, Springer-Verlag, 1977.
+ 
+  9. Example.
+        The problem is to determine the values of x(1), x(2), and x(3)
+        which provide the best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+        to the data
+ 
+                                                                  Page
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+  C     **********
+  C
+  C     DRIVER FOR LMDIF EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER J,M,N,MAXFEV,MODE,NPRINT,INFO,NFEV,LDFJAC,NWRITE
+        INTEGER IPVT(3)
+        DOUBLE PRECISION FTOL,XTOL,GTOL,EPSFCN,FACTOR,FNORM
+        DOUBLE PRECISION X(3),FVEC(15),DIAG(3),FJAC(15,3),QTF(3),
+       *                 WA1(3),WA2(3),WA3(3),WA4(15)
+        DOUBLE PRECISION ENORM,DPMPAR
+        EXTERNAL FCN
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING STARTING VALUES PROVIDE A ROUGH FIT.
+  C
+        X(1) = 1.D0
+        X(2) = 1.D0
+        X(3) = 1.D0
+  C
+        LDFJAC = 15
+  C
+  C     SET FTOL AND XTOL TO THE SQUARE ROOT OF THE MACHINE PRECISION
+  C     AND GTOL TO ZERO. UNLESS HIGH PRECISION SOLUTIONS ARE
+  C     REQUIRED, THESE ARE THE RECOMMENDED SETTINGS.
+  C
+        FTOL = DSQRT(DPMPAR(1))
+        XTOL = DSQRT(DPMPAR(1))
+        GTOL = 0.D0
+  C
+        MAXFEV = 800
+        EPSFCN = 0.D0
+        MODE = 1
+        FACTOR = 1.D2
+        NPRINT = 0
+  C
+        CALL LMDIF(FCN,M,N,X,FVEC,FTOL,XTOL,GTOL,MAXFEV,EPSFCN,
+       *           DIAG,MODE,FACTOR,NPRINT,INFO,NFEV,FJAC,LDFJAC,
+       *           IPVT,QTF,WA1,WA2,WA3,WA4)
+ 
+                                                                  Page
+        FNORM = ENORM(M,FVEC)
+        WRITE (NWRITE,1000) FNORM,NFEV,INFO,(X(J),J=1,N)
+        STOP
+   1000 FORMAT (5X,31H FINAL L2 NORM OF THE RESIDUALS,D15.7 //
+       *        5X,31H NUMBER OF FUNCTION EVALUATIONS,I10 //
+       *        5X,15H EXIT PARAMETER,16X,I10 //
+       *        5X,27H FINAL APPROXIMATE SOLUTION // 5X,3D15.7)
+  C
+  C     LAST CARD OF DRIVER FOR LMDIF EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,IFLAG)
+        INTEGER M,N,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M)
+  C
+  C     SUBROUTINE FCN FOR LMDIF EXAMPLE.
+  C
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+        IF (IFLAG .NE. 0) GO TO 5
+  C
+  C     INSERT PRINT STATEMENTS HERE WHEN NPRINT IS POSITIVE.
+  C
+        RETURN
+      5 CONTINUE
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be slightly different.
+        FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+        NUMBER OF FUNCTION EVALUATIONS        21
+        EXIT PARAMETER                         1
+        FINAL APPROXIMATE SOLUTION
+ 
+                                                                  Page
+         0.8241057D-01  0.1133037D+01  0.2343695D+01
+ 
+ 
+ 
+                                                                  Page
+               Documentation for MINPACK subroutine CHKDER
+                         Double precision version
+                       Argonne National Laboratory
+          Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
+                                March 1980
+ 
+  1. Purpose.
+        The purpose of CHKDER is to check the gradients of M nonlinear
+        functions in N variables, evaluated at a point X, for consis-
+        tency with the functions themselves.  The user must call CHKDER
+        twice, first with MODE = 1 and then with MODE = 2.
+ 
+  2. Subroutine and type statements.
+        SUBROUTINE CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR)
+        INTEGER M,N,LDFJAC,MODE
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N),XP(N),FVECP(M),
+       *                 ERR(M)
+ 
+  3. Parameters.
+        Parameters designated as input parameters must be specified on
+        entry to CHKDER and are not changed on exit, while parameters
+        designated as output parameters need not be specified on entry
+        and are set to appropriate values on exit from CHKDER.
+        M is a positive integer input variable set to the number of
+          functions.
+        N is a positive integer input variable set to the number of
+          variables.
+        X is an input array of length N.
+        FVEC is an array of length M.  On input when MODE = 2, FVEC must
+          contain the functions evaluated at X.
+        FJAC is an M by N array.  On input when MODE = 2, the rows of
+          FJAC must contain the gradients of the respective functions
+          evaluated at X.
+        LDFJAC is a positive integer input variable not less than M
+          which specifies the leading dimension of the array FJAC.
+        XP is an array of length N.  On output when MODE = 1, XP is set
+          to a neighboring point of X.
+ 
+                                                                  Page
+        FVECP is an array of length M.  On input when MODE = 2, FVECP
+          must contain the functions evaluated at XP.
+        MODE is an integer input variable set to 1 on the first call an
+          2 on the second.  Other values of MODE are equivalent to
+          MODE = 1.
+        ERR is an array of length M.  On output when MODE = 2, ERR con-
+          tains measures of correctness of the respective gradients.  I
+          there is no severe loss of significance, then if ERR(I) is 1.
+          the I-th gradient is correct, while if ERR(I) is 0.0 the I-th
+          gradient is incorrect.  For values of ERR between 0.0 and 1.0
+          the categorization is less certain.  In general, a value of
+          ERR(I) greater than 0.5 indicates that the I-th gradient is
+          probably correct, while a value of ERR(I) less than 0.5 indi-
+          cates that the I-th gradient is probably incorrect.
+ 
+  4. Successful completion.
+        CHKDER usually guarantees that if ERR(I) is 1.0, then the I-th
+        gradient at X is consistent with the I-th function.  This sug-
+        gests that the input X be such that consistency of the gradient
+        at X implies consistency of the gradient at all points of inter
+        est.  If all the components of X are distinct and the fractional
+        part of each one has two nonzero digits, then X is likely to be
+        a satisfactory choice.
+        If ERR(I) is not 1.0 but is greater than 0.5, then the I-th gra-
+        dient is probably consistent with the I-th function (the more s
+        the larger ERR(I) is), but the conditions for ERR(I) to be 1.0
+        have not been completely satisfied.  In this case, it is recom-
+        mended that CHKDER be rerun with other input values of X.  If
+        ERR(I) is always greater than 0.5, then the I-th gradient is
+        consistent with the I-th function.
+ 
+  5. Unsuccessful completion.
+        CHKDER does not perform reliably if cancellation or rounding
+        errors cause a severe loss of significance in the evaluation of
+        a function.  Therefore, none of the components of X should be
+        unusually small (in particular, zero) or any other value which
+        may cause loss of significance.  The relative differences
+        between corresponding elements of FVECP and FVEC should be at
+        least two orders of magnitude greater than the machine precision
+        (as defined by the MINPACK function DPMPAR(1)).  If there is a
+        severe loss of significance in the evaluation of the I-th func-
+        tion, then ERR(I) may be 0.0 and yet the I-th gradient could be
+        correct.
+        If ERR(I) is not 0.0 but is less than 0.5, then the I-th gra-
+        dient is probably not consistent with the I-th function (the
+        more so the smaller ERR(I) is), but the conditions for ERR(I) t
+ 
+                                                                  Page
+        be 0.0 have not been completely satisfied.  In this case, it is
+        recommended that CHKDER be rerun with other input values of X.
+        If ERR(I) is always less than 0.5 and if there is no severe loss
+        of significance, then the I-th gradient is not consistent with
+        the I-th function.
+ 
+  6. Characteristics of the algorithm.
+        CHKDER checks the I-th gradient for consistency with the I-th
+        function by computing a forward-difference approximation along
+        suitably chosen direction and comparing this approximation with
+        the user-supplied gradient along the same direction.  The prin-
+        cipal characteristic of CHKDER is its invariance to changes in
+        scale of the variables or functions.
+        Timing.  The time required by CHKDER depends only on M and N.
+          The number of arithmetic operations needed by CHKDER is about
+          N when MODE = 1 and M*N when MODE = 2.
+        Storage.  CHKDER requires M*N + 3*M + 2*N double precision stor-
+          age locations, in addition to the storage required by the pro
+          gram.  There are no internally declared storage arrays.
+ 
+  7. Subprograms required.
+        MINPACK-supplied ... DPMPAR
+        FORTRAN-supplied ... DABS,DLOG10,DSQRT
+ 
+  8. References.
+        None.
+ 
+  9. Example.
+        This example checks the Jacobian matrix for the problem that
+        determines the values of x(1), x(2), and x(3) which provide the
+        best fit (in the least squares sense) of
+              x(1) + u(i)/(v(i)*x(2) + w(i)*x(3)),  i = 1, 15
+        to the data
+              y = (0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,
+                   0.37,0.58,0.73,0.96,1.34,2.10,4.39),
+        where u(i) = i, v(i) = 16 - i, and w(i) = min(u(i),v(i)).  The
+        i-th component of FVEC is thus defined by
+              y(i) - (x(1) + u(i)/(v(i)*x(2) + w(i)*x(3))).
+ 
+                                                                  Page
+  C     **********
+  C
+  C     DRIVER FOR CHKDER EXAMPLE.
+  C     DOUBLE PRECISION VERSION
+  C
+  C     **********
+        INTEGER I,M,N,LDFJAC,MODE,NWRITE
+        DOUBLE PRECISION X(3),FVEC(15),FJAC(15,3),XP(3),FVECP(15),
+       *                 ERR(15)
+  C
+  C     LOGICAL OUTPUT UNIT IS ASSUMED TO BE NUMBER 6.
+  C
+        DATA NWRITE /6/
+  C
+        M = 15
+        N = 3
+  C
+  C     THE FOLLOWING VALUES SHOULD BE SUITABLE FOR
+  C     CHECKING THE JACOBIAN MATRIX.
+  C
+        X(1) = 9.2D-1
+        X(2) = 1.3D-1
+        X(3) = 5.4D-1
+  C
+        LDFJAC = 15
+  C
+        MODE = 1
+        CALL CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR)
+        MODE = 2
+        CALL FCN(M,N,X,FVEC,FJAC,LDFJAC,1)
+        CALL FCN(M,N,X,FVEC,FJAC,LDFJAC,2)
+        CALL FCN(M,N,XP,FVECP,FJAC,LDFJAC,1)
+        CALL CHKDER(M,N,X,FVEC,FJAC,LDFJAC,XP,FVECP,MODE,ERR)
+  C
+        DO 10 I = 1, M
+           FVECP(I) = FVECP(I) - FVEC(I)
+     10    CONTINUE
+        WRITE (NWRITE,1000) (FVEC(I),I=1,M)
+        WRITE (NWRITE,2000) (FVECP(I),I=1,M)
+        WRITE (NWRITE,3000) (ERR(I),I=1,M)
+        STOP
+   1000 FORMAT (/5X,5H FVEC // (5X,3D15.7))
+   2000 FORMAT (/5X,13H FVECP - FVEC // (5X,3D15.7))
+   3000 FORMAT (/5X,4H ERR // (5X,3D15.7))
+  C
+  C     LAST CARD OF DRIVER FOR CHKDER EXAMPLE.
+  C
+        END
+        SUBROUTINE FCN(M,N,X,FVEC,FJAC,LDFJAC,IFLAG)
+        INTEGER M,N,LDFJAC,IFLAG
+        DOUBLE PRECISION X(N),FVEC(M),FJAC(LDFJAC,N)
+  C
+  C     SUBROUTINE FCN FOR CHKDER EXAMPLE.
+  C
+ 
+                                                                  Page
+        INTEGER I
+        DOUBLE PRECISION TMP1,TMP2,TMP3,TMP4
+        DOUBLE PRECISION Y(15)
+        DATA Y(1),Y(2),Y(3),Y(4),Y(5),Y(6),Y(7),Y(8),
+       *     Y(9),Y(10),Y(11),Y(12),Y(13),Y(14),Y(15)
+       *     /1.4D-1,1.8D-1,2.2D-1,2.5D-1,2.9D-1,3.2D-1,3.5D-1,3.9D-1,
+       *      3.7D-1,5.8D-1,7.3D-1,9.6D-1,1.34D0,2.1D0,4.39D0/
+  C
+        IF (IFLAG .EQ. 2) GO TO 20
+        DO 10 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+           TMP3 = TMP1
+           IF (I .GT. 8) TMP3 = TMP2
+           FVEC(I) = Y(I) - (X(1) + TMP1/(X(2)*TMP2 + X(3)*TMP3))
+     10    CONTINUE
+        GO TO 40
+     20 CONTINUE
+        DO 30 I = 1, 15
+           TMP1 = I
+           TMP2 = 16 - I
+  C
+  C        ERROR INTRODUCED INTO NEXT STATEMENT FOR ILLUSTRATION.
+  C        CORRECTED STATEMENT SHOULD READ    TMP3 = TMP1 .
+  C
+           TMP3 = TMP2
+           IF (I .GT. 8) TMP3 = TMP2
+           TMP4 = (X(2)*TMP2 + X(3)*TMP3)**2
+           FJAC(I,1) = -1.D0
+           FJAC(I,2) = TMP1*TMP2/TMP4
+           FJAC(I,3) = TMP1*TMP3/TMP4
+     30    CONTINUE
+     40 CONTINUE
+        RETURN
+  C
+  C     LAST CARD OF SUBROUTINE FCN.
+  C
+        END
+        Results obtained with different compilers or machines
+        may be different.  In particular, the differences
+        FVECP - FVEC are machine dependent.
+        FVEC
+        -0.1181606D+01 -0.1429655D+01 -0.1606344D+01
+        -0.1745269D+01 -0.1840654D+01 -0.1921586D+01
+        -0.1984141D+01 -0.2022537D+01 -0.2468977D+01
+        -0.2827562D+01 -0.3473582D+01 -0.4437612D+01
+        -0.6047662D+01 -0.9267761D+01 -0.1891806D+02
+        FVECP - FVEC
+        -0.7724666D-08 -0.3432405D-08 -0.2034843D-09
+ 
+                                                                  Page
+         0.2313685D-08  0.4331078D-08  0.5984096D-08
+         0.7363281D-08  0.8531470D-08  0.1488591D-07
+         0.2335850D-07  0.3522012D-07  0.5301255D-07
+         0.8266660D-07  0.1419747D-06  0.3198990D-06
+        ERR
+         0.1141397D+00  0.9943516D-01  0.9674474D-01
+         0.9980447D-01  0.1073116D+00  0.1220445D+00
+         0.1526814D+00  0.1000000D+01  0.1000000D+01
+         0.1000000D+01  0.1000000D+01  0.1000000D+01
+         0.1000000D+01  0.1000000D+01  0.1000000D+01
diff --git a/dogleg.c b/dogleg.c
new file mode 100644
index 0000000..779f643
--- /dev/null
+++ b/dogleg.c
@@ -0,0 +1,219 @@
+/* dogleg.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+/* Table of constant values */
+
+__cminpack_attr__
+void __cminpack_func__(dogleg)(int n, const real *r, int lr, 
+	const real *diag, const real *qtb, real delta, real *x, 
+	real *wa1, real *wa2)
+{
+    /* System generated locals */
+    real d1, d2, d3, d4;
+
+    /* Local variables */
+    int i, j, k, l, jj, jp1;
+    real sum, temp, alpha, bnorm;
+    real gnorm, qnorm, epsmch;
+    real sgnorm;
+
+/*     ********** */
+
+/*     subroutine dogleg */
+
+/*     given an m by n matrix a, an n by n nonsingular diagonal */
+/*     matrix d, an m-vector b, and a positive number delta, the */
+/*     problem is to determine the convex combination x of the */
+/*     gauss-newton and scaled gradient directions that minimizes */
+/*     (a*x - b) in the least squares sense, subject to the */
+/*     restriction that the euclidean norm of d*x be at most delta. */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization of a. that is, if a = q*r, where q has */
+/*     orthogonal columns and r is an upper triangular matrix, */
+/*     then dogleg expects the full upper triangle of r and */
+/*     the first n components of (q transpose)*b. */
+
+/*     the subroutine statement is */
+
+/*       subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an input array of length lr which must contain the upper */
+/*         triangular matrix r stored by rows. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       delta is a positive input variable which specifies an upper */
+/*         bound on the euclidean norm of d*x. */
+
+/*       x is an output array of length n which contains the desired */
+/*         convex combination of the gauss-newton direction and the */
+/*         scaled gradient direction. */
+
+/*       wa1 and wa2 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa2;
+    --wa1;
+    --x;
+    --qtb;
+    --diag;
+    --r;
+    (void)lr;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+/*     first, calculate the gauss-newton direction. */
+
+    jj = n * (n + 1) / 2 + 1;
+    for (k = 1; k <= n; ++k) {
+	j = n - k + 1;
+	jp1 = j + 1;
+	jj -= k;
+	l = jj + 1;
+	sum = 0.;
+	if (n >= jp1) {
+            for (i = jp1; i <= n; ++i) {
+                sum += r[l] * x[i];
+                ++l;
+            }
+        }
+	temp = r[jj];
+	if (temp == 0.) {
+            l = j;
+            for (i = 1; i <= j; ++i) {
+                /* Computing MAX */
+                d2 = fabs(r[l]);
+                temp = max(temp,d2);
+                l = l + n - i;
+            }
+            temp = epsmch * temp;
+            if (temp == 0.) {
+                temp = epsmch;
+            }
+        }
+	x[j] = (qtb[j] - sum) / temp;
+    }
+
+/*     test whether the gauss-newton direction is acceptable. */
+
+    for (j = 1; j <= n; ++j) {
+	wa1[j] = 0.;
+	wa2[j] = diag[j] * x[j];
+    }
+    qnorm = __cminpack_enorm__(n, &wa2[1]);
+    if (qnorm <= delta) {
+        return;
+    }
+
+/*     the gauss-newton direction is not acceptable. */
+/*     next, calculate the scaled gradient direction. */
+
+    l = 1;
+    for (j = 1; j <= n; ++j) {
+	temp = qtb[j];
+	for (i = j; i <= n; ++i) {
+	    wa1[i] += r[l] * temp;
+	    ++l;
+	}
+	wa1[j] /= diag[j];
+    }
+
+/*     calculate the norm of the scaled gradient and test for */
+/*     the special case in which the scaled gradient is zero. */
+
+    gnorm = __cminpack_enorm__(n, &wa1[1]);
+    sgnorm = 0.;
+    alpha = delta / qnorm;
+    if (gnorm != 0.) {
+
+/*     calculate the point along the scaled gradient */
+/*     at which the quadratic is minimized. */
+
+        for (j = 1; j <= n; ++j) {
+            wa1[j] = wa1[j] / gnorm / diag[j];
+        }
+        l = 1;
+        for (j = 1; j <= n; ++j) {
+            sum = 0.;
+            for (i = j; i <= n; ++i) {
+                sum += r[l] * wa1[i];
+                ++l;
+            }
+            wa2[j] = sum;
+        }
+        temp = __cminpack_enorm__(n, &wa2[1]);
+        sgnorm = gnorm / temp / temp;
+
+/*     test whether the scaled gradient direction is acceptable. */
+
+        alpha = 0.;
+        if (sgnorm < delta) {
+
+/*     the scaled gradient direction is not acceptable. */
+/*     finally, calculate the point along the dogleg */
+/*     at which the quadratic is minimized. */
+
+            bnorm = __cminpack_enorm__(n, &qtb[1]);
+            temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta);
+            /* Computing 2nd power */
+            d1 = sgnorm / delta;
+            /* Computing 2nd power */
+            d2 = temp - delta / qnorm;
+            /* Computing 2nd power */
+            d3 = delta / qnorm;
+            /* Computing 2nd power */
+            d4 = sgnorm / delta;
+            temp = temp - delta / qnorm * (d1 * d1)
+                   + sqrt(d2 * d2
+                          + (1. - d3 * d3) * (1. - d4 * d4));
+            /* Computing 2nd power */
+            d1 = sgnorm / delta;
+            alpha = delta / qnorm * (1. - d1 * d1) / temp;
+        }
+    }
+
+/*     form appropriate convex combination of the gauss-newton */
+/*     direction and the scaled gradient direction. */
+
+    temp = (1. - alpha) * min(sgnorm,delta);
+    for (j = 1; j <= n; ++j) {
+	x[j] = temp * wa1[j] + alpha * x[j];
+    }
+
+/*     last card of subroutine dogleg. */
+
+} /* dogleg_ */
+
diff --git a/dogleg_.c b/dogleg_.c
new file mode 100644
index 0000000..860e144
--- /dev/null
+++ b/dogleg_.c
@@ -0,0 +1,253 @@
+/* dogleg.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+/* Table of constant values */
+
+__minpack_attr__
+void __minpack_func__(dogleg)(const int *n, const real *r__, const int *lr, 
+	const real *diag, const real *qtb, const real *delta, real *x, 
+	real *wa1, real *wa2)
+{
+    /* System generated locals */
+    int i__1, i__2;
+    real d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    int i__, j, k, l, jj, jp1;
+    real sum, temp, alpha, bnorm;
+    real gnorm, qnorm, epsmch;
+    real sgnorm;
+    const int c__1 = 1;
+
+/*     ********** */
+
+/*     subroutine dogleg */
+
+/*     given an m by n matrix a, an n by n nonsingular diagonal */
+/*     matrix d, an m-vector b, and a positive number delta, the */
+/*     problem is to determine the convex combination x of the */
+/*     gauss-newton and scaled gradient directions that minimizes */
+/*     (a*x - b) in the least squares sense, subject to the */
+/*     restriction that the euclidean norm of d*x be at most delta. */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization of a. that is, if a = q*r, where q has */
+/*     orthogonal columns and r is an upper triangular matrix, */
+/*     then dogleg expects the full upper triangle of r and */
+/*     the first n components of (q transpose)*b. */
+
+/*     the subroutine statement is */
+
+/*       subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an input array of length lr which must contain the upper */
+/*         triangular matrix r stored by rows. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       delta is a positive input variable which specifies an upper */
+/*         bound on the euclidean norm of d*x. */
+
+/*       x is an output array of length n which contains the desired */
+/*         convex combination of the gauss-newton direction and the */
+/*         scaled gradient direction. */
+
+/*       wa1 and wa2 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa2;
+    --wa1;
+    --x;
+    --qtb;
+    --diag;
+    --r__;
+    (void)lr;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+/*     first, calculate the gauss-newton direction. */
+
+    jj = *n * (*n + 1) / 2 + 1;
+    i__1 = *n;
+    for (k = 1; k <= i__1; ++k) {
+	j = *n - k + 1;
+	jp1 = j + 1;
+	jj -= k;
+	l = jj + 1;
+	sum = 0.;
+	if (*n < jp1) {
+	    goto L20;
+	}
+	i__2 = *n;
+	for (i__ = jp1; i__ <= i__2; ++i__) {
+	    sum += r__[l] * x[i__];
+	    ++l;
+/* L10: */
+	}
+L20:
+	temp = r__[jj];
+	if (temp != 0.) {
+	    goto L40;
+	}
+	l = j;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+/* Computing MAX */
+	    d__2 = temp, d__3 = fabs(r__[l]);
+	    temp = max(d__2,d__3);
+	    l = l + *n - i__;
+/* L30: */
+	}
+	temp = epsmch * temp;
+	if (temp == 0.) {
+	    temp = epsmch;
+	}
+L40:
+	x[j] = (qtb[j] - sum) / temp;
+/* L50: */
+    }
+
+/*     test whether the gauss-newton direction is acceptable. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = 0.;
+	wa2[j] = diag[j] * x[j];
+/* L60: */
+    }
+    qnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    if (qnorm <= *delta) {
+	/* goto L140; */
+        return;
+    }
+
+/*     the gauss-newton direction is not acceptable. */
+/*     next, calculate the scaled gradient direction. */
+
+    l = 1;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	temp = qtb[j];
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    wa1[i__] += r__[l] * temp;
+	    ++l;
+/* L70: */
+	}
+	wa1[j] /= diag[j];
+/* L80: */
+    }
+
+/*     calculate the norm of the scaled gradient and test for */
+/*     the special case in which the scaled gradient is zero. */
+
+    gnorm = __minpack_func__(enorm)(n, &wa1[1]);
+    sgnorm = 0.;
+    alpha = *delta / qnorm;
+    if (gnorm == 0.) {
+	goto L120;
+    }
+
+/*     calculate the point along the scaled gradient */
+/*     at which the quadratic is minimized. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = wa1[j] / gnorm / diag[j];
+/* L90: */
+    }
+    l = 1;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += r__[l] * wa1[i__];
+	    ++l;
+/* L100: */
+	}
+	wa2[j] = sum;
+/* L110: */
+    }
+    temp = __minpack_func__(enorm)(n, &wa2[1]);
+    sgnorm = gnorm / temp / temp;
+
+/*     test whether the scaled gradient direction is acceptable. */
+
+    alpha = 0.;
+    if (sgnorm >= *delta) {
+	goto L120;
+    }
+
+/*     the scaled gradient direction is not acceptable. */
+/*     finally, calculate the point along the dogleg */
+/*     at which the quadratic is minimized. */
+
+    bnorm = __minpack_func__(enorm)(n, &qtb[1]);
+    temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / *delta);
+/* Computing 2nd power */
+    d__1 = sgnorm / *delta;
+/* Computing 2nd power */
+    d__2 = temp - *delta / qnorm;
+/* Computing 2nd power */
+    d__3 = *delta / qnorm;
+/* Computing 2nd power */
+    d__4 = sgnorm / *delta;
+    temp = temp - *delta / qnorm * (d__1 * d__1) + sqrt(d__2 * d__2 + (1. - 
+	    d__3 * d__3) * (1. - d__4 * d__4));
+/* Computing 2nd power */
+    d__1 = sgnorm / *delta;
+    alpha = *delta / qnorm * (1. - d__1 * d__1) / temp;
+L120:
+
+/*     form appropriate convex combination of the gauss-newton */
+/*     direction and the scaled gradient direction. */
+
+    temp = (1. - alpha) * min(sgnorm,*delta);
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = temp * wa1[j] + alpha * x[j];
+/* L130: */
+    }
+/* L140: */
+    return;
+
+/*     last card of subroutine dogleg. */
+
+} /* dogleg_ */
+
diff --git a/dpmpar.c b/dpmpar.c
new file mode 100644
index 0000000..81c6fcd
--- /dev/null
+++ b/dpmpar.c
@@ -0,0 +1,201 @@
+#include "cminpack.h"
+#include <float.h>
+#include "cminpackP.h"
+
+#define double_EPSILON DBL_EPSILON
+#define double_MIN DBL_MIN
+#define double_MAX DBL_MAX
+#define float_EPSILON FLT_EPSILON
+#define float_MIN FLT_MIN
+#define float_MAX FLT_MAX
+#define half_EPSILON HALF_EPSILON
+#define half_MIN HALF_NRM_MIN
+#define half_MAX HALF_MAX
+
+#define DPMPAR(type,X) _DPMPAR(type,X)
+#define _DPMPAR(type,X) type ## _ ## X
+
+__cminpack_attr__
+real __cminpack_func__(dpmpar)(int i)
+{
+/*     ********** */
+
+/*     Function dpmpar */
+
+/*     This function provides double precision machine parameters */
+/*     when the appropriate set of data statements is activated (by */
+/*     removing the c from column 1) and all other data statements are */
+/*     rendered inactive. Most of the parameter values were obtained */
+/*     from the corresponding Bell Laboratories Port Library function. */
+
+/*     The function statement is */
+
+/*       double precision function dpmpar(i) */
+
+/*     where */
+
+/*       i is an integer input variable set to 1, 2, or 3 which */
+/*         selects the desired machine parameter. If the machine has */
+/*         t base b digits and its smallest and largest exponents are */
+/*         emin and emax, respectively, then these parameters are */
+
+/*         dpmpar(1) = b**(1 - t), the machine precision, */
+
+/*         dpmpar(2) = b**(emin - 1), the smallest magnitude, */
+
+/*         dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. */
+
+/*     Argonne National Laboratory. MINPACK Project. November 1996. */
+/*     Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' */
+
+/*     ********** */
+
+/*     Machine constants for the IBM 360/370 series, */
+/*     the Amdahl 470/V6, the ICL 2900, the Itel AS/6, */
+/*     the Xerox Sigma 5/7/9 and the Sel systems 85/86. */
+
+/*     data mcheps(1),mcheps(2) / z34100000, z00000000 / */
+/*     data minmag(1),minmag(2) / z00100000, z00000000 / */
+/*     data maxmag(1),maxmag(2) / z7fffffff, zffffffff / */
+
+/*     Machine constants for the Honeywell 600/6000 series. */
+
+/*     data mcheps(1),mcheps(2) / o606400000000, o000000000000 / */
+/*     data minmag(1),minmag(2) / o402400000000, o000000000000 / */
+/*     data maxmag(1),maxmag(2) / o376777777777, o777777777777 / */
+
+/*     Machine constants for the CDC 6000/7000 series. */
+
+/*     data mcheps(1) / 15614000000000000000b / */
+/*     data mcheps(2) / 15010000000000000000b / */
+
+/*     data minmag(1) / 00604000000000000000b / */
+/*     data minmag(2) / 00000000000000000000b / */
+
+/*     data maxmag(1) / 37767777777777777777b / */
+/*     data maxmag(2) / 37167777777777777777b / */
+
+/*     Machine constants for the PDP-10 (KA processor). */
+
+/*     data mcheps(1),mcheps(2) / "114400000000, "000000000000 / */
+/*     data minmag(1),minmag(2) / "033400000000, "000000000000 / */
+/*     data maxmag(1),maxmag(2) / "377777777777, "344777777777 / */
+
+/*     Machine constants for the PDP-10 (KI processor). */
+
+/*     data mcheps(1),mcheps(2) / "104400000000, "000000000000 / */
+/*     data minmag(1),minmag(2) / "000400000000, "000000000000 / */
+/*     data maxmag(1),maxmag(2) / "377777777777, "377777777777 / */
+
+/*     Machine constants for the PDP-11. */
+
+/*     data mcheps(1),mcheps(2) /   9472,      0 / */
+/*     data mcheps(3),mcheps(4) /      0,      0 / */
+
+/*     data minmag(1),minmag(2) /    128,      0 / */
+/*     data minmag(3),minmag(4) /      0,      0 / */
+
+/*     data maxmag(1),maxmag(2) /  32767,     -1 / */
+/*     data maxmag(3),maxmag(4) /     -1,     -1 / */
+
+/*     Machine constants for the Burroughs 6700/7700 systems. */
+
+/*     data mcheps(1) / o1451000000000000 / */
+/*     data mcheps(2) / o0000000000000000 / */
+
+/*     data minmag(1) / o1771000000000000 / */
+/*     data minmag(2) / o7770000000000000 / */
+
+/*     data maxmag(1) / o0777777777777777 / */
+/*     data maxmag(2) / o7777777777777777 / */
+
+/*     Machine constants for the Burroughs 5700 system. */
+
+/*     data mcheps(1) / o1451000000000000 / */
+/*     data mcheps(2) / o0000000000000000 / */
+
+/*     data minmag(1) / o1771000000000000 / */
+/*     data minmag(2) / o0000000000000000 / */
+
+/*     data maxmag(1) / o0777777777777777 / */
+/*     data maxmag(2) / o0007777777777777 / */
+
+/*     Machine constants for the Burroughs 1700 system. */
+
+/*     data mcheps(1) / zcc6800000 / */
+/*     data mcheps(2) / z000000000 / */
+
+/*     data minmag(1) / zc00800000 / */
+/*     data minmag(2) / z000000000 / */
+
+/*     data maxmag(1) / zdffffffff / */
+/*     data maxmag(2) / zfffffffff / */
+
+/*     Machine constants for the Univac 1100 series. */
+
+/*     data mcheps(1),mcheps(2) / o170640000000, o000000000000 / */
+/*     data minmag(1),minmag(2) / o000040000000, o000000000000 / */
+/*     data maxmag(1),maxmag(2) / o377777777777, o777777777777 / */
+
+/*     Machine constants for the Data General Eclipse S/200. */
+
+/*     Note - it may be appropriate to include the following card - */
+/*     static dmach(3) */
+
+/*     data minmag/20k,3*0/,maxmag/77777k,3*177777k/ */
+/*     data mcheps/32020k,3*0/ */
+
+/*     Machine constants for the Harris 220. */
+
+/*     data mcheps(1),mcheps(2) / '20000000, '00000334 / */
+/*     data minmag(1),minmag(2) / '20000000, '00000201 / */
+/*     data maxmag(1),maxmag(2) / '37777777, '37777577 / */
+
+/*     Machine constants for the Cray-1. */
+
+/*     data mcheps(1) / 0376424000000000000000b / */
+/*     data mcheps(2) / 0000000000000000000000b / */
+
+/*     data minmag(1) / 0200034000000000000000b / */
+/*     data minmag(2) / 0000000000000000000000b / */
+
+/*     data maxmag(1) / 0577777777777777777777b / */
+/*     data maxmag(2) / 0000007777777777777776b / */
+
+/*     Machine constants for the Prime 400. */
+
+/*     data mcheps(1),mcheps(2) / :10000000000, :00000000123 / */
+/*     data minmag(1),minmag(2) / :10000000000, :00000100000 / */
+/*     data maxmag(1),maxmag(2) / :17777777777, :37777677776 / */
+
+/*     Machine constants for the VAX-11. */
+
+/*     data mcheps(1),mcheps(2) /   9472,  0 / */
+/*     data minmag(1),minmag(2) /    128,  0 / */
+/*     data maxmag(1),maxmag(2) / -32769, -1 / */
+
+/*     Machine constants for IEEE machines. */
+
+/*    data dmach(1) /2.22044604926d-16/ */
+/*    data dmach(2) /2.22507385852d-308/ */
+/*    data dmach(3) /1.79769313485d+308/ */
+
+    switch(i) {
+        case 1:
+            return DPMPAR(real,EPSILON); /* 2.2204460492503131e-16 | 1.19209290e-07F */
+        case 2:
+            return DPMPAR(real,MIN);    /* 2.2250738585072014e-308 | 1.17549435e-38F */
+        default:
+            return DPMPAR(real,MAX);    /* 1.7976931348623157e+308 | 3.40282347e+38F */
+    }
+
+/*     Last card of function dpmpar. */
+
+} /* dpmpar_ */
+
+#undef mcheps
+#undef maxmag
+#undef minmag
+#undef dmach
+
+
diff --git a/dpmpar_.c b/dpmpar_.c
new file mode 100644
index 0000000..8e44d79
--- /dev/null
+++ b/dpmpar_.c
@@ -0,0 +1,207 @@
+/* dpmpar.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <float.h>
+#define real __minpack_real__
+
+#define double_EPSILON DBL_EPSILON
+#define double_MIN DBL_MIN
+#define double_MAX DBL_MAX
+#define float_EPSILON FLT_EPSILON
+#define float_MIN FLT_MIN
+#define float_MAX FLT_MAX
+#define half_EPSILON HALF_EPSILON
+#define half_MIN HALF_NRM_MIN
+#define half_MAX HALF_MAX
+
+#define DPMPAR(type,X) _DPMPAR(type,X)
+#define _DPMPAR(type,X) type ## _ ## X
+
+__minpack_attr__
+real __minpack_func__(dpmpar)(const int *i)
+{
+/*     ********** */
+
+/*     Function dpmpar */
+
+/*     This function provides double precision machine parameters */
+/*     when the appropriate set of data statements is activated (by */
+/*     removing the c from column 1) and all other data statements are */
+/*     rendered inactive. Most of the parameter values were obtained */
+/*     from the corresponding Bell Laboratories Port Library function. */
+
+/*     The function statement is */
+
+/*       double precision function dpmpar(i) */
+
+/*     where */
+
+/*       i is an integer input variable set to 1, 2, or 3 which */
+/*         selects the desired machine parameter. If the machine has */
+/*         t base b digits and its smallest and largest exponents are */
+/*         emin and emax, respectively, then these parameters are */
+
+/*         dpmpar(1) = b**(1 - t), the machine precision, */
+
+/*         dpmpar(2) = b**(emin - 1), the smallest magnitude, */
+
+/*         dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. */
+
+/*     Argonne National Laboratory. MINPACK Project. November 1996. */
+/*     Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' */
+
+/*     ********** */
+
+/*     Machine constants for the IBM 360/370 series, */
+/*     the Amdahl 470/V6, the ICL 2900, the Itel AS/6, */
+/*     the Xerox Sigma 5/7/9 and the Sel systems 85/86. */
+
+/*     data mcheps(1),mcheps(2) / z34100000, z00000000 / */
+/*     data minmag(1),minmag(2) / z00100000, z00000000 / */
+/*     data maxmag(1),maxmag(2) / z7fffffff, zffffffff / */
+
+/*     Machine constants for the Honeywell 600/6000 series. */
+
+/*     data mcheps(1),mcheps(2) / o606400000000, o000000000000 / */
+/*     data minmag(1),minmag(2) / o402400000000, o000000000000 / */
+/*     data maxmag(1),maxmag(2) / o376777777777, o777777777777 / */
+
+/*     Machine constants for the CDC 6000/7000 series. */
+
+/*     data mcheps(1) / 15614000000000000000b / */
+/*     data mcheps(2) / 15010000000000000000b / */
+
+/*     data minmag(1) / 00604000000000000000b / */
+/*     data minmag(2) / 00000000000000000000b / */
+
+/*     data maxmag(1) / 37767777777777777777b / */
+/*     data maxmag(2) / 37167777777777777777b / */
+
+/*     Machine constants for the PDP-10 (KA processor). */
+
+/*     data mcheps(1),mcheps(2) / "114400000000, "000000000000 / */
+/*     data minmag(1),minmag(2) / "033400000000, "000000000000 / */
+/*     data maxmag(1),maxmag(2) / "377777777777, "344777777777 / */
+
+/*     Machine constants for the PDP-10 (KI processor). */
+
+/*     data mcheps(1),mcheps(2) / "104400000000, "000000000000 / */
+/*     data minmag(1),minmag(2) / "000400000000, "000000000000 / */
+/*     data maxmag(1),maxmag(2) / "377777777777, "377777777777 / */
+
+/*     Machine constants for the PDP-11. */
+
+/*     data mcheps(1),mcheps(2) /   9472,      0 / */
+/*     data mcheps(3),mcheps(4) /      0,      0 / */
+
+/*     data minmag(1),minmag(2) /    128,      0 / */
+/*     data minmag(3),minmag(4) /      0,      0 / */
+
+/*     data maxmag(1),maxmag(2) /  32767,     -1 / */
+/*     data maxmag(3),maxmag(4) /     -1,     -1 / */
+
+/*     Machine constants for the Burroughs 6700/7700 systems. */
+
+/*     data mcheps(1) / o1451000000000000 / */
+/*     data mcheps(2) / o0000000000000000 / */
+
+/*     data minmag(1) / o1771000000000000 / */
+/*     data minmag(2) / o7770000000000000 / */
+
+/*     data maxmag(1) / o0777777777777777 / */
+/*     data maxmag(2) / o7777777777777777 / */
+
+/*     Machine constants for the Burroughs 5700 system. */
+
+/*     data mcheps(1) / o1451000000000000 / */
+/*     data mcheps(2) / o0000000000000000 / */
+
+/*     data minmag(1) / o1771000000000000 / */
+/*     data minmag(2) / o0000000000000000 / */
+
+/*     data maxmag(1) / o0777777777777777 / */
+/*     data maxmag(2) / o0007777777777777 / */
+
+/*     Machine constants for the Burroughs 1700 system. */
+
+/*     data mcheps(1) / zcc6800000 / */
+/*     data mcheps(2) / z000000000 / */
+
+/*     data minmag(1) / zc00800000 / */
+/*     data minmag(2) / z000000000 / */
+
+/*     data maxmag(1) / zdffffffff / */
+/*     data maxmag(2) / zfffffffff / */
+
+/*     Machine constants for the Univac 1100 series. */
+
+/*     data mcheps(1),mcheps(2) / o170640000000, o000000000000 / */
+/*     data minmag(1),minmag(2) / o000040000000, o000000000000 / */
+/*     data maxmag(1),maxmag(2) / o377777777777, o777777777777 / */
+
+/*     Machine constants for the Data General Eclipse S/200. */
+
+/*     Note - it may be appropriate to include the following card - */
+/*     static dmach(3) */
+
+/*     data minmag/20k,3*0/,maxmag/77777k,3*177777k/ */
+/*     data mcheps/32020k,3*0/ */
+
+/*     Machine constants for the Harris 220. */
+
+/*     data mcheps(1),mcheps(2) / '20000000, '00000334 / */
+/*     data minmag(1),minmag(2) / '20000000, '00000201 / */
+/*     data maxmag(1),maxmag(2) / '37777777, '37777577 / */
+
+/*     Machine constants for the Cray-1. */
+
+/*     data mcheps(1) / 0376424000000000000000b / */
+/*     data mcheps(2) / 0000000000000000000000b / */
+
+/*     data minmag(1) / 0200034000000000000000b / */
+/*     data minmag(2) / 0000000000000000000000b / */
+
+/*     data maxmag(1) / 0577777777777777777777b / */
+/*     data maxmag(2) / 0000007777777777777776b / */
+
+/*     Machine constants for the Prime 400. */
+
+/*     data mcheps(1),mcheps(2) / :10000000000, :00000000123 / */
+/*     data minmag(1),minmag(2) / :10000000000, :00000100000 / */
+/*     data maxmag(1),maxmag(2) / :17777777777, :37777677776 / */
+
+/*     Machine constants for the VAX-11. */
+
+/*     data mcheps(1),mcheps(2) /   9472,  0 / */
+/*     data minmag(1),minmag(2) /    128,  0 / */
+/*     data maxmag(1),maxmag(2) / -32769, -1 / */
+
+/*     Machine constants for IEEE machines. */
+
+/*    data dmach(1) /2.22044604926d-16/ */
+/*    data dmach(2) /2.22507385852d-308/ */
+/*    data dmach(3) /1.79769313485d+308/ */
+
+
+    switch(*i) {
+        case 1:
+            return DPMPAR(real,EPSILON); /* 2.2204460492503131e-16 | 1.19209290e-07F */
+        case 2:
+            return DPMPAR(real,MIN);    /* 2.2250738585072014e-308 | 1.17549435e-38F */
+        default:
+            return DPMPAR(real,MAX);    /* 1.7976931348623157e+308 | 3.40282347e+38F */
+    }
+
+/*     Last card of function dpmpar. */
+
+} /* dpmpar_ */
+
+#undef mcheps
+#undef maxmag
+#undef minmag
+#undef dmach
+
+
diff --git a/enorm.c b/enorm.c
new file mode 100644
index 0000000..ad10824
--- /dev/null
+++ b/enorm.c
@@ -0,0 +1,157 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+/*
+  About the values for rdwarf and rgiant.
+
+  The original values, both in signe-precision FORTRAN source code and in double-precision code were:
+#define rdwarf 3.834e-20
+#define rgiant 1.304e19
+  See for example:
+    http://www.netlib.org/slatec/src/denorm.f
+    http://www.netlib.org/slatec/src/enorm.f
+  However, rdwarf is smaller than sqrt(FLT_MIN) = 1.0842021724855044e-19, so that rdwarf**2 will
+  underflow. This contradicts the constraints expressed in the comments below.
+
+  We changed these constants to be sqrt(dpmpar(2))*0.9 and sqrt(dpmpar(3))*0.9, as proposed by the
+  implementation found in MPFIT http://cow.physics.wisc.edu/~craigm/idl/fitting.html
+*/
+
+#define double_dwarf (1.4916681462400413e-154*0.9)
+#define double_giant (1.3407807929942596e+154*0.9)
+#define float_dwarf (1.0842021724855044e-19f*0.9f)
+#define float_giant (1.8446743523953730e+19f*0.9f)
+#define half_dwarf (2.4414062505039999e-4f*0.9f)
+#define half_giant (255.93749236874225497222f*0.9f)
+
+#define dwarf(type) _dwarf(type)
+#define _dwarf(type) type ## _dwarf
+#define giant(type) _giant(type)
+#define _giant(type) type ## _giant
+
+#define rdwarf dwarf(real)
+#define rgiant giant(real)
+
+__cminpack_attr__
+real __cminpack_func__(enorm)(int n, const real *x)
+{
+#ifdef USE_CBLAS
+    return cblas_dnrm2(n, x, 1);
+#else /* !USE_CBLAS */
+    /* System generated locals */
+    real ret_val, d1;
+
+    /* Local variables */
+    int i;
+    real s1, s2, s3, xabs, x1max, x3max, agiant, floatn;
+
+/*     ********** */
+
+/*     function enorm */
+
+/*     given an n-vector x, this function calculates the */
+/*     euclidean norm of x. */
+
+/*     the euclidean norm is computed by accumulating the sum of */
+/*     squares in three different sums. the sums of squares for the */
+/*     small and large components are scaled so that no overflows */
+/*     occur. non-destructive underflows are permitted. underflows */
+/*     and overflows do not occur in the computation of the unscaled */
+/*     sum of squares for the intermediate components. */
+/*     the definitions of small, intermediate and large components */
+/*     depend on two constants, rdwarf and rgiant. the main */
+/*     restrictions on these constants are that rdwarf**2 not */
+/*     underflow and rgiant**2 not overflow. the constants */
+/*     given here are suitable for every known computer. */
+
+/*     the function statement is */
+
+/*       double precision function enorm(n,x) */
+
+/*     where */
+
+/*       n is a positive integer input variable. */
+
+/*       x is an input array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+    s1 = 0.;
+    s2 = 0.;
+    s3 = 0.;
+    x1max = 0.;
+    x3max = 0.;
+    floatn = (real) (n);
+    agiant = rgiant / floatn;
+    for (i = 0; i < n; ++i) {
+	xabs = fabs(x[i]);
+	if (xabs <= rdwarf || xabs >= agiant) {
+            if (xabs > rdwarf) {
+
+/*              sum for large components. */
+
+                if (xabs > x1max) {
+                    /* Computing 2nd power */
+                    d1 = x1max / xabs;
+                    s1 = 1. + s1 * (d1 * d1);
+                    x1max = xabs;
+                } else {
+                    /* Computing 2nd power */
+                    d1 = xabs / x1max;
+                    s1 += d1 * d1;
+                }
+            } else {
+
+/*              sum for small components. */
+
+                if (xabs > x3max) {
+                    /* Computing 2nd power */
+                    d1 = x3max / xabs;
+                    s3 = 1. + s3 * (d1 * d1);
+                    x3max = xabs;
+                } else {
+                    if (xabs != 0.) {
+                        /* Computing 2nd power */
+                        d1 = xabs / x3max;
+                        s3 += d1 * d1;
+                    }
+                }
+            }
+	} else {
+
+/*           sum for intermediate components. */
+
+            /* Computing 2nd power */
+            s2 += xabs * xabs;
+        }
+    }
+
+/*     calculation of norm. */
+
+    if (s1 != 0.) {
+        ret_val = x1max * sqrt(s1 + (s2 / x1max) / x1max);
+    } else {
+        if (s2 != 0.) {
+            if (s2 >= x3max) {
+                ret_val = sqrt(s2 * (1. + (x3max / s2) * (x3max * s3)));
+            } else {
+                ret_val = sqrt(x3max * ((s2 / x3max) + (x3max * s3)));
+            }
+        } else {
+            ret_val = x3max * sqrt(s3);
+        }
+    }
+    return ret_val;
+
+/*     last card of function enorm. */
+#endif /* !USE_CBLAS */
+} /* enorm_ */
+
diff --git a/enorm_.c b/enorm_.c
new file mode 100644
index 0000000..09202b7
--- /dev/null
+++ b/enorm_.c
@@ -0,0 +1,186 @@
+/* enorm.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+/*
+  About the values for rdwarf and rgiant.
+
+  The original values, both in single-precision FORTRAN source code and in double-precision code were:
+#define rdwarf 3.834e-20
+#define rgiant 1.304e19
+  See for example:
+    http://www.netlib.org/slatec/src/denorm.f
+    http://www.netlib.org/slatec/src/enorm.f
+  However, rdwarf is smaller than sqrt(FLT_MIN) = 1.0842021724855044e-19, so that rdwarf**2 will
+  underflow. This contradicts the constraints expressed in the comments below.
+
+  We changed these constants to be sqrt(TYPE_MIN)*0.9 and sqrt(TYPE_MAX)*0.9, as proposed by the
+  implementation found in MPFIT: http://cow.physics.wisc.edu/~craigm/idl/fitting.html
+*/
+
+#define double_dwarf (1.4916681462400413e-154*0.9)
+#define double_giant (1.3407807929942596e+154*0.9)
+#define float_dwarf (1.0842021724855044e-19f*0.9f)
+#define float_giant (1.8446743523953730e+19f*0.9f)
+#define half_dwarf (2.4414062505039999e-4f*0.9f)
+#define half_giant (255.93749236874225497222f*0.9f)
+
+#define dwarf(type) _dwarf(type)
+#define _dwarf(type) type ## _dwarf
+#define giant(type) _giant(type)
+#define _giant(type) type ## _giant
+
+#define rdwarf dwarf(real)
+#define rgiant giant(real)
+
+__minpack_attr__
+real __minpack_func__(enorm)(const int *n, const real *x)
+{
+    /* System generated locals */
+    int i__1;
+    real ret_val, d__1;
+
+    /* Local variables */
+    int i__;
+    real s1, s2, s3, xabs, x1max, x3max, agiant, floatn;
+
+/*     ********** */
+
+/*     function enorm */
+
+/*     given an n-vector x, this function calculates the */
+/*     euclidean norm of x. */
+
+/*     the euclidean norm is computed by accumulating the sum of */
+/*     squares in three different sums. the sums of squares for the */
+/*     small and large components are scaled so that no overflows */
+/*     occur. non-destructive underflows are permitted. underflows */
+/*     and overflows do not occur in the computation of the unscaled */
+/*     sum of squares for the intermediate components. */
+/*     the definitions of small, intermediate and large components */
+/*     depend on two constants, rdwarf and rgiant. the main */
+/*     restrictions on these constants are that rdwarf**2 not */
+/*     underflow and rgiant**2 not overflow. the constants */
+/*     given here are suitable for every known computer. */
+
+/*     the function statement is */
+
+/*       double precision function enorm(n,x) */
+
+/*     where */
+
+/*       n is a positive integer input variable. */
+
+/*       x is an input array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    s1 = 0.;
+    s2 = 0.;
+    s3 = 0.;
+    x1max = 0.;
+    x3max = 0.;
+    floatn = (real) (*n);
+    agiant = rgiant / floatn;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	xabs = fabs(x[i__]);
+	if (xabs > rdwarf && xabs < agiant) {
+	    goto L70;
+	}
+	if (xabs <= rdwarf) {
+	    goto L30;
+	}
+
+/*              sum for large components. */
+
+	if (xabs <= x1max) {
+	    goto L10;
+	}
+/* Computing 2nd power */
+	d__1 = x1max / xabs;
+	s1 = 1. + s1 * (d__1 * d__1);
+	x1max = xabs;
+	goto L20;
+L10:
+/* Computing 2nd power */
+	d__1 = xabs / x1max;
+	s1 += d__1 * d__1;
+L20:
+	goto L60;
+L30:
+
+/*              sum for small components. */
+
+	if (xabs <= x3max) {
+	    goto L40;
+	}
+/* Computing 2nd power */
+	d__1 = x3max / xabs;
+	s3 = 1. + s3 * (d__1 * d__1);
+	x3max = xabs;
+	goto L50;
+L40:
+	if (xabs != 0.) {
+/* Computing 2nd power */
+	    d__1 = xabs / x3max;
+	    s3 += d__1 * d__1;
+	}
+L50:
+L60:
+	goto L80;
+L70:
+
+/*           sum for intermediate components. */
+
+/* Computing 2nd power */
+	d__1 = xabs;
+	s2 += d__1 * d__1;
+L80:
+/* L90: */
+	;
+    }
+
+/*     calculation of norm. */
+
+    if (s1 == 0.) {
+	goto L100;
+    }
+    ret_val = x1max * sqrt(s1 + s2 / x1max / x1max);
+    goto L130;
+L100:
+    if (s2 == 0.) {
+	goto L110;
+    }
+    if (s2 >= x3max) {
+	ret_val = sqrt(s2 * (1. + x3max / s2 * (x3max * s3)));
+    }
+    if (s2 < x3max) {
+	ret_val = sqrt(x3max * (s2 / x3max + x3max * s3));
+    }
+    goto L120;
+L110:
+    ret_val = x3max * sqrt(s3);
+L120:
+L130:
+    return ret_val;
+
+/*     last card of function enorm. */
+
+} /* enorm_ */
+
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..d5cacd8
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,71 @@
+option (BUILD_EXAMPLES "Build the examples and tests." ON)
+option (BUILD_EXAMPLES_FORTRAN "Build the FORTRAN examples and tests." OFF)
+
+if (BUILD_EXAMPLES)
+  # Make sure the compiler can find include files from our cminpack library.
+  include_directories (${CMINPACK_SOURCE_DIR})
+
+  # Make sure the linker can find the cminpack library once it is built.
+  link_directories (${CMINPACK_BINARY_DIR})
+
+  set (FPGM tchkder thybrd thybrd1 thybrj thybrj1 tlmder tlmder1 tlmdif tlmdif1 tlmstr tlmstr1)
+  set (CPGM ${FPGM} tfdjac2)
+
+  # cmpfiles could be used by runtest.cmake... for now it's unused
+  add_executable (cmpfiles cmpfiles.c)
+
+  # inspired by http://www.netlib.org/clapack/clapack-3.2.1-CMAKE/TESTING/CMakeLists.txt
+  # except that here we have to compare the output to a reference
+  macro(add_minpack_test testname reference)
+    set(TEST_OUTPUT "${CMINPACK_BINARY_DIR}/examples/${testname}.out")
+    set(TEST_REFERENCE "${CMINPACK_SOURCE_DIR}/examples/ref/${reference}.ref")
+    get_target_property(TEST_LOC ${testname} LOCATION)
+    add_test(${testname} "${CMAKE_COMMAND}"
+      -DTEST=${TEST_LOC}
+      -DOUTPUT=${TEST_OUTPUT} 
+      -DREFERENCE=${TEST_REFERENCE} 
+      -DINTDIR=${CMAKE_CFG_INTDIR}
+      -P "${CMINPACK_SOURCE_DIR}/examples/runtest.cmake")
+  endmacro(add_minpack_test)
+
+  foreach (source ${CPGM})
+    add_executable (${source}_ ${source}_.c)
+    target_link_libraries (${source}_ cminpack)
+    if (OS_LINUX)
+      target_link_libraries (${source}_ m)
+    endif (OS_LINUX)
+    add_minpack_test(${source}_ ${source}c)
+    add_executable (${source}c ${source}c.c)
+    target_link_libraries (${source}c cminpack)
+    if (OS_LINUX)
+      target_link_libraries (${source}c m)
+    endif (OS_LINUX)
+    add_minpack_test(${source}c ${source}c)
+  endforeach(source)
+endif (BUILD_EXAMPLES)
+
+if (BUILD_EXAMPLES_FORTRAN)
+  enable_language (Fortran OPTIONAL)
+  if (CMAKE_Fortran_COMPILER_WORKS)
+    foreach (FPGM_item ${FPGM})
+      list (APPEND FPGM_SRCS ${CMINPACK_SOURCE_DIR}/examples/${FPGM_item}.f)
+    endforeach (FPGM_item ${FPGM})
+
+    # add the executable that will do the generation
+    add_executable (genf77tests genf77tests.c)
+    get_target_property (GENF77TESTS_EXE genf77tests LOCATION)
+    add_custom_command (
+      OUTPUT ${FPGM_SRCS}
+      COMMAND ${GENF77TESTS_EXE} ${CMINPACK_SOURCE_DIR}/doc/minpack-documentation.txt
+      WORKING_DIRECTORY ${CMINPACK_SOURCE_DIR}/examples
+      DEPENDS genf77tests
+      MAIN_DEPENDENCY ${CMINPACK_SOURCE_DIR}/doc/minpack-documentation.txt
+      )
+    foreach (source ${FPGM})
+      add_executable (${source} ${source}.f)
+      target_link_libraries (${source} cminpack)
+      add_minpack_test(${source} ${source})
+    endforeach (source)
+  endif (CMAKE_Fortran_COMPILER_WORKS)
+endif (BUILD_EXAMPLES_FORTRAN)
+
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..92d9ade
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,321 @@
+#!/usr/bin/make 
+
+# pick up your FORTRAN compiler
+#F77=g77
+F77=gfortran
+
+# uncomment the following for FORTRAN MINPACK
+#MINPACK=-lminpack
+#F77C=$(F77)
+#F77CFLAGS=-g
+
+# uncomment the following for C MINPACK
+MINPACK=../libcminpack$(LIBSUFFIX).a
+CC=gcc
+CFLAGS=-g -Wall
+CPPFLAGS=-I..
+
+FMINPACK=../fortran/libminpack.a
+
+# uncomment the following to debug using valgrind
+#VALGRIND=valgrind --tool=memcheck
+
+### The default configuration is to compile the double precision version
+
+### configuration for the LAPACK/BLAS (double precision) version:
+## make LIBSUFFIX= CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__"
+#LIBSUFFIX=s
+#CFLAGS="-O3 -g -Wall -Wextra -DUSE_CBLAS -DUSE_LAPACK"
+CFLAGS_L=$(CFLAGS) -DUSE_CBLAS -DUSE_LAPACK
+LDADD_L=-framework vecLib
+
+### configuration for the float (single precision) version:
+## make LIBSUFFIX=s CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__"
+#LIBSUFFIX=s
+#CFLAGS="-O3 -g -Wall -Wextra -D__cminpack_float__"
+CFLAGS_F=$(CFLAGS) -D__cminpack_float__
+
+### configuration for the half (half precision) version:
+## make LIBSUFFIX=h CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__" LDADD="-L/opt/local/lib -lHalf" CC=g++
+#LIBSUFFIX=h
+#CFLAGS="-O3 -g -Wall -Wextra -I/opt/local/include -D__cminpack_half__"
+#LDADD="-L/opt/local/lib -lHalf"
+#CC=g++
+CFLAGS_H=$(CFLAGS) -I/opt/local/include -D__cminpack_half__
+LDADD_H=-L/opt/local/lib -lHalf
+CC_H=$(CXX)
+
+FPGM=tchkder thybrd thybrd1 thybrj thybrj1 tlmder tlmder1 tlmdif \
+	tlmdif1 tlmstr tlmstr1 ibmdpdr
+PGM=tchkder_ thybrd_ thybrd1_ thybrj_ thybrj1_ tlmder_ tlmder1_ tlmdif_ \
+	tlmdif1_ tlmstr_ tlmstr1_ tfdjac2_ ibmdpdr_
+CPGM=tchkderc thybrdc thybrd1c thybrjc thybrj1c tlmderc tlmder1c tlmdifc \
+	tlmdif1c tlmstrc tlmstr1c tfdjac2c ibmdpdrc \
+	tchkderc_box tlmderc_box thybrjc_box
+FDRVPGM=lmddrv_ lmfdrv_ lmsdrv_ hyjdrv_ hybdrv_ chkdrv_
+DRVPGM=lmddrv lmfdrv lmsdrv hyjdrv hybdrv chkdrv
+CDRVPGM=lmddrvc lmfdrvc lmsdrvc hyjdrvc hybdrvc chkdrvc
+FSRCGEN=tchkder.f thybrd.f thybrd1.f thybrj.f thybrj1.f tlmder.f tlmder1.f \
+	tlmdif.f tlmdif1.f tlmstr.f tlmstr1.f
+FSRC=$(FSRCGEN) \
+	lmddrv.f lmdipt.f ssqfcn.f ssqjac.f lmfdrv.f lmsdrv.f \
+	hyjdrv.f hybipt.f vecfcn.f vecjac.f hybdrv.f \
+	errjac.f chkdrv.f ibmdpdr.f machar.f
+SRC=tchkder_.c thybrd_.c thybrd1_.c thybrj_.c thybrj1_.c tlmder_.c tlmder1_.c \
+	tlmdif_.c tlmdif1_.c tlmstr_.c tlmstr1_.c tfdjac2_.c \
+	lmddrv_.c lmfdrv_.c lmsdrv_.c \
+	hyjdrv_.c hybdrv_.c \
+	chkdrv_.c ibmdpdr_.c
+CSRC=tchkderc.c thybrdc.c thybrd1c.c thybrjc.c thybrj1c.c tlmderc.c tlmder1c.c \
+	tlmdifc.c tlmdif1c.c tlmstrc.c tlmstr1c.c tfdjac2c.c \
+	lmddrv.c lmdipt.c ssqfcn.c ssqjac.c lmfdrv.c lmsdrv.c \
+	hyjdrv.c hybipt.c vecfcn.c vecjac.c hybdrv.c \
+	errjac.c chkdrv.c ibmdpdr.c machar.c
+
+CDRVSRC=lmddrv.c lmfdrv.c lmsdrv.c hyjdrv.c hybdrv.c
+REF=test.ref ctest.ref ftest.ref
+
+all:
+	@echo "*****************************************************"
+	@echo "Please type 'make check' to run all tests at once, or:"
+	@echo "*****************************************************"
+	@echo "make test: calling FORTRAN CMINPACK from C"
+	@echo "make test MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from C"
+	@echo "make ctest: calling CMINPACK from C"
+	@echo "make ftest: calling FORTRAN CMINPACK from FORTRAN"
+	@echo "make ftest MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from FORTRAN"
+	@echo "Intensive (driver) tests:"
+	@echo "make testdrv: calling FORTRAN CMINPACK from C"
+	@echo "make testdrv MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from C"
+	@echo "make ctestdrv: calling CMINPACK from C"
+	@echo "make ftestdrv: calling FORTRAN CMINPACK from FORTRAN"
+	@echo "make ftestdrv MINPACK=../fortran/libminpack.a: calling FORTRAN MINPACK from FORTRAN"
+
+.PHONY: test ctest ctestdrv ctestlmdrv ctesthydrv ctestchkdrv ftest ftestdrv ftestlmdrv ftesthydrv ftestchkdrv check checkdoublec checkdouble checkfloatc checkfloat checkhalf checkfail
+test: $(MINPACK) $(PGM)
+	@echo "*** Running standard tests (calling MINPACK from C using $(MINPACK))"
+	for x in $(PGM); do echo $$x; $(VALGRIND) ./$$x > $$x.out; diff -u ref/$(LIBSUFFIX)`echo $$x.ref|sed -e s/_.ref/c.ref/` $$x.out ; done
+
+testdrv: $(MINPACK) $(FDRVPGM) testlmdrv testhydrv testchkdrv
+
+testlmdrv: lmddrv_ lmfdrv_ lmsdrv_
+	@echo "*** Running LM tests (calling MINPACK from C using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/lm.data > $$x.out; diff -u ref/$(LIBSUFFIX)`echo $$x |sed -e s/_/c/`.ref $$x.out ; done
+
+testhydrv: hyjdrv_ hybdrv_
+	@echo "*** Running HY tests (calling MINPACK from C using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/hybrd.data > $$x.out; diff -u ref/$(LIBSUFFIX)`echo $$x |sed -e s/_/c/`.ref $$x.out ; done
+
+testchkdrv:chkdrv_
+	@echo "*** Running CHK tests (calling MINPACK from C using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/chkder.data > $$x.out; diff -u ref/$(LIBSUFFIX)`echo $$x |sed -e s/_/c/`.ref $$x.out ; done
+
+ctest: $(MINPACK) $(CPGM)
+	@echo "*** Running standard tests (calling CMINPACK from C using $(MINPACK))"
+	for x in $(CPGM); do echo $$x; $(VALGRIND) ./$$x > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ctestdrv: $(MINPACK) $(CDRVPGM) ctestlmdrv ctesthydrv ctestchkdrv
+
+ctestlmdrv: lmddrvc lmfdrvc lmsdrvc
+	@echo "*** Running LM tests (calling CMINPACK from C using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/lm.data > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ctesthydrv: hyjdrvc hybdrvc
+	@echo "*** Running HY tests (calling CMINPACK from C using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/hybrd.data > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ctestchkdrv:chkdrvc
+	@echo "*** Running CHK tests (calling CMINPACK from C using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/chkder.data > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ftest: $(MINPACK) $(FPGM)
+	@echo "*** Running standard tests (calling MINPACK from FORTRAN using $(MINPACK))"
+	for x in ${FPGM}; do echo $$x; $(VALGRIND) ./$$x > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ftestdrv: $(MINPACK) $(DRVPGM) ftestlmdrv ftesthydrv ftestchkdrv
+
+ftestlmdrv: lmddrv lmfdrv lmsdrv
+	@echo "*** Running LM tests (calling MINPACK from FORTRAN using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/lm.data > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ftesthydrv: hyjdrv hybdrv
+	@echo "*** Running HY tests (calling MINPACK from FORTRAN using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/hybrd.data > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+ftestchkdrv: chkdrv
+	@echo "*** Running CHK tests (calling MINPACK from FORTRAN using $(MINPACK))"
+	for x in $^; do echo $$x; $(VALGRIND) ./$$x < testdata/chkder.data > $$x.out; diff -u ref/$(LIBSUFFIX)$$x.ref $$x.out ; done
+
+check: checkdouble checkfloat
+
+checkdoublec:
+	$(MAKE) -C .. double 2>&1 > /dev/null
+	$(MAKE) clean $(CPGM) LIBSUFFIX= 2>&1 > /dev/null
+	-$(MAKE) ctest LIBSUFFIX=
+	$(MAKE) clean 2>&1 > /dev/null
+
+checkdouble: checkdoublec ../fortran/libminpack.a
+	$(MAKE) clean $(PGM) LIBSUFFIX= 2>&1 > /dev/null
+	-$(MAKE) test LIBSUFFIX=
+	$(MAKE) clean $(PGM) LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null
+	-$(MAKE) test LIBSUFFIX= MINPACK=../fortran/libminpack.a
+	$(MAKE) clean $(FPGM) LIBSUFFIX= 2>&1 > /dev/null
+	-$(MAKE) ftest LIBSUFFIX=
+	$(MAKE) clean $(FPGM) LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null
+	-$(MAKE) ftest LIBSUFFIX= MINPACK=../fortran/libminpack.a
+	$(MAKE) clean $(FDRVPGM) LIBSUFFIX= 2>&1 > /dev/null
+	-$(MAKE) -k testdrv LIBSUFFIX=
+	$(MAKE) clean $(CDRVPGM) LIBSUFFIX= 2>&1 > /dev/null
+	-$(MAKE) -k ctestdrv LIBSUFFIX=
+	$(MAKE) clean 2>&1 > /dev/null
+
+checkfloatc:
+	$(MAKE) -C .. float 2>&1 > /dev/null
+	$(MAKE) clean $(CPGM) LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 2>&1 > /dev/null
+	-$(MAKE) ctest LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 
+	$(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null
+
+checkfloat: checkfloatc
+	$(MAKE) clean $(PGM) LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 2>&1 > /dev/null
+	-$(MAKE) test LIBSUFFIX=s CFLAGS="$(CFLAGS_F)"
+	$(MAKE) clean $(FDRVPGM) LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 2>&1 > /dev/null
+	-$(MAKE) -k testdrv LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 
+	$(MAKE) clean $(CDRVPGM) LIBSUFFIX=s CFLAGS="$(CFLAGS_F)" 2>&1 > /dev/null
+	-$(MAKE) -k ctestdrv LIBSUFFIX=s CFLAGS="$(CFLAGS_F)"
+	$(MAKE) clean LIBSUFFIX=s 2>&1 > /dev/null
+
+checklapack:
+	$(MAKE) -C .. lapack 2>&1 > /dev/null
+	$(MAKE) clean $(CPGM) LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)" 2>&1 > /dev/null
+	-$(MAKE) ctest LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)"
+	$(MAKE) clean $(CDRVPGM) LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)" 2>&1 > /dev/null
+	-$(MAKE) -k ctestdrv LIBSUFFIX=l CFLAGS="$(CFLAGS_L)" LDADD="$(LDADD_L)"
+
+checkhalf:
+	$(MAKE) -C .. half 2>&1 > /dev/null
+	$(MAKE) clean $(PGM) LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" 2>&1 > /dev/null
+	-$(MAKE) test LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)"
+	$(MAKE) clean $(CPGM) LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" 2>&1 > /dev/null
+	-$(MAKE) ctest LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)"
+	$(MAKE) clean $(FDRVPGM) LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" 2>&1 > /dev/null
+	-$(MAKE) -k testdrv LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)"
+	$(MAKE) clean $(CDRVPGM) LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)" 2>&1 > /dev/null
+	-$(MAKE) -k ctestdrv LIBSUFFIX=h CFLAGS="$(CFLAGS_H)" LDADD="$(LDADD_H)" CC="$(CC_H)"
+#	$(MAKE) clean LIBSUFFIX=h 2>&1 > /dev/null
+#	$(MAKE) -C .. clean LIBSUFFIX=h 2>&1 > /dev/null
+
+checkfail: ../fortran/libminpack.a check
+	$(MAKE) clean $(FDRVPGM) LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null
+	-$(MAKE) -k testdrv LIBSUFFIX= MINPACK=../fortran/libminpack.a
+	$(MAKE) clean $(DRVPGM) LIBSUFFIX= 2>&1 > /dev/null
+	-$(MAKE) -k ftestdrv LIBSUFFIX=
+	$(MAKE) clean $(DRVPGM) LIBSUFFIX= MINPACK=../fortran/libminpack.a 2>&1 > /dev/null
+	-$(MAKE) -k ftestdrv LIBSUFFIX= MINPACK=../fortran/libminpack.a
+	$(MAKE) clean LIBSUFFIX= 2>&1 > /dev/null
+
+../libcminpack$(LIBSUFFIX).a:
+	$(MAKE) -C ..
+
+../fortran/libminpack.a:
+	$(MAKE) -C ../fortran
+
+clean:
+	-rm -f $(PGM) $(FDRVPGM) $(DRVPGM) $(CPGM) $(CDRVPGM) $(SRC:.c=.o) $(CSRC:.c=.o) $(FPGM) $(FSRCGEN) $(FSRC:.f=.o) $(PGM:=.out) $(CPGM:=.out) $(FDRVPGM:=.out) $(DRVPGM:=.out) $(CDRVPGM:=.out) $(FPGM:=.out) *~ #*#
+	-rm -rf $(PGM:=.dSYM) $(CPGM:=.dSYM) $(CDRVPGM:=.dSYM) $(FPGM:=.dSYM)
+
+${FSRCGEN}: ../doc/minpack-documentation.txt
+	cat $< | awk  '					\
+	/DRIVER FOR [A-Z1]+ EXAMPLE/{				\
+	    pgm=tolower($$4);					\
+	    oname="t" pgm ".f";					\
+	    $$0 = substr($$0,3);				\
+	    print >oname;					\
+	    do {						\
+		getline; $$0 = substr($$0,3);			\
+		if (!/^ +Page$$/) print >>oname;		\
+	    }							\
+	    while (!/LAST CARD OF SUBROUTINE FCN/);		\
+	    getline; $$0 = substr($$0,3); print >>oname;	\
+	    getline; $$0 = substr($$0,3); print >>oname;	\
+	}'
+
+.f: $(MINPACK)
+	$(F77) -o $@ $< $(MINPACK)
+
+.c:
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(MINPACK) $(LDADD) -lm
+
+tchkderc_box: tchkderc.c
+	$(CC) $(CPPFLAGS) -DBOX_CONSTRAINTS $(CFLAGS) -o $@ $< $(MINPACK) $(LDADD) -lm
+
+tlmderc_box: tlmderc.c
+	$(CC) $(CPPFLAGS) -DBOX_CONSTRAINTS $(CFLAGS) -o $@ $< $(MINPACK) $(LDADD) -lm
+
+thybrjc_box: thybrjc.c
+	$(CC) $(CPPFLAGS) -DBOX_CONSTRAINTS $(CFLAGS) -o $@ $< $(MINPACK) $(LDADD) -lm
+
+.c.o:
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+lmddrv_: $(MINPACK) lmddrv_.o lmdipt.o ssqfcn.o ssqjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+lmfdrv_: $(MINPACK) lmfdrv_.o lmdipt.o ssqfcn.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+lmsdrv_: $(MINPACK) lmsdrv_.o lmdipt.o ssqfcn.o ssqjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+hyjdrv_: $(MINPACK) hyjdrv_.o hybipt.o vecfcn.o vecjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+hybdrv_: $(MINPACK) hybdrv_.o hybipt.o vecfcn.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+chkdrv_: $(MINPACK) chkdrv_.o hybipt.o vecfcn.o errjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+ibmdpdr_: $(MINPACK) ibmdpdr_.o machar.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+lmddrvc: $(MINPACK) lmddrv.o lmdipt.o ssqfcn.o ssqjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+lmfdrvc: $(MINPACK) lmfdrv.o lmdipt.o ssqfcn.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+lmsdrvc: $(MINPACK) lmsdrv.o lmdipt.o ssqfcn.o ssqjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+hyjdrvc: $(MINPACK) hyjdrv.o hybipt.o vecfcn.o vecjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+hybdrvc: $(MINPACK) hybdrv.o hybipt.o vecfcn.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+chkdrvc: $(MINPACK) chkdrv.o hybipt.o vecfcn.o errjac.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+ibmdpdrc: $(MINPACK) ibmdpdr.o machar.o
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(MINPACK) $(LDADD) -lm
+
+lmddrv: $(MINPACK) lmddrv.f lmdipt.f ssqfcn.f ssqjac.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
+
+lmfdrv: $(MINPACK) lmfdrv.f lmdipt.f ssqfcn.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
+
+lmsdrv: $(MINPACK) lmsdrv.f lmdipt.f ssqfcn.f ssqjac.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
+
+hyjdrv: $(MINPACK) hyjdrv.f hybipt.f vecfcn.f vecjac.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
+
+hybdrv: $(MINPACK) hybdrv.f hybipt.f vecfcn.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
+
+chkdrv: $(MINPACK) chkdrv.f hybipt.f vecfcn.f errjac.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
+
+ibmdpdr: $(MINPACK) ibmdpdr.f machar.f
+	$(F77) $(FFLAGS) -o $@ $^ $(MINPACK)
diff --git a/examples/chkdrv.c b/examples/chkdrv.c
new file mode 100644
index 0000000..2361938
--- /dev/null
+++ b/examples/chkdrv.c
@@ -0,0 +1,132 @@
+/* Usage: chkdrv < chkder.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+/*     ********** */
+
+/*     this program tests the ability of chkder to detect */
+/*     inconsistencies between functions and their first derivatives. */
+/*     fourteen test function vectors and jacobians are used. eleven of */
+/*     the tests are false(f), i.e. there are inconsistencies between */
+/*     the function vectors and the corresponding jacobians. three of */
+/*     the tests are true(t), i.e. there are no inconsistencies. the */
+/*     driver reads in data, calls chkder and prints out information */
+/*     required by and received from chkder. */
+
+/*     subprograms called */
+
+/*       minpack supplied ... chkder,errjac,initpt,vecfcn */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+    /* Initialized data */
+    const int a[14] = { 0,0,0,1,0,0,0,1,0,0,0,0,1,0 };
+    real cp = .123;
+    /* Local variables */
+    int i, n;
+    real x1[10], x2[10];
+    int na[14], np[14];
+    real err[10];
+    int lnp;
+    real fjac[10*10];
+    const int ldfjac = 10;
+    real diff[10];
+    real fvec1[10], fvec2[10];
+    int nprob;
+    real errmin[14], errmax[14];
+
+    for (;;) {
+        scanf("%5d%5d\n", &nprob, &n);
+        if (nprob <= 0) {
+            break;
+        }
+
+        hybipt(n,x1,nprob,1.);
+        for(i=0; i<n; ++i) {
+            x1[i] += cp;
+            cp = -cp;
+        }
+
+        printf("\n\n\n      problem%5d      with dimension%5d   is  %c\n\n", nprob, n, a[nprob-1]?'T':'F');
+
+        __cminpack_func__(chkder)(n,n,x1,NULL,NULL,ldfjac,x2,NULL,1,NULL);
+        vecfcn(n,x1,fvec1,nprob);
+        errjac(n,x1,fjac,ldfjac,nprob);
+        vecfcn(n,x2,fvec2,nprob);
+        __cminpack_func__(chkder)(n,n,x1,fvec1,fjac,ldfjac,NULL,fvec2,2,err);
+
+        errmin[nprob-1] = err[0];
+        errmax[nprob-1] = err[0];
+        for(i=0; i<n; ++i) {
+            diff[i] = fvec2[i] - fvec1[i];
+            if (errmin[nprob-1] > err[i])
+                errmin[nprob-1] = err[i];
+            if (errmax[nprob-1] < err[i])
+                errmax[nprob-1] = err[i];
+        }
+
+        np[nprob-1] = nprob;
+        lnp = nprob;
+        na[nprob-1] = n;
+
+        printf("\n      first function vector   \n\n");
+        printvec(n, fvec1);
+        printf("\n\n      function difference vector\n\n");
+        printvec(n, diff);
+        printf("\n\n      error vector\n\n");
+        printvec(n, err);
+    }
+
+    printf("\f summary of %3d tests of chkder\n", lnp);
+    printf("\n nprob   n    status     errmin         errmax\n\n");
+
+    for (i = 0; i < lnp; ++i) {
+        printf("%4d%6d      %c   %15.7e%15.7e\n",
+               np[i], na[i], a[i]?'T':'F', (double)errmin[i], (double)errmax[i]);
+    }
+    exit(0);
+}
diff --git a/examples/chkdrv.f b/examples/chkdrv.f
new file mode 100644
index 0000000..d50c582
--- /dev/null
+++ b/examples/chkdrv.f
@@ -0,0 +1,87 @@
+c     **********
+c
+c     this program tests the ability of chkder to detect
+c     inconsistencies between functions and their first derivatives.
+c     fourteen test function vectors and jacobians are used. eleven of
+c     the tests are false(f), i.e. there are inconsistencies between
+c     the function vectors and the corresponding jacobians. three of
+c     the tests are true(t), i.e. there are no inconsistencies. the
+c     driver reads in data, calls chkder and prints out information
+c     required by and received from chkder.
+c
+c     subprograms called
+c
+c       minpack supplied ... chkder,errjac,initpt,vecfcn
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ldfjac,lnp,mode,n,nprob,nread,nwrite
+      integer na(14),np(14)
+      logical a(14)
+      double precision cp,one
+      double precision diff(10),err(10),errmax(14),errmin(14),
+     *                 fjac(10,10),fvec1(10),fvec2(10),x1(10),x2(10)
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data a(1),a(2),a(3),a(4),a(5),a(6),a(7),a(8),a(9),a(10),a(11),
+     *     a(12),a(13),a(14)
+     *     /.false.,.false.,.false.,.true.,.false.,.false.,.false.,
+     *      .true.,.false.,.false.,.false.,.false.,.true.,.false./
+      data cp,one /1.23d-1,1.0d0/
+      ldfjac = 10
+   10 continue
+         read (nread,60) nprob,n
+         if (nprob .le. 0) go to 40
+         call initpt(n,x1,nprob,one)
+         do 20 i = 1, n
+            x1(i) = x1(i) + cp
+            cp = -cp
+   20       continue
+         write (nwrite,70) nprob,n,a(nprob)
+         mode = 1
+         call chkder(n,n,x1,fvec1,fjac,ldfjac,x2,fvec2,mode,err)
+         mode = 2
+         call vecfcn(n,x1,fvec1,nprob)
+         call errjac(n,x1,fjac,ldfjac,nprob)
+         call vecfcn(n,x2,fvec2,nprob)
+         call chkder(n,n,x1,fvec1,fjac,ldfjac,x2,fvec2,mode,err)
+         errmin(nprob) = err(1)
+         errmax(nprob) = err(1)
+         do 30 i = 1, n
+            diff(i) = fvec2(i) - fvec1(i)
+            if (errmin(nprob) .gt. err(i)) errmin(nprob) = err(i)
+            if (errmax(nprob) .lt. err(i)) errmax(nprob) = err(i)
+   30       continue
+         np(nprob) = nprob
+         lnp = nprob
+         na(nprob) = n
+         write (nwrite,80) (fvec1(i), i = 1, n)
+         write (nwrite,90) (diff(i), i = 1, n)
+         write (nwrite,100) (err(i), i = 1, n)
+         go to 10
+   40 continue
+      write (nwrite,110) lnp
+      write (nwrite,120)
+      do 50 i = 1, lnp
+         write (nwrite,130) np(i),na(i),a(i),errmin(i),errmax(i)
+   50    continue
+      stop
+   60 format (2i5)
+   70 format ( /// 5x, 8h problem, i5, 5x, 15h with dimension, i5, 2x,
+     *         5h is  , l1)
+   80 format ( // 5x, 25h first function vector    // (5x, 5d15.7))
+   90 format ( // 5x, 27h function difference vector // (5x, 5d15.7))
+  100 format ( // 5x, 13h error vector // (5x, 5d15.7))
+  110 format (12h1summary of , i3, 16h tests of chkder /)
+  120 format (46h nprob   n    status     errmin         errmax /)
+  130 format (i4, i6, 6x, l1, 3x, 2d15.7)
+c
+c     last card of derivative check test driver.
+c
+      end
diff --git a/examples/chkdrv_ b/examples/chkdrv_
new file mode 100755
index 0000000..71389b1
Binary files /dev/null and b/examples/chkdrv_ differ
diff --git a/examples/chkdrv_.c b/examples/chkdrv_.c
new file mode 100644
index 0000000..2bbd826
--- /dev/null
+++ b/examples/chkdrv_.c
@@ -0,0 +1,133 @@
+/* Usage: chkdrv < chkder.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "minpack.h"
+#include "vec.h"
+#define real __minpack_real__
+
+/*     ********** */
+
+/*     this program tests the ability of chkder to detect */
+/*     inconsistencies between functions and their first derivatives. */
+/*     fourteen test function vectors and jacobians are used. eleven of */
+/*     the tests are false(f), i.e. there are inconsistencies between */
+/*     the function vectors and the corresponding jacobians. three of */
+/*     the tests are true(t), i.e. there are no inconsistencies. the */
+/*     driver reads in data, calls chkder and prints out information */
+/*     required by and received from chkder. */
+
+/*     subprograms called */
+
+/*       minpack supplied ... chkder,errjac,initpt,vecfcn */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+    /* Initialized data */
+    const int a[14] = { 0,0,0,1,0,0,0,1,0,0,0,0,1,0 };
+    real cp = .123;
+    /* Local variables */
+    int i, n;
+    real x1[10], x2[10];
+    int na[14], np[14];
+    real err[10];
+    int lnp;
+    real fjac[10*10];
+    const int ldfjac = 10;
+    real diff[10];
+    real fvec1[10], fvec2[10];
+    int nprob;
+    real errmin[14], errmax[14];
+    const int i1 = 1, i2 = 2;
+
+    for (;;) {
+        scanf("%5d%5d\n", &nprob, &n);
+        if (nprob <= 0) {
+            break;
+        }
+
+        hybipt(n,x1,nprob,1.);
+        for(i=0; i<n; ++i) {
+            x1[i] += cp;
+            cp = -cp;
+        }
+
+        printf("\n\n\n      problem%5d      with dimension%5d   is  %c\n\n", nprob, n, a[nprob-1]?'T':'F');
+
+        __minpack_func__(chkder)(&n,&n,x1,NULL,NULL,&ldfjac,x2,NULL,&i1,NULL);
+        vecfcn(n,x1,fvec1,nprob);
+        errjac(n,x1,fjac,ldfjac,nprob);
+        vecfcn(n,x2,fvec2,nprob);
+        __minpack_func__(chkder)(&n,&n,x1,fvec1,fjac,&ldfjac,NULL,fvec2,&i2,err);
+
+        errmin[nprob-1] = err[0];
+        errmax[nprob-1] = err[0];
+        for(i=0; i<n; ++i) {
+            diff[i] = fvec2[i] - fvec1[i];
+            if (errmin[nprob-1] > err[i])
+                errmin[nprob-1] = err[i];
+            if (errmax[nprob-1] < err[i])
+                errmax[nprob-1] = err[i];
+        }
+
+        np[nprob-1] = nprob;
+        lnp = nprob;
+        na[nprob-1] = n;
+
+        printf("\n      first function vector   \n\n");
+        printvec(n, fvec1);
+        printf("\n\n      function difference vector\n\n");
+        printvec(n, diff);
+        printf("\n\n      error vector\n\n");
+        printvec(n, err);
+    }
+
+    printf("\f summary of %3d tests of chkder\n", lnp);
+    printf("\n nprob   n    status     errmin         errmax\n\n");
+
+    for (i = 0; i < lnp; ++i) {
+        printf("%4d%6d      %c   %15.7e%15.7e\n",
+               np[i], na[i], a[i]?'T':'F', (double)errmin[i], (double)errmax[i]);
+    }
+    exit(0);
+}
diff --git a/examples/cmpfiles.c b/examples/cmpfiles.c
new file mode 100644
index 0000000..b2159c2
--- /dev/null
+++ b/examples/cmpfiles.c
@@ -0,0 +1,55 @@
+/*
+  Compare two files line by line, output differences to stderr.
+  Exit status is 0 if files are the same, 1 if different.
+
+  Author: Frederic.Devernay at m4x.org
+*/
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+
+int main(int argc, char **argv)
+{
+    FILE *fp1, *fp2;
+    char buf1[1024], buf2[1024];
+    int differences = 0;
+    
+    if (argc != 3) {
+        fprintf(stderr,"Usage: %s filename1 filename2\n", argv[0]);
+        exit(2);
+    }
+
+    fp1 = fopen(argv[1],"r");
+    if (fp1 == NULL) {
+        perror("Error: cannot open input file");
+        exit(1);
+    }
+    fp2 = fopen(argv[2], "r");
+    if (fp2 == NULL) {
+        perror("Error: cannot open input file");
+        exit(1);
+    }
+
+    while (fgets(buf1, sizeof(buf1), fp1) != NULL)
+    {
+        if(fgets(buf2, sizeof(buf2), fp2) == NULL) {
+            fprintf(stderr, "<%s", buf1);
+            ++differences;
+        }
+        else if(strcmp(buf1, buf2) != 0)
+        {
+            fprintf(stderr, "<%s", buf1);
+            fprintf(stderr, ">%s", buf2);
+            ++differences;
+        }
+    }
+    while(fgets(buf2, sizeof(buf2), fp2) != NULL)  {
+        fprintf(stderr, ">%s", buf2);
+        ++differences;
+    }
+    if (differences != 0) {
+        fprintf(stderr,"Total differences between files '%s' and '%s': %d lines\n",
+                argv[1], argv[2], differences);
+    }
+    exit(differences != 0);
+}
diff --git a/examples/errjac.c b/examples/errjac.c
new file mode 100644
index 0000000..28e07ac
--- /dev/null
+++ b/examples/errjac.c
@@ -0,0 +1,442 @@
+#include <math.h>
+#include <assert.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+static inline int max(int a, int b)
+{
+    return (a > b) ? a : b;
+}
+
+static inline int min(int a, int b)
+{
+    return (a < b) ? a : b;
+}
+
+void errjac(int n, const real *x, real *fjac, int ldfjac, int nprob)
+{
+    /* System generated locals */
+    int fjac_offset;
+    real d__1, d__2;
+
+    /* Local variables */
+    static real h__;
+    static int i__, j, k, k1, k2, ml;
+    static real ti, tj, tk;
+    static int mu;
+    static real tpi, sum, sum1, sum2, prod, temp, temp1, temp2, temp3, 
+	    temp4;
+
+/*     ********** */
+
+/*     subroutine errjac */
+
+/*     this subroutine is derived from vecjac which defines the */
+/*     jacobian matrices of fourteen test functions. the problem */
+/*     dimensions are as described in the prologue comments of vecfcn. */
+/*     various errors are deliberately introduced to provide a test */
+/*     for chkder. */
+
+/*     the subroutine statement is */
+
+/*       subroutine errjac(n,x,fjac,ldfjac,nprob) */
+
+/*     where */
+
+/*       n is a positive integer variable. */
+
+/*       x is an array of length n. */
+
+/*       fjac is an n by n array. on output fjac contains the */
+/*         jacobian matrix, with various errors deliberately */
+/*         introduced, of the nprob function evaluated at x. */
+
+/*       ldfjac is a positive integer variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       nprob is a positive integer variable which defines the */
+/*         number of the problem. nprob must not exceed 14. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt, */
+/*                            max0,min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+    fjac_offset = 1 + ldfjac;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     jacobian routine selector. */
+    assert(nprob >= 1 && nprob <=14);
+    switch (nprob) {
+	case 1:  goto L10;
+	case 2:  goto L20;
+	case 3:  goto L50;
+	case 4:  goto L60;
+	case 5:  goto L90;
+	case 6:  goto L100;
+	case 7:  goto L200;
+	case 8:  goto L230;
+	case 9:  goto L290;
+	case 10:  goto L320;
+	case 11:  goto L350;
+	case 12:  goto L380;
+	case 13:  goto L420;
+	case 14:  goto L450;
+    }
+
+/*     rosenbrock function with sign reversal affecting element (1,1). */
+
+L10:
+    fjac[1 * ldfjac + 1] = 1.;
+    fjac[2 * ldfjac + 1] = 0.;
+    fjac[1 * ldfjac + 2] = -20. * x[1];
+    fjac[2 * ldfjac + 2] = 10.;
+    goto L490;
+
+/*     powell singular function with sign reversal affecting element */
+/*     (3,3). */
+
+L20:
+    for (k = 1; k <= 4; ++k) {
+	for (j = 1; j <= 4; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L30: */
+	}
+/* L40: */
+    }
+    fjac[1 * ldfjac + 1] = 1.;
+    fjac[2 * ldfjac + 1] = 10.;
+    fjac[3 * ldfjac + 2] = sqrt(5.);
+    fjac[4 * ldfjac + 2] = -fjac[3 * ldfjac + 2];
+    fjac[2 * ldfjac + 3] = 2. * (x[2] - 2. * x[3]);
+    fjac[3 * ldfjac + 3] = 2. * fjac[2 * ldfjac + 3];
+    fjac[1 * ldfjac + 4] = 2. * sqrt(10.) * (x[1] - x[4]);
+    fjac[4 * ldfjac + 4] = -fjac[1 * ldfjac + 4];
+    goto L490;
+
+/*     powell badly scaled function with the sign of the jacobian */
+/*     reversed. */
+
+L50:
+    fjac[1 * ldfjac + 1] = -1e4 * x[2];
+    fjac[2 * ldfjac + 1] = -1e4 * x[1];
+    fjac[1 * ldfjac + 2] = exp(-x[1]);
+    fjac[2 * ldfjac + 2] = exp(-x[2]);
+    goto L490;
+
+/*     wood function without error. */
+
+L60:
+    for (k = 1; k <= 4; ++k) {
+	for (j = 1; j <= 4; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L70: */
+	}
+/* L80: */
+    }
+/* Computing 2nd power */
+    d__1 = x[1];
+    temp1 = x[2] - 3. * (d__1 * d__1);
+/* Computing 2nd power */
+    d__1 = x[3];
+    temp2 = x[4] - 3. * (d__1 * d__1);
+    fjac[1 * ldfjac + 1] = -200. * temp1 + 1.;
+    fjac[2 * ldfjac + 1] = -200. * x[1];
+    fjac[1 * ldfjac + 2] = -2. * 200. * x[1];
+    fjac[2 * ldfjac + 2] = 200. + 20.2;
+    fjac[4 * ldfjac + 2] = 19.8;
+    fjac[3 * ldfjac + 3] = -180. * temp2 + 1.;
+    fjac[4 * ldfjac + 3] = -180. * x[3];
+    fjac[2 * ldfjac + 4] = 19.8;
+    fjac[3 * ldfjac + 4] = -2. * 180. * x[3];
+    fjac[4 * ldfjac + 4] = 180. + 20.2;
+    goto L490;
+
+/*     helical valley function with multiplicative error affecting */
+/*     elements (2,1) and (2,2). */
+
+L90:
+    tpi = 8. * atan(1.);
+/* Computing 2nd power */
+    d__1 = x[1];
+/* Computing 2nd power */
+    d__2 = x[2];
+    temp = d__1 * d__1 + d__2 * d__2;
+    temp1 = tpi * temp;
+    temp2 = sqrt(temp);
+    fjac[1 * ldfjac + 1] = 100. * x[2] / temp1;
+    fjac[2 * ldfjac + 1] = -100. * x[1] / temp1;
+    fjac[3 * ldfjac + 1] = 10.;
+    fjac[1 * ldfjac + 2] = 5. * x[1] / temp2;
+    fjac[2 * ldfjac + 2] = 5. * x[2] / temp2;
+    fjac[3 * ldfjac + 2] = 0.;
+    fjac[1 * ldfjac + 3] = 0.;
+    fjac[2 * ldfjac + 3] = 0.;
+    fjac[3 * ldfjac + 3] = 1.;
+    goto L490;
+
+/*     watson function with sign reversals affecting the computation of */
+/*     temp1. */
+
+L100:
+    for (k = 1; k <= n; ++k) {
+	for (j = k; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L110: */
+	}
+/* L120: */
+    }
+    for (i__ = 1; i__ <= 29; ++i__) {
+	ti = (real) i__ / 29.;
+	sum1 = 0.;
+	temp = 1.;
+	for (j = 2; j <= n; ++j) {
+	    sum1 += (real) (j-1) * temp * x[j];
+	    temp = ti * temp;
+/* L130: */
+	}
+	sum2 = 0.;
+	temp = 1.;
+	for (j = 1; j <= n; ++j) {
+	    sum2 += temp * x[j];
+	    temp = ti * temp;
+/* L140: */
+	}
+/* Computing 2nd power */
+	d__1 = sum2;
+	temp1 = 2. * (sum1 - d__1 * d__1 + 1.);
+	temp2 = 2. * sum2;
+/* Computing 2nd power */
+	d__1 = ti;
+	temp = d__1 * d__1;
+	tk = 1.;
+	for (k = 1; k <= n; ++k) {
+	    tj = tk;
+	    for (j = k; j <= n; ++j) {
+		fjac[k + j * ldfjac] += tj * (((real) (k-1) / ti - 
+			temp2) * ((real) (j-1) / ti - temp2) - temp1);
+		tj = ti * tj;
+/* L150: */
+	    }
+	    tk = temp * tk;
+/* L160: */
+	}
+/* L170: */
+    }
+/* Computing 2nd power */
+    d__1 = x[1];
+    fjac[1 * ldfjac + 1] = fjac[1 * ldfjac + 1] + 6. * (d__1 * d__1) - 2. * x[2] + 3.;
+    fjac[2 * ldfjac + 1] -= 2. * x[1];
+    fjac[2 * ldfjac + 2] += 1.;
+    for (k = 1; k <= n; ++k) {
+	for (j = k; j <= n; ++j) {
+	    fjac[j + k * ldfjac] = fjac[k + j * ldfjac];
+/* L180: */
+	}
+/* L190: */
+    }
+    goto L490;
+
+/*     chebyquad function with jacobian twice correct size. */
+
+L200:
+    tk = 1. / (real) (n);
+    for (j = 1; j <= n; ++j) {
+	temp1 = 1.;
+	temp2 = 2. * x[j] - 1.;
+	temp = 2. * temp2;
+	temp3 = 0.;
+	temp4 = 2.;
+	for (k = 1; k <= n; ++k) {
+	    fjac[k + j * ldfjac] = 2. * tk * temp4;
+	    ti = 4. * temp2 + temp * temp4 - temp3;
+	    temp3 = temp4;
+	    temp4 = ti;
+	    ti = temp * temp2 - temp1;
+	    temp1 = temp2;
+	    temp2 = ti;
+/* L210: */
+	}
+/* L220: */
+    }
+    goto L490;
+
+/*     brown almost-linear function without error. */
+
+L230:
+    prod = 1.;
+    for (j = 1; j <= n; ++j) {
+	prod = x[j] * prod;
+	for (k = 1; k <= n; ++k) {
+	    fjac[k + j * ldfjac] = 1.;
+/* L240: */
+	}
+	fjac[j + j * ldfjac] = 2.;
+/* L250: */
+    }
+    for (j = 1; j <= n; ++j) {
+	temp = x[j];
+	if (temp != 0.) {
+	    goto L270;
+	}
+	temp = 1.;
+	prod = 1.;
+	for (k = 1; k <= n; ++k) {
+	    if (k != j) {
+		prod = x[k] * prod;
+	    }
+/* L260: */
+	}
+L270:
+	fjac[n + j * ldfjac] = prod / temp;
+/* L280: */
+    }
+    goto L490;
+
+/*     discrete boundary value function with multiplicative error */
+/*     affecting the jacobian diagonal. */
+
+L290:
+    h__ = 1. / (real) (n+1);
+    for (k = 1; k <= n; ++k) {
+/* Computing 2nd power */
+	d__1 = x[k] + (real) k * h__ + 1.;
+	temp = 3. * (d__1 * d__1);
+	for (j = 1; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L300: */
+	}
+/* Computing 2nd power */
+	d__1 = h__;
+	fjac[k + k * ldfjac] = 4. + temp * (d__1 * d__1);
+	if (k != 1) {
+	    fjac[k + (k - 1) * ldfjac] = -1.;
+	}
+	if (k != n) {
+	    fjac[k + (k + 1) * ldfjac] = -1.;
+	}
+/* L310: */
+    }
+    goto L490;
+
+/*     discrete integral equation function with sign error affecting */
+/*     the jacobian diagonal. */
+
+L320:
+    h__ = 1. / (real) (n+1);
+    for (k = 1; k <= n; ++k) {
+	tk = (real) k * h__;
+	for (j = 1; j <= n; ++j) {
+	    tj = (real) j * h__;
+/* Computing 2nd power */
+	    d__1 = x[j] + tj + 1.;
+	    temp = 3. * (d__1 * d__1);
+/* Computing MIN */
+	    d__1 = tj * (1. - tk), d__2 = tk * (1. - tj);
+	    fjac[k + j * ldfjac] = h__ * min(d__1,d__2) * temp / 2.;
+/* L330: */
+	}
+	fjac[k + k * ldfjac] -= 1.;
+/* L340: */
+    }
+    goto L490;
+
+/*     trigonometric function with sign errors affecting the */
+/*     offdiagonal elements of the jacobian. */
+
+L350:
+    for (j = 1; j <= n; ++j) {
+	temp = sin(x[j]);
+	for (k = 1; k <= n; ++k) {
+	    fjac[k + j * ldfjac] = -temp;
+/* L360: */
+	}
+	fjac[j + j * ldfjac] = (real) (j+1) * temp - cos(x[j]);
+/* L370: */
+    }
+    goto L490;
+
+/*     variably dimensioned function with operation error affecting */
+/*     the upper triangular elements of the jacobian. */
+
+L380:
+    sum = 0.;
+    for (j = 1; j <= n; ++j) {
+	sum += (real) j * (x[j] - 1.);
+/* L390: */
+    }
+/* Computing 2nd power */
+    d__1 = sum;
+    temp = 1. + 6. * (d__1 * d__1);
+    for (k = 1; k <= n; ++k) {
+	for (j = k; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = (real) (k*j) / temp;
+	    fjac[j + k * ldfjac] = fjac[k + j * ldfjac];
+/* L400: */
+	}
+	fjac[k + k * ldfjac] += 1.;
+/* L410: */
+    }
+    goto L490;
+
+/*     broyden tridiagonal function without error. */
+
+L420:
+    for (k = 1; k <= n; ++k) {
+	for (j = 1; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L430: */
+	}
+	fjac[k + k * ldfjac] = 3. - 4. * x[k];
+	if (k != 1) {
+	    fjac[k + (k - 1) * ldfjac] = -1.;
+	}
+	if (k != n) {
+	    fjac[k + (k + 1) * ldfjac] = -2.;
+	}
+/* L440: */
+    }
+    goto L490;
+
+/*     broyden banded function with sign error affecting the jacobian */
+/*     diagonal. */
+
+L450:
+    ml = 5;
+    mu = 1;
+    for (k = 1; k <= n; ++k) {
+	for (j = 1; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L460: */
+	}
+/* Computing MAX */
+	k1 = max(1,k-ml);
+/* Computing MIN */
+	k2 = min(k+mu,n);
+	for (j = k1; j <= k2; ++j) {
+	    if (j != k) {
+		fjac[k + j * ldfjac] = -(1. + 2. * x[j]);
+	    }
+/* L470: */
+	}
+/* Computing 2nd power */
+	d__1 = x[k];
+	fjac[k + k * ldfjac] = 2. - 15. * (d__1 * d__1);
+/* L480: */
+    }
+L490:
+    return;
+
+/*     last card of subroutine errjac. */
+
+} /* errjac_ */
+
diff --git a/examples/errjac.f b/examples/errjac.f
new file mode 100644
index 0000000..3913f23
--- /dev/null
+++ b/examples/errjac.f
@@ -0,0 +1,333 @@
+      subroutine errjac(n,x,fjac,ldfjac,nprob)
+      integer n,ldfjac,nprob
+      double precision x(n),fjac(ldfjac,n)
+c     **********
+c
+c     subroutine errjac
+c
+c     this subroutine is derived from vecjac which defines the
+c     jacobian matrices of fourteen test functions. the problem
+c     dimensions are as described in the prologue comments of vecfcn.
+c     various errors are deliberately introduced to provide a test
+c     for chkder.
+c
+c     the subroutine statement is
+c
+c       subroutine errjac(n,x,fjac,ldfjac,nprob)
+c
+c     where
+c
+c       n is a positive integer variable.
+c
+c       x is an array of length n.
+c
+c       fjac is an n by n array. on output fjac contains the
+c         jacobian matrix, with various errors deliberately
+c         introduced, of the nprob function evaluated at x.
+c
+c       ldfjac is a positive integer variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       nprob is a positive integer variable which defines the
+c         number of the problem. nprob must not exceed 14.
+c
+c     subprograms called
+c
+c       fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt,
+c                            max0,min0
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ivar,j,k,k1,k2,ml,mu
+      double precision c1,c3,c4,c5,c6,c9,eight,fiftn,five,four,h,
+     *                 hundrd,one,prod,six,sum,sum1,sum2,temp,temp1,
+     *                 temp2,temp3,temp4,ten,three,ti,tj,tk,tpi,
+     *                 twenty,two,zero
+      double precision dfloat
+      data zero,one,two,three,four,five,six,eight,ten,fiftn,twenty,
+     *     hundrd
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,6.0d0,8.0d0,1.0d1,
+     *      1.5d1,2.0d1,1.0d2/
+      data c1,c3,c4,c5,c6,c9 /1.0d4,2.0d2,2.02d1,1.98d1,1.8d2,2.9d1/
+      dfloat(ivar) = ivar
+c
+c     jacobian routine selector.
+c
+      go to (10,20,50,60,90,100,200,230,290,320,350,380,420,450),
+     *      nprob
+c
+c     rosenbrock function with sign reversal affecting element (1,1).
+c
+   10 continue
+      fjac(1,1) = one
+      fjac(1,2) = zero
+      fjac(2,1) = -twenty*x(1)
+      fjac(2,2) = ten
+      go to 490
+c
+c     powell singular function with sign reversal affecting element
+c     (3,3).
+c
+   20 continue
+      do 40 k = 1, 4
+         do 30 j = 1, 4
+            fjac(k,j) = zero
+   30       continue
+   40    continue
+      fjac(1,1) = one
+      fjac(1,2) = ten
+      fjac(2,3) = dsqrt(five)
+      fjac(2,4) = -fjac(2,3)
+      fjac(3,2) = two*(x(2) - two*x(3))
+      fjac(3,3) = two*fjac(3,2)
+      fjac(4,1) = two*dsqrt(ten)*(x(1) - x(4))
+      fjac(4,4) = -fjac(4,1)
+      go to 490
+c
+c     powell badly scaled function with the sign of the jacobian
+c     reversed.
+c
+   50 continue
+      fjac(1,1) = -c1*x(2)
+      fjac(1,2) = -c1*x(1)
+      fjac(2,1) = dexp(-x(1))
+      fjac(2,2) = dexp(-x(2))
+      go to 490
+c
+c     wood function without error.
+c
+   60 continue
+      do 80 k = 1, 4
+         do 70 j = 1, 4
+            fjac(k,j) = zero
+   70       continue
+   80    continue
+      temp1 = x(2) - three*x(1)**2
+      temp2 = x(4) - three*x(3)**2
+      fjac(1,1) = -c3*temp1 + one
+      fjac(1,2) = -c3*x(1)
+      fjac(2,1) = -two*c3*x(1)
+      fjac(2,2) = c3 + c4
+      fjac(2,4) = c5
+      fjac(3,3) = -c6*temp2 + one
+      fjac(3,4) = -c6*x(3)
+      fjac(4,2) = c5
+      fjac(4,3) = -two*c6*x(3)
+      fjac(4,4) = c6 + c4
+      go to 490
+c
+c     helical valley function with multiplicative error affecting
+c     elements (2,1) and (2,2).
+c
+   90 continue
+      tpi = eight*datan(one)
+      temp = x(1)**2 + x(2)**2
+      temp1 = tpi*temp
+      temp2 = dsqrt(temp)
+      fjac(1,1) = hundrd*x(2)/temp1
+      fjac(1,2) = -hundrd*x(1)/temp1
+      fjac(1,3) = ten
+      fjac(2,1) = five*x(1)/temp2
+      fjac(2,2) = five*x(2)/temp2
+      fjac(2,3) = zero
+      fjac(3,1) = zero
+      fjac(3,2) = zero
+      fjac(3,3) = one
+      go to 490
+c
+c     watson function with sign reversals affecting the computation of
+c     temp1.
+c
+  100 continue
+      do 120 k = 1, n
+         do 110 j = k, n
+            fjac(k,j) = zero
+  110       continue
+  120    continue
+      do 170 i = 1, 29
+         ti = dfloat(i)/c9
+         sum1 = zero
+         temp = one
+         do 130 j = 2, n
+            sum1 = sum1 + dfloat(j-1)*temp*x(j)
+            temp = ti*temp
+  130       continue
+         sum2 = zero
+         temp = one
+         do 140 j = 1, n
+            sum2 = sum2 + temp*x(j)
+            temp = ti*temp
+  140       continue
+         temp1 = two*(sum1 + sum2**2 + one)
+         temp2 = two*sum2
+         temp = ti**2
+         tk = one
+         do 160 k = 1, n
+            tj = tk
+            do 150 j = k, n
+               fjac(k,j) = fjac(k,j)
+     *                     + tj
+     *                       *((dfloat(k-1)/ti - temp2)
+     *                         *(dfloat(j-1)/ti - temp2) - temp1)
+               tj = ti*tj
+  150          continue
+            tk = temp*tk
+  160       continue
+  170    continue
+      fjac(1,1) = fjac(1,1) + six*x(1)**2 - two*x(2) + three
+      fjac(1,2) = fjac(1,2) - two*x(1)
+      fjac(2,2) = fjac(2,2) + one
+      do 190 k = 1, n
+         do 180 j = k, n
+            fjac(j,k) = fjac(k,j)
+  180       continue
+  190    continue
+      go to 490
+c
+c     chebyquad function with jacobian twice correct size.
+c
+  200 continue
+      tk = one/dfloat(n)
+      do 220 j = 1, n
+         temp1 = one
+         temp2 = two*x(j) - one
+         temp = two*temp2
+         temp3 = zero
+         temp4 = two
+         do 210 k = 1, n
+            fjac(k,j) = two*tk*temp4
+            ti = four*temp2 + temp*temp4 - temp3
+            temp3 = temp4
+            temp4 = ti
+            ti = temp*temp2 - temp1
+            temp1 = temp2
+            temp2 = ti
+  210       continue
+  220    continue
+      go to 490
+c
+c     brown almost-linear function without error.
+c
+  230 continue
+      prod = one
+      do 250 j = 1, n
+         prod = x(j)*prod
+         do 240 k = 1, n
+            fjac(k,j) = one
+  240       continue
+         fjac(j,j) = two
+  250    continue
+      do 280 j = 1, n
+         temp = x(j)
+         if (temp .ne. zero) go to 270
+         temp = one
+         prod = one
+         do 260 k = 1, n
+            if (k .ne. j) prod = x(k)*prod
+  260       continue
+  270    continue
+         fjac(n,j) = prod/temp
+  280    continue
+      go to 490
+c
+c     discrete boundary value function with multiplicative error
+c     affecting the jacobian diagonal.
+c
+  290 continue
+      h = one/dfloat(n+1)
+      do 310 k = 1, n
+         temp = three*(x(k) + dfloat(k)*h + one)**2
+         do 300 j = 1, n
+            fjac(k,j) = zero
+  300       continue
+         fjac(k,k) = four + temp*h**2
+         if (k .ne. 1) fjac(k,k-1) = -one
+         if (k .ne. n) fjac(k,k+1) = -one
+  310    continue
+      go to 490
+c
+c     discrete integral equation function with sign error affecting
+c     the jacobian diagonal.
+c
+  320 continue
+      h = one/dfloat(n+1)
+      do 340 k = 1, n
+         tk = dfloat(k)*h
+         do 330 j = 1, n
+            tj = dfloat(j)*h
+            temp = three*(x(j) + tj + one)**2
+            fjac(k,j) = h*dmin1(tj*(one-tk),tk*(one-tj))*temp/two
+  330       continue
+         fjac(k,k) = fjac(k,k) - one
+  340    continue
+      go to 490
+c
+c     trigonometric function with sign errors affecting the
+c     offdiagonal elements of the jacobian.
+c
+  350 continue
+      do 370 j = 1, n
+         temp = dsin(x(j))
+         do 360 k = 1, n
+            fjac(k,j) = -temp
+  360       continue
+         fjac(j,j) = dfloat(j+1)*temp - dcos(x(j))
+  370    continue
+      go to 490
+c
+c     variably dimensioned function with operation error affecting
+c     the upper triangular elements of the jacobian.
+c
+  380 continue
+      sum = zero
+      do 390 j = 1, n
+         sum = sum + dfloat(j)*(x(j) - one)
+  390    continue
+      temp = one + six*sum**2
+      do 410 k = 1, n
+         do 400 j = k, n
+            fjac(k,j) = dfloat(k*j)/temp
+            fjac(j,k) = fjac(k,j)
+  400       continue
+         fjac(k,k) = fjac(k,k) + one
+  410    continue
+      go to 490
+c
+c     broyden tridiagonal function without error.
+c
+  420 continue
+      do 440 k = 1, n
+         do 430 j = 1, n
+            fjac(k,j) = zero
+  430       continue
+         fjac(k,k) = three - four*x(k)
+         if (k .ne. 1) fjac(k,k-1) = -one
+         if (k .ne. n) fjac(k,k+1) = -two
+  440    continue
+      go to 490
+c
+c     broyden banded function with sign error affecting the jacobian
+c     diagonal.
+c
+  450 continue
+      ml = 5
+      mu = 1
+      do 480 k = 1, n
+         do 460 j = 1, n
+            fjac(k,j) = zero
+  460       continue
+         k1 = max0(1,k-ml)
+         k2 = min0(k+mu,n)
+         do 470 j = k1, k2
+            if (j .ne. k) fjac(k,j) = -(one + two*x(j))
+  470       continue
+         fjac(k,k) = two - fiftn*x(k)**2
+  480    continue
+  490 continue
+      return
+c
+c     last card of subroutine errjac.
+c
+      end
diff --git a/examples/fcn.mpl b/examples/fcn.mpl
new file mode 100644
index 0000000..8b28243
--- /dev/null
+++ b/examples/fcn.mpl
@@ -0,0 +1,18 @@
+with(VectorCalculus):
+fvec := Vector(15);
+y := Vector([.14, .18, .22, .25, .29, .32, .35, .39, .37, .58, .73, .96, 1.34, 2.1, 4.39]);
+for i to 15 do
+  tmp1 := (i -1)+ 1:
+  tmp2 := 15 - (i-1):
+  if (i-1) > 7 then
+    tmp3 := tmp2
+  else
+    tmp3 := tmp1
+  fi:
+  fvec[i] := y[i] -  (x[1] + tmp1/(x[2]*tmp2 + x[3]*tmp3)):
+od:
+Jacobian(fvec,[x[1],x[2],x[3]]);
+
+# now, with the second variable, x[2] bounded between a=0.1 and b=0.9
+a:=0.1:
+b:=
\ No newline at end of file
diff --git a/examples/genf77tests.c b/examples/genf77tests.c
new file mode 100644
index 0000000..542b6f0
--- /dev/null
+++ b/examples/genf77tests.c
@@ -0,0 +1,100 @@
+/* generate F77 test sources for MINPACK from the documentation
+   author: Frederic.Devernay at m4x.org
+*/
+/* Original awk program was:
+   /DRIVER FOR [A-Z1]+ EXAMPLE/{
+    pgm=tolower($4);
+    oname="t" pgm ".f";
+    $0 = substr($0,3);
+    print >oname;
+    do {
+        getline; $0 = substr($0,3);
+        if (!/^ +Page$/) print >>oname;
+    }
+    while (!/LAST CARD OF SUBROUTINE FCN/);
+    getline; $0 = substr($0,3); print >>oname;
+    getline; $0 = substr($0,3); print >>oname;
+   }
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+int
+main(int argc, char **argv)
+{
+    FILE *f_doc;
+    char buf[256];
+    
+    if (argc != 2) {
+        fprintf(stderr,"Usage: %s path/to/minpack-documentation.txt\n", argv[0]);
+        exit(2);
+    }
+    f_doc = fopen(argv[1], "r");
+    if (f_doc == NULL) {
+        perror("Error: cannot open input file");
+        exit(1);
+    }
+    while (fgets(buf, sizeof(buf), f_doc) != NULL)
+    {
+        const char *head = "DRIVER FOR";
+        char *pos;
+        pos = strstr(buf, head); /* fgets() always returns a NUL-terminated buffer, so there's no buffer over-read risk */
+        if (pos != NULL) {
+            FILE *f_src;
+            /* we found a test source */
+            char *name, *line;
+            int i;
+            int finished = 0;
+            pos = pos + strlen(head);
+            name = strdup(pos);
+            assert(name[0] == ' ');
+            name[0] = 't';
+            i = 1;
+            while(name[i] != 0 && name[i] != ' ') {
+                if (name[i] >= 'A' && name[i] <= 'Z')
+                    name[i] = name[i] - 'A' + 'a';
+                i++;
+            }
+            assert(name[i] == ' ' && name[i+1] != 0);
+            name[i] = '.';
+            name[i+1] = 'f';
+            name[i+2] = 0;
+            f_src = fopen(name, "w");
+            if (f_src == NULL) {
+                perror("Error: cannot open output file");
+                exit(1);
+            }
+            fputs(buf+2, f_src);
+            while (!finished && fgets(buf, sizeof(buf), f_doc) != NULL)
+            {
+                /* test for page skip */
+                const char *buf1 = buf;
+                while(*buf1 != 0 && *buf1 == ' ')
+                    buf1++;
+                if (*buf1 == 0) {
+                    /* blank line (happens before page skip) */
+                }
+                else if(strcmp(buf1, "Page\n") == 0) {
+                    /* page skip */
+                    /* fputs("\n",f_src); */
+                }
+                else {
+                    /* test for end of function */
+                    finished = (strstr(buf, "LAST CARD OF SUBROUTINE FCN") != NULL);
+                    fputs(buf+2, f_src);
+                }
+            }
+            assert(finished); /* two more lines */
+            line = fgets(buf, sizeof(buf), f_doc);
+            assert(line != NULL);
+            fputs(buf+2, f_src);
+            line = fgets(buf, sizeof(buf), f_doc);
+            assert(line != NULL);
+            fputs(buf+2, f_src);
+            fclose(f_src);
+        }
+    }
+    fclose(f_doc);
+}
diff --git a/examples/grdfcn.f b/examples/grdfcn.f
new file mode 100644
index 0000000..1dcb003
--- /dev/null
+++ b/examples/grdfcn.f
@@ -0,0 +1,438 @@
+      subroutine grdfcn(n,x,g,nprob)
+      integer n,nprob
+      double precision x(n),g(n)
+c     **********
+c
+c     subroutine grdfcn
+c
+c     this subroutine defines the gradient vectors of eighteen
+c     nonlinear unconstrained minimization problems. the problem
+c     dimensions are as described in the prologue comments of objfcn.
+c
+c     the subroutine statement is
+c
+c       subroutine grdfcn(n,x,g,nprob)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an input array of length n.
+c
+c       g is an output array of length n which contains the components
+c         of the gradient vector of the nprob objective function
+c         evaluated at x.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin,
+c                            dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iev,ivar,j
+      double precision ap,arg,c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,
+     *                 c2p25,c2p625,c3p5,c19p8,c20p2,c25,c29,c100,
+     *                 c180,c200,c10000,c1pd6,d1,d2,eight,fifty,five,
+     *                 four,one,r,s1,s2,s3,t,t1,t2,t3,ten,th,three,
+     *                 tpi,twenty,two,zero
+      double precision fvec(50),y(15)
+      double precision dfloat
+      data zero,one,two,three,four,five,eight,ten,twenty,fifty
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,2.0d1,
+     *      5.0d1/
+      data c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,c2p25,c2p625,c3p5,
+     *     c19p8,c20p2,c25,c29,c100,c180,c200,c10000,c1pd6
+     *     /2.0d-6,1.0d-4,1.0d-1,2.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,
+     *      2.625d0,3.5d0,1.98d1,2.02d1,2.5d1,2.9d1,1.0d2,1.8d2,2.0d2,
+     *      1.0d4,1.0d6/
+      data ap /1.0d-5/
+      data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11),
+     *     y(12),y(13),y(14),y(15)
+     *     /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1,
+     *      3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3,
+     *      9.0d-4/
+      dfloat(ivar) = ivar
+c
+c     gradient routine selector.
+c
+      go to (10,20,50,70,80,100,130,190,220,260,270,290,310,350,370,
+     *       390,400,410), nprob
+c
+c     helical valley function.
+c
+   10 continue
+      tpi = eight*datan(one)
+      th = dsign(cp25,x(2))
+      if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi
+      if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5
+      arg = x(1)**2 + x(2)**2
+      r = dsqrt(arg)
+      t = x(3) - ten*th
+      s1 = ten*t/(tpi*arg)
+      g(1) = c200*(x(1) - x(1)/r + x(2)*s1)
+      g(2) = c200*(x(2) - x(2)/r - x(1)*s1)
+      g(3) = two*(c100*t + x(3))
+      go to 490
+c
+c     biggs exp6 function.
+c
+   20 continue
+      do 30 j = 1, 6
+         g(j) = zero
+   30    continue
+      do 40 i = 1, 13
+         d1 = dfloat(i)/ten
+         d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1)
+         s1 = dexp(-d1*x(1))
+         s2 = dexp(-d1*x(2))
+         s3 = dexp(-d1*x(5))
+         t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2
+         th = d1*t
+         g(1) = g(1) - s1*th
+         g(2) = g(2) + s2*th
+         g(3) = g(3) + s1*t
+         g(4) = g(4) - s2*t
+         g(5) = g(5) - s3*th
+         g(6) = g(6) + s3*t
+   40    continue
+      g(1) = two*x(3)*g(1)
+      g(2) = two*x(4)*g(2)
+      g(3) = two*g(3)
+      g(4) = two*g(4)
+      g(5) = two*x(6)*g(5)
+      g(6) = two*g(6)
+      go to 490
+c
+c     gaussian function.
+c
+   50 continue
+      g(1) = zero
+      g(2) = zero
+      g(3) = zero
+      do 60 i = 1, 15
+         d1 = cp5*dfloat(i-1)
+         d2 = c3p5 - d1 - x(3)
+         arg = -cp5*x(2)*d2**2
+         r = dexp(arg)
+         t = x(1)*r - y(i)
+         s1 = r*t
+         s2 = d2*s1
+         g(1) = g(1) + s1
+         g(2) = g(2) - d2*s2
+         g(3) = g(3) + s2
+   60    continue
+      g(1) = two*g(1)
+      g(2) = x(1)*g(2)
+      g(3) = two*x(1)*x(2)*g(3)
+      go to 490
+c
+c     powell badly scaled function.
+c
+   70 continue
+      t1 = c10000*x(1)*x(2) - one
+      s1 = dexp(-x(1))
+      s2 = dexp(-x(2))
+      t2 = s1 + s2 - one - cp0001
+      g(1) = two*(c10000*x(2)*t1 - s1*t2)
+      g(2) = two*(c10000*x(1)*t1 - s2*t2)
+      go to 490
+c
+c     box 3-dimensional function.
+c
+   80 continue
+      g(1) = zero
+      g(2) = zero
+      g(3) = zero
+      do 90 i = 1, 10
+         d1 = dfloat(i)
+         d2 = d1/ten
+         s1 = dexp(-d2*x(1))
+         s2 = dexp(-d2*x(2))
+         s3 = dexp(-d2) - dexp(-d1)
+         t = s1 - s2 - s3*x(3)
+         th = d2*t
+         g(1) = g(1) - s1*th
+         g(2) = g(2) + s2*th
+         g(3) = g(3) - s3*t
+   90    continue
+      g(1) = two*g(1)
+      g(2) = two*g(2)
+      g(3) = two*g(3)
+      go to 490
+c
+c     variably dimensioned function.
+c
+  100 continue
+      t1 = zero
+      do 110 j = 1, n
+         t1 = t1 + dfloat(j)*(x(j) - one)
+  110    continue
+      t = t1*(one + two*t1**2)
+      do 120 j = 1, n
+         g(j) = two*(x(j) - one + dfloat(j)*t)
+  120    continue
+      go to 490
+c
+c     watson function.
+c
+  130 continue
+      do 140 j = 1, n
+         g(j) = zero
+  140    continue
+      do 180 i = 1, 29
+         d1 = dfloat(i)/c29
+         s1 = zero
+         d2 = one
+         do 150 j = 2, n
+            s1 = s1 + dfloat(j-1)*d2*x(j)
+            d2 = d1*d2
+  150       continue
+         s2 = zero
+         d2 = one
+         do 160 j = 1, n
+            s2 = s2 + d2*x(j)
+            d2 = d1*d2
+  160       continue
+         t = s1 - s2**2 - one
+         s3 = two*d1*s2
+         d2 = two/d1
+         do 170 j = 1, n
+            g(j) = g(j) + d2*(dfloat(j-1) - s3)*t
+            d2 = d1*d2
+  170       continue
+  180    continue
+      t1 = x(2) - x(1)**2 - one
+      g(1) = g(1) + x(1)*(two - four*t1)
+      g(2) = g(2) + two*t1
+      go to 490
+c
+c     penalty function i.
+c
+  190 continue
+      t1 = -cp25
+      do 200 j = 1, n
+         t1 = t1 + x(j)**2
+  200    continue
+      d1 = two*ap
+      th = four*t1
+      do 210 j = 1, n
+         g(j) = d1*(x(j) - one) + x(j)*th
+  210    continue
+      go to 490
+c
+c     penalty function ii.
+c
+  220 continue
+      t1 = -one
+      do 230 j = 1, n
+         t1 = t1 + dfloat(n-j+1)*x(j)**2
+  230    continue
+      d1 = dexp(cp1)
+      d2 = one
+      th = four*t1
+      do 250 j = 1, n
+         g(j) = dfloat(n-j+1)*x(j)*th
+         s1 = dexp(x(j)/ten)
+         if (j .eq. 1) go to 240
+         s3 = s1 + s2 - d2*(d1 + one)
+         g(j) = g(j) + ap*s1*(s3 + s1 - one/d1)/five
+         g(j-1) = g(j-1) + ap*s2*s3/five
+  240    continue
+         s2 = s1
+         d2 = d1*d2
+  250    continue
+      g(1) = g(1) + two*(x(1) - cp2)
+      go to 490
+c
+c     brown badly scaled function.
+c
+  260 continue
+      t1 = x(1) - c1pd6
+      t2 = x(2) - c2pdm6
+      t3 = x(1)*x(2) - two
+      g(1) = two*(t1 + x(2)*t3)
+      g(2) = two*(t2 + x(1)*t3)
+      go to 490
+c
+c     brown and dennis function.
+c
+  270 continue
+      g(1) = zero
+      g(2) = zero
+      g(3) = zero
+      g(4) = zero
+      do 280 i = 1, 20
+         d1 = dfloat(i)/five
+         d2 = dsin(d1)
+         t1 = x(1) + d1*x(2) - dexp(d1)
+         t2 = x(3) + d2*x(4) - dcos(d1)
+         t = t1**2 + t2**2
+         s1 = t1*t
+         s2 = t2*t
+         g(1) = g(1) + s1
+         g(2) = g(2) + d1*s1
+         g(3) = g(3) + s2
+         g(4) = g(4) + d2*s2
+  280    continue
+      g(1) = four*g(1)
+      g(2) = four*g(2)
+      g(3) = four*g(3)
+      g(4) = four*g(4)
+      go to 490
+c
+c     gulf research and development function.
+c
+  290 continue
+      g(1) = zero
+      g(2) = zero
+      g(3) = zero
+      d1 = two/three
+      do 300 i = 1, 99
+         arg = dfloat(i)/c100
+         r = (-fifty*dlog(arg))**d1 + c25 - x(2)
+         t1 = dabs(r)**x(3)/x(1)
+         t2 = dexp(-t1)
+         t = t2 - arg
+         s1 = t1*t2*t
+         g(1) = g(1) + s1
+         g(2) = g(2) + s1/r
+         g(3) = g(3) - s1*dlog(dabs(r))
+  300    continue
+      g(1) = two*g(1)/x(1)
+      g(2) = two*x(3)*g(2)
+      g(3) = two*g(3)
+      go to 490
+c
+c     trigonometric function.
+c
+  310 continue
+      s1 = zero
+      do 320 j = 1, n
+         g(j) = dcos(x(j))
+         s1 = s1 + g(j)
+  320    continue
+      s2 = zero
+      do 330 j = 1, n
+         th = dsin(x(j))
+         t = dfloat(n+j) - th - s1 - dfloat(j)*g(j)
+         s2 = s2 + t
+         g(j) = (dfloat(j)*th - g(j))*t
+  330    continue
+      do 340 j = 1, n
+         g(j) = two*(g(j) + dsin(x(j))*s2)
+  340    continue
+      go to 490
+c
+c     extended rosenbrock function.
+c
+  350 continue
+      do 360 j = 1, n, 2
+         t1 = one - x(j)
+         g(j+1) = c200*(x(j+1) - x(j)**2)
+         g(j) = -two*(x(j)*g(j+1) + t1)
+  360    continue
+      go to 490
+c
+c     extended powell function.
+c
+  370 continue
+      do 380 j = 1, n, 4
+         t = x(j) + ten*x(j+1)
+         t1 = x(j+2) - x(j+3)
+         s1 = five*t1
+         t2 = x(j+1) - two*x(j+2)
+         s2 = four*t2**3
+         t3 = x(j) - x(j+3)
+         s3 = twenty*t3**3
+         g(j) = two*(t + s3)
+         g(j+1) = twenty*t + s2
+         g(j+2) = two*(s1 - s2)
+         g(j+3) = -two*(s1 + s3)
+  380    continue
+      go to 490
+c
+c     beale function.
+c
+  390 continue
+      s1 = one - x(2)
+      t1 = c1p5 - x(1)*s1
+      s2 = one - x(2)**2
+      t2 = c2p25 - x(1)*s2
+      s3 = one - x(2)**3
+      t3 = c2p625 - x(1)*s3
+      g(1) = -two*(s1*t1 + s2*t2 + s3*t3)
+      g(2) = two*x(1)*(t1 + x(2)*(two*t2 + three*x(2)*t3))
+      go to 490
+c
+c     wood function.
+c
+  400 continue
+      s1 = x(2) - x(1)**2
+      s2 = one - x(1)
+      s3 = x(2) - one
+      t1 = x(4) - x(3)**2
+      t2 = one - x(3)
+      t3 = x(4) - one
+      g(1) = -two*(c200*x(1)*s1 + s2)
+      g(2) = c200*s1 + c20p2*s3 + c19p8*t3
+      g(3) = -two*(c180*x(3)*t1 + t2)
+      g(4) = c180*t1 + c20p2*t3 + c19p8*s3
+      go to 490
+c
+c     chebyquad function.
+c
+  410 continue
+      do 420 i = 1, n
+         fvec(i) = zero
+  420    continue
+      do 440 j = 1, n
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         do 430 i = 1, n
+            fvec(i) = fvec(i) + t2
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  430       continue
+  440    continue
+      d1 = one/dfloat(n)
+      iev = -1
+      do 450 i = 1, n
+         fvec(i) = d1*fvec(i)
+         if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one)
+         iev = -iev
+  450    continue
+      do 470 j = 1, n
+         g(j) = zero
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         s1 = zero
+         s2 = two
+         do 460 i = 1, n
+            g(j) = g(j) + fvec(i)*s2
+            th = four*t2 + t*s2 - s1
+            s1 = s2
+            s2 = th
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  460       continue
+  470    continue
+      d2 = two*d1
+      do 480 j = 1, n
+         g(j) = d2*g(j)
+  480    continue
+  490 continue
+      return
+c
+c     last card of subroutine grdfcn.
+c
+      end
diff --git a/examples/hesfcn.f b/examples/hesfcn.f
new file mode 100644
index 0000000..15a8d03
--- /dev/null
+++ b/examples/hesfcn.f
@@ -0,0 +1,651 @@
+      subroutine hesfcn(n,x,h,ldh,nprob)
+      integer n,ldh,nprob
+      double precision x(n),h(ldh,n)
+c     **********
+c
+c     subroutine hesfcn
+c
+c     this subroutine defines the hessian matrices of eighteen
+c     nonlinear unconstrained minimization problems. the problem
+c     dimensions are as described in the prologue comments of objfcn.
+c     the upper triangle of the (symmetric) hessian matrix is
+c     computed columnwise. storage locations below the diagonal
+c     are not disturbed until the final step, which reflects the
+c     upper triangle to fill the square matrix.
+c
+c     the subroutine statement is
+c
+c       subroutine hesfcn(n,x,h,ldh,nprob)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an input array of length n.
+c
+c       h is an n by n array. on output h contains the hessian
+c         matrix of the nprob objective function evaluated at x.
+c
+c       ldh is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array h.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin,
+c                            dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iev,ivar,j,k,n2
+      double precision ap,arg,cp0001,cp1,cp25,cp5,c1p5,c2p25,
+     *                 c2p625,c3p5,c19p8,c25,c29,c100,c200,c10000,d1,
+     *                 d2,eight,fifty,five,four,one,r,s1,s2,s3,t,t1,
+     *                 t2,t3,ten,th,three,tpi,twenty,two,zero
+      double precision d3,r1,r2,r3,u1,u2,v,v1,v2
+      double precision fvec(50),fvec1(50),y(15)
+      double precision dfloat
+      double precision six,xnine,twelve,c120,c200p2,c202,c220p2,c360,
+     *                 c400,c1200
+      data six,xnine,twelve,c120,c200p2,c202,c220p2,c360,c400,c1200
+     *     /6.0d0,9.0d0,1.2d1,1.2d2,2.002d2,2.02d2,2.202d2,3.6d2,
+     *      4.0d2,1.2d3/
+      data zero,one,two,three,four,five,eight,ten,twenty,fifty
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,2.0d1,
+     *      5.0d1/
+      data cp0001,cp1,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c19p8,c25,c29,
+     *     c100,c200,c10000
+     *     /1.0d-4,1.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,2.625d0,3.5d0,
+     *      1.98d1,2.5d1,2.9d1,1.0d2,2.0d2,1.0d4/
+      data ap /1.0d-5/
+      data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11),
+     *     y(12),y(13),y(14),y(15)
+     *     /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1,
+     *      3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3,
+     *      9.0d-4/
+      dfloat(ivar) = ivar
+c
+c     hessian routine selector.
+c
+      go to (10,20,60,100,110,170,210,290,330,380,390,450,490,580,620,
+     *       660,670,680), nprob
+c
+c     helical valley function.
+c
+   10 continue
+      tpi = eight*datan(one)
+      th = dsign(cp25,x(2))
+      if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi
+      if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5
+      arg = x(1)**2 + x(2)**2
+      r = dsqrt(arg)
+      t = x(3) - ten*th
+      s1 = ten*t/(tpi*arg)
+      t1 = ten/tpi
+      t2 = t1/arg
+      t3 = (x(1)/r - t1*t2*x(1) - two*x(2)*s1)/arg
+      h(1,1) = c200
+     *         *(one - x(2)/arg*(x(2)/r - t1*t2*x(2) + two*x(1)*s1))
+      h(1,2) = c200*(s1 + x(2)*t3)
+      h(2,2) = c200*(one - x(1)*t3)
+      h(1,3) = c200*t2*x(2)
+      h(2,3) = -c200*t2*x(1)
+      h(3,3) = c202
+      go to 800
+c
+c     biggs exp6 function.
+c
+   20 continue
+      do 40 j = 1, 6
+         do 30 i = 1, j
+            h(i,j) = zero
+   30       continue
+   40    continue
+      do 50 i = 1, 13
+         d1 = dfloat(i)/ten
+         d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1)
+         s1 = dexp(-d1*x(1))
+         s2 = dexp(-d1*x(2))
+         s3 = dexp(-d1*x(5))
+         t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2
+         th = d1*t
+         r1 = d1*s1
+         r2 = d1*s2
+         r3 = d1*s3
+         h(1,1) = h(1,1) + r1*(th + x(3)*r1)
+         h(1,2) = h(1,2) - r1*r2
+         h(2,2) = h(2,2) - r2*(th - x(4)*r2)
+         h(1,3) = h(1,3) - s1*(th + x(3)*r1)
+         h(3,3) = h(3,3) + s1**2
+         h(1,4) = h(1,4) + r1*s2
+         h(2,4) = h(2,4) + s2*(th - x(4)*r2)
+         h(3,4) = h(3,4) - s1*s2
+         h(4,4) = h(4,4) + s2**2
+         h(1,5) = h(1,5) + r1*r3
+         h(2,5) = h(2,5) - r2*r3
+         h(5,5) = h(5,5) + r3*(th + x(6)*r3)
+         h(1,6) = h(1,6) - r1*s3
+         h(2,6) = h(2,6) + r2*s3
+         h(3,6) = h(3,6) + s1*s3
+         h(4,6) = h(4,6) - s2*s3
+         h(5,6) = h(5,6) - s3*(th + x(6)*r3)
+         h(6,6) = h(6,6) + s3**2
+   50    continue
+      h(1,1) = two*x(3)*h(1,1)
+      h(1,2) = two*x(3)*x(4)*h(1,2)
+      h(2,2) = two*x(4)*h(2,2)
+      h(1,3) = two*h(1,3)
+      h(2,3) = two*x(4)*h(1,4)
+      h(3,3) = two*h(3,3)
+      h(1,4) = two*x(3)*h(1,4)
+      h(2,4) = two*h(2,4)
+      h(3,4) = two*h(3,4)
+      h(4,4) = two*h(4,4)
+      h(1,5) = two*x(3)*x(6)*h(1,5)
+      h(2,5) = two*x(4)*x(6)*h(2,5)
+      h(3,5) = two*x(6)*h(1,6)
+      h(4,5) = two*x(6)*h(2,6)
+      h(5,5) = two*x(6)*h(5,5)
+      h(1,6) = two*x(3)*h(1,6)
+      h(2,6) = two*x(4)*h(2,6)
+      h(3,6) = two*h(3,6)
+      h(4,6) = two*h(4,6)
+      h(5,6) = two*h(5,6)
+      h(6,6) = two*h(6,6)
+      go to 800
+c
+c     gaussian function.
+c
+   60 continue
+      do 80 j = 1, 3
+         do 70 i = 1, j
+            h(i,j) = zero
+   70       continue
+   80    continue
+      do 90 i = 1, 15
+         d1 = cp5*dfloat(i-1)
+         d2 = c3p5 - d1 - x(3)
+         arg = -cp5*x(2)*d2**2
+         r = dexp(arg)
+         t = x(1)*r - y(i)
+         s1 = r*t
+         s2 = d2*s1
+         t1 = s2 + d2*x(1)*r**2
+         t2 = d2*t1
+         h(1,1) = h(1,1) + r**2
+         h(1,2) = h(1,2) - t2
+         h(2,2) = h(2,2) + d2**2*t2
+         h(1,3) = h(1,3) + t1
+         h(2,3) = h(2,3) + two*s2 - d2*x(2)*t2
+         h(3,3) = h(3,3) + x(2)*t2 - s1
+   90    continue
+      h(1,1) = two*h(1,1)
+      h(1,2) = h(1,2)
+      h(2,2) = cp5*x(1)*h(2,2)
+      h(1,3) = two*x(2)*h(1,3)
+      h(2,3) = x(1)*h(2,3)
+      h(3,3) = two*x(1)*x(2)*h(3,3)
+      go to 800
+c
+c     powell badly scaled function.
+c
+  100 continue
+      t1 = c10000*x(1)*x(2) - one
+      s1 = dexp(-x(1))
+      s2 = dexp(-x(2))
+      t2 = s1 + s2 - one - cp0001
+      h(1,1) = two*((c10000*x(2))**2 + s1*(s1 + t2))
+      h(1,2) = two*(c10000*(one + two*t1) + s1*s2)
+      h(2,2) = two*((c10000*x(1))**2 + s2*(s2 + t2))
+      go to 800
+c
+c     box 3-dimensional function.
+c
+  110 continue
+      do 130 j = 1, 3
+         do 120 i = 1, j
+            h(i,j) = zero
+  120       continue
+  130    continue
+      do 140 i = 1, 10
+         d1 = dfloat(i)
+         d2 = d1/ten
+         s1 = dexp(-d2*x(1))
+         s2 = dexp(-d2*x(2))
+         s3 = dexp(-d2) - dexp(-d1)
+         t = s1 - s2 - s3*x(3)
+         th = d2*t
+         r1 = d2*s1
+         r2 = d2*s2
+         h(1,1) = h(1,1) + r1*(th + r1)
+         h(1,2) = h(1,2) - r1*r2
+         h(2,2) = h(2,2) - r2*(th - r2)
+         h(1,3) = h(1,3) + r1*s3
+         h(2,3) = h(2,3) - r2*s3
+         h(3,3) = h(3,3) + s3**2
+  140    continue
+      do 160 j = 1, 3
+         do 150 i = 1, j
+            h(i,j) = two*h(i,j)
+  150       continue
+  160    continue
+      go to 800
+c
+c     variably dimensioned function.
+c
+  170 continue
+      t1 = zero
+      do 180 j = 1, n
+         t1 = t1 + dfloat(j)*(x(j) - one)
+  180    continue
+c     t = t1*(one + two*t1**2)
+      t2 = two + twelve*t1**2
+      do 200 j = 1, n
+         do 190 i = 1, j
+            h(i,j) = dfloat(i*j)*t2
+  190       continue
+         h(j,j) = h(j,j) + two
+  200    continue
+      go to 800
+c
+c     watson function.
+c
+  210 continue
+      do 230 j = 1, n
+         do 220 k = 1, j
+            h(k,j) = zero
+  220       continue
+  230    continue
+      do 280 i = 1, 29
+         d1 = dfloat(i)/c29
+         s1 = zero
+         d2 = one
+         do 240 j = 2, n
+            s1 = s1 + dfloat(j-1)*d2*x(j)
+            d2 = d1*d2
+  240       continue
+         s2 = zero
+         d2 = one
+         do 250 j = 1, n
+            s2 = s2 + d2*x(j)
+            d2 = d1*d2
+  250       continue
+         t = s1 - s2**2 - one
+         s3 = two*d1*s2
+         d2 = two/d1
+         th = two*d1**2*t
+         do 270 j = 1, n
+            v = dfloat(j-1) - s3
+            d3 = one/d1
+            do 260 k = 1, j
+               h(k,j) = h(k,j) + d2*d3*(v*(dfloat(k-1) - s3) - th)
+               d3 = d1*d3
+  260          continue
+            d2 = d1*d2
+  270       continue
+  280    continue
+      t1 = x(2) - x(1)**2 - one
+      h(1,1) = h(1,1) + eight*x(1)**2 + two - four*t1
+      h(1,2) = h(1,2) - four*x(1)
+      h(2,2) = h(2,2) + two
+      go to 800
+c
+c     penalty function i.
+c
+  290 continue
+      t1 = -cp25
+      do 300 j = 1, n
+         t1 = t1 + x(j)**2
+  300    continue
+      d1 = two*ap
+      th = four*t1
+      do 320 j = 1, n
+         t2 = eight*x(j)
+         do 310 i = 1, j
+            h(i,j) = x(i)*t2
+  310       continue
+         h(j,j) = h(j,j) + d1 + th
+  320    continue
+      go to 800
+c
+c     penalty function ii.
+c
+  330 continue
+      t1 = -one
+      do 340 j = 1, n
+         t1 = t1 + dfloat(n-j+1)*x(j)**2
+  340    continue
+      d1 = dexp(cp1)
+      d2 = one
+      th = four*t1
+      do 370 j = 1, n
+         t2 = eight*dfloat(n-j+1)*x(j)
+         do 350 i = 1, j
+            h(i,j) = dfloat(n-i+1)*x(i)*t2
+  350       continue
+         h(j,j) = h(j,j) + dfloat(n-j+1)*th
+         s1 = dexp(x(j)/ten)
+         if (j .eq. 1) go to 360
+         s3 = s1 + s2 - d2*(d1 + one)
+         h(j,j) = h(j,j) + ap*s1*(s3 + three*s1 - one/d1)/fifty
+         h(j-1,j) = h(j-1,j) + ap*s1*s2/fifty
+         h(j-1,j-1) = h(j-1,j-1) + ap*s2*(s2 + s3)/fifty
+  360    continue
+         s2 = s1
+         d2 = d1*d2
+  370    continue
+      h(1,1) = h(1,1) + two
+      go to 800
+c
+c     brown badly scaled function.
+c
+  380 continue
+c     t1 = x(1) - c1pd6
+c     t2 = x(2) - c2pdm6
+      t3 = x(1)*x(2) - two
+      h(1,1) = two*(one + x(2)**2)
+      h(1,2) = four*(one + t3)
+      h(2,2) = two*(one + x(1)**2)
+      go to 800
+c
+c     brown and dennis function.
+c
+  390 continue
+      do 410 j = 1, 4
+         do 400 i = 1, j
+            h(i,j) = zero
+  400       continue
+  410    continue
+      do 420 i = 1, 20
+         d1 = dfloat(i)/five
+         d2 = dsin(d1)
+         t1 = x(1) + d1*x(2) - dexp(d1)
+         t2 = x(3) + d2*x(4) - dcos(d1)
+         t = t1**2 + t2**2
+c        s1 = t1*t
+c        s2 = t2*t
+         s3 = two*t1*t2
+         r1 = t + two*t1**2
+         r2 = t + two*t2**2
+         h(1,1) = h(1,1) + r1
+         h(1,2) = h(1,2) + d1*r1
+         h(2,2) = h(2,2) + d1**2*r1
+         h(1,3) = h(1,3) + s3
+         h(2,3) = h(2,3) + d1*s3
+         h(3,3) = h(3,3) + r2
+         h(1,4) = h(1,4) + d2*s3
+         h(2,4) = h(2,4) + d1*d2*s3
+         h(3,4) = h(3,4) + d2*r2
+         h(4,4) = h(4,4) + d2**2*r2
+  420    continue
+      do 440 j = 1, 4
+         do 430 i = 1, j
+            h(i,j) = four*h(i,j)
+  430       continue
+  440    continue
+      go to 800
+c
+c     gulf research and development function.
+c
+  450 continue
+      do 470 j = 1, 3
+         do 460 i = 1, j
+            h(i,j) = zero
+  460       continue
+  470    continue
+      d1 = two/three
+      do 480 i = 1, 99
+         arg = dfloat(i)/c100
+         r = (-fifty*dlog(arg))**d1 + c25 - x(2)
+         t1 = dabs(r)**x(3)/x(1)
+         t2 = dexp(-t1)
+         t = t2 - arg
+         s1 = t1*t2*t
+         s2 = t1*(s1 + t2*(t1*t2 - t))
+         r1 = dlog(dabs(r))
+         r2 = r1*s2
+         h(1,1) = h(1,1) + s2 - s1
+         h(1,2) = h(1,2) + s2/r
+         h(2,2) = h(2,2) + (s1 + x(3)*s2)/r**2
+         h(1,3) = h(1,3) - r2
+         h(2,3) = h(2,3) + (s1 - x(3)*r2)/r
+         h(3,3) = h(3,3) + r1*r2
+  480    continue
+      h(1,1) = two*h(1,1)/x(1)**2
+      h(1,2) = two*x(3)*h(1,2)/x(1)
+      h(2,2) = two*x(3)*h(2,2)
+      h(1,3) = two*h(1,3)/x(1)
+      h(2,3) = two*h(2,3)
+      h(3,3) = two*h(3,3)
+      go to 800
+c
+c     trigonometric function.
+c
+  490 continue
+      u2 = dcos(x(n))
+      s1 = u2
+      if (n .eq. 1) go to 510
+      u1 = dcos(x(n-1))
+      s1 = s1 + u1
+      if (n .eq. 2) go to 510
+      n2 = n - 2
+      do 500 j = 1, n2
+         h(j,n-1) = dcos(x(j))
+         s1 = s1 + h(j,n-1)
+  500    continue
+  510 continue
+      v2 = dsin(x(n))
+      s2 = dfloat(2*n) - v2 - s1 - dfloat(n)*u2
+      r2 = dfloat(2*n)*v2 - u2
+      if (n .eq. 1) go to 570
+      v1 = dsin(x(n-1))
+      s2 = s2 + dfloat(2*n-1) - v1 - s1 - dfloat(n-1)*u1
+      r1 = dfloat(2*n-1)*v1 - u1
+      if (n .eq. 2) go to 560
+      do 520 j = 1, n2
+         h(j,n) = dsin(x(j))
+         t = dfloat(n+j) - h(j,n) - s1 - dfloat(j)*h(j,n-1)
+         s2 = s2 + t
+  520    continue
+      do 540 j = 1, n2
+         v = dfloat(j)*h(j,n-1) + h(j,n)
+         t = dfloat(n+j) - s1 - v
+         t1 = dfloat(n+j)*h(j,n) - h(j,n-1)
+         do 530 i = 1, j
+            th = dfloat(i)*h(i,n) - h(i,n-1)
+            h(i,j) = two*(h(i,n)*t1 + h(j,n)*th)
+  530       continue
+         h(j,j) = h(j,j) + two*(h(j,n-1)*s2 + v*t + th**2)
+  540    continue
+      do 550 i = 1, n2
+         th = dfloat(i)*h(i,n) - h(i,n-1)
+         h(i,n-1) = two*(h(i,n)*r1 + v1*th)
+         h(i,n) = two*(h(i,n)*r2 + v2*th)
+  550    continue
+  560 continue
+      v = dfloat(n-1)*u1 + v1
+      t = dfloat(2*n-1) - s1 - v
+      th = dfloat(n-1)*v1 - u1
+      h(n-1,n-1) = two*(v1*(r1 + th) + u1*s2 + v*t + th**2)
+      h(n-1,n) = two*(v1*r2 + v2*th)
+  570 continue
+      v = dfloat(n)*u2 + v2
+      t = dfloat(2*n) - s1 - v
+      th = dfloat(n)*v2 - u2
+      h(n,n) = two*(v2*(r2 + th) + u2*s2 + v*t + th**2)
+      go to 800
+c
+c     extended rosenbrock function.
+c
+  580 continue
+      do 600 j = 1, n
+         do 590 i = 1, j
+            h(i,j) = zero
+  590       continue
+  600    continue
+      do 610 j = 1, n, 2
+c        t1 = one - x(j)
+         h(j,j) = c1200*x(j)**2 - c400*x(j+1) + two
+         h(j,j+1) = -c400*x(j)
+         h(j+1,j+1) = c200
+  610    continue
+      go to 800
+c
+c     extended powell function.
+c
+  620 continue
+      do 640 j = 1, n
+         do 630 i = 1, j
+            h(i,j) = zero
+  630       continue
+  640    continue
+      do 650 j = 1, n, 4
+c        t = x(j) + ten*x(j+1)
+c        t1 = x(j+2) - x(j+3)
+c        s1 = five*t1
+         t2 = x(j+1) - two*x(j+2)
+c        s2 = four*t2**3
+         t3 = x(j) - x(j+3)
+c        s3 = twenty*t3**3
+         r2 = twelve*t2**2
+         r3 = c120*t3**2
+         h(j,j) = two + r3
+         h(j,j+1) = twenty
+         h(j+1,j+1) = c200 + r2
+         h(j+1,j+2) = -two*r2
+         h(j+2,j+2) = ten + four*r2
+         h(j,j+3) = -r3
+         h(j+2,j+3) = -ten
+         h(j+3,j+3) = ten + r3
+  650    continue
+      go to 800
+c
+c     beale function.
+c
+  660 continue
+      s1 = one - x(2)
+      t1 = c1p5 - x(1)*s1
+      s2 = one - x(2)**2
+      t2 = c2p25 - x(1)*s2
+      s3 = one - x(2)**3
+      t3 = c2p625 - x(1)*s3
+      h(1,1) = two*(s1**2 + s2**2 + s3**2)
+      h(1,2) = two
+     *         *(t1 + x(2)*(two*t2 + three*x(2)*t3)
+     *           - x(1)*(s1 + x(2)*(two*s2 + three*x(2)*s3)))
+      h(2,2) = two*x(1)
+     *         *(x(1) + two*t2
+     *           + x(2)*(six*t3 + x(1)*x(2)*(four + xnine*x(2)**2)))
+      go to 800
+c
+c     wood function.
+c
+  670 continue
+      s1 = x(2) - x(1)**2
+c     s2 = one - x(1)
+c     s3 = x(2) - one
+      t1 = x(4) - x(3)**2
+c     t2 = one - x(3)
+c     t3 = x(4) - one
+      h(1,1) = c400*(two*x(1)**2 - s1) + two
+      h(1,2) = -c400*x(1)
+      h(2,2) = c220p2
+      h(1,3) = zero
+      h(2,3) = zero
+      h(3,3) = c360*(two*x(3)**2 - t1) + two
+      h(1,4) = zero
+      h(2,4) = c19p8
+      h(3,4) = -c360*x(3)
+      h(4,4) = c200p2
+      go to 800
+c
+c     chebyquad function.
+c
+  680 continue
+      do 690 i = 1, n
+         fvec(i) = zero
+  690    continue
+      do 710 j = 1, n
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         do 700 i = 1, n
+            fvec(i) = fvec(i) + t2
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  700       continue
+  710    continue
+      d1 = one/dfloat(n)
+      iev = -1
+      do 720 i = 1, n
+         fvec(i) = d1*fvec(i)
+         if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one)
+         iev = -iev
+  720    continue
+      do 770 j = 1, n
+         do 730 k = 1, j
+            h(k,j) = zero
+  730       continue
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         s1 = zero
+         s2 = two
+         r1 = zero
+         r2 = zero
+         do 740 i = 1, n
+            h(j,j) = h(j,j) + fvec(i)*r2
+            th = eight*s2 + t*r2 - r1
+            r1 = r2
+            r2 = th
+            fvec1(i) = d1*s2
+            th = four*t2 + t*s2 - s1
+            s1 = s2
+            s2 = th
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  740       continue
+         do 760 k = 1, j
+            v1 = one
+            v2 = two*x(k) - one
+            v = two*v2
+            u1 = zero
+            u2 = two
+            do 750 i = 1, n
+               h(k,j) = h(k,j) + fvec1(i)*u2
+               th = four*v2 + v*u2 - u1
+               u1 = u2
+               u2 = th
+               th = v*v2 - v1
+               v1 = v2
+               v2 = th
+  750          continue
+  760       continue
+  770    continue
+      d2 = two*d1
+      do 790 j = 1, n
+         do 780 k = 1, j
+            h(k,j) = d2*h(k,j)
+  780       continue
+  790    continue
+c
+c     reflect the upper triangle to fill the square matrix.
+c
+  800 continue
+      do 820 j = 1, n
+         do 810 i = j, n
+            h(i,j) = h(j,i)
+  810       continue
+  820    continue
+      return
+c
+c     last card of subroutine hesfcn.
+c
+      end
+
diff --git a/examples/hybdrv.c b/examples/hybdrv.c
new file mode 100644
index 0000000..c4d7bdc
--- /dev/null
+++ b/examples/hybdrv.c
@@ -0,0 +1,186 @@
+/* Usage: lmddrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the solution of n nonlinear */
+/*     equations in n variables. it consists of a driver and an */
+/*     interface subroutine fcn. the driver reads in data, calls the */
+/*     nonlinear equation solver, and finally prints out information */
+/*     on the performance of the solver. this is only a sample driver, */
+/*     many other drivers are possible. the interface subroutine fcn */
+/*     is necessary to take into account the forms of calling */
+/*     sequences used by the function subroutines in the various */
+/*     nonlinear equation solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,hybrd1,initpt,vecfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+int fcn(void *p, int n, const real *x, real *fvec, int iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,n,ntries;
+    struct refnum hybrdtest;
+    int info;
+
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fnm[60];
+    real fvec[40];
+    real x[40];
+
+    real wa[2660];
+    const int lwa = 2660;
+
+    tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d\n", &hybrdtest.nprob, &n, &ntries);
+        if (hybrdtest.nprob <= 0.)
+            break;
+
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            hybipt(n,x,hybrdtest.nprob,factor);
+
+            vecfcn(n,x,fvec,hybrdtest.nprob);
+
+            fnorm1 = __cminpack_func__(enorm)(n,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimension%5d\n\n", hybrdtest.nprob, n);
+
+            hybrdtest.nfev = 0;
+            hybrdtest.njev = 0;
+
+            info = __cminpack_func__(hybrd1)(fcn,&hybrdtest,n,x,fvec,tol,wa,lwa);
+
+            fnorm2 = __cminpack_func__(enorm)(n,fvec);
+
+            np[ic] = hybrdtest.nprob;
+            na[ic] = n;
+            nf[ic] = hybrdtest.nfev;
+            hybrdtest.njev /= n;
+            nj[ic] = hybrdtest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of Jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, hybrdtest.nfev, hybrdtest.njev, info);
+            printvec(n, x);
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to hybrd1\n", ic);
+    printf("\n nprob   n    nfev   njev  info  final l2 norm\n\n");
+    for (i = 0; i < ic; ++i) {
+        printf("%4d%6d%7d%7d%6d%16.7e\n",
+               np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+    }
+    exit(0);
+}
+
+
+int fcn(void *p, int n, const real *x, real *fvec, int iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     equation solver. fcn should only call the testing function */
+/*     subroutine vecfcn with the appropriate value of problem */
+/*     number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... vecfcn */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    struct refnum *hybrdtest = (struct refnum *)p;
+    vecfcn(n, x, fvec, hybrdtest->nprob);
+    if (iflag == 1) {
+        hybrdtest->nfev++;
+    }
+    if (iflag == 2) {
+        hybrdtest->njev++;
+    }
+
+    return 0;
+} /* fcn_ */
diff --git a/examples/hybdrv.f b/examples/hybdrv.f
new file mode 100644
index 0000000..29b8b45
--- /dev/null
+++ b/examples/hybdrv.f
@@ -0,0 +1,112 @@
+c     **********
+c
+c     this program tests codes for the solution of n nonlinear
+c     equations in n variables. it consists of a driver and an
+c     interface subroutine fcn. the driver reads in data, calls the
+c     nonlinear equation solver, and finally prints out information
+c     on the performance of the solver. this is only a sample driver,
+c     many other drivers are possible. the interface subroutine fcn
+c     is necessary to take into account the forms of calling
+c     sequences used by the function subroutines in the various
+c     nonlinear equation solvers.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,hybrd1,initpt,vecfcn
+c
+c       fortran-supplied ... dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ic,info,k,lwa,n,nfev,nprob,nread,ntries,nwrite
+      integer na(60),nf(60),np(60),nx(60)
+      double precision factor,fnorm1,fnorm2,one,ten,tol
+      double precision fnm(60),fvec(40),wa(2660),x(40)
+      double precision dpmpar,enorm
+      external fcn
+      common /refnum/ nprob,nfev
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data one,ten /1.0d0,1.0d1/
+      tol = dsqrt(dpmpar(1))
+      lwa = 2660
+      ic = 0
+   10 continue
+         read (nread,50) nprob,n,ntries
+         if (nprob .le. 0) go to 30
+         factor = one
+         do 20 k = 1, ntries
+            ic = ic + 1
+            call initpt(n,x,nprob,factor)
+            call vecfcn(n,x,fvec,nprob)
+            fnorm1 = enorm(n,fvec)
+            write (nwrite,60) nprob,n
+            nfev = 0
+            call hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
+            fnorm2 = enorm(n,fvec)
+            np(ic) = nprob
+            na(ic) = n
+            nf(ic) = nfev
+            nx(ic) = info
+            fnm(ic) = fnorm2
+            write (nwrite,70) fnorm1,fnorm2,nfev,info,(x(i), i = 1, n)
+            factor = ten*factor
+   20       continue
+         go to 10
+   30 continue
+      write (nwrite,80) ic
+      write (nwrite,90)
+      do 40 i = 1, ic
+         write (nwrite,100) np(i),na(i),nf(i),nx(i),fnm(i)
+   40    continue
+      stop
+   50 format (3i5)
+   60 format ( //// 5x, 8h problem, i5, 5x, 10h dimension, i5, 5x //)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+   80 format (12h1summary of , i3, 16h calls to hybrd1 /)
+   90 format (39h nprob   n    nfev  info  final l2 norm /)
+  100 format (i4, i6, i7, i6, 1x, d15.7)
+c
+c     last card of driver.
+c
+      end
+      subroutine fcn(n,x,fvec,iflag)
+      integer n,iflag
+      double precision x(n),fvec(n)
+c     **********
+c
+c     the calling sequence of fcn should be identical to the
+c     calling sequence of the function subroutine in the nonlinear
+c     equation solver. fcn should only call the testing function
+c     subroutine vecfcn with the appropriate value of problem
+c     number (nprob).
+c
+c     subprograms called
+c
+c       minpack-supplied ... vecfcn
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer nprob,nfev
+      common /refnum/ nprob,nfev
+      call vecfcn(n,x,fvec,nprob)
+      nfev = nfev + 1
+      return
+c
+c     last card of interface subroutine fcn.
+c
+      end
diff --git a/examples/hybdrv_ b/examples/hybdrv_
new file mode 100755
index 0000000..0239fb9
Binary files /dev/null and b/examples/hybdrv_ differ
diff --git a/examples/hybdrv_.c b/examples/hybdrv_.c
new file mode 100644
index 0000000..73671c6
--- /dev/null
+++ b/examples/hybdrv_.c
@@ -0,0 +1,185 @@
+/* Usage: lmddrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "minpack.h"
+#include "vec.h"
+#define real __minpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the solution of n nonlinear */
+/*     equations in n variables. it consists of a driver and an */
+/*     interface subroutine fcn. the driver reads in data, calls the */
+/*     nonlinear equation solver, and finally prints out information */
+/*     on the performance of the solver. this is only a sample driver, */
+/*     many other drivers are possible. the interface subroutine fcn */
+/*     is necessary to take into account the forms of calling */
+/*     sequences used by the function subroutines in the various */
+/*     nonlinear equation solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,hybrd1,initpt,vecfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+void fcn(const int *n, const real *x, real *fvec, int *iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+struct refnum hybrdtest;
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,n,ntries;
+    int info;
+
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fnm[60];
+    real fvec[40];
+    real x[40];
+
+    real wa[2660];
+    const int lwa = 2660;
+    const int i1 = 1;
+
+    tol = sqrt(__minpack_func__(dpmpar)(&i1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d\n", &hybrdtest.nprob, &n, &ntries);
+        if (hybrdtest.nprob <= 0.)
+            break;
+
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            hybipt(n,x,hybrdtest.nprob,factor);
+
+            vecfcn(n,x,fvec,hybrdtest.nprob);
+
+            fnorm1 = __minpack_func__(enorm)(&n,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimension%5d\n\n", hybrdtest.nprob, n);
+
+            hybrdtest.nfev = 0;
+            hybrdtest.njev = 0;
+
+            __minpack_func__(hybrd1)(fcn,&n,x,fvec,&tol,&info,wa,&lwa);
+
+            fnorm2 = __minpack_func__(enorm)(&n,fvec);
+
+            np[ic] = hybrdtest.nprob;
+            na[ic] = n;
+            nf[ic] = hybrdtest.nfev;
+            hybrdtest.njev /= n;
+            nj[ic] = hybrdtest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of Jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, hybrdtest.nfev, hybrdtest.njev, info);
+            printvec(n, x);
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to hybrd1\n", ic);
+    printf("\n nprob   n    nfev   njev  info  final l2 norm\n\n");
+    for (i = 0; i < ic; ++i) {
+        printf("%4d%6d%7d%7d%6d%16.7e\n",
+               np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+    }
+    exit(0);
+}
+
+
+void fcn(const int *n, const real *x, real *fvec, int *iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     equation solver. fcn should only call the testing function */
+/*     subroutine vecfcn with the appropriate value of problem */
+/*     number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... vecfcn */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    vecfcn(*n, x, fvec, hybrdtest.nprob);
+    if (*iflag == 1) {
+        hybrdtest.nfev++;
+    }
+    if (*iflag == 2) {
+        hybrdtest.njev++;
+    }
+} /* fcn_ */
diff --git a/examples/hybipt.c b/examples/hybipt.c
new file mode 100644
index 0000000..7dfb902
--- /dev/null
+++ b/examples/hybipt.c
@@ -0,0 +1,150 @@
+#include <math.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+void hybipt(int n, real *x, int nprob, real factor)
+{
+    /* Local variables */
+    static real h__;
+    static int j;
+    static real tj;
+
+/*     ********** */
+
+/*     subroutine initpt */
+
+/*     this subroutine specifies the standard starting points for */
+/*     the functions defined by subroutine vecfcn. the subroutine */
+/*     returns in x a multiple (factor) of the standard starting */
+/*     point. for the sixth function the standard starting point is */
+/*     zero, so in this case, if factor is not unity, then the */
+/*     subroutine returns the vector  x(j) = factor, j=1,...,n. */
+
+/*     the subroutine statement is */
+
+/*       subroutine initpt(n,x,nprob,factor) */
+
+/*     where */
+
+/*       n is a positive integer input variable. */
+
+/*       x is an output array of length n which contains the standard */
+/*         starting point for problem nprob multiplied by factor. */
+
+/*       nprob is a positive integer input variable which defines the */
+/*         number of the problem. nprob must not exceed 14. */
+
+/*       factor is an input variable which specifies the multiple of */
+/*         the standard starting point. if factor is unity, no */
+/*         multiplication is performed. */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+
+    /*     selection of initial point. */
+
+    switch (nprob) {
+	case 1:
+            /*     rosenbrock function. */
+            x[1] = -1.2;
+            x[2] = 1.;
+            break;
+	case 2:
+            /*     powell singular function. */
+            x[1] = 3.;
+            x[2] = -1.;
+            x[3] = 0.;
+            x[4] = 1.;
+            break;
+	case 3:
+            /*     powell badly scaled function. */
+            x[1] = 0.;
+            x[2] = 1.;
+            break;
+	case 4:
+            /*     wood function. */
+            x[1] = -3.;
+            x[2] = -1.;
+            x[3] = -3.;
+            x[4] = -1.;
+            break;
+	case 5:
+            /*     helical valley function. */
+            x[1] = -1.;
+            x[2] = 0.;
+            x[3] = 0.;
+            break;
+	case 6:
+            /*     watson function. */
+            for (j = 1; j <= n; ++j) {
+                x[j] = 0.;
+            }
+            break;
+	case 7:
+            /*     chebyquad function. */
+            h__ = 1. / (real) (n+1);
+            for (j = 1; j <= n; ++j) {
+                x[j] = (real) j * h__;
+            }
+            break;
+	case 8:
+            /*     brown almost-linear function. */
+            for (j = 1; j <= n; ++j) {
+                x[j] = .5;
+            }
+            break;
+	case 9:
+	case 10:
+            /*     discrete boundary value and integral equation functions. */
+            h__ = 1. / (real) (n+1);
+            for (j = 1; j <= n; ++j) {
+                tj = (real) j * h__;
+                x[j] = tj * (tj - 1.);
+            }
+            break;
+	case 11:
+            /*     trigonometric function. */
+            h__ = 1. / (real) (n);
+            for (j = 1; j <= n; ++j) {
+                x[j] = h__;
+            }
+            break;
+	case 12:
+            /*     variably dimensioned function. */
+            h__ = 1. / (real) (n);
+            for (j = 1; j <= n; ++j) {
+                x[j] = 1. - (real) j * h__;
+            }
+            break;
+	case 13:
+        case 14:
+            /*     broyden tridiagonal and banded functions. */
+            for (j = 1; j <= n; ++j) {
+                x[j] = -1.;
+            }
+            break;
+    }
+
+    /*     compute multiple of initial point. */
+
+    if (factor == 1.) {
+	return;
+    }
+    if (nprob == 6) {
+        for (j = 1; j <= n; ++j) {
+            x[j] = factor;
+        }
+    } else {
+        for (j = 1; j <= n; ++j) {
+            x[j] = factor * x[j];
+        }
+    }
+} /* initpt_ */
+
diff --git a/examples/hybipt.f b/examples/hybipt.f
new file mode 100644
index 0000000..5bf4d2e
--- /dev/null
+++ b/examples/hybipt.f
@@ -0,0 +1,167 @@
+      subroutine initpt(n,x,nprob,factor)
+      integer n,nprob
+      double precision factor
+      double precision x(n)
+c     **********
+c
+c     subroutine initpt
+c
+c     this subroutine specifies the standard starting points for
+c     the functions defined by subroutine vecfcn. the subroutine
+c     returns in x a multiple (factor) of the standard starting
+c     point. for the sixth function the standard starting point is
+c     zero, so in this case, if factor is not unity, then the
+c     subroutine returns the vector  x(j) = factor, j=1,...,n.
+c
+c     the subroutine statement is
+c
+c       subroutine initpt(n,x,nprob,factor)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an output array of length n which contains the standard
+c         starting point for problem nprob multiplied by factor.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 14.
+c
+c       factor is an input variable which specifies the multiple of
+c         the standard starting point. if factor is unity, no
+c         multiplication is performed.
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer ivar,j
+      double precision c1,h,half,one,three,tj,zero
+      double precision dfloat
+      data zero,half,one,three,c1 /0.0d0,5.0d-1,1.0d0,3.0d0,1.2d0/
+      dfloat(ivar) = ivar
+c
+c     selection of initial point.
+c
+      go to (10,20,30,40,50,60,80,100,120,120,140,160,180,180), nprob
+c
+c     rosenbrock function.
+c
+   10 continue
+      x(1) = -c1
+      x(2) = one
+      go to 200
+c
+c     powell singular function.
+c
+   20 continue
+      x(1) = three
+      x(2) = -one
+      x(3) = zero
+      x(4) = one
+      go to 200
+c
+c     powell badly scaled function.
+c
+   30 continue
+      x(1) = zero
+      x(2) = one
+      go to 200
+c
+c     wood function.
+c
+   40 continue
+      x(1) = -three
+      x(2) = -one
+      x(3) = -three
+      x(4) = -one
+      go to 200
+c
+c     helical valley function.
+c
+   50 continue
+      x(1) = -one
+      x(2) = zero
+      x(3) = zero
+      go to 200
+c
+c     watson function.
+c
+   60 continue
+      do 70 j = 1, n
+         x(j) = zero
+   70    continue
+      go to 200
+c
+c     chebyquad function.
+c
+   80 continue
+      h = one/dfloat(n+1)
+      do 90 j = 1, n
+         x(j) = dfloat(j)*h
+   90    continue
+      go to 200
+c
+c     brown almost-linear function.
+c
+  100 continue
+      do 110 j = 1, n
+         x(j) = half
+  110    continue
+      go to 200
+c
+c     discrete boundary value and integral equation functions.
+c
+  120 continue
+      h = one/dfloat(n+1)
+      do 130 j = 1, n
+         tj = dfloat(j)*h
+         x(j) = tj*(tj - one)
+  130    continue
+      go to 200
+c
+c     trigonometric function.
+c
+  140 continue
+      h = one/dfloat(n)
+      do 150 j = 1, n
+         x(j) = h
+  150    continue
+      go to 200
+c
+c     variably dimensioned function.
+c
+  160 continue
+      h = one/dfloat(n)
+      do 170 j = 1, n
+         x(j) = one - dfloat(j)*h
+  170    continue
+      go to 200
+c
+c     broyden tridiagonal and banded functions.
+c
+  180 continue
+      do 190 j = 1, n
+         x(j) = -one
+  190    continue
+  200 continue
+c
+c     compute multiple of initial point.
+c
+      if (factor .eq. one) go to 250
+      if (nprob .eq. 6) go to 220
+         do 210 j = 1, n
+            x(j) = factor*x(j)
+  210       continue
+         go to 240
+  220 continue
+         do 230 j = 1, n
+            x(j) = factor
+  230       continue
+  240 continue
+  250 continue
+      return
+c
+c     last card of subroutine initpt.
+c
+      end
diff --git a/examples/hyjdrv.c b/examples/hyjdrv.c
new file mode 100644
index 0000000..5c4d510
--- /dev/null
+++ b/examples/hyjdrv.c
@@ -0,0 +1,192 @@
+/* Usage: hyjdrv < hybrd.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the solution of n nonlinear */
+/*     equations in n variables. it consists of a driver and an */
+/*     interface subroutine fcn. the driver reads in data, calls the */
+/*     nonlinear equation solver, and finally prints out information */
+/*     on the performance of the solver. this is only a sample driver, */
+/*     many other drivers are possible. the interface subroutine fcn */
+/*     is necessary to take into account the forms of calling */
+/*     sequences used by the function and jacobian subroutines in */
+/*     the various nonlinear equation solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,hybrj1,initpt,vecfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+int fcn(void *p, int n, const real *x, real *fvec, real *fjac,
+        int ldfjac, int iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,n,ntries;
+    struct refnum hybrjtest;
+    int info;
+
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fjac[40*40];
+    const int ldfjac = 40;
+
+    real fnm[60];
+    real fvec[40];
+    real x[40];
+
+    real wa[1060];
+    const int lwa = 1060;
+
+    tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d\n", &hybrjtest.nprob, &n, &ntries);
+        if (hybrjtest.nprob <= 0.)
+            break;
+
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            hybipt(n,x,hybrjtest.nprob,factor);
+
+            vecfcn(n,x,fvec,hybrjtest.nprob);
+
+            fnorm1 = __cminpack_func__(enorm)(n,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimension%5d\n\n", hybrjtest.nprob, n);
+
+            hybrjtest.nfev = 0;
+            hybrjtest.njev = 0;
+
+            info = __cminpack_func__(hybrj1)(fcn,&hybrjtest,n,x,fvec,fjac,ldfjac,tol,wa,lwa);
+
+            fnorm2 = __cminpack_func__(enorm)(n,fvec);
+
+            np[ic] = hybrjtest.nprob;
+            na[ic] = n;
+            nf[ic] = hybrjtest.nfev;
+            nj[ic] = hybrjtest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, hybrjtest.nfev, hybrjtest.njev, info);
+            printvec(n, x);
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to hybrj1\n", ic);
+    printf("\n nprob   n    nfev   njev  info  final l2 norm\n\n");
+
+    for (i = 0; i < ic; ++i) {
+        printf("%4d%6d%7d%7d%6d%16.7e\n",
+               np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+    }
+    exit(0);
+}
+
+
+int fcn(void *p, int n, const real *x, real *fvec, real *fjac,
+	 int ldfjac, int iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     equation solver. fcn should only call the testing function */
+/*     and jacobian subroutines vecfcn and vecjac with the */
+/*     appropriate value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... vecfcn,vecjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    struct refnum *hybrjtest = (struct refnum *)p;
+    if (iflag == 1) {
+        vecfcn(n, x, fvec, hybrjtest->nprob);
+        hybrjtest->nfev++;
+    }
+    if (iflag == 2) {
+        vecjac(n, x, fjac, ldfjac, hybrjtest->nprob);
+        hybrjtest->njev++;
+    }
+
+    return 0;
+} /* fcn_ */
diff --git a/examples/hyjdrv.f b/examples/hyjdrv.f
new file mode 100644
index 0000000..dca87ad
--- /dev/null
+++ b/examples/hyjdrv.f
@@ -0,0 +1,120 @@
+c     **********
+c
+c     this program tests codes for the solution of n nonlinear
+c     equations in n variables. it consists of a driver and an
+c     interface subroutine fcn. the driver reads in data, calls the
+c     nonlinear equation solver, and finally prints out information
+c     on the performance of the solver. this is only a sample driver,
+c     many other drivers are possible. the interface subroutine fcn
+c     is necessary to take into account the forms of calling
+c     sequences used by the function and jacobian subroutines in
+c     the various nonlinear equation solvers.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,hybrj1,initpt,vecfcn
+c
+c       fortran-supplied ... dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ic,info,k,ldfjac,lwa,n,nfev,njev,nprob,nread,ntries,
+     1        nwrite
+      integer na(60),nf(60),nj(60),np(60),nx(60)
+      double precision factor,fnorm1,fnorm2,one,ten,tol
+      double precision fnm(60),fjac(40,40),fvec(40),wa(1060),x(40)
+      double precision dpmpar,enorm
+      external fcn
+      common /refnum/ nprob,nfev,njev
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data one,ten /1.0d0,1.0d1/
+      tol = dsqrt(dpmpar(1))
+      ldfjac = 40
+      lwa = 1060
+      ic = 0
+   10 continue
+         read (nread,50) nprob,n,ntries
+         if (nprob .le. 0) go to 30
+         factor = one
+         do 20 k = 1, ntries
+            ic = ic + 1
+            call initpt(n,x,nprob,factor)
+            call vecfcn(n,x,fvec,nprob)
+            fnorm1 = enorm(n,fvec)
+            write (nwrite,60) nprob,n
+            nfev = 0
+            njev = 0
+            call hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)
+            fnorm2 = enorm(n,fvec)
+            np(ic) = nprob
+            na(ic) = n
+            nf(ic) = nfev
+            nj(ic) = njev
+            nx(ic) = info
+            fnm(ic) = fnorm2
+            write (nwrite,70)
+     1            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+            factor = ten*factor
+   20       continue
+         go to 10
+   30 continue
+      write (nwrite,80) ic
+      write (nwrite,90)
+      do 40 i = 1, ic
+         write (nwrite,100) np(i),na(i),nf(i),nj(i),nx(i),fnm(i)
+   40    continue
+      stop
+   50 format (3i5)
+   60 format ( //// 5x, 8h problem, i5, 5x, 10h dimension, i5, 5x //)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     1        33h final l2 norm of the residuals  , d15.7 // 5x,
+     2        33h number of function evaluations  , i10 // 5x,
+     3        33h number of jacobian evaluations  , i10 // 5x,
+     4        15h exit parameter, 18x, i10 // 5x,
+     5        27h final approximate solution // (5x, 5d15.7))
+   80 format (12h1summary of , i3, 16h calls to hybrj1 /)
+   90 format (46h nprob   n    nfev   njev  info  final l2 norm /)
+  100 format (i4, i6, 2i7, i6, 1x, d15.7)
+c
+c     last card of driver.
+c
+      end
+      subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+      integer n,ldfjac,iflag
+      double precision x(n),fvec(n),fjac(ldfjac,n)
+c     **********
+c
+c     the calling sequence of fcn should be identical to the
+c     calling sequence of the function subroutine in the nonlinear
+c     equation solver. fcn should only call the testing function
+c     and jacobian subroutines vecfcn and vecjac with the
+c     appropriate value of problem number (nprob).
+c
+c     subprograms called
+c
+c       minpack-supplied ... vecfcn,vecjac
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer nprob,nfev,njev
+      common /refnum/ nprob,nfev,njev
+      if (iflag .eq. 1) call vecfcn(n,x,fvec,nprob)
+      if (iflag .eq. 2) call vecjac(n,x,fjac,ldfjac,nprob)
+      if (iflag .eq. 1) nfev = nfev + 1
+      if (iflag .eq. 2) njev = njev + 1
+      return
+c
+c     last card of interface subroutine fcn.
+c
+      end
diff --git a/examples/hyjdrv_ b/examples/hyjdrv_
new file mode 100755
index 0000000..89ef3bd
Binary files /dev/null and b/examples/hyjdrv_ differ
diff --git a/examples/hyjdrv_.c b/examples/hyjdrv_.c
new file mode 100644
index 0000000..15c31f8
--- /dev/null
+++ b/examples/hyjdrv_.c
@@ -0,0 +1,191 @@
+/* Usage: hyjdrv < hybrd.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "minpack.h"
+#include "vec.h"
+#define real __minpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the solution of n nonlinear */
+/*     equations in n variables. it consists of a driver and an */
+/*     interface subroutine fcn. the driver reads in data, calls the */
+/*     nonlinear equation solver, and finally prints out information */
+/*     on the performance of the solver. this is only a sample driver, */
+/*     many other drivers are possible. the interface subroutine fcn */
+/*     is necessary to take into account the forms of calling */
+/*     sequences used by the function and jacobian subroutines in */
+/*     the various nonlinear equation solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,hybrj1,initpt,vecfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+void fcn(const int *n, const real *x, real *fvec, real *fjac,
+         const int *ldfjac, int *iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+struct refnum hybrjtest;
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,n,ntries;
+    int info;
+
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fjac[40*40];
+    const int ldfjac = 40;
+
+    real fnm[60];
+    real fvec[40];
+    real x[40];
+
+    real wa[1060];
+    const int lwa = 1060;
+    const int i1 = 1;
+
+    tol = sqrt(__minpack_func__(dpmpar)(&i1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d\n", &hybrjtest.nprob, &n, &ntries);
+        if (hybrjtest.nprob <= 0.)
+            break;
+
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            hybipt(n,x,hybrjtest.nprob,factor);
+
+            vecfcn(n,x,fvec,hybrjtest.nprob);
+
+            fnorm1 = __minpack_func__(enorm)(&n,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimension%5d\n\n", hybrjtest.nprob, n);
+
+            hybrjtest.nfev = 0;
+            hybrjtest.njev = 0;
+
+            __minpack_func__(hybrj1)(fcn,&n,x,fvec,fjac,&ldfjac,&tol,&info,wa,&lwa);
+
+            fnorm2 = __minpack_func__(enorm)(&n,fvec);
+
+            np[ic] = hybrjtest.nprob;
+            na[ic] = n;
+            nf[ic] = hybrjtest.nfev;
+            nj[ic] = hybrjtest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, hybrjtest.nfev, hybrjtest.njev, info);
+            printvec(n, x);
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to hybrj1\n", ic);
+    printf("\n nprob   n    nfev   njev  info  final l2 norm\n\n");
+
+    for (i = 0; i < ic; ++i) {
+        printf("%4d%6d%7d%7d%6d%16.7e\n",
+               np[i], na[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+    }
+    exit(0);
+}
+
+
+void fcn(const int *n, const real *x, real *fvec, real *fjac,
+         const int *ldfjac, int *iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     equation solver. fcn should only call the testing function */
+/*     and jacobian subroutines vecfcn and vecjac with the */
+/*     appropriate value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... vecfcn,vecjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    if (*iflag == 1) {
+        vecfcn(*n, x, fvec, hybrjtest.nprob);
+        hybrjtest.nfev++;
+    }
+    if (*iflag == 2) {
+        vecjac(*n, x, fjac, *ldfjac, hybrjtest.nprob);
+        hybrjtest.njev++;
+    }
+} /* fcn_ */
diff --git a/examples/ibmdpdr.c b/examples/ibmdpdr.c
new file mode 100644
index 0000000..7acc75b
--- /dev/null
+++ b/examples/ibmdpdr.c
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include <math.h>
+#include "cminpack.h"
+#define real __cminpack_real__
+
+extern void machar_(int *ibeta, int *it, int *irnd, 
+                    int *ngrd, int *machep, int *negep, int *iexp, 
+                    int *minexp, int *maxexp, real *eps, real *epsneg,
+                    real *xmin, real *xmax);
+
+/*     ********** */
+
+/*     this program checks the constants of machine precision and */
+/*     smallest and largest machine representable numbers specified in */
+/*     function dpmpar, against the corresponding hardware-determined */
+/*     machine constants obtained by machar, a subroutine due to */
+/*     w. j. cody. */
+
+/*     data statements in dpmpar corresponding to the machine used must */
+/*     be activated by removing c in column 1. */
+
+/*     the printed output consists of the machine constants obtained by */
+/*     machar and comparisons of the dpmpar constants with their */
+/*     machar counterparts. descriptions of the machine constants are */
+/*     given in the prologue comments of machar. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... machar,dpmpar */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+/* Main program */
+int main(int argc, char **argv)
+{
+    /* Local variables */
+    int it;
+    real eps;
+    int ngrd, irnd, iexp;
+    real rerr[3], xmin, xmax;
+    int ibeta, negep;
+    real giant, dwarf;
+    int machep;
+    real epsmch, epsneg;
+    int minexp, maxexp;
+
+/*     determine the machine constants dynamically from machar. */
+
+    machar_(&ibeta, &it, &irnd, &ngrd, &machep, &negep, &iexp, &minexp, &
+	    maxexp, &eps, &epsneg, &xmin, &xmax);
+
+/*     compare the dpmpar constants with their machar counterparts and */
+/*     store the relative differences in rerr. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+    dwarf = __cminpack_func__(dpmpar)(2);
+    giant = __cminpack_func__(dpmpar)(3);
+    rerr[0] = (epsmch - eps) / epsmch;
+    rerr[1] = (dwarf - xmin) / dwarf;
+    rerr[2] = (xmax - giant) / giant;
+
+/*     write the MACHAR constants. */
+
+    printf("\f MACHAR constants\n\n\n");
+    printf(" ibeta =%6i\n\n", ibeta);
+    printf(" it    =%6i\n\n", it);
+    printf(" irnd  =%6i\n\n", irnd);
+    printf(" ngrd  =%6i\n\n", ngrd);
+    printf(" machep =%6i\n\n", machep);
+    printf(" negep =%6i\n\n", negep);
+    printf(" iexp =%6i\n\n", iexp);
+    printf(" minexp =%6i\n\n", minexp);
+    printf(" maxexp =%6i\n\n", maxexp);
+    printf(" eps =%15.7e\n\n", (double)eps);
+    printf(" epsneg =%15.7e\n\n", (double)epsneg);
+    printf(" xmin =%15.7e\n\n", (double)xmin);
+    printf(" xmax =%15.7e\n\n", (double)xmax);
+
+
+/*     write the DPMPAR constants and the relative differences. */
+
+    printf("\n\n DPMPAR constants and relative differences\n\n\n");
+    printf(" epsmch =%15.7e\n", (double)epsmch);
+    printf(" rerr(1) =%15.7e\n\n", (double)rerr[0]);
+    printf(" dwarf =%15.7e\n", (double)dwarf);
+    printf(" rerr(2) =%15.7e\n\n", (double)rerr[1]);
+    printf(" giant =%15.7e\n", (double)giant);
+    printf(" rerr(3) =%15.7e\n", (double)rerr[2]);
+
+    return 0;
+} /* MAIN__ */
+
diff --git a/examples/ibmdpdr.f b/examples/ibmdpdr.f
new file mode 100644
index 0000000..6f00e12
--- /dev/null
+++ b/examples/ibmdpdr.f
@@ -0,0 +1,72 @@
+c     **********
+c
+c     this program checks the constants of machine precision and
+c     smallest and largest machine representable numbers specified in
+c     function dpmpar, against the corresponding hardware-determined
+c     machine constants obtained by machar, a subroutine due to
+c     w. j. cody.
+c
+c     data statements in dpmpar corresponding to the machine used must
+c     be activated by removing c in column 1.
+c
+c     the printed output consists of the machine constants obtained by
+c     machar and comparisons of the dpmpar constants with their
+c     machar counterparts. descriptions of the machine constants are
+c     given in the prologue comments of machar.
+c
+c     subprograms called
+c
+c       minpack-supplied ... machar,dpmpar
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer ibeta,iexp,irnd,it,machep,maxexp,minexp,negep,ngrd,
+     *        nwrite
+      double precision dwarf,eps,epsmch,epsneg,giant,xmax,xmin
+      double precision rerr(3)
+      double precision dpmpar
+c
+c     logical output unit is assumed to be number 6.
+c
+      data nwrite /6/
+c
+c     determine the machine constants dynamically from machar.
+c
+      call machar(ibeta,it,irnd,ngrd,machep,negep,iexp,minexp,maxexp,
+     *            eps,epsneg,xmin,xmax)
+c
+c     compare the dpmpar constants with their machar counterparts and
+c     store the relative differences in rerr.
+c
+      epsmch = dpmpar(1)
+      dwarf = dpmpar(2)
+      giant = dpmpar(3)
+      rerr(1) = (epsmch - eps)/epsmch
+      rerr(2) = (dwarf - xmin)/dwarf
+      rerr(3) = (xmax - giant)/giant
+c
+c     write the machar constants.
+c
+      write (nwrite,10)
+     *      ibeta,it,irnd,ngrd,machep,negep,iexp,minexp,maxexp,eps,
+     *      epsneg,xmin,xmax
+c
+c     write the dpmpar constants and the relative differences.
+c
+      write (nwrite,20) epsmch,rerr(1),dwarf,rerr(2),giant,rerr(3)
+      stop
+   10 format (17h1MACHAR constants /// 8h ibeta =, i6 // 8h it    =,
+     *        i6 // 8h irnd  =, i6 // 8h ngrd  =, i6 // 9h machep =,
+     *        i6 // 8h negep =, i6 // 7h iexp =, i6 // 9h minexp =,
+     *        i6 // 9h maxexp =, i6 // 6h eps =, d15.7 // 9h epsneg =,
+     *        d15.7 // 7h xmin =, d15.7 // 7h xmax =, d15.7)
+   20 format ( /// 42h dpmpar constants and relative differences ///
+     *         9h epsmch =, d15.7 / 10h rerr(1) =, d15.7 //
+     *         8h dwarf =, d15.7 / 10h rerr(2) =, d15.7 // 8h giant =,
+     *         d15.7 / 10h rerr(3) =, d15.7)
+c
+c     last card of driver.
+c
+      end
diff --git a/examples/ibmdpdr_ b/examples/ibmdpdr_
new file mode 100755
index 0000000..adf0955
Binary files /dev/null and b/examples/ibmdpdr_ differ
diff --git a/examples/ibmdpdr_.c b/examples/ibmdpdr_.c
new file mode 100644
index 0000000..2e571bd
--- /dev/null
+++ b/examples/ibmdpdr_.c
@@ -0,0 +1,95 @@
+#include <stdio.h>
+#include <math.h>
+#include "minpack.h"
+#define real __minpack_real__
+
+extern void machar_(int *ibeta, int *it, int *irnd, 
+                    int *ngrd, int *machep, int *negep, int *iexp, 
+                    int *minexp, int *maxexp, real *eps, real *epsneg,
+                    real *xmin, real *xmax);
+
+/*     ********** */
+
+/*     this program checks the constants of machine precision and */
+/*     smallest and largest machine representable numbers specified in */
+/*     function dpmpar, against the corresponding hardware-determined */
+/*     machine constants obtained by machar, a subroutine due to */
+/*     w. j. cody. */
+
+/*     data statements in dpmpar corresponding to the machine used must */
+/*     be activated by removing c in column 1. */
+
+/*     the printed output consists of the machine constants obtained by */
+/*     machar and comparisons of the dpmpar constants with their */
+/*     machar counterparts. descriptions of the machine constants are */
+/*     given in the prologue comments of machar. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... machar,dpmpar */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+/* Main program */
+int main(int argc, char **argv)
+{
+    /* Local variables */
+    int it;
+    real eps;
+    int ngrd, irnd, iexp;
+    real rerr[3], xmin, xmax;
+    int ibeta, negep;
+    real giant, dwarf;
+    int machep;
+    real epsmch, epsneg;
+    int minexp, maxexp;
+    const int i1 = 1, i2 = 2, i3 = 3;
+
+/*     determine the machine constants dynamically from machar. */
+
+    machar_(&ibeta, &it, &irnd, &ngrd, &machep, &negep, &iexp, &minexp, &
+	    maxexp, &eps, &epsneg, &xmin, &xmax);
+
+/*     compare the dpmpar constants with their machar counterparts and */
+/*     store the relative differences in rerr. */
+
+    epsmch = __minpack_func__(dpmpar)(&i1);
+    dwarf = __minpack_func__(dpmpar)(&i2);
+    giant = __minpack_func__(dpmpar)(&i3);
+    rerr[0] = (epsmch - eps) / epsmch;
+    rerr[1] = (dwarf - xmin) / dwarf;
+    rerr[2] = (xmax - giant) / giant;
+
+/*     write the MACHAR constants. */
+
+    printf("\f MACHAR constants\n\n\n");
+    printf(" ibeta =%6i\n\n", ibeta);
+    printf(" it    =%6i\n\n", it);
+    printf(" irnd  =%6i\n\n", irnd);
+    printf(" ngrd  =%6i\n\n", ngrd);
+    printf(" machep =%6i\n\n", machep);
+    printf(" negep =%6i\n\n", negep);
+    printf(" iexp =%6i\n\n", iexp);
+    printf(" minexp =%6i\n\n", minexp);
+    printf(" maxexp =%6i\n\n", maxexp);
+    printf(" eps =%15.7e\n\n", (double)eps);
+    printf(" epsneg =%15.7e\n\n", (double)epsneg);
+    printf(" xmin =%15.7e\n\n", (double)xmin);
+    printf(" xmax =%15.7e\n\n", (double)xmax);
+
+
+/*     write the DPMPAR constants and the relative differences. */
+
+    printf("\n\n DPMPAR constants and relative differences\n\n\n");
+    printf(" epsmch =%15.7e\n", (double)epsmch);
+    printf(" rerr(1) =%15.7e\n\n", (double)rerr[0]);
+    printf(" dwarf =%15.7e\n", (double)dwarf);
+    printf(" rerr(2) =%15.7e\n\n", (double)rerr[1]);
+    printf(" giant =%15.7e\n", (double)giant);
+    printf(" rerr(3) =%15.7e\n", (double)rerr[2]);
+
+    return 0;
+} /* MAIN__ */
+
diff --git a/examples/ibmdpdrc b/examples/ibmdpdrc
new file mode 100755
index 0000000..e6bd91e
Binary files /dev/null and b/examples/ibmdpdrc differ
diff --git a/examples/lhesfcn.f b/examples/lhesfcn.f
new file mode 100644
index 0000000..146e272
--- /dev/null
+++ b/examples/lhesfcn.f
@@ -0,0 +1,663 @@
+      subroutine hesfcn(n,x,h,ldh,nprob)
+      integer n,ldh,nprob
+      double precision x(n),h(ldh)
+c     **********
+c
+c     subroutine hesfcn
+c
+c     this subroutine defines the hessian matrices of eighteen
+c     nonlinear unconstrained minimization problems. the problem
+c     dimensions are as described in the prologue comments of objfcn.
+c     the upper triangle of the (symmetric) hessian matrix is
+c     computed columnwise and stored as a one-dimensional array.
+c
+c     the subroutine statement is
+c
+c       subroutine hesfcn(n,x,h,ldh,nprob)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an input array of length n.
+c
+c       h is an array of length ldh. on output h contains the hessian
+c         matrix of the nprob objective function evaluated at x.
+c
+c       ldh is a positive integer input variable not less than
+c         (n*(n+1))/2 which specifies the dimension of the array h.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin,
+c                            dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iev,ivar,j,k,n2
+      integer ij,ijm1,ijp1,ijp2,ijp3,ki,kip1,kj,kjp1,ntr
+      double precision ap,arg,cp0001,cp1,cp25,cp5,c1p5,c2p25,
+     *                 c2p625,c3p5,c19p8,c25,c29,c100,c200,c10000,d1,
+     *                 d2,eight,fifty,five,four,one,r,s1,s2,s3,t,t1,
+     *                 t2,t3,ten,th,three,tpi,twenty,two,zero
+      double precision d3,r1,r2,r3,u1,u2,v,v1,v2
+      double precision fvec(50),fvec1(50),y(15)
+      double precision dfloat
+      double precision six,xnine,twelve,c120,c200p2,c202,c220p2,c360,
+     *                 c400,c1200
+      data six,xnine,twelve,c120,c200p2,c202,c220p2,c360,c400,c1200
+     *     /6.0d0,9.0d0,1.2d1,1.2d2,2.002d2,2.02d2,2.202d2,3.6d2,
+     *      4.0d2,1.2d3/
+      data zero,one,two,three,four,five,eight,ten,twenty,fifty
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,2.0d1,
+     *      5.0d1/
+      data cp0001,cp1,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c19p8,c25,c29,
+     *     c100,c200,c10000
+     *     /1.0d-4,1.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,2.625d0,3.5d0,
+     *      1.98d1,2.5d1,2.9d1,1.0d2,2.0d2,1.0d4/
+      data ap /1.0d-5/
+      data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11),
+     *     y(12),y(13),y(14),y(15)
+     *     /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1,
+     *      3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3,
+     *      9.0d-4/
+      dfloat(ivar) = ivar
+c
+c     hessian routine selector.
+c
+      go to (10,20,60,100,110,170,210,290,330,380,390,450,490,580,620,
+     *       660,670,680), nprob
+c
+c     helical valley function.
+c
+   10 continue
+      tpi = eight*datan(one)
+      th = dsign(cp25,x(2))
+      if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi
+      if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5
+      arg = x(1)**2 + x(2)**2
+      r = dsqrt(arg)
+      t = x(3) - ten*th
+      s1 = ten*t/(tpi*arg)
+      t1 = ten/tpi
+      t2 = t1/arg
+      t3 = (x(1)/r - t1*t2*x(1) - two*x(2)*s1)/arg
+      h(1) = c200
+     *         *(one - x(2)/arg*(x(2)/r - t1*t2*x(2) + two*x(1)*s1))
+      h(2) = c200*(s1 + x(2)*t3)
+      h(3) = c200*(one - x(1)*t3)
+      h(4) = c200*t2*x(2)
+      h(5) = -c200*t2*x(1)
+      h(6) = c202
+      go to 800
+c
+c     biggs exp6 function.
+c
+   20 continue
+      do 40 ij = 1, 21
+         h(ij) = zero
+   40    continue
+      do 50 i = 1, 13
+         d1 = dfloat(i)/ten
+         d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1)
+         s1 = dexp(-d1*x(1))
+         s2 = dexp(-d1*x(2))
+         s3 = dexp(-d1*x(5))
+         t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2
+         th = d1*t
+         r1 = d1*s1
+         r2 = d1*s2
+         r3 = d1*s3
+         h(1) = h(1) + r1*(th + x(3)*r1)
+         h(2) = h(2) - r1*r2
+         h(3) = h(3) - r2*(th - x(4)*r2)
+         h(4) = h(4) - s1*(th + x(3)*r1)
+         h(6) = h(6) + s1**2
+         h(7) = h(7) + r1*s2
+         h(8) = h(8) + s2*(th - x(4)*r2)
+         h(9) = h(9) - s1*s2
+         h(10) = h(10) + s2**2
+         h(11) = h(11) + r1*r3
+         h(12) = h(12) - r2*r3
+         h(15) = h(15) + r3*(th + x(6)*r3)
+         h(16) = h(16) - r1*s3
+         h(17) = h(17) + r2*s3
+         h(18) = h(18) + s1*s3
+         h(19) = h(19) - s2*s3
+         h(20) = h(20) - s3*(th + x(6)*r3)
+         h(21) = h(21) + s3**2
+   50    continue
+      h(1) = two*x(3)*h(1)
+      h(2) = two*x(3)*x(4)*h(2)
+      h(3) = two*x(4)*h(3)
+      h(4) = two*h(4)
+      h(5) = two*x(4)*h(7)
+      h(6) = two*h(6)
+      h(7) = two*x(3)*h(7)
+      h(8) = two*h(8)
+      h(9) = two*h(9)
+      h(10) = two*h(10)
+      h(11) = two*x(3)*x(6)*h(11)
+      h(12) = two*x(4)*x(6)*h(12)
+      h(13) = two*x(6)*h(16)
+      h(14) = two*x(6)*h(17)
+      h(15) = two*x(6)*h(15)
+      h(16) = two*x(3)*h(16)
+      h(17) = two*x(4)*h(17)
+      h(18) = two*h(18)
+      h(19) = two*h(19)
+      h(20) = two*h(20)
+      h(21) = two*h(21)
+      go to 800
+c
+c     gaussian function.
+c
+   60 continue
+      do 80 ij = 1, 6
+         h(ij) = zero
+   80    continue
+      do 90 i = 1, 15
+         d1 = cp5*dfloat(i-1)
+         d2 = c3p5 - d1 - x(3)
+         arg = -cp5*x(2)*d2**2
+         r = dexp(arg)
+         t = x(1)*r - y(i)
+         s1 = r*t
+         s2 = d2*s1
+         t1 = s2 + d2*x(1)*r**2
+         t2 = d2*t1
+         h(1) = h(1) + r**2
+         h(2) = h(2) - t2
+         h(3) = h(3) + d2**2*t2
+         h(4) = h(4) + t1
+         h(5) = h(5) + two*s2 - d2*x(2)*t2
+         h(6) = h(6) + x(2)*t2 - s1
+   90    continue
+      h(1) = two*h(1)
+      h(2) = h(2)
+      h(3) = cp5*x(1)*h(3)
+      h(4) = two*x(2)*h(4)
+      h(5) = x(1)*h(5)
+      h(6) = two*x(1)*x(2)*h(6)
+      go to 800
+c
+c     powell badly scaled function.
+c
+  100 continue
+      t1 = c10000*x(1)*x(2) - one
+      s1 = dexp(-x(1))
+      s2 = dexp(-x(2))
+      t2 = s1 + s2 - one - cp0001
+      h(1) = two*((c10000*x(2))**2 + s1*(s1 + t2))
+      h(2) = two*(c10000*(one + two*t1) + s1*s2)
+      h(3) = two*((c10000*x(1))**2 + s2*(s2 + t2))
+      go to 800
+c
+c     box 3-dimensional function.
+c
+  110 continue
+      do 130 ij = 1, 6
+         h(ij) = zero
+  130    continue
+      do 140 i = 1, 10
+         d1 = dfloat(i)
+         d2 = d1/ten
+         s1 = dexp(-d2*x(1))
+         s2 = dexp(-d2*x(2))
+         s3 = dexp(-d2) - dexp(-d1)
+         t = s1 - s2 - s3*x(3)
+         th = d2*t
+         r1 = d2*s1
+         r2 = d2*s2
+         h(1) = h(1) + r1*(th + r1)
+         h(2) = h(2) - r1*r2
+         h(3) = h(3) - r2*(th - r2)
+         h(4) = h(4) + r1*s3
+         h(5) = h(5) - r2*s3
+         h(6) = h(6) + s3**2
+  140    continue
+      do 160 ij = 1, 6
+         h(ij) = two*h(ij)
+  160    continue
+      go to 800
+c
+c     variably dimensioned function.
+c
+  170 continue
+      t1 = zero
+      do 180 j = 1, n
+         t1 = t1 + dfloat(j)*(x(j) - one)
+  180    continue
+c     t = t1*(one + two*t1**2)
+      t2 = two + twelve*t1**2
+      ij = 0
+      do 200 j = 1, n
+         do 190 i = 1, j
+            ij = ij + 1
+            h(ij) = dfloat(i*j)*t2
+  190       continue
+         h(ij) = h(ij) + two
+  200    continue
+      go to 800
+c
+c     watson function.
+c
+  210 continue
+      ntr = (n*(n + 1))/2
+      do 230 kj = 1, ntr
+         h(kj) = zero
+  230    continue
+      do 280 i = 1, 29
+         d1 = dfloat(i)/c29
+         s1 = zero
+         d2 = one
+         do 240 j = 2, n
+            s1 = s1 + dfloat(j-1)*d2*x(j)
+            d2 = d1*d2
+  240       continue
+         s2 = zero
+         d2 = one
+         do 250 j = 1, n
+            s2 = s2 + d2*x(j)
+            d2 = d1*d2
+  250       continue
+         t = s1 - s2**2 - one
+         s3 = two*d1*s2
+         d2 = two/d1
+         th = two*d1**2*t
+         kj = 0
+         do 270 j = 1, n
+            v = dfloat(j-1) - s3
+            d3 = one/d1
+            do 260 k = 1, j
+               kj = kj + 1
+               h(kj) = h(kj) + d2*d3*(v*(dfloat(k-1) - s3) - th)
+               d3 = d1*d3
+  260          continue
+            d2 = d1*d2
+  270       continue
+  280    continue
+      t1 = x(2) - x(1)**2 - one
+      h(1) = h(1) + eight*x(1)**2 + two - four*t1
+      h(2) = h(2) - four*x(1)
+      h(3) = h(3) + two
+      go to 800
+c
+c     penalty function i.
+c
+  290 continue
+      t1 = -cp25
+      do 300 j = 1, n
+         t1 = t1 + x(j)**2
+  300    continue
+      d1 = two*ap
+      th = four*t1
+      ij = 0
+      do 320 j = 1, n
+         t2 = eight*x(j)
+         do 310 i = 1, j
+            ij = ij + 1
+            h(ij) = x(i)*t2
+  310       continue
+         h(ij) = h(ij) + d1 + th
+  320    continue
+      go to 800
+c
+c     penalty function ii.
+c
+  330 continue
+      t1 = -one
+      do 340 j = 1, n
+         t1 = t1 + dfloat(n-j+1)*x(j)**2
+  340    continue
+      d1 = dexp(cp1)
+      d2 = one
+      th = four*t1
+      ij = 0
+      do 370 j = 1, n
+         t2 = eight*dfloat(n-j+1)*x(j)
+         do 350 i = 1, j
+            ij = ij + 1
+            h(ij) = dfloat(n-i+1)*x(i)*t2
+  350       continue
+         h(ij) = h(ij) + dfloat(n-j+1)*th
+         s1 = dexp(x(j)/ten)
+         if (j .eq. 1) go to 360
+         s3 = s1 + s2 - d2*(d1 + one)
+         h(ij) = h(ij) + ap*s1*(s3 + three*s1 - one/d1)/fifty
+         h(ij-1) = h(ij-1) + ap*s1*s2/fifty
+         h(ijm1) = h(ijm1) + ap*s2*(s2 + s3)/fifty
+  360    continue
+         s2 = s1
+         d2 = d1*d2
+         ijm1 = ij
+  370    continue
+      h(1) = h(1) + two
+      go to 800
+c
+c     brown badly scaled function.
+c
+  380 continue
+c     t1 = x(1) - c1pd6
+c     t2 = x(2) - c2pdm6
+      t3 = x(1)*x(2) - two
+      h(1) = two*(one + x(2)**2)
+      h(2) = four*(one + t3)
+      h(3) = two*(one + x(1)**2)
+      go to 800
+c
+c     brown and dennis function.
+c
+  390 continue
+      do 410 ij = 1, 10
+         h(ij) = zero
+  410    continue
+      do 420 i = 1, 20
+         d1 = dfloat(i)/five
+         d2 = dsin(d1)
+         t1 = x(1) + d1*x(2) - dexp(d1)
+         t2 = x(3) + d2*x(4) - dcos(d1)
+         t = t1**2 + t2**2
+c        s1 = t1*t
+c        s2 = t2*t
+         s3 = two*t1*t2
+         r1 = t + two*t1**2
+         r2 = t + two*t2**2
+         h(1) = h(1) + r1
+         h(2) = h(2) + d1*r1
+         h(3) = h(3) + d1**2*r1
+         h(4) = h(4) + s3
+         h(5) = h(5) + d1*s3
+         h(6) = h(6) + r2
+         h(7) = h(7) + d2*s3
+         h(8) = h(8) + d1*d2*s3
+         h(9) = h(9) + d2*r2
+         h(10) = h(10) + d2**2*r2
+  420    continue
+      do 440 ij = 1, 10
+         h(ij) = four*h(ij)
+  440    continue
+      go to 800
+c
+c     gulf research and development function.
+c
+  450 continue
+      do 470 ij = 1, 6
+         h(ij) = zero
+  470    continue
+      d1 = two/three
+      do 480 i = 1, 99
+         arg = dfloat(i)/c100
+         r = (-fifty*dlog(arg))**d1 + c25 - x(2)
+         t1 = dabs(r)**x(3)/x(1)
+         t2 = dexp(-t1)
+         t = t2 - arg
+         s1 = t1*t2*t
+         s2 = t1*(s1 + t2*(t1*t2 - t))
+         r1 = dlog(dabs(r))
+         r2 = r1*s2
+         h(1) = h(1) + s2 - s1
+         h(2) = h(2) + s2/r
+         h(3) = h(3) + (s1 + x(3)*s2)/r**2
+         h(4) = h(4) - r2
+         h(5) = h(5) + (s1 - x(3)*r2)/r
+         h(6) = h(6) + r1*r2
+  480    continue
+      h(1) = two*h(1)/x(1)**2
+      h(2) = two*x(3)*h(2)/x(1)
+      h(3) = two*x(3)*h(3)
+      h(4) = two*h(4)/x(1)
+      h(5) = two*h(5)
+      h(6) = two*h(6)
+      go to 800
+c
+c     trigonometric function.
+c
+  490 continue
+      u2 = dcos(x(n))
+      s1 = u2
+      if (n .eq. 1) go to 510
+      u1 = dcos(x(n-1))
+      s1 = s1 + u1
+      if (n .eq. 2) go to 510
+      n2 = n - 2
+      ntr = (n2*(n - 1))/2
+      kj = ntr
+      do 500 j = 1, n2
+         kj = kj + 1
+         h(kj) = dcos(x(j))
+         s1 = s1 + h(kj)
+  500    continue
+  510 continue
+      v2 = dsin(x(n))
+      s2 = dfloat(2*n) - v2 - s1 - dfloat(n)*u2
+      r2 = dfloat(2*n)*v2 - u2
+      ij = 0
+      if (n .eq. 1) go to 570
+      v1 = dsin(x(n-1))
+      s2 = s2 + dfloat(2*n-1) - v1 - s1 - dfloat(n-1)*u1
+      r1 = dfloat(2*n-1)*v1 - u1
+      if (n .eq. 2) go to 560
+      kj = ntr
+      do 520 j = 1, n2
+         kjp1 = kj + n
+         kj = kj + 1
+         h(kjp1) = dsin(x(j))
+         t = dfloat(n+j) - h(kjp1) - s1 - dfloat(j)*h(kj)
+         s2 = s2 + t
+  520    continue
+      kj = ntr
+      do 540 j = 1, n2
+         kjp1 = kj + n
+         kj = kj + 1
+         v = dfloat(j)*h(kj) + h(kjp1)
+         t = dfloat(n+j) - s1 - v
+         t1 = dfloat(n+j)*h(kjp1) - h(kj)
+         ki = ntr
+         do 530 i = 1, j
+            ij = ij + 1
+            kip1 = ki + n
+            ki = ki + 1
+            th = dfloat(i)*h(kip1) - h(ki)
+            h(ij) = two*(h(kip1)*t1 + h(kjp1)*th)
+  530       continue
+         h(ij) = h(ij) + two*(h(kj)*s2 + v*t + th**2)
+  540    continue
+      do 550 i = 1, n2
+         ijp1 = ij + n
+         ij = ij + 1
+         th = dfloat(i)*h(ijp1) - h(ij)
+         h(ij) = two*(h(ijp1)*r1 + v1*th)
+         h(ijp1) = two*(h(ijp1)*r2 + v2*th)
+  550    continue
+  560 continue
+      v = dfloat(n-1)*u1 + v1
+      t = dfloat(2*n-1) - s1 - v
+      th = dfloat(n-1)*v1 - u1
+      ijp1 = ij + n
+      ij = ij + 1
+      h(ij) = two*(v1*(r1 + th) + u1*s2 + v*t + th**2)
+      h(ijp1) = two*(v1*r2 + v2*th)
+  570 continue
+      v = dfloat(n)*u2 + v2
+      t = dfloat(2*n) - s1 - v
+      th = dfloat(n)*v2 - u2
+      ijp1 = ij + n
+      h(ijp1) = two*(v2*(r2 + th) + u2*s2 + v*t + th**2)
+      go to 800
+c
+c     extended rosenbrock function.
+c
+  580 continue
+      ntr = (n*(n + 1))/2
+      do 600 ij = 1, ntr
+         h(ij) = zero
+  600    continue
+      ijp1 = 0
+      do 610 j = 1, n, 2
+c        t1 = one - x(j)
+         ij = ijp1 + j
+         ijp1 = ij + j + 1
+         h(ij) = c1200*x(j)**2 - c400*x(j+1) + two
+         h(ijp1-1) = -c400*x(j)
+         h(ijp1) = c200
+  610    continue
+      go to 800
+c
+c     extended powell function.
+c
+  620 continue
+      ntr = (n*(n + 1))/2
+      do 640 ij = 1, ntr
+         h(ij) = zero
+  640    continue
+      ijp3 = 0
+      do 650 j = 1, n, 4
+c        t = x(j) + ten*x(j+1)
+c        t1 = x(j+2) - x(j+3)
+c        s1 = five*t1
+         t2 = x(j+1) - two*x(j+2)
+c        s2 = four*t2**3
+         t3 = x(j) - x(j+3)
+c        s3 = twenty*t3**3
+         r2 = twelve*t2**2
+         r3 = c120*t3**2
+         ij = ijp3 + j
+         ijp1 = ij + j + 1
+         ijp2 = ijp1 + j + 2
+         ijp3 = ijp2 + j + 3
+         h(ij) = two + r3
+         h(ijp1-1) = twenty
+         h(ijp1) = c200 + r2
+         h(ijp2-1) = -two*r2
+         h(ijp2) = ten + four*r2
+         h(ijp3-3) = -r3
+         h(ijp3-1) = -ten
+         h(ijp3) = ten + r3
+  650    continue
+      go to 800
+c
+c     beale function.
+c
+  660 continue
+      s1 = one - x(2)
+      t1 = c1p5 - x(1)*s1
+      s2 = one - x(2)**2
+      t2 = c2p25 - x(1)*s2
+      s3 = one - x(2)**3
+      t3 = c2p625 - x(1)*s3
+      h(1) = two*(s1**2 + s2**2 + s3**2)
+      h(2) = two
+     *         *(t1 + x(2)*(two*t2 + three*x(2)*t3)
+     *           - x(1)*(s1 + x(2)*(two*s2 + three*x(2)*s3)))
+      h(3) = two*x(1)
+     *         *(x(1) + two*t2
+     *           + x(2)*(six*t3 + x(1)*x(2)*(four + xnine*x(2)**2)))
+      go to 800
+c
+c     wood function.
+c
+  670 continue
+      s1 = x(2) - x(1)**2
+c     s2 = one - x(1)
+c     s3 = x(2) - one
+      t1 = x(4) - x(3)**2
+c     t2 = one - x(3)
+c     t3 = x(4) - one
+      h(1) = c400*(two*x(1)**2 - s1) + two
+      h(2) = -c400*x(1)
+      h(3) = c220p2
+      h(4) = zero
+      h(5) = zero
+      h(6) = c360*(two*x(3)**2 - t1) + two
+      h(7) = zero
+      h(8) = c19p8
+      h(9) = -c360*x(3)
+      h(10) = c200p2
+      go to 800
+c
+c     chebyquad function.
+c
+  680 continue
+      do 690 i = 1, n
+         fvec(i) = zero
+  690    continue
+      do 710 j = 1, n
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         do 700 i = 1, n
+            fvec(i) = fvec(i) + t2
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  700       continue
+  710    continue
+      d1 = one/dfloat(n)
+      iev = -1
+      do 720 i = 1, n
+         fvec(i) = d1*fvec(i)
+         if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one)
+         iev = -iev
+  720    continue
+      kj = 0
+      do 770 j = 1, n
+         do 730 k = 1, j
+            kj = kj + 1
+            h(kj) = zero
+  730       continue
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         s1 = zero
+         s2 = two
+         r1 = zero
+         r2 = zero
+         do 740 i = 1, n
+            h(kj) = h(kj) + fvec(i)*r2
+            th = eight*s2 + t*r2 - r1
+            r1 = r2
+            r2 = th
+            fvec1(i) = d1*s2
+            th = four*t2 + t*s2 - s1
+            s1 = s2
+            s2 = th
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  740       continue
+         kj = kj - j
+         do 760 k = 1, j
+            kj = kj + 1
+            v1 = one
+            v2 = two*x(k) - one
+            v = two*v2
+            u1 = zero
+            u2 = two
+            do 750 i = 1, n
+               h(kj) = h(kj) + fvec1(i)*u2
+               th = four*v2 + v*u2 - u1
+               u1 = u2
+               u2 = th
+               th = v*v2 - v1
+               v1 = v2
+               v2 = th
+  750          continue
+  760       continue
+  770    continue
+      d2 = two*d1
+      ntr = (n*(n + 1))/2
+      do 790 kj = 1, ntr
+         h(kj) = d2*h(kj)
+  790    continue
+  800 continue
+      return
+c
+c     last card of subroutine hesfcn.
+c
+      end
diff --git a/examples/lmddrv.c b/examples/lmddrv.c
new file mode 100644
index 0000000..2e3db57
--- /dev/null
+++ b/examples/lmddrv.c
@@ -0,0 +1,228 @@
+/* Usage: lmddrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "cminpack.h"
+#include "ssq.h"
+#define real __cminpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the least-squares solution of */
+/*     m nonlinear equations in n variables. it consists of a driver */
+/*     and an interface subroutine fcn. the driver reads in data, */
+/*     calls the nonlinear least-squares solver, and finally prints */
+/*     out information on the performance of the solver. this is */
+/*     only a sample driver, many other drivers are possible. the */
+/*     interface subroutine fcn is necessary to take into account the */
+/*     forms of calling sequences used by the function and jacobian */
+/*     subroutines in the various nonlinear least-squares solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,initpt,lmder1,ssqfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac,
+        int ldfjac, int iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,m,n,ntries;
+    struct refnum lmdertest;
+    int info;
+
+    int ma[60];
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fjac[65*40];
+
+    real fnm[60];
+    real fvec[65];
+    real x[40];
+
+    int ipvt[40];
+
+    real wa[5*40+65];
+    const int lwa = 5*40+65;
+
+    tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d%5d\n", &lmdertest.nprob, &n, &m, &ntries);
+/*
+         read (nread,50) nprob,n,m,ntries
+   50 format (4i5)
+*/
+        if (lmdertest.nprob <= 0.)
+            break;
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            lmdipt(n,x,lmdertest.nprob,factor);
+
+            ssqfcn(m,n,x,fvec,lmdertest.nprob);
+
+            fnorm1 = __cminpack_func__(enorm)(m,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmdertest.nprob, n, m);
+/*
+            write (nwrite,60) nprob,n,m
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+*/
+
+            lmdertest.nfev = 0;
+            lmdertest.njev = 0;
+
+            info = __cminpack_func__(lmder1)(fcn,&lmdertest,m,n,x,fvec,fjac,m,tol,ipvt,wa,lwa);
+
+            ssqfcn(m,n,x,fvec,lmdertest.nprob);
+
+            fnorm2 = __cminpack_func__(enorm)(m,fvec);
+
+            np[ic] = lmdertest.nprob;
+            na[ic] = n;
+            ma[ic] = m;
+            nf[ic] = lmdertest.nfev;
+            nj[ic] = lmdertest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, lmdertest.nfev, lmdertest.njev, info);
+            printvec(n, x);
+/*
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+*/
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to lmder1: \n\n", ic);
+/*
+      write (nwrite,80) ic
+   80 format (12h1summary of , i3, 16h calls to lmder1 /)
+*/
+    printf("\n\n nprob   n    m   nfev  njev  info  final L2 norm \n\n");
+/*
+      write (nwrite,90)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+*/
+
+    for (i = 0; i < ic; ++i) {
+        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
+               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+/*
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+  100 format (3i5, 3i6, 1x, d15.7)
+*/
+
+    }
+    exit(0);
+}
+
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac,
+	 int ldfjac, int iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     least-squares solver. fcn should only call the testing */
+/*     function and jacobian subroutines ssqfcn and ssqjac with */
+/*     the appropriate value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... ssqfcn,ssqjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    struct refnum *lmdertest = (struct refnum *)p;
+    if (iflag == 1) {
+        ssqfcn(m,n,x,fvec,lmdertest->nprob);
+        lmdertest->nfev++;
+    }
+    if (iflag == 2) {
+        ssqjac(m,n,x,fjac,ldfjac,lmdertest->nprob);
+        lmdertest->njev++;
+    }
+
+    return 0;
+} /* fcn_ */
diff --git a/examples/lmddrv.f b/examples/lmddrv.f
new file mode 100644
index 0000000..31a34c9
--- /dev/null
+++ b/examples/lmddrv.f
@@ -0,0 +1,124 @@
+c     **********
+c
+c     this program tests codes for the least-squares solution of
+c     m nonlinear equations in n variables. it consists of a driver
+c     and an interface subroutine fcn. the driver reads in data,
+c     calls the nonlinear least-squares solver, and finally prints
+c     out information on the performance of the solver. this is
+c     only a sample driver, many other drivers are possible. the
+c     interface subroutine fcn is necessary to take into account the
+c     forms of calling sequences used by the function and jacobian
+c     subroutines in the various nonlinear least-squares solvers.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,initpt,lmder1,ssqfcn
+c
+c       fortran-supplied ... dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ic,info,k,ldfjac,lwa,m,n,nfev,njev,nprob,nread,ntries,
+     *        nwrite
+      integer iwa(40),ma(60),na(60),nf(60),nj(60),np(60),nx(60)
+      double precision factor,fnorm1,fnorm2,one,ten,tol
+      double precision fjac(65,40),fnm(60),fvec(65),wa(265),x(40)
+      double precision dpmpar,enorm
+      external fcn
+      common /refnum/ nprob,nfev,njev
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data one,ten /1.0d0,1.0d1/
+      tol = dsqrt(dpmpar(1))
+      ldfjac = 65
+      lwa = 265
+      ic = 0
+   10 continue
+         read (nread,50) nprob,n,m,ntries
+         if (nprob .le. 0) go to 30
+         factor = one
+         do 20 k = 1, ntries
+            ic = ic + 1
+            call initpt(n,x,nprob,factor)
+            call ssqfcn(m,n,x,fvec,nprob)
+            fnorm1 = enorm(m,fvec)
+            write (nwrite,60) nprob,n,m
+            nfev = 0
+            njev = 0
+            call lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,iwa,wa,
+     *                  lwa)
+            call ssqfcn(m,n,x,fvec,nprob)
+            fnorm2 = enorm(m,fvec)
+            np(ic) = nprob
+            na(ic) = n
+            ma(ic) = m
+            nf(ic) = nfev
+            nj(ic) = njev
+            nx(ic) = info
+            fnm(ic) = fnorm2
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+            factor = ten*factor
+   20       continue
+         go to 10
+   30 continue
+      write (nwrite,80) ic
+      write (nwrite,90)
+      do 40 i = 1, ic
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+   40    continue
+      stop
+   50 format (4i5)
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+   80 format (12h1summary of , i3, 16h calls to lmder1 /)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+  100 format (3i5, 3i6, 1x, d15.7)
+c
+c     last card of driver.
+c
+      end
+      subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+      integer m,n,ldfjac,iflag
+      double precision x(n),fvec(m),fjac(ldfjac,n)
+c     **********
+c
+c     the calling sequence of fcn should be identical to the
+c     calling sequence of the function subroutine in the nonlinear
+c     least-squares solver. fcn should only call the testing
+c     function and jacobian subroutines ssqfcn and ssqjac with
+c     the appropriate value of problem number (nprob).
+c
+c     subprograms called
+c
+c       minpack-supplied ... ssqfcn,ssqjac
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer nprob,nfev,njev
+      common /refnum/ nprob,nfev,njev
+      if (iflag .eq. 1) call ssqfcn(m,n,x,fvec,nprob)
+      if (iflag .eq. 2) call ssqjac(m,n,x,fjac,ldfjac,nprob)
+      if (iflag .eq. 1) nfev = nfev + 1
+      if (iflag .eq. 2) njev = njev + 1
+      return
+c
+c     last card of interface subroutine fcn.
+c
+      end
diff --git a/examples/lmddrv_ b/examples/lmddrv_
new file mode 100755
index 0000000..fff26e6
Binary files /dev/null and b/examples/lmddrv_ differ
diff --git a/examples/lmddrv_.c b/examples/lmddrv_.c
new file mode 100644
index 0000000..00c9083
--- /dev/null
+++ b/examples/lmddrv_.c
@@ -0,0 +1,227 @@
+/* Usage: lmddrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "minpack.h"
+#include "ssq.h"
+#define real __minpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the least-squares solution of */
+/*     m nonlinear equations in n variables. it consists of a driver */
+/*     and an interface subroutine fcn. the driver reads in data, */
+/*     calls the nonlinear least-squares solver, and finally prints */
+/*     out information on the performance of the solver. this is */
+/*     only a sample driver, many other drivers are possible. the */
+/*     interface subroutine fcn is necessary to take into account the */
+/*     forms of calling sequences used by the function and jacobian */
+/*     subroutines in the various nonlinear least-squares solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,initpt,lmder1,ssqfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac,
+         const int *ldfjac, int *iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+struct refnum lmdertest;
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,m,n,ntries;
+    int info;
+
+    int ma[60];
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fjac[65*40];
+
+    real fnm[60];
+    real fvec[65];
+    real x[40];
+
+    int ipvt[40];
+
+    real wa[5*40+65];
+    const int lwa = 5*40+65;
+    const int i1 = 1;
+
+    tol = sqrt(__minpack_func__(dpmpar)(&i1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d%5d\n", &lmdertest.nprob, &n, &m, &ntries);
+/*
+         read (nread,50) nprob,n,m,ntries
+   50 format (4i5)
+*/
+        if (lmdertest.nprob <= 0.)
+            break;
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            lmdipt(n,x,lmdertest.nprob,factor);
+
+            ssqfcn(m,n,x,fvec,lmdertest.nprob);
+
+            fnorm1 = __minpack_func__(enorm)(&m,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmdertest.nprob, n, m);
+/*
+            write (nwrite,60) nprob,n,m
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+*/
+
+            lmdertest.nfev = 0;
+            lmdertest.njev = 0;
+
+            __minpack_func__(lmder1)(fcn,&m,&n,x,fvec,fjac,&m,&tol,&info,ipvt,wa,&lwa);
+
+            ssqfcn(m,n,x,fvec,lmdertest.nprob);
+
+            fnorm2 = __minpack_func__(enorm)(&m,fvec);
+
+            np[ic] = lmdertest.nprob;
+            na[ic] = n;
+            ma[ic] = m;
+            nf[ic] = lmdertest.nfev;
+            nj[ic] = lmdertest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, lmdertest.nfev, lmdertest.njev, info);
+            printvec(n, x);
+/*
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+*/
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to lmder1: \n\n", ic);
+/*
+      write (nwrite,80) ic
+   80 format (12h1summary of , i3, 16h calls to lmder1 /)
+*/
+    printf("\n\n nprob   n    m   nfev  njev  info  final L2 norm \n\n");
+/*
+      write (nwrite,90)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+*/
+
+    for (i = 0; i < ic; ++i) {
+        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
+               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+/*
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+  100 format (3i5, 3i6, 1x, d15.7)
+*/
+
+    }
+    exit(0);
+}
+
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac,
+         const int *ldfjac, int *iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     least-squares solver. fcn should only call the testing */
+/*     function and jacobian subroutines ssqfcn and ssqjac with */
+/*     the appropriate value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... ssqfcn,ssqjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    if (*iflag == 1) {
+        ssqfcn(*m,*n,x,fvec,lmdertest.nprob);
+        lmdertest.nfev++;
+    }
+    if (*iflag == 2) {
+        ssqjac(*m,*n,x,fjac,*ldfjac,lmdertest.nprob);
+        lmdertest.njev++;
+    }
+} /* fcn_ */
diff --git a/examples/lmdipt.c b/examples/lmdipt.c
new file mode 100644
index 0000000..9753d09
--- /dev/null
+++ b/examples/lmdipt.c
@@ -0,0 +1,214 @@
+#include <math.h>
+#include "cminpack.h"
+#include "ssq.h"
+#define real __cminpack_real__
+
+void lmdipt(int n, real *x, int nprob, real factor)
+{
+    /* Local variables */
+    static real h;
+    static int j;
+
+/*     ********** */
+
+/*     subroutine initpt */
+
+/*     this subroutine specifies the standard starting points for the */
+/*     functions defined by subroutine ssqfcn. the subroutine returns */
+/*     in x a multiple (factor) of the standard starting point. for */
+/*     the 11th function the standard starting point is zero, so in */
+/*     this case, if factor is not unity, then the subroutine returns */
+/*     the vector  x(j) = factor, j=1,...,n. */
+
+/*     the subroutine statement is */
+
+/*       subroutine initpt(n,x,nprob,factor) */
+
+/*     where */
+
+/*       n is a positive integer input variable. */
+
+/*       x is an output array of length n which contains the standard */
+/*         starting point for problem nprob multiplied by factor. */
+
+/*       nprob is a positive integer input variable which defines the */
+/*         number of the problem. nprob must not exceed 18. */
+
+/*       factor is an input variable which specifies the multiple of */
+/*         the standard starting point. if factor is unity, no */
+/*         multiplication is performed. */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+
+/*     selection of initial point. */
+
+    switch (nprob) {
+
+/*     linear function - full rank or rank 1. */
+
+        case 1:
+        case 2:
+        case 3:
+            for (j = 1; j <= n; ++j) {
+                x[j] = 1.;
+            }
+            break;
+
+/*     rosenbrock function. */
+
+        case 4:
+            x[1] = -1.2;
+            x[2] = 1.;
+            break;
+
+/*     helical valley function. */
+
+        case 5:
+            x[1] = -1.;
+            x[2] = 0.;
+            x[3] = 0.;
+            break;
+
+/*     powell singular function. */
+
+        case 6:
+            x[1] = 3.;
+            x[2] = -1.;
+            x[3] = 0.;
+            x[4] = 1.;
+            break;
+
+/*     freudenstein and roth function. */
+
+        case 7:
+            x[1] = .5;
+            x[2] = -2.;
+            break;
+
+/*     bard function. */
+
+        case 8:
+            x[1] = 1.;
+            x[2] = 1.;
+            x[3] = 1.;
+            break;
+
+/*     kowalik and osborne function. */
+
+        case 9:
+            x[1] = .25;
+            x[2] = .39;
+            x[3] = .415;
+            x[4] = .39;
+            break;
+
+/*     meyer function. */
+
+        case 10:
+            x[1] = .02;
+            x[2] = 4e3;
+            x[3] = 250.;
+            break;
+
+/*     watson function. */
+
+        case 11:
+            for (j = 1; j <= n; ++j) {
+                x[j] = 0.;
+            }
+            break;
+
+/*     box 3-dimensional function. */
+
+        case 12:
+            x[1] = 0.;
+            x[2] = 10.;
+            x[3] = 20.;
+            break;
+
+/*     jennrich and sampson function. */
+
+        case 13:
+            x[1] = .3;
+            x[2] = .4;
+            break;
+
+/*     brown and dennis function. */
+
+
+        case 14:
+            x[1] = 25.;
+            x[2] = 5.;
+            x[3] = -5.;
+            x[4] = -1.;
+            break;
+
+/*     chebyquad function. */
+
+        case 15:
+            h = 1. / (real) (n + 1);
+            for (j = 1; j <= n; ++j) {
+                x[j] = (real) j * h;
+            }
+            break;
+
+/*     brown almost-linear function. */
+
+        case 16:
+            for (j = 1; j <= n; ++j) {
+                x[j] = .5;
+            }
+            break;
+
+/*     osborne 1 function. */
+
+        case 17:
+            x[1] = .5;
+            x[2] = 1.5;
+            x[3] = -1.;
+            x[4] = .01;
+            x[5] = .02;
+            break;
+
+/*     osborne 2 function. */
+
+        case 18:
+            x[1] = 1.3;
+            x[2] = .65;
+            x[3] = .65;
+            x[4] = .7;
+            x[5] = .6;
+            x[6] = 3.;
+            x[7] = 5.;
+            x[8] = 7.;
+            x[9] = 2.;
+            x[10] = 4.5;
+            x[11] = 5.5;
+            break;
+    }
+
+/*     compute multiple of initial point. */
+
+    if (factor != 1.) {
+        if (nprob != 11) {
+            for (j = 1; j <= n; ++j) {
+                x[j] *= factor;
+            }
+        } else {
+            for (j = 1; j <= n; ++j) {
+                x[j] = factor;
+            }
+        }
+    }
+
+/*     last card of subroutine initpt. */
+
+} /* initpt_ */
+
diff --git a/examples/lmdipt.f b/examples/lmdipt.f
new file mode 100644
index 0000000..bdc93a3
--- /dev/null
+++ b/examples/lmdipt.f
@@ -0,0 +1,214 @@
+      subroutine initpt(n,x,nprob,factor)
+      integer n,nprob
+      double precision factor
+      double precision x(n)
+c     **********
+c
+c     subroutine initpt
+c
+c     this subroutine specifies the standard starting points for the
+c     functions defined by subroutine ssqfcn. the subroutine returns
+c     in x a multiple (factor) of the standard starting point. for
+c     the 11th function the standard starting point is zero, so in
+c     this case, if factor is not unity, then the subroutine returns
+c     the vector  x(j) = factor, j=1,...,n.
+c
+c     the subroutine statement is
+c
+c       subroutine initpt(n,x,nprob,factor)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an output array of length n which contains the standard
+c         starting point for problem nprob multiplied by factor.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c       factor is an input variable which specifies the multiple of
+c         the standard starting point. if factor is unity, no
+c         multiplication is performed.
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer ivar,j
+      double precision c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,
+     *                 c15,c16,c17,five,h,half,one,seven,ten,three,
+     *                 twenty,twntf,two,zero
+      double precision dfloat
+      data zero,half,one,two,three,five,seven,ten,twenty,twntf
+     *     /0.0d0,5.0d-1,1.0d0,2.0d0,3.0d0,5.0d0,7.0d0,1.0d1,2.0d1,
+     *      2.5d1/
+      data c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17
+     *     /1.2d0,2.5d-1,3.9d-1,4.15d-1,2.0d-2,4.0d3,2.5d2,3.0d-1,
+     *      4.0d-1,1.5d0,1.0d-2,1.3d0,6.5d-1,7.0d-1,6.0d-1,4.5d0,
+     *      5.5d0/
+      dfloat(ivar) = ivar
+c
+c     selection of initial point.
+c
+      go to (10,10,10,30,40,50,60,70,80,90,100,120,130,140,150,170,
+     *       190,200), nprob
+c
+c     linear function - full rank or rank 1.
+c
+   10 continue
+      do 20 j = 1, n
+         x(j) = one
+   20    continue
+      go to 210
+c
+c     rosenbrock function.
+c
+   30 continue
+      x(1) = -c1
+      x(2) = one
+      go to 210
+c
+c     helical valley function.
+c
+   40 continue
+      x(1) = -one
+      x(2) = zero
+      x(3) = zero
+      go to 210
+c
+c     powell singular function.
+c
+   50 continue
+      x(1) = three
+      x(2) = -one
+      x(3) = zero
+      x(4) = one
+      go to 210
+c
+c     freudenstein and roth function.
+c
+   60 continue
+      x(1) = half
+      x(2) = -two
+      go to 210
+c
+c     bard function.
+c
+   70 continue
+      x(1) = one
+      x(2) = one
+      x(3) = one
+      go to 210
+c
+c     kowalik and osborne function.
+c
+   80 continue
+      x(1) = c2
+      x(2) = c3
+      x(3) = c4
+      x(4) = c3
+      go to 210
+c
+c     meyer function.
+c
+   90 continue
+      x(1) = c5
+      x(2) = c6
+      x(3) = c7
+      go to 210
+c
+c     watson function.
+c
+  100 continue
+      do 110 j = 1, n
+         x(j) = zero
+  110    continue
+      go to 210
+c
+c     box 3-dimensional function.
+c
+  120 continue
+      x(1) = zero
+      x(2) = ten
+      x(3) = twenty
+      go to 210
+c
+c     jennrich and sampson function.
+c
+  130 continue
+      x(1) = c8
+      x(2) = c9
+      go to 210
+c
+c     brown and dennis function.
+c
+  140 continue
+      x(1) = twntf
+      x(2) = five
+      x(3) = -five
+      x(4) = -one
+      go to 210
+c
+c     chebyquad function.
+c
+  150 continue
+      h = one/dfloat(n+1)
+      do 160 j = 1, n
+         x(j) = dfloat(j)*h
+  160    continue
+      go to 210
+c
+c     brown almost-linear function.
+c
+  170 continue
+      do 180 j = 1, n
+         x(j) = half
+  180    continue
+      go to 210
+c
+c     osborne 1 function.
+c
+  190 continue
+      x(1) = half
+      x(2) = c10
+      x(3) = -one
+      x(4) = c11
+      x(5) = c5
+      go to 210
+c
+c     osborne 2 function.
+c
+  200 continue
+      x(1) = c12
+      x(2) = c13
+      x(3) = c13
+      x(4) = c14
+      x(5) = c15
+      x(6) = three
+      x(7) = five
+      x(8) = seven
+      x(9) = two
+      x(10) = c16
+      x(11) = c17
+  210 continue
+c
+c     compute multiple of initial point.
+c
+      if (factor .eq. one) go to 260
+      if (nprob .eq. 11) go to 230
+         do 220 j = 1, n
+            x(j) = factor*x(j)
+  220       continue
+         go to 250
+  230 continue
+         do 240 j = 1, n
+            x(j) = factor
+  240       continue
+  250 continue
+  260 continue
+      return
+c
+c     last card of subroutine initpt.
+c
+      end
diff --git a/examples/lmfdrv.c b/examples/lmfdrv.c
new file mode 100644
index 0000000..1ab81e5
--- /dev/null
+++ b/examples/lmfdrv.c
@@ -0,0 +1,223 @@
+/* Usage: lmfdrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "cminpack.h"
+#include "ssq.h"
+#define real __cminpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the least-squares solution of */
+/*     m nonlinear equations in n variables. it consists of a driver */
+/*     and an interface subroutine fcn. the driver reads in data, */
+/*     calls the nonlinear least-squares solver, and finally prints */
+/*     out information on the performance of the solver. this is */
+/*     only a sample driver, many other drivers are possible. the */
+/*     interface subroutine fcn is necessary to take into account the */
+/*     forms of calling sequences used by the function and jacobian */
+/*     subroutines in the various nonlinear least-squares solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,initpt,lmdif1,ssqfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,m,n,ntries;
+    struct refnum lmdiftest;
+    int info;
+
+    int ma[60];
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fnm[60];
+    real fvec[65];
+    real x[40];
+
+    int iwa[40];
+    real wa[65*40+5*40+65];
+    const int lwa = 65*40+5*40+65;
+
+    tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d%5d\n", &lmdiftest.nprob, &n, &m, &ntries);
+/*
+         read (nread,50) nprob,n,m,ntries
+   50 format (4i5)
+*/
+        if (lmdiftest.nprob <= 0.)
+            break;
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            lmdipt(n,x,lmdiftest.nprob,factor);
+
+            ssqfcn(m,n,x,fvec,lmdiftest.nprob);
+
+            fnorm1 = __cminpack_func__(enorm)(m,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmdiftest.nprob, n, m);
+/*
+            write (nwrite,60) nprob,n,m
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+*/
+
+            lmdiftest.nfev = 0;
+            lmdiftest.njev = 0;
+
+            info = __cminpack_func__(lmdif1)(fcn,&lmdiftest,m,n,x,fvec,tol,iwa,wa,lwa);
+
+            ssqfcn(m,n,x,fvec,lmdiftest.nprob);
+
+            fnorm2 = __cminpack_func__(enorm)(m,fvec);
+
+            np[ic] = lmdiftest.nprob;
+            na[ic] = n;
+            ma[ic] = m;
+            nf[ic] = lmdiftest.nfev;
+            lmdiftest.njev /= n;
+            nj[ic] = lmdiftest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of Jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, lmdiftest.nfev, lmdiftest.njev, info);
+            printvec(n, x);
+/*
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+*/
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to lmdif1: \n\n", ic);
+/*
+      write (nwrite,80) ic
+   80 format (12h1summary of , i3, 16h calls to lmdif1 /)
+*/
+    printf("\n\n nprob   n    m   nfev  njev  info  final L2 norm \n\n");
+/*
+      write (nwrite,90)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+*/
+
+    for (i = 0; i < ic; ++i) {
+        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
+               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+/*
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+  100 format (3i5, 3i6, 1x, d15.7)
+*/
+
+    }
+    exit(0);
+}
+
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     least-squares solver. fcn should only call the testing */
+/*     function and jacobian subroutines ssqfcn and ssqjac with */
+/*     the appropriate value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... ssqfcn,ssqjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    struct refnum *lmdiftest = (struct refnum *)p;
+    ssqfcn(m,n,x,fvec,lmdiftest->nprob);
+    if (iflag == 1) {
+        lmdiftest->nfev++;
+    }
+    if (iflag == 2) {
+        lmdiftest->njev++;
+    }
+
+    return 0;
+} /* fcn_ */
diff --git a/examples/lmfdrv.f b/examples/lmfdrv.f
new file mode 100644
index 0000000..ad8756f
--- /dev/null
+++ b/examples/lmfdrv.f
@@ -0,0 +1,121 @@
+c     **********
+c
+c     this program tests codes for the least-squares solution of
+c     m nonlinear equations in n variables. it consists of a driver
+c     and an interface subroutine fcn. the driver reads in data,
+c     calls the nonlinear least-squares solver, and finally prints
+c     out information on the performance of the solver. this is
+c     only a sample driver, many other drivers are possible. the
+c     interface subroutine fcn is necessary to take into account the
+c     forms of calling sequences used by the function and jacobian
+c     subroutines in the various nonlinear least-squares solvers.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,initpt,lmdif1,ssqfcn
+c
+c       fortran-supplied ... dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ic,info,k,lwa,m,n,nfev,njev,nprob,nread,ntries,nwrite
+      integer iwa(40),ma(60),na(60),nf(60),nj(60),np(60),nx(60)
+      double precision factor,fnorm1,fnorm2,one,ten,tol
+      double precision fnm(60),fvec(65),wa(2865),x(40)
+      double precision dpmpar,enorm
+      external fcn
+      common /refnum/ nprob,nfev,njev
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data one,ten /1.0d0,1.0d1/
+      tol = dsqrt(dpmpar(1))
+      lwa = 2865
+      ic = 0
+   10 continue
+         read (nread,50) nprob,n,m,ntries
+         if (nprob .le. 0) go to 30
+         factor = one
+         do 20 k = 1, ntries
+            ic = ic + 1
+            call initpt(n,x,nprob,factor)
+            call ssqfcn(m,n,x,fvec,nprob)
+            fnorm1 = enorm(m,fvec)
+            write (nwrite,60) nprob,n,m
+            nfev = 0
+            njev = 0
+            call lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa)
+            call ssqfcn(m,n,x,fvec,nprob)
+            fnorm2 = enorm(m,fvec)
+            np(ic) = nprob
+            na(ic) = n
+            ma(ic) = m
+            nf(ic) = nfev
+            njev = njev/n
+            nj(ic) = njev
+            nx(ic) = info
+            fnm(ic) = fnorm2
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+            factor = ten*factor
+   20       continue
+         go to 10
+   30 continue
+      write (nwrite,80) ic
+      write (nwrite,90)
+      do 40 i = 1, ic
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+   40    continue
+      stop
+   50 format (4i5)
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+   80 format (12h1summary of , i3, 16h calls to lmdif1 /)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+  100 format (3i5, 3i6, 1x, d15.7)
+c
+c     last card of driver.
+c
+      end
+      subroutine fcn(m,n,x,fvec,iflag)
+      integer m,n,iflag
+      double precision x(n),fvec(m)
+c     **********
+c
+c     the calling sequence of fcn should be identical to the
+c     calling sequence of the function subroutine in the nonlinear
+c     least-squares solver. fcn should only call the testing
+c     function subroutine ssqfcn with the appropriate value of
+c     problem number (nprob).
+c
+c     subprograms called
+c
+c       minpack-supplied ... ssqfcn
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer nprob,nfev,njev
+      common /refnum/ nprob,nfev,njev
+      call ssqfcn(m,n,x,fvec,nprob)
+      if (iflag .eq. 1) nfev = nfev + 1
+      if (iflag .eq. 2) njev = njev + 1
+      return
+c
+c     last card of interface subroutine fcn.
+c
+      end
diff --git a/examples/lmfdrv_ b/examples/lmfdrv_
new file mode 100755
index 0000000..9c301d3
Binary files /dev/null and b/examples/lmfdrv_ differ
diff --git a/examples/lmfdrv_.c b/examples/lmfdrv_.c
new file mode 100644
index 0000000..883238a
--- /dev/null
+++ b/examples/lmfdrv_.c
@@ -0,0 +1,222 @@
+/* Usage: lmfdrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "minpack.h"
+#include "ssq.h"
+#define real __minpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the least-squares solution of */
+/*     m nonlinear equations in n variables. it consists of a driver */
+/*     and an interface subroutine fcn. the driver reads in data, */
+/*     calls the nonlinear least-squares solver, and finally prints */
+/*     out information on the performance of the solver. this is */
+/*     only a sample driver, many other drivers are possible. the */
+/*     interface subroutine fcn is necessary to take into account the */
+/*     forms of calling sequences used by the function and jacobian */
+/*     subroutines in the various nonlinear least-squares solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,initpt,lmdif1,ssqfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+struct refnum lmdiftest;
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,m,n,ntries;
+    int info;
+
+    int ma[60];
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fnm[60];
+    real fvec[65];
+    real x[40];
+
+    int iwa[40];
+    real wa[65*40+5*40+65];
+    const int lwa = 65*40+5*40+65;
+    const int i1 = 1;
+
+    tol = sqrt(__minpack_func__(dpmpar)(&i1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d%5d\n", &lmdiftest.nprob, &n, &m, &ntries);
+/*
+         read (nread,50) nprob,n,m,ntries
+   50 format (4i5)
+*/
+        if (lmdiftest.nprob <= 0.)
+            break;
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            lmdipt(n,x,lmdiftest.nprob,factor);
+
+            ssqfcn(m,n,x,fvec,lmdiftest.nprob);
+
+            fnorm1 = __minpack_func__(enorm)(&m,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmdiftest.nprob, n, m);
+/*
+            write (nwrite,60) nprob,n,m
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+*/
+
+            lmdiftest.nfev = 0;
+            lmdiftest.njev = 0;
+
+            __minpack_func__(lmdif1)(fcn,&m,&n,x,fvec,&tol,&info,iwa,wa,&lwa);
+
+            ssqfcn(m,n,x,fvec,lmdiftest.nprob);
+
+            fnorm2 = __minpack_func__(enorm)(&m,fvec);
+
+            np[ic] = lmdiftest.nprob;
+            na[ic] = n;
+            ma[ic] = m;
+            nf[ic] = lmdiftest.nfev;
+            lmdiftest.njev /= n;
+            nj[ic] = lmdiftest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of Jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, lmdiftest.nfev, lmdiftest.njev, info);
+            printvec(n, x);
+/*
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+*/
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to lmdif1: \n\n", ic);
+/*
+      write (nwrite,80) ic
+   80 format (12h1summary of , i3, 16h calls to lmdif1 /)
+*/
+    printf("\n\n nprob   n    m   nfev  njev  info  final L2 norm \n\n");
+/*
+      write (nwrite,90)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+*/
+
+    for (i = 0; i < ic; ++i) {
+        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
+               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+/*
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+  100 format (3i5, 3i6, 1x, d15.7)
+*/
+
+    }
+    exit(0);
+}
+
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag)
+{
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     least-squares solver. fcn should only call the testing */
+/*     function and jacobian subroutines ssqfcn and ssqjac with */
+/*     the appropriate value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... ssqfcn,ssqjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    ssqfcn(*m,*n,x,fvec,lmdiftest.nprob);
+    if (*iflag == 1) {
+        lmdiftest.nfev++;
+    }
+    if (*iflag == 2) {
+        lmdiftest.njev++;
+    }
+} /* fcn_ */
diff --git a/examples/lmsdrv.c b/examples/lmsdrv.c
new file mode 100644
index 0000000..e44ea7b
--- /dev/null
+++ b/examples/lmsdrv.c
@@ -0,0 +1,240 @@
+/* Usage: lmddrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "cminpack.h"
+#include "ssq.h"
+#define real __cminpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the least-squares solution of */
+/*     m nonlinear equations in n variables. it consists of a driver */
+/*     and an interface subroutine fcn. the driver reads in data, */
+/*     calls the nonlinear least-squares solver, and finally prints */
+/*     out information on the performance of the solver. this is */
+/*     only a sample driver, many other drivers are possible. the */
+/*     interface subroutine fcn is necessary to take into account the */
+/*     forms of calling sequences used by the function and jacobian */
+/*     subroutines in the various nonlinear least-squares solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,initpt,lmstr1,ssqfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,m,n,ntries;
+    struct refnum lmstrtest;
+    int info;
+
+    int ma[60];
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fjac[40*40];
+    const int ldfjac = 40;
+
+    real fnm[60];
+    real fvec[65];
+    real x[40];
+
+    int ipvt[40];
+
+    real wa[5*40+65];
+    const int lwa = 5*40+65;
+
+    tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d%5d\n", &lmstrtest.nprob, &n, &m, &ntries);
+/*
+         read (nread,50) nprob,n,m,ntries
+   50 format (4i5)
+*/
+        if (lmstrtest.nprob <= 0.)
+            break;
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            lmdipt(n,x,lmstrtest.nprob,factor);
+
+            ssqfcn(m,n,x,fvec,lmstrtest.nprob);
+
+            fnorm1 = __cminpack_func__(enorm)(m,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmstrtest.nprob, n, m);
+/*
+            write (nwrite,60) nprob,n,m
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+*/
+
+            lmstrtest.nfev = 0;
+            lmstrtest.njev = 0;
+
+            info = __cminpack_func__(lmstr1)(fcn,&lmstrtest,m,n,x,fvec,fjac,ldfjac,tol,ipvt,wa,lwa);
+
+            ssqfcn(m,n,x,fvec,lmstrtest.nprob);
+
+            fnorm2 = __cminpack_func__(enorm)(m,fvec);
+
+            np[ic] = lmstrtest.nprob;
+            na[ic] = n;
+            ma[ic] = m;
+            nf[ic] = lmstrtest.nfev;
+            nj[ic] = lmstrtest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, lmstrtest.nfev, lmstrtest.njev, info);
+            printvec(n, x);
+/*
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+*/
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to lmstr1\n", ic);
+/*
+      write (nwrite,80) ic
+   80 format (12h1summary of , i3, 16h calls to lmstr1 /)
+*/
+    printf(" nprob   n    m   nfev  njev  info  final L2 norm \n\n");
+/*
+      write (nwrite,90)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+*/
+
+    for (i = 0; i < ic; ++i) {
+        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
+               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+/*
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+  100 format (3i5, 3i6, 1x, d15.7)
+*/
+
+    }
+    exit(0);
+}
+
+real temp[65*40];
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag)
+{
+    /* Local variables */
+    int j;
+
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     least squares solver. if iflag = 1, fcn should only call the */
+/*     testing function subroutine ssqfcn. if iflag = i, i .ge. 2, */
+/*     fcn should only call subroutine ssqjac to calculate the */
+/*     (i-1)-st row of the jacobian. (the ssqjac subroutine provided */
+/*     here for testing purposes calculates the entire jacobian */
+/*     matrix and is therefore called only when iflag = 2.) each */
+/*     call to ssqfcn or ssqjac should specify the appropriate */
+/*     value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... ssqfcn,ssqjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    struct refnum *lmstrtest = (struct refnum *)p;
+    if (iflag == 1) {
+        ssqfcn(m,n,x,fvec,lmstrtest->nprob);
+        lmstrtest->nfev++;
+    }
+    if (iflag >= 2) {
+        if (iflag == 2) {
+            ssqjac(m,n,x,temp,65,lmstrtest->nprob);
+            lmstrtest->njev++;
+        }
+        for (j = 0; j < n; ++j) {
+            fjrow[j] = temp[(iflag - 2) + j * 65];
+        }
+    }
+
+    return 0;
+} /* fcn_ */
diff --git a/examples/lmsdrv.f b/examples/lmsdrv.f
new file mode 100644
index 0000000..8681beb
--- /dev/null
+++ b/examples/lmsdrv.f
@@ -0,0 +1,135 @@
+c     **********
+c
+c     this program tests codes for the least-squares solution of
+c     m nonlinear equations in n variables. it consists of a driver
+c     and an interface subroutine fcn. the driver reads in data,
+c     calls the nonlinear least-squares solver, and finally prints
+c     out information on the performance of the solver. this is
+c     only a sample driver, many other drivers are possible. the
+c     interface subroutine fcn is necessary to take into account the
+c     forms of calling sequences used by the function and jacobian
+c     subroutines in the various nonlinear least-squares solvers.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,initpt,lmstr1,ssqfcn
+c
+c       fortran-supplied ... dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ic,info,k,ldfjac,lwa,m,n,nfev,njev,nprob,nread,ntries,
+     *        nwrite
+      integer iwa(40),ma(60),na(60),nf(60),nj(60),np(60),nx(60)
+      double precision factor,fnorm1,fnorm2,one,ten,tol
+      double precision fjac(40,40),fnm(60),fvec(65),wa(265),x(40)
+      double precision dpmpar,enorm
+      external fcn
+      common /refnum/ nprob,nfev,njev
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data one,ten /1.0d0,1.0d1/
+      tol = dsqrt(dpmpar(1))
+      ldfjac = 40
+      lwa = 265
+      ic = 0
+   10 continue
+         read (nread,50) nprob,n,m,ntries
+         if (nprob .le. 0) go to 30
+         factor = one
+         do 20 k = 1, ntries
+            ic = ic + 1
+            call initpt(n,x,nprob,factor)
+            call ssqfcn(m,n,x,fvec,nprob)
+            fnorm1 = enorm(m,fvec)
+            write (nwrite,60) nprob,n,m
+            nfev = 0
+            njev = 0
+            call lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,iwa,wa,
+     *                  lwa)
+            call ssqfcn(m,n,x,fvec,nprob)
+            fnorm2 = enorm(m,fvec)
+            np(ic) = nprob
+            na(ic) = n
+            ma(ic) = m
+            nf(ic) = nfev
+            nj(ic) = njev
+            nx(ic) = info
+            fnm(ic) = fnorm2
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+            factor = ten*factor
+   20       continue
+         go to 10
+   30 continue
+      write (nwrite,80) ic
+      write (nwrite,90)
+      do 40 i = 1, ic
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+   40    continue
+      stop
+   50 format (4i5)
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+   80 format (12h1summary of , i3, 16h calls to lmstr1 /)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+  100 format (3i5, 3i6, 1x, d15.7)
+c
+c     last card of driver.
+c
+      end
+      subroutine fcn(m,n,x,fvec,fjrow,iflag)
+      integer m,n,iflag
+      double precision x(n),fvec(m),fjrow(n)
+c     **********
+c
+c     the calling sequence of fcn should be identical to the
+c     calling sequence of the function subroutine in the nonlinear
+c     least squares solver. if iflag = 1, fcn should only call the
+c     testing function subroutine ssqfcn. if iflag = i, i .ge. 2,
+c     fcn should only call subroutine ssqjac to calculate the
+c     (i-1)-st row of the jacobian. (the ssqjac subroutine provided
+c     here for testing purposes calculates the entire jacobian
+c     matrix and is therefore called only when iflag = 2.) each
+c     call to ssqfcn or ssqjac should specify the appropriate
+c     value of problem number (nprob).
+c
+c     subprograms called
+c
+c       minpack-supplied ... ssqfcn,ssqjac
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer nprob,nfev,njev,j
+      double precision temp(65,40)
+      common /refnum/ nprob,nfev,njev
+      if (iflag .eq. 1) call ssqfcn(m,n,x,fvec,nprob)
+      if (iflag .eq. 2) call ssqjac(m,n,x,temp,65,nprob)
+      if (iflag .eq. 1) nfev = nfev + 1
+      if (iflag .eq. 2) njev = njev + 1
+      if (iflag .eq. 1) go to 120
+      do 110 j = 1, n
+         fjrow(j) = temp(iflag-1,j)
+  110    continue
+  120 continue
+      return
+c
+c     last card of interface subroutine fcn.
+c
+      end
diff --git a/examples/lmsdrv_ b/examples/lmsdrv_
new file mode 100755
index 0000000..cddfbac
Binary files /dev/null and b/examples/lmsdrv_ differ
diff --git a/examples/lmsdrv_.c b/examples/lmsdrv_.c
new file mode 100644
index 0000000..52759d9
--- /dev/null
+++ b/examples/lmsdrv_.c
@@ -0,0 +1,240 @@
+/* Usage: lmddrv < lm.data */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "minpack.h"
+#include "ssq.h"
+#define real __minpack_real__
+
+/*     ********** */
+
+/*     this program tests codes for the least-squares solution of */
+/*     m nonlinear equations in n variables. it consists of a driver */
+/*     and an interface subroutine fcn. the driver reads in data, */
+/*     calls the nonlinear least-squares solver, and finally prints */
+/*     out information on the performance of the solver. this is */
+/*     only a sample driver, many other drivers are possible. the */
+/*     interface subroutine fcn is necessary to take into account the */
+/*     forms of calling sequences used by the function and jacobian */
+/*     subroutines in the various nonlinear least-squares solvers. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,initpt,lmstr1,ssqfcn */
+
+/*       fortran-supplied ... dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag);
+
+struct refnum {
+    int nprob, nfev, njev;
+};
+
+struct refnum lmstrtest;
+
+static void printvec(int n, const real *x)
+{
+    int i, num5, ilow, numleft;
+    num5 = n/5;
+
+    for (i = 0; i < num5; ++i) {
+        ilow = i*5;
+        printf("     %15.7e%15.7e%15.7e%15.7e%15.7e\n",
+               (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3], (double)x[ilow+4]);
+    }
+    
+    numleft = n%5;
+    ilow = n - numleft;
+
+    switch (numleft) {
+        case 1:
+            printf("     %15.7e\n",
+                   (double)x[ilow+0]);
+            break;
+        case 2:
+            printf("     %15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1]);
+            break;
+        case 3:
+            printf("     %15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2]);
+            break;
+        case 4:
+            printf("     %15.7e%15.7e%15.7e%15.7e\n",
+                   (double)x[ilow+0], (double)x[ilow+1], (double)x[ilow+2], (double)x[ilow+3]);
+            break;
+    }
+}
+
+/* Main program */
+int main(int argc, char **argv)
+{
+
+    int i,ic,k,m,n,ntries;
+    int info;
+
+    int ma[60];
+    int na[60];
+    int nf[60];
+    int nj[60];
+    int np[60];
+    int nx[60];
+
+    real factor,fnorm1,fnorm2,tol;
+
+    real fjac[40*40];
+    const int ldfjac = 40;
+
+    real fnm[60];
+    real fvec[65];
+    real x[40];
+
+    int ipvt[40];
+
+    real wa[5*40+65];
+    const int lwa = 5*40+65;
+    const int i1 = 1;
+
+    tol = sqrt(__minpack_func__(dpmpar)(&i1));
+
+    ic = 0;
+
+    for (;;) {
+        scanf("%5d%5d%5d%5d\n", &lmstrtest.nprob, &n, &m, &ntries);
+/*
+         read (nread,50) nprob,n,m,ntries
+   50 format (4i5)
+*/
+        if (lmstrtest.nprob <= 0.)
+            break;
+        factor = 1.;
+
+        for (k = 0; k < ntries; ++k, ++ic) {
+            lmdipt(n,x,lmstrtest.nprob,factor);
+
+            ssqfcn(m,n,x,fvec,lmstrtest.nprob);
+
+            fnorm1 = __minpack_func__(enorm)(&m,fvec);
+
+            printf("\n\n\n\n      problem%5d      dimensions%5d%5d\n\n", lmstrtest.nprob, n, m);
+/*
+            write (nwrite,60) nprob,n,m
+   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
+     *         )
+*/
+
+            lmstrtest.nfev = 0;
+            lmstrtest.njev = 0;
+
+            __minpack_func__(lmstr1)(fcn,&m,&n,x,fvec,fjac,&ldfjac,&tol,&info,ipvt,wa,&lwa);
+
+            ssqfcn(m,n,x,fvec,lmstrtest.nprob);
+
+            fnorm2 = __minpack_func__(enorm)(&m,fvec);
+
+            np[ic] = lmstrtest.nprob;
+            na[ic] = n;
+            ma[ic] = m;
+            nf[ic] = lmstrtest.nfev;
+            nj[ic] = lmstrtest.njev;
+            nx[ic] = info;
+
+            fnm[ic] = fnorm2;
+
+            printf("\n      initial l2 norm of the residuals%15.7e\n"
+                   "\n      final l2 norm of the residuals  %15.7e\n"
+                   "\n      number of function evaluations  %10d\n"
+                   "\n      number of jacobian evaluations  %10d\n"
+                   "\n      exit parameter                  %10d\n"
+                   "\n      final approximate solution\n\n",
+                   (double)fnorm1, (double)fnorm2, lmstrtest.nfev, lmstrtest.njev, info);
+            printvec(n, x);
+/*
+            write (nwrite,70)
+     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
+   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
+     *        33h final l2 norm of the residuals  , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        33h number of jacobian evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+*/
+
+            factor *= 10.;
+
+        }
+
+    }
+
+    printf("\f summary of %d calls to lmstr1\n", ic);
+/*
+      write (nwrite,80) ic
+   80 format (12h1summary of , i3, 16h calls to lmstr1 /)
+*/
+    printf(" nprob   n    m   nfev  njev  info  final L2 norm \n\n");
+/*
+      write (nwrite,90)
+   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)
+*/
+
+    for (i = 0; i < ic; ++i) {
+        printf("%5d%5d%5d%6d%6d%6d%16.7e\n",
+               np[i], na[i], ma[i], nf[i], nj[i], nx[i], (double)fnm[i]);
+/*
+         write (nwrite,100) np(i),na(i),ma(i),nf(i),nj(i),nx(i),fnm(i)
+  100 format (3i5, 3i6, 1x, d15.7)
+*/
+
+    }
+    exit(0);
+}
+
+real temp[65*40];
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag)
+{
+    /* Local variables */
+    int j;
+
+/*     ********** */
+
+/*     the calling sequence of fcn should be identical to the */
+/*     calling sequence of the function subroutine in the nonlinear */
+/*     least squares solver. if iflag = 1, fcn should only call the */
+/*     testing function subroutine ssqfcn. if iflag = i, i .ge. 2, */
+/*     fcn should only call subroutine ssqjac to calculate the */
+/*     (i-1)-st row of the jacobian. (the ssqjac subroutine provided */
+/*     here for testing purposes calculates the entire jacobian */
+/*     matrix and is therefore called only when iflag = 2.) each */
+/*     call to ssqfcn or ssqjac should specify the appropriate */
+/*     value of problem number (nprob). */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... ssqfcn,ssqjac */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    if (*iflag == 1) {
+        ssqfcn(*m,*n,x,fvec,lmstrtest.nprob);
+        lmstrtest.nfev++;
+    }
+    if (*iflag >= 2) {
+        if (*iflag == 2) {
+            ssqjac(*m,*n,x,temp,65,lmstrtest.nprob);
+            lmstrtest.njev++;
+        }
+        for (j = 0; j < *n; ++j) {
+            fjrow[j] = temp[(*iflag - 2) + j * 65];
+        }
+    }
+} /* fcn_ */
diff --git a/examples/machar.c b/examples/machar.c
new file mode 100644
index 0000000..f927eee
--- /dev/null
+++ b/examples/machar.c
@@ -0,0 +1,338 @@
+#include <math.h>
+#include <stdio.h>
+#include "cminpack.h"
+#define real __cminpack_real__
+
+#define ABS(xxx) ((xxx>(real)0.)?(xxx):(-xxx))
+
+extern void machar_(int *ibeta, int *it, int *irnd, 
+                   int *ngrd, int *machep, int *negep, int *iexp, 
+                   int *minexp, int *maxexp, real *eps, real *epsneg,
+                   real *xmin, real *xmax);
+
+void machar_(int *ibeta, int *it, int *irnd, 
+                   int *ngrd, int *machep, int *negep, int *iexp, 
+                   int *minexp, int *maxexp, real *eps, real *epsneg,
+                   real *xmin, real *xmax)
+/*
+
+   This subroutine is intended to determine the parameters of the
+    floating-point arithmetic system specified below.  The
+    determination of the first three uses an extension of an algorithm
+    due to M. Malcolm, CACM 15 (1972), pp. 949-951, incorporating some,
+    but not all, of the improvements suggested by M. Gentleman and S.
+    Marovich, CACM 17 (1974), pp. 276-277.  An earlier version of this
+    program was published in the book Software Manual for the
+    Elementary Functions by W. J. Cody and W. Waite, Prentice-Hall,
+    Englewood Cliffs, NJ, 1980.  The present program is a
+    translation of the Fortran 77 program in W. J. Cody, "MACHAR:
+    A subroutine to dynamically determine machine parameters".
+    TOMS (14), 1988.
+ 
+   Parameter values reported are as follows:
+ 
+        ibeta   - the radix for the floating-point representation
+        it      - the number of base ibeta digits in the floating-point
+                  significand
+        irnd    - 0 if floating-point addition chops
+                  1 if floating-point addition rounds, but not in the
+                    IEEE style
+                  2 if floating-point addition rounds in the IEEE style
+                  3 if floating-point addition chops, and there is
+                    partial underflow
+                  4 if floating-point addition rounds, but not in the
+                    IEEE style, and there is partial underflow
+                  5 if floating-point addition rounds in the IEEE style,
+                    and there is partial underflow
+        ngrd    - the number of guard digits for multiplication with
+                  truncating arithmetic.  It is
+                  0 if floating-point arithmetic rounds, or if it
+                    truncates and only  it  base  ibeta digits
+                    participate in the post-normalization shift of the
+                    floating-point significand in multiplication;
+                  1 if floating-point arithmetic truncates and more
+                    than  it  base  ibeta  digits participate in the
+                    post-normalization shift of the floating-point
+                    significand in multiplication.
+        machep  - the largest negative integer such that
+                  1.0+FLOAT(ibeta)**machep .NE. 1.0, except that
+                  machep is bounded below by  -(it+3)
+        negeps  - the largest negative integer such that
+                  1.0-FLOAT(ibeta)**negeps .NE. 1.0, except that
+                  negeps is bounded below by  -(it+3)
+        iexp    - the number of bits (decimal places if ibeta = 10)
+                  reserved for the representation of the exponent
+                  (including the bias or sign) of a floating-point
+                  number
+        minexp  - the largest in magnitude negative integer such that
+                  FLOAT(ibeta)**minexp is positive and normalized
+        maxexp  - the smallest positive power of  BETA  that overflows
+        eps     - the smallest positive floating-point number such
+                  that  1.0+eps .NE. 1.0. In particular, if either
+                  ibeta = 2  or  IRND = 0, eps = FLOAT(ibeta)**machep.
+                  Otherwise,  eps = (FLOAT(ibeta)**machep)/2
+        epsneg  - A small positive floating-point number such that
+                  1.0-epsneg .NE. 1.0. In particular, if ibeta = 2
+                  or  IRND = 0, epsneg = FLOAT(ibeta)**negeps.
+                  Otherwise,  epsneg = (ibeta**negeps)/2.  Because
+                  negeps is bounded below by -(it+3), epsneg may not
+                  be the smallest number that can alter 1.0 by
+                  subtraction.
+        xmin    - the smallest non-vanishing normalized floating-point
+                  power of the radix, i.e.,  xmin = FLOAT(ibeta)**minexp
+        xmax    - the largest finite floating-point number.  In
+                  particular  xmax = (1.0-epsneg)*FLOAT(ibeta)**maxexp
+                  Note - on some machines  xmax  will be only the
+                  second, or perhaps third, largest number, being
+                  too small by 1 or 2 units in the last digit of
+                  the significand.
+ 
+      Latest revision - August 4, 1988
+ 
+      Author - W. J. Cody
+               Argonne National Laboratory
+ 
+*/
+
+{
+      int i,iz,j,k;
+      int mx,itmp,nxres;
+      real a,b,beta,betain,one,y,z,zero;
+      real betah,t,tmp,tmpa,tmp1,two;
+
+      (*irnd) = 1;
+      one = (real)(*irnd);
+      two = one + one;
+      a = two;
+      b = a;
+      zero = 0.0e0;
+
+/*
+  determine ibeta,beta ala malcolm
+*/
+
+      tmp = ((a+one)-a)-one;
+
+      while (tmp == zero) {
+         a = a+a;
+         tmp = a+one;
+         tmp1 = tmp-a;
+         tmp = tmp1-one;
+      }
+
+      tmp = a+b;
+      itmp = (int)(tmp-a);
+      while (itmp == 0) {
+         b = b+b;
+         tmp = a+b;
+         itmp = (int)(tmp-a);
+      }
+
+      *ibeta = itmp;
+      beta = (real)(*ibeta);
+
+/*
+  determine irnd, it
+*/
+
+      (*it) = 0;
+      b = one;
+      tmp = ((b+one)-b)-one;
+
+      while (tmp == zero) {
+         *it = *it+1;
+         b = b*beta;
+         tmp = b+one;
+         tmp1 = tmp-b;
+         tmp = tmp1-one;
+      }
+
+      *irnd = 0;
+      betah = beta/two;
+      tmp = a+betah;
+      tmp1 = tmp-a;
+      if (tmp1 != zero) *irnd = 1;
+      tmpa = a+beta;
+      tmp = tmpa+betah;
+      if ((*irnd == 0) && (tmp-tmpa != zero)) *irnd = 2;
+
+/*
+  determine negep, epsneg
+*/
+
+      (*negep) = (*it) + 3;
+      betain = one / beta;
+      a = one;
+ 
+      for (i = 1; i<=(*negep); i++) {
+         a = a * betain;
+      }
+ 
+      b = a;
+      tmp = (one-a);
+      tmp = tmp-one;
+
+      while (tmp == zero) {
+         a = a*beta;
+         *negep = *negep-1;
+         tmp1 = one-a;
+         tmp = tmp1-one;
+      }
+
+      (*negep) = -(*negep);
+      (*epsneg) = a;
+
+/*
+  determine machep, eps
+*/
+
+      (*machep) = -(*it) - 3;
+      a = b;
+      tmp = one+a;
+
+      while (tmp-one == zero) {
+         a = a*beta;
+         *machep = *machep+1;
+         tmp = one+a;
+      }
+
+      *eps = a;
+      
+/*
+  determine ngrd
+*/
+
+      (*ngrd) = 0;
+      tmp = one+*eps;
+      tmp = tmp*one;
+      if (((*irnd) == 0) && (tmp-one) != zero) (*ngrd) = 1;
+
+/*
+  determine iexp, minexp, xmin
+
+  loop to determine largest i such that
+         (1/beta) ** (2**(i))
+    does not underflow.
+    exit from loop is signaled by an underflow.
+*/
+
+      i = 0;
+      k = 1;
+      z = betain;
+      t = one+*eps;
+      nxres = 0;
+
+      for (;;) {
+         y = z;
+         z = y * y;
+
+/*
+  check for underflow
+*/
+
+         a = z * one;
+         tmp = z*t;
+         if ((a+a == zero) || (ABS(z) > y)) break;
+         tmp1 = tmp*betain;
+         if (tmp1*beta == z) break;
+         i = i + 1;
+         k = k+k;
+      }
+
+/*
+  determine k such that (1/beta)**k does not underflow
+    first set  k = 2 ** i
+*/
+
+      (*iexp) = i + 1;
+      mx = k + k;
+      if (*ibeta == 10) {
+
+/*
+  for decimal machines only
+*/
+
+         (*iexp) = 2;
+         iz = *ibeta;
+         while (k >= iz) {
+            iz = iz * (*ibeta);
+            (*iexp) = (*iexp) + 1;
+         }
+         mx = iz + iz - 1;
+      }
+ 
+/*
+  loop to determine minexp, xmin.
+    exit from loop is signaled by an underflow.
+*/
+
+      for (;;) {
+         (*xmin) = y;
+         y = y * betain;
+         a = y * one;
+         tmp = y*t;
+         tmp1 = a+a;
+         if ((tmp1 == zero) || (ABS(y) >= (*xmin))) break;
+         k = k + 1;
+         tmp1 = tmp*betain;
+         tmp1 = tmp1*beta;
+
+         if ((tmp1 == y) && (tmp != y)) {
+            nxres = 3;
+            *xmin = y;
+            break;
+         }
+
+      }
+
+      (*minexp) = -k;
+
+/*
+  determine maxexp, xmax
+*/
+
+      if ((mx <= k+k-3) && ((*ibeta) != 10)) {
+         mx = mx + mx;
+         (*iexp) = (*iexp) + 1;
+      }
+
+      (*maxexp) = mx + (*minexp);
+
+/*
+  Adjust *irnd to reflect partial underflow.
+*/
+
+      (*irnd) = (*irnd)+nxres;
+
+/*
+  Adjust for IEEE style machines.
+*/
+
+      if ((*irnd) >= 2) (*maxexp) = (*maxexp)-2;
+
+/*
+  adjust for machines with implicit leading bit in binary
+    significand and machines with radix point at extreme
+    right of significand.
+*/
+
+      i = (*maxexp) + (*minexp);
+      if (((*ibeta) == 2) && (i == 0)) (*maxexp) = (*maxexp) - 1;
+      if (i > 20) (*maxexp) = (*maxexp) - 1;
+      if (a != y) (*maxexp) = (*maxexp) - 2;
+      (*xmax) = one - (*epsneg);
+      tmp = (*xmax)*one;
+      if (tmp != (*xmax)) (*xmax) = one - beta * (*epsneg);
+      (*xmax) = (*xmax) / (beta * beta * beta * (*xmin));
+      i = (*maxexp) + (*minexp) + 3;
+      if (i > 0) {
+ 
+         for (j = 1; j<=i; j++ ) {
+             if ((*ibeta) == 2) (*xmax) = (*xmax) + (*xmax);
+             if ((*ibeta) != 2) (*xmax) = (*xmax) * beta;
+         }
+
+      }
+ 
+    return;
+}
diff --git a/examples/machar.f b/examples/machar.f
new file mode 100644
index 0000000..4d77bf5
--- /dev/null
+++ b/examples/machar.f
@@ -0,0 +1,258 @@
+      SUBROUTINE MACHAR(IBETA,IT,IRND,NGRD,MACHEP,NEGEP,IEXP,MINEXP,
+     1                   MAXEXP,EPS,EPSNEG,XMIN,XMAX)
+C-----------------------------------------------------------------------
+C  This Fortran 77 subroutine is intended to determine the parameters
+C   of the floating-point arithmetic system specified below.  The
+C   determination of the first three uses an extension of an algorithm
+C   due to M. Malcolm, CACM 15 (1972), pp. 949-951, incorporating some,
+C   but not all, of the improvements suggested by M. Gentleman and S.
+C   Marovich, CACM 17 (1974), pp. 276-277.  An earlier version of this
+C   program was published in the book Software Manual for the
+C   Elementary Functions by W. J. Cody and W. Waite, Prentice-Hall,
+C   Englewood Cliffs, NJ, 1980.  The present version is documented in 
+C   W. J. Cody, "MACHAR: A subroutine to dynamically determine machine
+C   parameters," TOMS 14, December, 1988.
+C
+C  The program as given here must be modified before compiling.  If
+C   a single (double) precision version is desired, change all
+C   occurrences of CS (CD) in columns 1 and 2 to blanks.
+C
+C  Parameter values reported are as follows:
+C
+C       IBETA   - the radix for the floating-point representation
+C       IT      - the number of base IBETA digits in the floating-point
+C                 significand
+C       IRND    - 0 if floating-point addition chops
+C                 1 if floating-point addition rounds, but not in the
+C                   IEEE style
+C                 2 if floating-point addition rounds in the IEEE style
+C                 3 if floating-point addition chops, and there is
+C                   partial underflow
+C                 4 if floating-point addition rounds, but not in the
+C                   IEEE style, and there is partial underflow
+C                 5 if floating-point addition rounds in the IEEE style,
+C                   and there is partial underflow
+C       NGRD    - the number of guard digits for multiplication with
+C                 truncating arithmetic.  It is
+C                 0 if floating-point arithmetic rounds, or if it
+C                   truncates and only  IT  base  IBETA digits
+C                   participate in the post-normalization shift of the
+C                   floating-point significand in multiplication;
+C                 1 if floating-point arithmetic truncates and more
+C                   than  IT  base  IBETA  digits participate in the
+C                   post-normalization shift of the floating-point
+C                   significand in multiplication.
+C       MACHEP  - the largest negative integer such that
+C                 1.0+FLOAT(IBETA)**MACHEP .NE. 1.0, except that
+C                 MACHEP is bounded below by  -(IT+3)
+C       NEGEPS  - the largest negative integer such that
+C                 1.0-FLOAT(IBETA)**NEGEPS .NE. 1.0, except that
+C                 NEGEPS is bounded below by  -(IT+3)
+C       IEXP    - the number of bits (decimal places if IBETA = 10)
+C                 reserved for the representation of the exponent
+C                 (including the bias or sign) of a floating-point
+C                 number
+C       MINEXP  - the largest in magnitude negative integer such that
+C                 FLOAT(IBETA)**MINEXP is positive and normalized
+C       MAXEXP  - the smallest positive power of  BETA  that overflows
+C       EPS     - the smallest positive floating-point number such
+C                 that  1.0+EPS .NE. 1.0. In particular, if either
+C                 IBETA = 2  or  IRND = 0, EPS = FLOAT(IBETA)**MACHEP.
+C                 Otherwise,  EPS = (FLOAT(IBETA)**MACHEP)/2
+C       EPSNEG  - A small positive floating-point number such that
+C                 1.0-EPSNEG .NE. 1.0. In particular, if IBETA = 2
+C                 or  IRND = 0, EPSNEG = FLOAT(IBETA)**NEGEPS.
+C                 Otherwise,  EPSNEG = (IBETA**NEGEPS)/2.  Because
+C                 NEGEPS is bounded below by -(IT+3), EPSNEG may not
+C                 be the smallest number that can alter 1.0 by
+C                 subtraction.
+C       XMIN    - the smallest non-vanishing normalized floating-point
+C                 power of the radix, i.e.,  XMIN = FLOAT(IBETA)**MINEXP
+C       XMAX    - the largest finite floating-point number.  In
+C                 particular  XMAX = (1.0-EPSNEG)*FLOAT(IBETA)**MAXEXP
+C                 Note - on some machines  XMAX  will be only the
+C                 second, or perhaps third, largest number, being
+C                 too small by 1 or 2 units in the last digit of
+C                 the significand.
+C
+C     Latest revision - December 4, 1987
+C
+C     Author - W. J. Cody
+C              Argonne National Laboratory
+C
+C-----------------------------------------------------------------------
+      INTEGER I,IBETA,IEXP,IRND,IT,ITEMP,IZ,J,K,MACHEP,MAXEXP,
+     1        MINEXP,MX,NEGEP,NGRD,NXRES
+CS    REAL
+      DOUBLE PRECISION
+     1   A,B,BETA,BETAIN,BETAH,CONV,EPS,EPSNEG,ONE,T,TEMP,TEMPA,
+     2   TEMP1,TWO,XMAX,XMIN,Y,Z,ZERO
+C-----------------------------------------------------------------------
+CS    CONV(I) = REAL(I)
+      CONV(I) = DBLE(I)
+      ONE = CONV(1)
+      TWO = ONE + ONE
+      ZERO = ONE - ONE
+C-----------------------------------------------------------------------
+C  Determine IBETA, BETA ala Malcolm.
+C-----------------------------------------------------------------------
+      A = ONE
+   10 A = A + A
+         TEMP = A+ONE
+         TEMP1 = TEMP-A
+         IF (TEMP1-ONE .EQ. ZERO) GO TO 10
+      B = ONE
+   20 B = B + B
+         TEMP = A+B
+         ITEMP = INT(TEMP-A)
+         IF (ITEMP .EQ. 0) GO TO 20
+      IBETA = ITEMP
+      BETA = CONV(IBETA)
+C-----------------------------------------------------------------------
+C  Determine IT, IRND.
+C-----------------------------------------------------------------------
+      IT = 0
+      B = ONE
+  100 IT = IT + 1
+         B = B * BETA
+         TEMP = B+ONE
+         TEMP1 = TEMP-B
+         IF (TEMP1-ONE .EQ. ZERO) GO TO 100
+      IRND = 0
+      BETAH = BETA / TWO
+      TEMP = A+BETAH
+      IF (TEMP-A .NE. ZERO) IRND = 1
+      TEMPA = A + BETA
+      TEMP = TEMPA+BETAH
+      IF ((IRND .EQ. 0) .AND. (TEMP-TEMPA .NE. ZERO)) IRND = 2
+C-----------------------------------------------------------------------
+C  Determine NEGEP, EPSNEG.
+C-----------------------------------------------------------------------
+      NEGEP = IT + 3
+      BETAIN = ONE / BETA
+      A = ONE
+      DO 200 I = 1, NEGEP
+         A = A * BETAIN
+  200 CONTINUE
+      B = A
+  210 TEMP = ONE-A
+         IF (TEMP-ONE .NE. ZERO) GO TO 220
+         A = A * BETA
+         NEGEP = NEGEP - 1
+      GO TO 210
+  220 NEGEP = -NEGEP
+      EPSNEG = A
+C-----------------------------------------------------------------------
+C  Determine MACHEP, EPS.
+C-----------------------------------------------------------------------
+      MACHEP = -IT - 3
+      A = B
+  300 TEMP = ONE+A
+         IF (TEMP-ONE .NE. ZERO) GO TO 320
+         A = A * BETA
+         MACHEP = MACHEP + 1
+      GO TO 300
+  320 EPS = A
+C-----------------------------------------------------------------------
+C  Determine NGRD.
+C-----------------------------------------------------------------------
+      NGRD = 0
+      TEMP = ONE+EPS
+      IF ((IRND .EQ. 0) .AND. (TEMP*ONE-ONE .NE. ZERO)) NGRD = 1
+C-----------------------------------------------------------------------
+C  Determine IEXP, MINEXP, XMIN.
+C
+C  Loop to determine largest I and K = 2**I such that
+C         (1/BETA) ** (2**(I))
+C  does not underflow.
+C  Exit from loop is signaled by an underflow.
+C-----------------------------------------------------------------------
+      I = 0
+      K = 1
+      Z = BETAIN
+      T = ONE + EPS
+      NXRES = 0
+  400 Y = Z
+         Z = Y * Y
+C-----------------------------------------------------------------------
+C  Check for underflow here.
+C-----------------------------------------------------------------------
+         A = Z * ONE
+         TEMP = Z * T
+         IF ((A+A .EQ. ZERO) .OR. (ABS(Z) .GE. Y)) GO TO 410
+         TEMP1 = TEMP * BETAIN
+         IF (TEMP1*BETA .EQ. Z) GO TO 410
+         I = I + 1
+         K = K + K
+      GO TO 400
+  410 IF (IBETA .EQ. 10) GO TO 420
+      IEXP = I + 1
+      MX = K + K
+      GO TO 450
+C-----------------------------------------------------------------------
+C  This segment is for decimal machines only.
+C-----------------------------------------------------------------------
+  420 IEXP = 2
+      IZ = IBETA
+  430 IF (K .LT. IZ) GO TO 440
+         IZ = IZ * IBETA
+         IEXP = IEXP + 1
+      GO TO 430
+  440 MX = IZ + IZ - 1
+C-----------------------------------------------------------------------
+C  Loop to determine MINEXP, XMIN.
+C  Exit from loop is signaled by an underflow.
+C-----------------------------------------------------------------------
+  450 XMIN = Y
+         Y = Y * BETAIN
+C-----------------------------------------------------------------------
+C  Check for underflow here.
+C-----------------------------------------------------------------------
+         A = Y * ONE
+         TEMP = Y * T
+         IF (((A+A) .EQ. ZERO) .OR. (ABS(Y) .GE. XMIN)) GO TO 460
+         K = K + 1
+         TEMP1 = TEMP * BETAIN
+         IF ((TEMP1*BETA .NE. Y) .OR. (TEMP .EQ. Y)) THEN
+               GO TO 450
+            ELSE
+               NXRES = 3
+               XMIN = Y
+         END IF
+  460 MINEXP = -K
+C-----------------------------------------------------------------------
+C  Determine MAXEXP, XMAX.
+C-----------------------------------------------------------------------
+      IF ((MX .GT. K+K-3) .OR. (IBETA .EQ. 10)) GO TO 500
+      MX = MX + MX
+      IEXP = IEXP + 1
+  500 MAXEXP = MX + MINEXP
+C-----------------------------------------------------------------
+C  Adjust IRND to reflect partial underflow.
+C-----------------------------------------------------------------
+      IRND = IRND + NXRES
+C-----------------------------------------------------------------
+C  Adjust for IEEE-style machines.
+C-----------------------------------------------------------------
+      IF (IRND .GE. 2) MAXEXP = MAXEXP - 2
+C-----------------------------------------------------------------
+C  Adjust for machines with implicit leading bit in binary
+C  significand, and machines with radix point at extreme
+C  right of significand.
+C-----------------------------------------------------------------
+      I = MAXEXP + MINEXP
+      IF ((IBETA .EQ. 2) .AND. (I .EQ. 0)) MAXEXP = MAXEXP - 1
+      IF (I .GT. 20) MAXEXP = MAXEXP - 1
+      IF (A .NE. Y) MAXEXP = MAXEXP - 2
+      XMAX = ONE - EPSNEG
+      IF (XMAX*ONE .NE. XMAX) XMAX = ONE - BETA * EPSNEG
+      XMAX = XMAX / (BETA * BETA * BETA * XMIN)
+      I = MAXEXP + MINEXP + 3
+      IF (I .LE. 0) GO TO 520
+      DO 510 J = 1, I
+          IF (IBETA .EQ. 2) XMAX = XMAX + XMAX
+          IF (IBETA .NE. 2) XMAX = XMAX * BETA
+  510 CONTINUE
+  520 RETURN
+C---------- LAST CARD OF MACHAR ----------
+      END
diff --git a/examples/objfcn.f b/examples/objfcn.f
new file mode 100644
index 0000000..979325d
--- /dev/null
+++ b/examples/objfcn.f
@@ -0,0 +1,342 @@
+      subroutine objfcn(n,x,f,nprob)
+      integer n,nprob
+      double precision f
+      double precision x(n)
+c     **********
+c
+c     subroutine objfcn
+c
+c     this subroutine defines the objective functions of eighteen
+c     nonlinear unconstrained minimization problems. the values
+c     of n for functions 1,2,3,4,5,10,11,12,16 and 17 are
+c     3,6,3,2,3,2,4,3,2 and 4, respectively.
+c     for function 7, n may be 2 or greater but is usually 6 or 9.
+c     for functions 6,8,9,13,14,15 and 18 n may be variable,
+c     however it must be even for function 14, a multiple of 4 for
+c     function 15, and not greater than 50 for function 18.
+c
+c     the subroutine statement is
+c
+c       subroutine objfcn(n,x,f,nprob)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an input array of length n.
+c
+c       f is an output variable which contains the value of
+c         the nprob objective function evaluated at x.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,datan,dcos,dexp,dlog,dsign,dsin,
+c                            dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iev,ivar,j
+      double precision ap,arg,c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,
+     *                 c2p25,c2p625,c3p5,c25,c29,c90,c100,c10000,
+     *                 c1pd6,d1,d2,eight,fifty,five,four,one,r,s1,s2,
+     *                 s3,t,t1,t2,t3,ten,th,three,tpi,two,zero
+      double precision fvec(50),y(15)
+      double precision dfloat
+      data zero,one,two,three,four,five,eight,ten,fifty
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,5.0d1/
+      data c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c25,
+     *     c29,c90,c100,c10000,c1pd6
+     *     /2.0d-6,1.0d-4,1.0d-1,2.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,
+     *      2.625d0,3.5d0,2.5d1,2.9d1,9.0d1,1.0d2,1.0d4,1.0d6/
+      data ap /1.0d-5/
+      data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11),
+     *     y(12),y(13),y(14),y(15)
+     *     /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1,
+     *      3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3,
+     *      9.0d-4/
+      dfloat(ivar) = ivar
+c
+c     function routine selector.
+c
+      go to (10,20,40,60,70,90,110,150,170,200,210,230,250,280,300,
+     *       320,330,340), nprob
+c
+c     helical valley function.
+c
+   10 continue
+      tpi = eight*datan(one)
+      th = dsign(cp25,x(2))
+      if (x(1) .gt. zero) th = datan(x(2)/x(1))/tpi
+      if (x(1) .lt. zero) th = datan(x(2)/x(1))/tpi + cp5
+      arg = x(1)**2 + x(2)**2
+      r = dsqrt(arg)
+      t = x(3) - ten*th
+      f = c100*(t**2 + (r - one)**2) + x(3)**2
+      go to 390
+c
+c     biggs exp6 function.
+c
+   20 continue
+      f = zero
+      do 30 i = 1, 13
+         d1 = dfloat(i)/ten
+         d2 = dexp(-d1) - five*dexp(-ten*d1) + three*dexp(-four*d1)
+         s1 = dexp(-d1*x(1))
+         s2 = dexp(-d1*x(2))
+         s3 = dexp(-d1*x(5))
+         t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2
+         f = f + t**2
+   30    continue
+      go to 390
+c
+c     gaussian function.
+c
+   40 continue
+      f = zero
+      do 50 i = 1, 15
+         d1 = cp5*dfloat(i-1)
+         d2 = c3p5 - d1 - x(3)
+         arg = -cp5*x(2)*d2**2
+         r = dexp(arg)
+         t = x(1)*r - y(i)
+         f = f + t**2
+   50    continue
+      go to 390
+c
+c     powell badly scaled function.
+c
+   60 continue
+      t1 = c10000*x(1)*x(2) - one
+      s1 = dexp(-x(1))
+      s2 = dexp(-x(2))
+      t2 = s1 + s2 - one - cp0001
+      f = t1**2 + t2**2
+      go to 390
+c
+c     box 3-dimensional function.
+c
+   70 continue
+      f = zero
+      do 80 i = 1, 10
+         d1 = dfloat(i)
+         d2 = d1/ten
+         s1 = dexp(-d2*x(1))
+         s2 = dexp(-d2*x(2))
+         s3 = dexp(-d2) - dexp(-d1)
+         t = s1 - s2 - s3*x(3)
+         f = f + t**2
+   80    continue
+      go to 390
+c
+c     variably dimensioned function.
+c
+   90 continue
+      t1 = zero
+      t2 = zero
+      do 100 j = 1, n
+         t1 = t1 + dfloat(j)*(x(j) - one)
+         t2 = t2 + (x(j) - one)**2
+  100    continue
+      f = t2 + t1**2*(one + t1**2)
+      go to 390
+c
+c     watson function.
+c
+  110 continue
+      f = zero
+      do 140 i = 1, 29
+         d1 = dfloat(i)/c29
+         s1 = zero
+         d2 = one
+         do 120 j = 2, n
+            s1 = s1 + dfloat(j-1)*d2*x(j)
+            d2 = d1*d2
+  120       continue
+         s2 = zero
+         d2 = one
+         do 130 j = 1, n
+            s2 = s2 + d2*x(j)
+            d2 = d1*d2
+  130       continue
+         t = s1 - s2**2 - one
+         f = f + t**2
+  140    continue
+      t1 = x(2) - x(1)**2 - one
+      f = f + x(1)**2 + t1**2
+      go to 390
+c
+c     penalty function i.
+c
+  150 continue
+      t1 = -cp25
+      t2 = zero
+      do 160 j = 1, n
+         t1 = t1 + x(j)**2
+         t2 = t2 + (x(j) - one)**2
+  160    continue
+      f = ap*t2 + t1**2
+      go to 390
+c
+c     penalty function ii.
+c
+  170 continue
+      t1 = -one
+      t2 = zero
+      t3 = zero
+      d1 = dexp(cp1)
+      d2 = one
+      do 190 j = 1, n
+         t1 = t1 + dfloat(n-j+1)*x(j)**2
+         s1 = dexp(x(j)/ten)
+         if (j .eq. 1) go to 180
+         s3 = s1 + s2 - d2*(d1 + one)
+         t2 = t2 + s3**2
+         t3 = t3 + (s1 - one/d1)**2
+  180    continue
+         s2 = s1
+         d2 = d1*d2
+  190    continue
+      f = ap*(t2 + t3) + t1**2 + (x(1) - cp2)**2
+      go to 390
+c
+c     brown badly scaled function.
+c
+  200 continue
+      t1 = x(1) - c1pd6
+      t2 = x(2) - c2pdm6
+      t3 = x(1)*x(2) - two
+      f = t1**2 + t2**2 + t3**2
+      go to 390
+c
+c     brown and dennis function.
+c
+  210 continue
+      f = zero
+      do 220 i = 1, 20
+         d1 = dfloat(i)/five
+         d2 = dsin(d1)
+         t1 = x(1) + d1*x(2) - dexp(d1)
+         t2 = x(3) + d2*x(4) - dcos(d1)
+         t = t1**2 + t2**2
+         f = f + t**2
+  220    continue
+      go to 390
+c
+c     gulf research and development function.
+c
+  230 continue
+      f = zero
+      d1 = two/three
+      do 240 i = 1, 99
+         arg = dfloat(i)/c100
+         r = (-fifty*dlog(arg))**d1 + c25 - x(2)
+         t1 = dabs(r)**x(3)/x(1)
+         t2 = dexp(-t1)
+         t = t2 - arg
+         f = f + t**2
+  240    continue
+      go to 390
+c
+c     trigonometric function.
+c
+  250 continue
+      s1 = zero
+      do 260 j = 1, n
+         s1 = s1 + dcos(x(j))
+  260    continue
+      f = zero
+      do 270 j = 1, n
+         t = dfloat(n+j) - dsin(x(j)) - s1 - dfloat(j)*dcos(x(j))
+         f = f + t**2
+  270    continue
+      go to 390
+c
+c     extended rosenbrock function.
+c
+  280 continue
+      f = zero
+      do 290 j = 1, n, 2
+         t1 = one - x(j)
+         t2 = ten*(x(j+1) - x(j)**2)
+         f = f + t1**2 + t2**2
+  290    continue
+      go to 390
+c
+c     extended powell function.
+c
+  300 continue
+      f = zero
+      do 310 j = 1, n, 4
+         t = x(j) + ten*x(j+1)
+         t1 = x(j+2) - x(j+3)
+         s1 = five*t1
+         t2 = x(j+1) - two*x(j+2)
+         s2 = t2**3
+         t3 = x(j) - x(j+3)
+         s3 = ten*t3**3
+         f = f + t**2 + s1*t1 + s2*t2 + s3*t3
+  310    continue
+      go to 390
+c
+c     beale function.
+c
+  320 continue
+      s1 = one - x(2)
+      t1 = c1p5 - x(1)*s1
+      s2 = one - x(2)**2
+      t2 = c2p25 - x(1)*s2
+      s3 = one - x(2)**3
+      t3 = c2p625 - x(1)*s3
+      f = t1**2 + t2**2 + t3**2
+      go to 390
+c
+c     wood function.
+c
+  330 continue
+      s1 = x(2) - x(1)**2
+      s2 = one - x(1)
+      s3 = x(2) - one
+      t1 = x(4) - x(3)**2
+      t2 = one - x(3)
+      t3 = x(4) - one
+      f = c100*s1**2 + s2**2 + c90*t1**2 + t2**2 + ten*(s3 + t3)**2
+     *    + (s3 - t3)**2/ten
+      go to 390
+c
+c     chebyquad function.
+c
+  340 continue
+      do 350 i = 1, n
+         fvec(i) = zero
+  350    continue
+      do 370 j = 1, n
+         t1 = one
+         t2 = two*x(j) - one
+         t = two*t2
+         do 360 i = 1, n
+            fvec(i) = fvec(i) + t2
+            th = t*t2 - t1
+            t1 = t2
+            t2 = th
+  360       continue
+  370    continue
+      f = zero
+      d1 = one/dfloat(n)
+      iev = -1
+      do 380 i = 1, n
+         t = d1*fvec(i)
+         if (iev .gt. 0) t = t + one/(dfloat(i)**2 - one)
+         f = f + t**2
+         iev = -iev
+  380    continue
+  390 continue
+      return
+c
+c     last card of subroutine objfcn.
+c
+      end
diff --git a/examples/ocpipt.f b/examples/ocpipt.f
new file mode 100644
index 0000000..762ae9e
--- /dev/null
+++ b/examples/ocpipt.f
@@ -0,0 +1,223 @@
+      subroutine initpt(n,x,nprob,factor)
+      integer n,nprob
+      double precision factor
+      double precision x(n)
+c     **********
+c
+c     subroutine initpt
+c
+c     this subroutine specifies the standard starting points for the
+c     functions defined by subroutine objfcn. the subroutine returns
+c     in x a multiple (factor) of the standard starting point. for
+c     the seventh function the standard starting point is zero, so in
+c     this case, if factor is not unity, then the subroutine returns
+c     the vector  x(j) = factor, j=1,...,n.
+c
+c     the subroutine statement is
+c
+c       subroutine initpt(n,x,nprob,factor)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an output array of length n which contains the standard
+c         starting point for problem nprob multiplied by factor.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c       factor is an input variable which specifies the multiple of
+c         the standard starting point. if factor is unity, no
+c         multiplication is performed.
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer ivar,j
+      double precision c1,c2,c3,c4,five,h,half,one,ten,three,twenty,
+     *                 twntf,two,zero
+      double precision dfloat
+      data zero,half,one,two,three,five,ten,twenty,twntf
+     *     /0.0d0,0.5d0,1.0d0,2.0d0,3.0d0,5.0d0,1.0d1,2.0d1,2.5d1/
+      data c1,c2,c3,c4 /4.0d-1,2.5d0,1.5d-1,1.2d0/
+      dfloat(ivar) = ivar
+c
+c     selection of initial point.
+c
+      go to (10,20,30,40,50,60,80,100,120,140,150,160,170,190,210,230,
+     *       240,250), nprob
+c
+c     helical valley function.
+c
+   10 continue
+      x(1) = -one
+      x(2) = zero
+      x(3) = zero
+      go to 270
+c
+c     biggs exp6 function.
+c
+   20 continue
+      x(1) = one
+      x(2) = two
+      x(3) = one
+      x(4) = one
+      x(5) = one
+      x(6) = one
+      go to 270
+c
+c     gaussian function.
+c
+   30 continue
+      x(1) = c1
+      x(2) = one
+      x(3) = zero
+      go to 270
+c
+c     powell badly scaled function.
+c
+   40 continue
+      x(1) = zero
+      x(2) = one
+      go to 270
+c
+c     box 3-dimensional function.
+c
+   50 continue
+      x(1) = zero
+      x(2) = ten
+      x(3) = twenty
+      go to 270
+c
+c     variably dimensioned function.
+c
+   60 continue
+      h = one/dfloat(n)
+      do 70 j = 1, n
+         x(j) = one - dfloat(j)*h
+   70    continue
+      go to 270
+c
+c     watson function.
+c
+   80 continue
+      do 90 j = 1, n
+         x(j) = zero
+   90    continue
+      go to 270
+c
+c     penalty function i.
+c
+  100 continue
+      do 110 j = 1, n
+         x(j) = dfloat(j)
+  110    continue
+      go to 270
+c
+c     penalty function ii.
+c
+  120 continue
+      do 130 j = 1, n
+         x(j) = half
+  130    continue
+      go to 270
+c
+c     brown badly scaled function.
+c
+  140 continue
+      x(1) = one
+      x(2) = one
+      go to 270
+c
+c     brown and dennis function.
+c
+  150 continue
+      x(1) = twntf
+      x(2) = five
+      x(3) = -five
+      x(4) = -one
+      go to 270
+c
+c     gulf research and development function.
+c
+  160 continue
+      x(1) = five
+      x(2) = c2
+      x(3) = c3
+      go to 270
+c
+c     trigonometric function.
+c
+  170 continue
+      h = one/dfloat(n)
+      do 180 j = 1, n
+         x(j) = h
+  180    continue
+      go to 270
+c
+c     extended rosenbrock function.
+c
+  190 continue
+      do 200 j = 1, n, 2
+         x(j) = -c4
+         x(j+1) = one
+  200    continue
+      go to 270
+c
+c     extended powell singular function.
+c
+  210 continue
+      do 220 j = 1, n, 4
+         x(j) = three
+         x(j+1) = -one
+         x(j+2) = zero
+         x(j+3) = one
+  220    continue
+      go to 270
+c
+c     beale function.
+c
+  230 continue
+      x(1) = one
+      x(2) = one
+      go to 270
+c
+c     wood function.
+c
+  240 continue
+      x(1) = -three
+      x(2) = -one
+      x(3) = -three
+      x(4) = -one
+      go to 270
+c
+c     chebyquad function.
+c
+  250 continue
+      h = one/dfloat(n+1)
+      do 260 j = 1, n
+         x(j) = dfloat(j)*h
+  260    continue
+  270 continue
+c
+c     compute multiple of initial point.
+c
+      if (factor .eq. one) go to 320
+      if (nprob .eq. 7) go to 290
+         do 280 j = 1, n
+            x(j) = factor*x(j)
+  280       continue
+         go to 310
+  290 continue
+         do 300 j = 1, n
+            x(j) = factor
+  300       continue
+  310 continue
+  320 continue
+      return
+c
+c     last card of subroutine initpt.
+c
+      end
diff --git a/examples/ref/chkdrv.ref b/examples/ref/chkdrv.ref
new file mode 100644
index 0000000..7f8f92b
--- /dev/null
+++ b/examples/ref/chkdrv.ref
@@ -0,0 +1,311 @@
+
+
+
+      problem    1      with dimension    2   is  F
+
+
+      first function vector   
+
+       0.2077000D+01 -0.2829290D+01
+
+
+      function difference vector
+
+      -0.1604855D-07  0.4763690D-06
+
+
+      error vector
+
+       0.3644165D-01  0.1000000D+01
+
+
+
+      problem    2      with dimension    4   is  F
+
+
+      first function vector   
+
+      -0.8107000D+01 -0.1685995D+01  0.1874161D+01  0.1595216D+02
+
+
+      function difference vector
+
+       0.2138764D-06 -0.2512329D-07 -0.3578106D-07  0.4754114D-06
+
+
+      error vector
+
+       0.1000000D+01  0.1000000D+01  0.5678431D-01  0.1000000D+01
+
+
+
+      problem    3      with dimension    2   is  F
+
+
+      first function vector   
+
+       0.1077710D+04  0.3001928D+00
+
+
+      function difference vector
+
+       0.3214806D-04 -0.7057517D-08
+
+
+      error vector
+
+       0.0000000D+00  0.0000000D+00
+
+
+
+      problem    4      with dimension    4   is  T
+
+
+      first function vector   
+
+      -0.5412711D+04 -0.1964946D+04 -0.4871828D+04 -0.1776943D+04
+
+
+      function difference vector
+
+       0.2322079D-03  0.5335169D-04  0.2089914D-03  0.4808346D-04
+
+
+      error vector
+
+       0.9831445D+00  0.1000000D+01  0.9658781D+00  0.1000000D+01
+
+
+
+      problem    5      with dimension    3   is  F
+
+
+      first function vector   
+
+      -0.5098770D+02 -0.1144166D+01  0.1230000D+00
+
+
+      function difference vector
+
+       0.1832842D-07 -0.1319622D-06  0.1832843D-08
+
+
+      error vector
+
+       0.1000000D+01  0.0000000D+00  0.1000000D+01
+
+
+
+      problem    6      with dimension    9   is  F
+
+
+      first function vector   
+
+      -0.5793063D+01 -0.3339075D+02 -0.3468318D+02 -0.3636873D+02 -0.3794767D+02
+      -0.3943133D+02 -0.4083424D+02 -0.4217079D+02 -0.4345330D+02
+
+
+      function difference vector
+
+       0.4515008D-06  0.8252608D-06  0.1047076D-05  0.1220878D-05  0.1363613D-05
+       0.1485300D-05  0.1592015D-05  0.1687697D-05  0.1775024D-05
+
+
+      error vector
+
+       0.0000000D+00  0.4428514D-01  0.5843401D-01  0.6994800D-01  0.7939773D-01
+       0.8744020D-01  0.9445016D-01  0.1006670D+00  0.1062543D+00
+
+
+
+      problem    7      with dimension    7   is  F
+
+
+      first function vector   
+
+       0.3514286D-01 -0.4563467D-01  0.2193640D+00  0.2130282D+00  0.2586583D+00
+       0.2308881D+00  0.5919599D-01
+
+
+      function difference vector
+
+       0.1542483D-07  0.2060287D-07  0.2376946D-07  0.5349155D-07  0.9704076D-07
+       0.1576633D-06  0.2112184D-06
+
+
+      error vector
+
+       0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
+       0.0000000D+00  0.0000000D+00
+
+
+
+      problem    8      with dimension   10   is  T
+
+
+      first function vector   
+
+      -0.5623000D+01 -0.5377000D+01 -0.5623000D+01 -0.5377000D+01 -0.5623000D+01
+      -0.5377000D+01 -0.5623000D+01 -0.5377000D+01 -0.5623000D+01 -0.9992853D+00
+
+
+      function difference vector
+
+       0.8012354D-07  0.8378923D-07  0.8012354D-07  0.8378923D-07  0.8012354D-07
+       0.8378923D-07  0.8012354D-07  0.8378923D-07  0.8012354D-07  0.1065044D-09
+
+
+      error vector
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+      problem    9      with dimension   10   is  F
+
+
+      first function vector   
+
+      -0.3826621D+00  0.4818555D+00 -0.5049706D+00  0.4836436D+00 -0.5032711D+00
+       0.4873159D+00 -0.4998232D+00  0.4940986D+00 -0.4932473D+00  0.3830850D+00
+
+
+      function difference vector
+
+       0.5774599D-08 -0.7078711D-08  0.7631400D-08 -0.7053519D-08  0.7658129D-08
+      -0.7038502D-08  0.7685262D-08 -0.7047090D-08  0.6495039D-08 -0.2818530D-08
+
+
+      error vector
+
+       0.3418948D-01  0.1620568D+00  0.2476906D-01  0.8244201D-01  0.1652737D-01
+       0.7483691D-01  0.1851528D-01  0.1034222D+00  0.3225956D-01  0.1235862D+00
+
+
+
+      problem   10      with dimension   10   is  F
+
+
+      first function vector   
+
+      -0.1679668D+00  0.4672854D-01 -0.2204317D+00  0.1737871D-01 -0.2284545D+00
+       0.2898338D-01 -0.2008946D+00  0.6905061D-01 -0.1551028D+00  0.1139911D+00
+
+
+      function difference vector
+
+       0.3294705D-08  0.8148107D-09  0.5413628D-08  0.2381044D-08  0.6401981D-08
+       0.2764787D-08  0.6166095D-08  0.1882141D-08  0.4645277D-08  0.9133732D-09
+
+
+      error vector
+
+       0.0000000D+00  0.3304434D-01  0.0000000D+00  0.0000000D+00  0.0000000D+00
+       0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.5761877D-01
+
+
+
+      problem   11      with dimension   10   is  F
+
+
+      first function vector   
+
+       0.1483931D+00 -0.4650248D-01  0.1489220D+00  0.3020784D-02  0.1494510D+00
+       0.5254404D-01  0.1499800D+00  0.1020673D+00  0.1505090D+00  0.1515906D+00
+
+
+      function difference vector
+
+       0.3284537D-08  0.1864165D-08  0.3268773D-08  0.3333951D-08  0.3253009D-08
+       0.4803739D-08  0.3237243D-08  0.6273523D-08  0.3221478D-08  0.7743310D-08
+
+
+      error vector
+
+       0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
+       0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
+
+
+
+      problem   12      with dimension   10   is  F
+
+
+      first function vector   
+
+      -0.1087888D+06 -0.2175772D+06 -0.3263660D+06 -0.4351544D+06 -0.5439433D+06
+      -0.6527317D+06 -0.7615206D+06 -0.8703090D+06 -0.9790979D+06 -0.1087886D+07
+
+
+      function difference vector
+
+       0.2249654D-02  0.4499299D-02  0.6748936D-02  0.8998581D-02  0.1124822D-01
+       0.1349786D-01  0.1574750D-01  0.1799715D-01  0.2024678D-01  0.2249643D-01
+
+
+      error vector
+
+       0.2027917D-01  0.2027908D-01  0.2027913D-01  0.2027909D-01  0.2027912D-01
+       0.2027910D-01  0.2027912D-01  0.2027910D-01  0.2027912D-01  0.2027910D-01
+
+
+
+      problem   13      with dimension   10   is  T
+
+
+      first function vector   
+
+      -0.3137258D+01  0.1997420D+00 -0.2260258D+01  0.1997420D+00 -0.2260258D+01
+       0.1997420D+00 -0.2260258D+01  0.1997420D+00 -0.2260258D+01 -0.2046258D+01
+
+
+      function difference vector
+
+       0.9923452D-07  0.3484660D-07  0.8616620D-07  0.3484660D-07  0.8616620D-07
+       0.3484660D-07  0.8616620D-07  0.3484660D-07  0.8616620D-07  0.6831461D-07
+
+
+      error vector
+
+       0.1000000D+01  0.8322908D+00  0.1000000D+01  0.8322908D+00  0.1000000D+01
+       0.8322908D+00  0.1000000D+01  0.8322908D+00  0.1000000D+01  0.9578359D+00
+
+
+
+      problem   14      with dimension   10   is  F
+
+
+      first function vector   
+
+      -0.8219368D+01 -0.4402889D+01 -0.8249626D+01 -0.4433147D+01 -0.8279884D+01
+      -0.4463405D+01 -0.8172013D+01 -0.4463405D+01 -0.8172013D+01 -0.4325276D+01
+
+
+      function difference vector
+
+       0.3598776D-06  0.2186061D-06  0.3905817D-06  0.2493102D-06  0.4212857D-06
+       0.2800143D-06  0.4311393D-06  0.2800143D-06  0.4311393D-06  0.2591637D-06
+
+
+      error vector
+
+       0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
+       0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00  0.0000000D+00
+1summary of  14 tests of chkder
+
+ nprob   n    status     errmin         errmax
+
+   1     2      F     0.3644165D-01  0.1000000D+01
+   2     4      F     0.5678431D-01  0.1000000D+01
+   3     2      F     0.0000000D+00  0.0000000D+00
+   4     4      T     0.9658781D+00  0.1000000D+01
+   5     3      F     0.0000000D+00  0.1000000D+01
+   6     9      F     0.0000000D+00  0.1062543D+00
+   7     7      F     0.0000000D+00  0.0000000D+00
+   8    10      T     0.1000000D+01  0.1000000D+01
+   9    10      F     0.1652737D-01  0.1620568D+00
+  10    10      F     0.0000000D+00  0.5761877D-01
+  11    10      F     0.0000000D+00  0.0000000D+00
+  12    10      F     0.2027908D-01  0.2027917D-01
+  13    10      T     0.8322908D+00  0.1000000D+01
+  14    10      F     0.0000000D+00  0.0000000D+00
diff --git a/examples/ref/chkdrvc.ref b/examples/ref/chkdrvc.ref
new file mode 100644
index 0000000..a895f86
--- /dev/null
+++ b/examples/ref/chkdrvc.ref
@@ -0,0 +1,311 @@
+
+
+
+      problem    1      with dimension    2   is  F
+
+
+      first function vector   
+
+       2.0770000e+00 -2.8292900e+00
+
+
+      function difference vector
+
+      -1.6048551e-08  4.7636896e-07
+
+
+      error vector
+
+       3.6441652e-02  1.0000000e+00
+
+
+
+      problem    2      with dimension    4   is  F
+
+
+      first function vector   
+
+      -8.1070000e+00 -1.6859953e+00  1.8741610e+00  1.5952160e+01
+
+
+      function difference vector
+
+       2.1387637e-07 -2.5123287e-08 -3.5781055e-08  4.7541143e-07
+
+
+      error vector
+
+       1.0000000e+00  1.0000000e+00  5.6784314e-02  1.0000000e+00
+
+
+
+      problem    3      with dimension    2   is  F
+
+
+      first function vector   
+
+       1.0777100e+03  3.0019279e-01
+
+
+      function difference vector
+
+       3.2148063e-05 -7.0575175e-09
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    4      with dimension    4   is  T
+
+
+      first function vector   
+
+      -5.4127112e+03 -1.9649458e+03 -4.8718278e+03 -1.7769432e+03
+
+
+      function difference vector
+
+       2.3220785e-04  5.3351694e-05  2.0899135e-04  4.8083460e-05
+
+
+      error vector
+
+       9.8314445e-01  1.0000000e+00  9.6587806e-01  1.0000000e+00
+
+
+
+      problem    5      with dimension    3   is  F
+
+
+      first function vector   
+
+      -5.0987696e+01 -1.1441658e+00  1.2300000e-01
+
+
+      function difference vector
+
+       1.8328421e-08 -1.3196221e-07  1.8328428e-09
+
+
+      error vector
+
+       1.0000000e+00  0.0000000e+00  1.0000000e+00
+
+
+
+      problem    6      with dimension    9   is  F
+
+
+      first function vector   
+
+      -5.7930631e+00 -3.3390751e+01 -3.4683179e+01 -3.6368725e+01 -3.7947668e+01
+      -3.9431326e+01 -4.0834243e+01 -4.2170791e+01 -4.3453299e+01
+
+
+      function difference vector
+
+       4.5150085e-07  8.2526081e-07  1.0470759e-06  1.2208782e-06  1.3636127e-06
+       1.4852995e-06  1.5920150e-06  1.6876970e-06  1.7750240e-06
+
+
+      error vector
+
+       0.0000000e+00  4.4776909e-02  5.8948123e-02  7.0484722e-02  7.9955256e-02
+       8.8016532e-02  9.5043433e-02  1.0127560e-01  1.0687673e-01
+
+
+
+      problem    7      with dimension    7   is  F
+
+
+      first function vector   
+
+       3.5142857e-02 -4.5634667e-02  2.1936396e-01  2.1302816e-01  2.5865828e-01
+       2.3088814e-01  5.9195986e-02
+
+
+      function difference vector
+
+       1.5424831e-08  2.0602874e-08  2.3769456e-08  5.3491546e-08  9.7040762e-08
+       1.5766330e-07  2.1121844e-07
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    8      with dimension   10   is  T
+
+
+      first function vector   
+
+      -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00
+      -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -9.9928526e-01
+
+
+      function difference vector
+
+       8.0123543e-08  8.3789228e-08  8.0123543e-08  8.3789228e-08  8.0123543e-08
+       8.3789228e-08  8.0123543e-08  8.3789228e-08  8.0123543e-08  1.0650436e-10
+
+
+      error vector
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+      problem    9      with dimension   10   is  F
+
+
+      first function vector   
+
+      -3.8266208e-01  4.8185552e-01 -5.0497059e-01  4.8364359e-01 -5.0327111e-01
+       4.8731586e-01 -4.9982317e-01  4.9409864e-01 -4.9324735e-01  3.8308496e-01
+
+
+      function difference vector
+
+       5.7745994e-09 -7.0787115e-09  7.6314004e-09 -7.0535194e-09  7.6581295e-09
+      -7.0385017e-09  7.6852619e-09 -7.0470895e-09  6.4950392e-09 -2.8185304e-09
+
+
+      error vector
+
+       3.4189481e-02  1.6205676e-01  2.4769060e-02  8.2442013e-02  1.6527366e-02
+       7.4836913e-02  1.8515282e-02  1.0342218e-01  3.2259557e-02  1.2358623e-01
+
+
+
+      problem   10      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.6796677e-01  4.6728538e-02 -2.2043167e-01  1.7378706e-02 -2.2845451e-01
+       2.8983382e-02 -2.0089459e-01  6.9050605e-02 -1.5510284e-01  1.1399106e-01
+
+
+      function difference vector
+
+       3.2947051e-09  8.1481072e-10  5.4136278e-09  2.3810444e-09  6.4019805e-09
+       2.7647869e-09  6.1660951e-09  1.8821412e-09  4.6452768e-09  9.1337315e-10
+
+
+      error vector
+
+       0.0000000e+00  8.3217918e-03  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  4.4819193e-02
+
+
+
+      problem   11      with dimension   10   is  F
+
+
+      first function vector   
+
+       1.4839305e-01 -4.6502477e-02  1.4892203e-01  3.0207835e-03  1.4945101e-01
+       5.2544044e-02  1.4997998e-01  1.0206730e-01  1.5050896e-01  1.5159056e-01
+
+
+      function difference vector
+
+       3.2845368e-09  1.8641646e-09  3.2687728e-09  3.3339513e-09  3.2530085e-09
+       4.8037387e-09  3.2372434e-09  6.2735230e-09  3.2214782e-09  7.7433100e-09
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   12      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.0878876e+05 -2.1757715e+05 -3.2636603e+05 -4.3515443e+05 -5.4394331e+05
+      -6.5273170e+05 -7.6152058e+05 -8.7030898e+05 -9.7909786e+05 -1.0878862e+06
+
+
+      function difference vector
+
+       2.2496541e-03  4.4992989e-03  6.7489363e-03  8.9985810e-03  1.1248218e-02
+       1.3497863e-02  1.5747500e-02  1.7997145e-02  2.0246784e-02  2.2496427e-02
+
+
+      error vector
+
+       2.0279172e-02  2.0279078e-02  2.0279130e-02  2.0279094e-02  2.0279122e-02
+       2.0279099e-02  2.0279119e-02  2.0279101e-02  2.0279116e-02  2.0279103e-02
+
+
+
+      problem   13      with dimension   10   is  T
+
+
+      first function vector   
+
+      -3.1372580e+00  1.9974200e-01 -2.2602580e+00  1.9974200e-01 -2.2602580e+00
+       1.9974200e-01 -2.2602580e+00  1.9974200e-01 -2.2602580e+00 -2.0462580e+00
+
+
+      function difference vector
+
+       9.9234522e-08  3.4846602e-08  8.6166204e-08  3.4846602e-08  8.6166204e-08
+       3.4846602e-08  8.6166204e-08  3.4846602e-08  8.6166204e-08  6.8314610e-08
+
+
+      error vector
+
+       1.0000000e+00  8.3229083e-01  1.0000000e+00  8.3229083e-01  1.0000000e+00
+       8.3229083e-01  1.0000000e+00  8.3229083e-01  1.0000000e+00  9.5783592e-01
+
+
+
+      problem   14      with dimension   10   is  F
+
+
+      first function vector   
+
+      -8.2193683e+00 -4.4028887e+00 -8.2496263e+00 -4.4331467e+00 -8.2798843e+00
+      -4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252757e+00
+
+
+      function difference vector
+
+       3.5987758e-07  2.1860611e-07  3.9058166e-07  2.4931019e-07  4.2128574e-07
+       2.8001427e-07  4.3113925e-07  2.8001427e-07  4.3113925e-07  2.5916370e-07
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
 summary of  14 tests of chkder
+
+ nprob   n    status     errmin         errmax
+
+   1     2      F     3.6441652e-02  1.0000000e+00
+   2     4      F     5.6784314e-02  1.0000000e+00
+   3     2      F     0.0000000e+00  0.0000000e+00
+   4     4      T     9.6587806e-01  1.0000000e+00
+   5     3      F     0.0000000e+00  1.0000000e+00
+   6     9      F     0.0000000e+00  1.0687673e-01
+   7     7      F     0.0000000e+00  0.0000000e+00
+   8    10      T     1.0000000e+00  1.0000000e+00
+   9    10      F     1.6527366e-02  1.6205676e-01
+  10    10      F     0.0000000e+00  4.4819193e-02
+  11    10      F     0.0000000e+00  0.0000000e+00
+  12    10      F     2.0279078e-02  2.0279172e-02
+  13    10      T     8.3229083e-01  1.0000000e+00
+  14    10      F     0.0000000e+00  0.0000000e+00
diff --git a/examples/ref/hchkdrvc.ref b/examples/ref/hchkdrvc.ref
new file mode 100644
index 0000000..681065b
--- /dev/null
+++ b/examples/ref/hchkdrvc.ref
@@ -0,0 +1,311 @@
+
+
+
+      problem    1      with dimension    2   is  F
+
+
+      first function vector   
+
+       2.0781250e+00 -2.8320312e+00
+
+
+      function difference vector
+
+      -3.5156250e-02  9.7656250e-01
+
+
+      error vector
+
+       0.0000000e+00  5.4150391e-01
+
+
+
+      problem    2      with dimension    4   is  F
+
+
+      first function vector   
+
+      -8.1093750e+00 -1.6855469e+00  1.8750000e+00  1.5953125e+01
+
+
+      function difference vector
+
+       4.5312500e-01 -5.2734375e-02 -7.4218750e-02  1.0156250e+00
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem    3      with dimension    2   is  F
+
+
+      first function vector   
+
+       1.0780000e+03  3.0029297e-01
+
+
+      function difference vector
+
+       6.8000000e+01 -1.4648438e-02
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    4      with dimension    4   is  T
+
+
+      first function vector   
+
+      -5.4120000e+03 -1.9650000e+03 -4.8720000e+03 -1.7770000e+03
+
+
+      function difference vector
+
+       4.6800000e+02  1.1000000e+02  4.2400000e+02  9.9000000e+01
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem    5      with dimension    3   is  F
+
+
+      first function vector   
+
+      -5.0968750e+01 -1.1425781e+00  1.2298584e-01
+
+
+      function difference vector
+
+       3.1250000e-02 -2.7832031e-01  3.8452148e-03
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem    6      with dimension    9   is  F
+
+
+      first function vector   
+
+      -5.7968750e+00 -3.3406250e+01 -3.4687500e+01 -3.6375000e+01 -3.7937500e+01
+      -3.9406250e+01 -4.0812500e+01 -4.2156250e+01 -4.3437500e+01
+
+
+      function difference vector
+
+       8.9843750e-01  1.6718750e+00  2.1562500e+00  2.5312500e+00  2.8125000e+00
+       3.0312500e+00  3.2500000e+00  3.4687500e+00  3.6562500e+00
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem    7      with dimension    7   is  F
+
+
+      first function vector   
+
+       3.5156250e-02 -4.5562744e-02  2.1936035e-01  2.1313477e-01  2.5878906e-01
+       2.3120117e-01  5.9967041e-02
+
+
+      function difference vector
+
+       3.2348633e-02  4.6386719e-02  5.8959961e-02  1.3500977e-01  2.5927734e-01
+       4.5629883e-01  6.9824219e-01
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    8      with dimension   10   is  T
+
+
+      first function vector   
+
+      -5.6250000e+00 -5.3750000e+00 -5.6250000e+00 -5.3750000e+00 -5.6250000e+00
+      -5.3750000e+00 -5.6250000e+00 -5.3750000e+00 -5.6250000e+00 -9.9951172e-01
+
+
+      function difference vector
+
+       1.7187500e-01  1.7187500e-01  1.7187500e-01  1.7187500e-01  1.7187500e-01
+       1.7187500e-01  1.7187500e-01  1.7187500e-01  1.7187500e-01  4.8828125e-04
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem    9      with dimension   10   is  F
+
+
+      first function vector   
+
+      -3.8256836e-01  4.8193359e-01 -5.0488281e-01  4.8364258e-01 -5.0292969e-01
+       4.8730469e-01 -4.9975586e-01  4.9414062e-01 -4.9316406e-01  3.8256836e-01
+
+
+      function difference vector
+
+       1.2207031e-02 -1.4892578e-02  1.5869141e-02 -1.4648438e-02  1.5625000e-02
+      -1.4648438e-02  1.5869141e-02 -1.4648438e-02  1.3671875e-02 -5.8593750e-03
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   10      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.6784668e-01  4.6783447e-02 -2.2033691e-01  1.7379761e-02 -2.2839355e-01
+       2.8976440e-02 -2.0092773e-01  6.8969727e-02 -1.5515137e-01  1.1395264e-01
+
+
+      function difference vector
+
+       6.9580078e-03  1.7089844e-03  1.1230469e-02  5.0659180e-03  1.3427734e-02
+       5.8441162e-03  1.2939453e-02  4.0893555e-03  9.7656250e-03  1.8920898e-03
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   11      with dimension   10   is  F
+
+
+      first function vector   
+
+       1.4843750e-01 -4.6264648e-02  1.4941406e-01  3.5495758e-03  1.5039062e-01
+       5.3344727e-02  1.5136719e-01  1.0314941e-01  1.5234375e-01  1.5295410e-01
+
+
+      function difference vector
+
+       7.2021484e-03  3.9672852e-03  7.2021484e-03  6.8969727e-03  7.2021484e-03
+       9.8266602e-03  7.2021484e-03  1.2756348e-02  7.2021484e-03  1.5747070e-02
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   12      with dimension   10   is  F
+
+
+      first function vector   
+
+                -inf           -inf           -inf           -inf           -inf
+                -inf           -inf           -inf           -inf           -inf
+
+
+      function difference vector
+
+                 nan            nan            nan            nan            nan
+                 nan            nan            nan            nan            nan
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   13      with dimension   10   is  T
+
+
+      first function vector   
+
+      -3.1367188e+00  2.0117188e-01 -2.2597656e+00  2.0117188e-01 -2.2597656e+00
+       2.0117188e-01 -2.2597656e+00  2.0117188e-01 -2.2597656e+00 -2.0449219e+00
+
+
+      function difference vector
+
+       2.0703125e-01  7.0312500e-02  1.7968750e-01  7.0312500e-02  1.7968750e-01
+       7.0312500e-02  1.7968750e-01  7.0312500e-02  1.7968750e-01  1.4062500e-01
+
+
+      error vector
+
+       0.0000000e+00  4.7924805e-01  0.0000000e+00  4.7924805e-01  0.0000000e+00
+       4.7924805e-01  0.0000000e+00  4.7924805e-01  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   14      with dimension   10   is  F
+
+
+      first function vector   
+
+      -8.2187500e+00 -4.4023438e+00 -8.2500000e+00 -4.4335938e+00 -8.2812500e+00
+      -4.4648438e+00 -8.1718750e+00 -4.4648438e+00 -8.1718750e+00 -4.3242188e+00
+
+
+      function difference vector
+
+       7.3437500e-01  4.4531250e-01  7.9687500e-01  5.0976562e-01  8.5937500e-01
+       5.7226562e-01  8.7890625e-01  5.7226562e-01  8.7890625e-01  5.2734375e-01
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
 summary of  14 tests of chkder
+
+ nprob   n    status     errmin         errmax
+
+   1     2      F     0.0000000e+00  5.4150391e-01
+   2     4      F     0.0000000e+00  0.0000000e+00
+   3     2      F     0.0000000e+00  0.0000000e+00
+   4     4      T     0.0000000e+00  0.0000000e+00
+   5     3      F     0.0000000e+00  0.0000000e+00
+   6     9      F     0.0000000e+00  0.0000000e+00
+   7     7      F     0.0000000e+00  0.0000000e+00
+   8    10      T     0.0000000e+00  0.0000000e+00
+   9    10      F     0.0000000e+00  0.0000000e+00
+  10    10      F     0.0000000e+00  0.0000000e+00
+  11    10      F     0.0000000e+00  0.0000000e+00
+  12    10      F     0.0000000e+00  0.0000000e+00
+  13    10      T     0.0000000e+00  4.7924805e-01
+  14    10      F     0.0000000e+00  0.0000000e+00
diff --git a/examples/ref/hhybdrvc.ref b/examples/ref/hhybdrvc.ref
new file mode 100644
index 0000000..95745e5
--- /dev/null
+++ b/examples/ref/hhybdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9257812e+00
+
+      final l2 norm of the residuals    1.9531250e-02
+
+      number of function evaluations          24
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0019531e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400000e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.2000000e+02  1.0000000e+02
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4664062e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          24
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.7683716e-05 -4.7683716e-06  2.6702881e-05  2.6702881e-05
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2710000e+03
+
+      final l2 norm of the residuals    5.9604645e-08
+
+      number of function evaluations          39
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+       1.0424852e-04 -1.0430813e-05  4.5299530e-06  4.5299530e-06
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.0000000e+02 -1.0000000e+02  0.0000000e+00  1.0000000e+02
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654297e+00
+
+      final l2 norm of the residuals    1.3046265e-02
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.0861626e-05  4.8437500e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.0000000e+00  1.0000000e+01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5520000e+03
+
+      final l2 norm of the residuals    2.2497559e-01
+
+      number of function evaluations          27
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.0146484e+00  1.0390625e+00 -9.1943359e-01  8.5644531e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -3.0000000e+01 -1.0000000e+01 -3.0000000e+01 -1.0000000e+01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -3.0000000e+02 -1.0000000e+02 -3.0000000e+02 -1.0000000e+02
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    5.9795380e-04
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  3.8504601e-05  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0293750e+02
+
+      final l2 norm of the residuals    3.2024384e-03
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -2.0122528e-04  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9150000e+02
+
+      final l2 norm of the residuals    9.9150000e+02
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.0000000e+02  0.0000000e+00  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8500000e+01
+
+      final l2 norm of the residuals    1.0461426e-01
+
+      number of function evaluations          40
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.6640625e-02  9.6191406e-01  2.0141602e-03  7.7050781e-01 -1.1230469e+00
+       8.2421875e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+       1.0000000e+01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8812500e+01
+
+      final l2 norm of the residuals    3.0419922e-01
+
+      number of function evaluations          29
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.8515625e-01  1.0703125e+00 -4.4091797e-01  1.1025391e+00 -5.6591797e-01
+      -6.8359375e-01 -5.7617188e-01  2.7031250e+00 -1.4453125e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570801e-01
+
+      final l2 norm of the residuals    1.0314941e-02
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.1665039e-02  3.1469727e-01  4.9902344e-01  6.8847656e-01  9.1601562e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6660156e+00  3.3320312e+00  5.0000000e+00  6.6640625e+00  8.3281250e+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6656250e+01  3.3312500e+01  5.0000000e+01  6.6625000e+01  8.3312500e+01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1533203e-01
+
+      final l2 norm of the residuals    5.9890747e-03
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+       6.6955566e-02  3.6621094e-01  2.8930664e-01  7.1386719e-01  6.3085938e-01
+       9.3261719e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.4277344e+00  2.8554688e+00  4.2851562e+00  5.7109375e+00  7.1406250e+00
+       8.5703125e+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.4281250e+01  2.8562500e+01  4.2843750e+01  5.7125000e+01  7.1375000e+01
+       8.5687500e+01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8371582e-01
+
+      final l2 norm of the residuals    1.6342163e-02
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.4992676e-02  2.3339844e-01  3.4179688e-01  4.9951172e-01  6.6601562e-01
+       7.6123047e-01  9.4335938e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+00  2.5000000e+00  3.7500000e+00  5.0000000e+00  6.2500000e+00
+       7.5000000e+00  8.7500000e+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+01  2.5000000e+01  3.7500000e+01  5.0000000e+01  6.2500000e+01
+       7.5000000e+01  8.7500000e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9628906e-01
+
+      final l2 norm of the residuals    1.2292480e-01
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6162109e-02  2.1008301e-01  2.9614258e-01  4.8583984e-01  5.1171875e-01
+       7.4121094e-01  7.5390625e-01  9.3701172e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.7041016e-01
+
+      final l2 norm of the residuals    1.5783691e-01
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.1308594e-02  2.0617676e-01  2.7783203e-01  4.1113281e-01  5.2929688e-01
+       5.6054688e-01  7.5488281e-01  7.5732422e-01  9.1162109e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6531250e+01
+
+      final l2 norm of the residuals    1.6531250e+01
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3500000e+01
+
+      final l2 norm of the residuals    8.3500000e+01
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2800000e+02
+
+      final l2 norm of the residuals    1.2800000e+02
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.7954102e-02
+
+      final l2 norm of the residuals    2.2244453e-04
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3121338e-02 -8.1542969e-02 -1.1444092e-01 -1.4086914e-01 -1.5979004e-01
+      -1.6979980e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5378418e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2636719e-01
+
+      final l2 norm of the residuals    1.9133091e-04
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3212891e-02 -8.1665039e-02 -1.1462402e-01 -1.4111328e-01 -1.6003418e-01
+      -1.7004395e-01 -1.6931152e-01 -1.5539551e-01 -1.2548828e-01 -7.5500488e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0650000e+02
+
+      final l2 norm of the residuals    2.2244453e-04
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3121338e-02 -8.1542969e-02 -1.1444092e-01 -1.4086914e-01 -1.5979004e-01
+      -1.6979980e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5378418e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    1.2207031e-04
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5283203e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    2.4414062e-04
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5270996e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3600000e+02
+
+      final l2 norm of the residuals    1.2207031e-04
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5283203e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5195312e-01
+
+      final l2 norm of the residuals    2.7704239e-04
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3182373e-02 -8.1542969e-02 -1.1444092e-01 -1.4099121e-01 -1.5991211e-01
+      -1.6979980e-01 -1.6906738e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1171875e+00
+
+      final l2 norm of the residuals    1.2266636e-04
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3151855e-02 -8.1542969e-02 -1.1450195e-01 -1.4099121e-01 -1.5991211e-01
+      -1.6992188e-01 -1.6918945e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2690000e+03
+
+      final l2 norm of the residuals    3.4570694e-04
+
+      number of function evaluations          31
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3182373e-02 -8.1604004e-02 -1.1456299e-01 -1.4111328e-01 -1.6003418e-01
+      -1.7004395e-01 -1.6918945e-01 -1.5527344e-01 -1.2548828e-01 -7.5683594e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3688965e-02
+
+      final l2 norm of the residuals    7.9040527e-03
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.5898438e-02  4.7912598e-02  4.9285889e-02  5.1391602e-02  5.2490234e-02
+       5.1940918e-02  5.3375244e-02  1.9348145e-01  1.6394043e-01  1.3696289e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0296875e+01
+
+      final l2 norm of the residuals    8.7890625e-02
+
+      number of function evaluations          40
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.5021973e-02  9.0087891e-02  1.3342285e-01  1.6113281e-01  1.3232422e-01
+       1.1614990e-01  8.3679199e-02  6.1950684e-02  1.0296631e-01  1.9531250e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3437500e+01
+
+      final l2 norm of the residuals    4.2148438e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.7531250e+01  1.2921875e+01  1.2656250e+01  1.2718750e+01  1.2796875e+01
+       1.2718750e+01  1.2703125e+01  1.2437500e+01  1.2507812e+01  1.3062500e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       8.9990234e-01  7.9980469e-01  7.0019531e-01  6.0009766e-01  5.0000000e-01
+       4.0014648e-01  3.0029297e-01  2.0019531e-01  1.0021973e-01  2.4414062e-04
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       9.0000000e+00  8.0000000e+00  7.0000000e+00  6.0000000e+00  5.0000000e+00
+       4.0000000e+00  3.0039062e+00  2.0019531e+00  1.0019531e+00  2.4414062e-03
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       9.0000000e+01  8.0000000e+01  7.0000000e+01  6.0000000e+01  5.0000000e+01
+       4.0000000e+01  3.0031250e+01  2.0015625e+01  1.0023438e+01  2.4414062e-02
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5820312e+00
+
+      final l2 norm of the residuals    5.9394836e-03
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -5.7031250e-01 -6.8164062e-01 -7.0166016e-01 -7.0507812e-01 -7.0458984e-01
+      -7.0117188e-01 -6.9189453e-01 -6.6650391e-01 -5.9667969e-01 -4.1699219e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3900000e+02
+
+      final l2 norm of the residuals    1.8936157e-02
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -5.7080078e-01 -6.8115234e-01 -7.0263672e-01 -7.0605469e-01 -7.0605469e-01
+      -7.0312500e-01 -6.9287109e-01 -6.6503906e-01 -5.9277344e-01 -4.1552734e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3392000e+04
+
+      final l2 norm of the residuals    5.6304932e-03
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7080078e-01 -6.8164062e-01 -7.0214844e-01 -7.0556641e-01 -7.0507812e-01
+      -7.0166016e-01 -6.9189453e-01 -6.6601562e-01 -5.9619141e-01 -4.1552734e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8968750e+01
+
+      final l2 norm of the residuals    6.0119629e-03
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2895508e-01 -4.7656250e-01 -5.1953125e-01 -5.5810547e-01 -5.9277344e-01
+      -6.2451172e-01 -6.2304688e-01 -6.2158203e-01 -6.2060547e-01 -5.8593750e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7136000e+04
+
+      final l2 norm of the residuals    4.2083740e-02
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3579102e-01 -4.7973633e-01 -5.2099609e-01 -5.5908203e-01 -5.9277344e-01
+      -6.2548828e-01 -6.2402344e-01 -6.2207031e-01 -6.2060547e-01 -5.8642578e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02
+      -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02
+
 summary of 55 calls to hybrd1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     24      5     1   1.9531250e-02
+   1     2      8      1     1   0.0000000e+00
+   1     2     11      2     4             inf
+   2     4     24      2     1   0.0000000e+00
+   2     4     39      4     3   5.9604645e-08
+   2     4     11      2     4             inf
+   3     2     18      3     1   1.3046265e-02
+   3     2     11      2     4   1.0000000e+00
+   4     4     27      2     1   2.2497559e-01
+   4     4     11      2     4             nan
+   4     4     11      2     4             nan
+   5     3     14      3     1   5.9795380e-04
+   5     3     15      3     1   3.2024384e-03
+   5     3     11      2     4   9.9150000e+02
+   6     6     40      6     1   1.0461426e-01
+   6     6     11      2     4             nan
+   6     9     29      3     1   3.0419922e-01
+   6     9     11      2     4             nan
+   7     5      6      1     1   1.0314941e-02
+   7     5     11      2     4             nan
+   7     5     11      2     4             nan
+   7     6     11      1     3   5.9890747e-03
+   7     6     11      2     4             nan
+   7     6     11      2     4             nan
+   7     7     10      2     1   1.6342163e-02
+   7     7     11      2     4             nan
+   7     7     11      2     4             nan
+   7     8      9      2     1   1.2292480e-01
+   7     9      8      2     1   1.5783691e-01
+   8    10     11      2     4   1.6531250e+01
+   8    10     11      2     4             inf
+   8    10     11      2     4             inf
+   8    30     11      2     4   8.3500000e+01
+   8    40     11      2     4   1.2800000e+02
+   9    10      3      1     1   2.2244453e-04
+   9    10      5      1     1   1.9133091e-04
+   9    10     16      2     1   2.2244453e-04
+  10     1      3      1     1   1.2207031e-04
+  10     1      5      1     1   2.4414062e-04
+  10     1     15      1     3   1.2207031e-04
+  10    10      3      1     1   2.7704239e-04
+  10    10      5      1     1   1.2266636e-04
+  10    10     31      1     1   3.4570694e-04
+  11    10     20      4     1   7.9040527e-03
+  11    10     40      8     1   8.7890625e-02
+  11    10      7      2     1   4.2148438e+00
+  12    10     11      2     4             nan
+  12    10     11      2     4             nan
+  12    10     11      2     4             nan
+  13    10      5      1     3   5.9394836e-03
+  13    10     20      1     3   1.8936157e-02
+  13    10     17      2     1   5.6304932e-03
+  14    10      8      1     1   6.0119629e-03
+  14    10     17      2     1   4.2083740e-02
+  14    10     11      2     4             nan
diff --git a/examples/ref/hhyjdrvc.ref b/examples/ref/hhyjdrvc.ref
new file mode 100644
index 0000000..6684081
--- /dev/null
+++ b/examples/ref/hhyjdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9257812e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400000e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.2000000e+02  1.0000000e+02
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4664062e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          26
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -8.4042549e-05  8.4042549e-06 -5.6743622e-05 -5.6743622e-05
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2710000e+03
+
+      final l2 norm of the residuals    5.9604645e-08
+
+      number of function evaluations          32
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.3709068e-05  1.3709068e-06 -1.4531612e-04 -1.4531612e-04
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.0000000e+02 -1.0000000e+02  0.0000000e+00  1.0000000e+02
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654297e+00
+
+      final l2 norm of the residuals    1.1634827e-02
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.1219254e-05  4.7500000e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.0000000e+00  1.0000000e+01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5520000e+03
+
+      final l2 norm of the residuals    1.7578125e-01
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.0009766e+00  1.0126953e+00 -9.3212891e-01  8.8085938e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -3.0000000e+01 -1.0000000e+01 -3.0000000e+01 -1.0000000e+01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -3.0000000e+02 -1.0000000e+02 -3.0000000e+02 -1.0000000e+02
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    2.1438599e-02
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9902344e-01 -1.1978149e-03  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0293750e+02
+
+      final l2 norm of the residuals    2.1839142e-03
+
+      number of function evaluations          17
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.3732910e-04  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9150000e+02
+
+      final l2 norm of the residuals    1.0047913e-02
+
+      number of function evaluations          34
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9902344e-01 -1.4877319e-04  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8500000e+01
+
+      final l2 norm of the residuals    2.0837402e-01
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.2241211e-01  1.0410156e+00 -1.8884277e-01  3.0053711e-01 -1.0900879e-01
+       1.6516113e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+       1.0000000e+01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8812500e+01
+
+      final l2 norm of the residuals    2.5097656e-01
+
+      number of function evaluations          21
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.6074219e-01  1.0810547e+00 -3.7304688e-01  6.5869141e-01 -3.2885742e-01
+      -2.5238037e-02  2.4536133e-01 -1.0021973e-01  2.6489258e-02
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570801e-01
+
+      final l2 norm of the residuals    9.3307495e-03
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3007812e-02  3.1298828e-01  5.0097656e-01  6.8505859e-01  9.1748047e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6660156e+00  3.3320312e+00  5.0000000e+00  6.6640625e+00  8.3281250e+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6656250e+01  3.3312500e+01  5.0000000e+01  6.6625000e+01  8.3312500e+01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1533203e-01
+
+      final l2 norm of the residuals    1.2073517e-03
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6894531e-02  3.6645508e-01  2.8881836e-01  7.1093750e-01  6.3378906e-01
+       9.3310547e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.4277344e+00  2.8554688e+00  4.2851562e+00  5.7109375e+00  7.1406250e+00
+       8.5703125e+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.4281250e+01  2.8562500e+01  4.2843750e+01  5.7125000e+01  7.1375000e+01
+       8.5687500e+01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8371582e-01
+
+      final l2 norm of the residuals    2.4414062e-02
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+       6.2988281e-02  2.4389648e-01  3.3374023e-01  5.0000000e-01  6.6552734e-01
+       7.5634766e-01  9.3701172e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+00  2.5000000e+00  3.7500000e+00  5.0000000e+00  6.2500000e+00
+       7.5000000e+00  8.7500000e+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+01  2.5000000e+01  3.7500000e+01  5.0000000e+01  6.2500000e+01
+       7.5000000e+01  8.7500000e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9628906e-01
+
+      final l2 norm of the residuals    1.5161133e-01
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.0699463e-02  1.9433594e-01  3.1909180e-01  4.3750000e-01  5.6396484e-01
+       6.7724609e-01  8.0810547e-01  9.3847656e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.7041016e-01
+
+      final l2 norm of the residuals    1.6394043e-01
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4769287e-02  1.8212891e-01  2.8344727e-01  3.8452148e-01  5.0878906e-01
+       6.0009766e-01  7.2509766e-01  8.1591797e-01  9.5410156e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6531250e+01
+
+      final l2 norm of the residuals    1.6531250e+01
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3500000e+01
+
+      final l2 norm of the residuals    8.3500000e+01
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2800000e+02
+
+      final l2 norm of the residuals    1.2800000e+02
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+       5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01  5.0000000e-01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.7954102e-02
+
+      final l2 norm of the residuals    2.0611286e-04
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -4.3151855e-02 -8.1542969e-02 -1.1437988e-01 -1.4086914e-01 -1.5979004e-01
+      -1.6967773e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5317383e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2636719e-01
+
+      final l2 norm of the residuals    2.1624565e-04
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -4.3151855e-02 -8.1542969e-02 -1.1444092e-01 -1.4086914e-01 -1.5979004e-01
+      -1.6979980e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5378418e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0650000e+02
+
+      final l2 norm of the residuals    1.9276142e-04
+
+      number of function evaluations          21
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -4.3121338e-02 -8.1481934e-02 -1.1437988e-01 -1.4086914e-01 -1.5979004e-01
+      -1.6967773e-01 -1.6894531e-01 -1.5515137e-01 -1.2524414e-01 -7.5317383e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    1.2207031e-04
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5283203e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    2.4414062e-04
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5270996e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3600000e+02
+
+      final l2 norm of the residuals    8.3600000e+02
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.5000000e+01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5195312e-01
+
+      final l2 norm of the residuals    1.1938810e-04
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3182373e-02 -8.1542969e-02 -1.1456299e-01 -1.4099121e-01 -1.5991211e-01
+      -1.6992188e-01 -1.6906738e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1171875e+00
+
+      final l2 norm of the residuals    3.1781197e-04
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3151855e-02 -8.1542969e-02 -1.1450195e-01 -1.4099121e-01 -1.5979004e-01
+      -1.6979980e-01 -1.6906738e-01 -1.5527344e-01 -1.2548828e-01 -7.5622559e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2690000e+03
+
+      final l2 norm of the residuals    1.2690000e+03
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -8.2656250e+00 -1.4867188e+01 -1.9843750e+01 -2.3125000e+01 -2.4796875e+01
+      -2.4796875e+01 -2.3140625e+01 -1.9843750e+01 -1.4890625e+01 -8.2968750e+00
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3688965e-02
+
+      final l2 norm of the residuals    6.8588257e-03
+
+      number of function evaluations          22
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.0781250e-02  5.2215576e-02  5.3649902e-02  5.4077148e-02  5.9051514e-02
+       5.9631348e-02  2.2363281e-01  1.7907715e-01  7.6416016e-02  8.3618164e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0296875e+01
+
+      final l2 norm of the residuals    2.7942657e-03
+
+      number of function evaluations          30
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.6997070e-02  4.8187256e-02  4.9621582e-02  5.2062988e-02  5.3619385e-02
+       5.5084229e-02  5.6671143e-02  1.8615723e-01  1.5698242e-01  1.2036133e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3437500e+01
+
+      final l2 norm of the residuals    4.4296875e+00
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.0125000e+01  1.8703125e+01  1.2906250e+01  1.2812500e+01  1.2804688e+01
+       1.2843750e+01  1.3078125e+01  6.2578125e+00  1.2312500e+01  1.2484375e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       8.9990234e-01  7.9980469e-01  7.0019531e-01  6.0009766e-01  5.0000000e-01
+       4.0014648e-01  3.0029297e-01  2.0019531e-01  1.0021973e-01  2.4414062e-04
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       9.0000000e+00  8.0000000e+00  7.0000000e+00  6.0000000e+00  5.0000000e+00
+       4.0000000e+00  3.0039062e+00  2.0019531e+00  1.0019531e+00  2.4414062e-03
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       9.0000000e+01  8.0000000e+01  7.0000000e+01  6.0000000e+01  5.0000000e+01
+       4.0000000e+01  3.0031250e+01  2.0015625e+01  1.0023438e+01  2.4414062e-02
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5820312e+00
+
+      final l2 norm of the residuals    5.9394836e-03
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           1
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -5.7031250e-01 -6.8164062e-01 -7.0166016e-01 -7.0507812e-01 -7.0458984e-01
+      -7.0117188e-01 -6.9189453e-01 -6.6650391e-01 -5.9667969e-01 -4.1699219e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3900000e+02
+
+      final l2 norm of the residuals    7.8735352e-02
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.6640625e-01 -6.8017578e-01 -7.0312500e-01 -7.0654297e-01 -7.0703125e-01
+      -7.0605469e-01 -6.9970703e-01 -6.7285156e-01 -5.8984375e-01 -4.0380859e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3392000e+04
+
+      final l2 norm of the residuals    7.7056885e-03
+
+      number of function evaluations          17
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7080078e-01 -6.8164062e-01 -7.0214844e-01 -7.0556641e-01 -7.0507812e-01
+      -7.0166016e-01 -6.9189453e-01 -6.6601562e-01 -5.9619141e-01 -4.1503906e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8968750e+01
+
+      final l2 norm of the residuals    4.9209595e-03
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2895508e-01 -4.7680664e-01 -5.1953125e-01 -5.5810547e-01 -5.9277344e-01
+      -6.2451172e-01 -6.2304688e-01 -6.2109375e-01 -6.2060547e-01 -5.8642578e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7136000e+04
+
+      final l2 norm of the residuals    5.3161621e-02
+
+      number of function evaluations          17
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3774414e-01 -4.8046875e-01 -5.2148438e-01 -5.5957031e-01 -5.9326172e-01
+      -6.2548828e-01 -6.2402344e-01 -6.2207031e-01 -6.2109375e-01 -5.8642578e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02
+      -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02 -1.0000000e+02
+
 summary of 55 calls to hybrj1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      8      1     1   0.0000000e+00
+   1     2     11      2     4             inf
+   2     4     26      2     1   0.0000000e+00
+   2     4     32      3     1   5.9604645e-08
+   2     4     11      2     4             inf
+   3     2     25      3     1   1.1634827e-02
+   3     2     11      2     4   1.0000000e+00
+   4     4     20      2     1   1.7578125e-01
+   4     4     11      2     4             nan
+   4     4     11      2     4             nan
+   5     3     14      3     1   2.1438599e-02
+   5     3     17      4     1   2.1839142e-03
+   5     3     34      8     1   1.0047913e-02
+   6     6     20      2     1   2.0837402e-01
+   6     6     11      2     4             nan
+   6     9     21      3     1   2.5097656e-01
+   6     9     11      2     4             nan
+   7     5      5      1     1   9.3307495e-03
+   7     5     11      2     4             nan
+   7     5     11      2     4             nan
+   7     6      9      2     1   1.2073517e-03
+   7     6     11      2     4             nan
+   7     6     11      2     4             nan
+   7     7      4      1     3   2.4414062e-02
+   7     7     11      2     4             nan
+   7     7     11      2     4             nan
+   7     8      7      2     1   1.5161133e-01
+   7     9      6      2     1   1.6394043e-01
+   8    10     11      2     4   1.6531250e+01
+   8    10     11      2     4             inf
+   8    10     11      2     4             inf
+   8    30     11      2     4   8.3500000e+01
+   8    40     11      2     4   1.2800000e+02
+   9    10      8      2     3   2.0611286e-04
+   9    10      6      1     3   2.1624565e-04
+   9    10     21      2     3   1.9276142e-04
+  10     1      4      1     1   1.2207031e-04
+  10     1      5      1     1   2.4414062e-04
+  10     1      3      1     1   8.3600000e+02
+  10    10      4      1     1   1.1938810e-04
+  10    10      5      1     1   3.1781197e-04
+  10    10     11      2     4   1.2690000e+03
+  11    10     22      4     1   6.8588257e-03
+  11    10     30      6     1   2.7942657e-03
+  11    10     13      4     1   4.4296875e+00
+  12    10     11      2     4             nan
+  12    10     11      2     4             nan
+  12    10     11      2     4             nan
+  13    10      5      1     3   5.9394836e-03
+  13    10     12      1     1   7.8735352e-02
+  13    10     17      2     1   7.7056885e-03
+  14    10      8      1     1   4.9209595e-03
+  14    10     17      2     1   5.3161621e-02
+  14    10     11      2     4             nan
diff --git a/examples/ref/hibmdpdrc.ref b/examples/ref/hibmdpdrc.ref
new file mode 100644
index 0000000..c139fa5
--- /dev/null
+++ b/examples/ref/hibmdpdrc.ref
@@ -0,0 +1,42 @@
+
 MACHAR constants
+
+
+ ibeta =     2
+
+ it    =    11
+
+ irnd  =     5
+
+ ngrd  =     0
+
+ machep =   -10
+
+ negep =   -11
+
+ iexp =     5
+
+ minexp =   -14
+
+ maxexp =    16
+
+ eps =  9.7656250e-04
+
+ epsneg =  4.8828125e-04
+
+ xmin =  6.1035156e-05
+
+ xmax =  6.5504000e+04
+
+
+
+ DPMPAR constants and relative differences
+
+
+ epsmch =  9.7656250e-04
+ rerr(1) =  0.0000000e+00
+
+ dwarf =  6.1035156e-05
+ rerr(2) =  0.0000000e+00
+
+ giant =  6.5504000e+04
+ rerr(3) =  0.0000000e+00
diff --git a/examples/ref/hlmddrvc.ref b/examples/ref/hlmddrvc.ref
new file mode 100644
index 0000000..360cb05
--- /dev/null
+++ b/examples/ref/hlmddrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2343750e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -9.9707031e-01 -1.0019531e+00 -1.0000000e+00 -1.0039062e+00 -1.0039062e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0546875e+00
+
+      final l2 norm of the residuals    6.6875000e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0117188e+00 -1.0312500e+00 -9.8925781e-01 -9.8339844e-01 -9.8925781e-01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9150000e+02
+
+      final l2 norm of the residuals    2.9150000e+02
+
+      number of function evaluations         600
+
+      number of jacobian evaluations         599
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1000000e+03
+
+      final l2 norm of the residuals    3.1000000e+03
+
+      number of function evaluations         600
+
+      number of jacobian evaluations         599
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2600000e+02
+
+      final l2 norm of the residuals    1.9306641e+00
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -3.2781250e+01  3.4093750e+01 -9.1406250e+00  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7470000e+03
+
+      final l2 norm of the residuals    3.6855469e+00
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -3.7281250e+01  2.1625000e+01  2.4296875e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9257812e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          17
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400000e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         300
+
+      number of jacobian evaluations         299
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.2000000e+02  1.0000000e+02
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -1.1920929e-07  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0293750e+02
+
+      final l2 norm of the residuals    2.4414062e-04
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.5258789e-05  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9150000e+02
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          17
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4664062e+01
+
+      final l2 norm of the residuals    2.3841858e-07
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         496
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.0469894e-04 -3.0457973e-05  4.3392181e-05  4.3392181e-05
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2710000e+03
+
+      final l2 norm of the residuals    5.9604645e-08
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          18
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.2828579e-04 -2.2828579e-05  8.9585781e-05  8.9585781e-05
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         499
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.0000000e+02 -1.0000000e+02  0.0000000e+00  1.0000000e+02
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0015625e+01
+
+      final l2 norm of the residuals    7.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1382812e+01 -9.0478516e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432000e+04
+
+      final l2 norm of the residuals    7.0000000e+00
+
+      number of function evaluations         300
+
+      number of jacobian evaluations         297
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.1617188e+01 -8.8769531e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         300
+
+      number of jacobian evaluations         299
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01 -2.0000000e+02
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4570312e+00
+
+      final l2 norm of the residuals    9.0393066e-02
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.2275391e-02  1.1298828e+00  2.3457031e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6125000e+01
+
+      final l2 norm of the residuals    4.1835938e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.4277344e-01  1.4800000e+02 -1.7730000e+03
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8400000e+02
+
+      final l2 norm of the residuals    4.1757812e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4130859e-01  1.2688000e+04 -2.1792000e+04
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2998047e-02
+
+      final l2 norm of the residuals    1.7532349e-02
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.9274902e-01  1.9116211e-01  1.2292480e-01  1.3610840e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9785156e+00
+
+      final l2 norm of the residuals    3.2531738e-02
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       7.2509766e-01 -1.0562500e+01 -2.4812500e+01 -1.5226562e+01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9968750e+01
+
+      final l2 norm of the residuals    4.2053223e-02
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.8603516e-01  1.1325000e+02  9.0625000e+01  3.7750000e+01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         399
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.0004272e-02  4.0000000e+03  2.5000000e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         399
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.0007324e-01  4.0000000e+04  2.5000000e+03
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    4.7729492e-02
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.6235352e-02  1.0126953e+00 -2.3474121e-01  1.2636719e+00 -1.5166016e+00
+       9.9316406e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4360000e+03
+
+      final l2 norm of the residuals    4.7760010e-02
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.6418457e-02  1.0117188e+00 -2.3083496e-01  1.2539062e+00 -1.5078125e+00
+       9.8974609e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         700
+
+      number of jacobian evaluations         699
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    7.1296692e-03
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.1175871e-04  1.0000000e+00 -1.5083313e-02  4.5996094e-01 -3.7597656e-01
+       4.5629883e-01  4.2504883e-01 -8.9404297e-01  5.0048828e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088000e+04
+
+      final l2 norm of the residuals    4.0585938e+00
+
+      number of function evaluations        1000
+
+      number of jacobian evaluations         999
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.5400391e-01  1.0468750e+00  5.5322266e-01 -3.6474609e-01  2.6220703e-01
+       6.8007812e+00 -1.5742188e+01  1.4671875e+01 -4.6914062e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations        1000
+
+      number of jacobian evaluations         999
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    1.0879517e-02
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.2707710e-04  1.0000000e+00  5.2719116e-03  2.9907227e-01  9.9731445e-02
+      -7.6049805e-02  3.2031250e-01 -2.1875000e-01  2.3352051e-01 -4.9560547e-01
+       5.9521484e-01 -2.0581055e-01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9216000e+04
+
+      final l2 norm of the residuals    2.1062500e+01
+
+      number of function evaluations        1300
+
+      number of jacobian evaluations        1299
+
+      exit parameter                           5
+
+      final approximate solution
+
+       6.0791016e-01  1.2402344e+00  2.2011719e+00 -1.0171875e+01  3.3968750e+01
+      -4.6781250e+01  1.9359375e+01  3.8625000e+01 -7.5437500e+01  6.8000000e+01
+      -3.1593750e+01  6.0039062e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations        1300
+
+      number of jacobian evaluations        1299
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2093750e+01
+
+      final l2 norm of the residuals    1.1557341e-04
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4500000e+01
+
+      final l2 norm of the residuals    1.1179688e+01
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.4621582e-01  2.6977539e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8160000e+03
+
+      final l2 norm of the residuals    2.8160000e+03
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         250
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+01  5.0000000e+00 -5.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         499
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+02  5.0000000e+01 -5.0000000e+01 -1.0000000e+01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         499
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+03  5.0000000e+02 -5.0000000e+02 -1.0000000e+02
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8857422e+00
+
+      final l2 norm of the residuals    1.8857422e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         200
+
+      number of jacobian evaluations         199
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         200
+
+      number of jacobian evaluations         199
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9628906e-01
+
+      final l2 norm of the residuals    1.3708496e-01
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       7.4218750e-02  2.4121094e-01  2.5781250e-01  5.3027344e-01  4.7070312e-01
+       7.3974609e-01  7.5976562e-01  9.2480469e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.7041016e-01
+
+      final l2 norm of the residuals    9.1003418e-02
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       7.2937012e-02  2.0349121e-01  2.6977539e-01  4.1137695e-01  4.9975586e-01
+       5.8837891e-01  7.2998047e-01  7.9638672e-01  9.2675781e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8408203e-01
+
+      final l2 norm of the residuals    1.4660645e-01
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.3415527e-02  1.8835449e-01  2.2192383e-01  4.1943359e-01  3.7426758e-01
+       6.2646484e-01  5.7958984e-01  7.7929688e-01  8.1103516e-01  9.3701172e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6531250e+01
+
+      final l2 norm of the residuals    2.4902344e-02
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7802734e-01  9.7802734e-01  9.7802734e-01  9.7802734e-01  9.7802734e-01
+       9.7802734e-01  9.7802734e-01  9.7802734e-01  9.7802734e-01  1.2207031e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations        1100
+
+      number of jacobian evaluations        1099
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations        1100
+
+      number of jacobian evaluations        1099
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3500000e+01
+
+      final l2 norm of the residuals    8.1115723e-02
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.9755859e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01
+       9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01
+       9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01
+       9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01
+       9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01
+       9.9951172e-01  9.9951172e-01  9.9951172e-01  9.9951172e-01  1.0156250e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2800000e+02
+
+      final l2 norm of the residuals    1.5966797e-01
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0107422e+00  1.0068359e+00  1.0087891e+00  1.0068359e+00  1.0087891e+00
+       1.0087891e+00  1.0087891e+00  1.0107422e+00  1.0087891e+00  1.0087891e+00
+       1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0097656e+00
+       1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00
+       1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00
+       1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00
+       1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00
+       1.0087891e+00  1.0087891e+00  1.0087891e+00  1.0087891e+00  6.4355469e-01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3652344e-01
+
+      final l2 norm of the residuals    8.1558228e-03
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       3.7329102e-01  1.7373047e+00 -1.2646484e+00  1.2420654e-02  2.3040771e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4453125e+00
+
+      final l2 norm of the residuals    4.4506836e-01
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1513672e+00  1.9274902e-01  5.3759766e-01  5.2343750e-01  3.9404297e-01
+       2.4843750e+00  1.6025391e+00  4.3007812e+00  2.4746094e+00  4.5937500e+00
+       5.6640625e+00
+
 summary of 53 calls to lmder1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     3   2.2343750e+00
+    1    5   50     3     2     3   6.6875000e+00
+    2    5   10   600   599     5   2.9150000e+02
+    2    5   50   600   599     5   3.1000000e+03
+    3    5   10     4     2     2   1.9306641e+00
+    3    5   50     4     2     2   3.6855469e+00
+    4    2    2    17    13     2   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2   300   299     5             inf
+    5    3    3    10     7     2   0.0000000e+00
+    5    3    3    18    13     2   2.4414062e-04
+    5    3    3    17    14     2   0.0000000e+00
+    6    4    4   500   496     5   2.3841858e-07
+    6    4    4    19    18     4   5.9604645e-08
+    6    4    4   500   499     5             inf
+    7    2    2     5     3     2   7.0000000e+00
+    7    2    2   300   297     5   7.0000000e+00
+    7    2    2   300   299     5             nan
+    8    3   15     5     4     3   9.0393066e-02
+    8    3   15     5     4     3   4.1835938e+00
+    8    3   15     3     2     1   4.1757812e+00
+    9    4   11     7     5     2   1.7532349e-02
+    9    4   11    12     8     1   3.2531738e-02
+    9    4   11    10     9     2   4.2053223e-02
+   10    3   16   400   399     5             nan
+   10    3   16   400   399     5             nan
+   11    6   31     5     4     2   4.7729492e-02
+   11    6   31    10     9     2   4.7760010e-02
+   11    6   31   700   699     5             nan
+   11    9   31    10     6     2   7.1296692e-03
+   11    9   31  1000   999     5   4.0585938e+00
+   11    9   31  1000   999     5             nan
+   11   12   31     5     4     2   1.0879517e-02
+   11   12   31  1300  1299     5   2.1062500e+01
+   11   12   31  1300  1299     5             nan
+   12    3   10     5     4     2   1.1557341e-04
+   13    2   10    10     6     1   1.1179688e+01
+   14    4   20   500   250     5   2.8160000e+03
+   14    4   20   500   499     5             nan
+   14    4   20   500   499     5             nan
+   15    1    8     1     1     4   1.8857422e+00
+   15    1    8   200   199     5             nan
+   15    1    8   200   199     5             nan
+   15    8    8     4     2     2   1.3708496e-01
+   15    9    9     4     2     2   9.1003418e-02
+   15   10   10     5     2     2   1.4660645e-01
+   16   10   10    10     7     2   2.4902344e-02
+   16   10   10  1100  1099     5             inf
+   16   10   10  1100  1099     5             inf
+   16   30   30     5     4     2   8.1115723e-02
+   16   40   40     4     3     2   1.5966797e-01
+   17    5   33     9     6     2   8.1558228e-03
+   18   11   65     5     3     2   4.4506836e-01
diff --git a/examples/ref/hlmfdrvc.ref b/examples/ref/hlmfdrvc.ref
new file mode 100644
index 0000000..89a09af
--- /dev/null
+++ b/examples/ref/hlmfdrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2402344e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.0253906e+00 -1.0273438e+00 -1.0292969e+00 -1.0302734e+00 -8.8330078e-01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0546875e+00
+
+      final l2 norm of the residuals    6.7109375e+00
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -7.5488281e-01 -9.7656250e-01 -9.7460938e-01 -1.0156250e+00 -1.0107422e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9150000e+02
+
+      final l2 norm of the residuals    1.7900391e+00
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.0644531e-01  1.0625000e+00 -1.4007812e+01  2.6687500e+01 -1.3460938e+01
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1000000e+03
+
+      final l2 norm of the residuals    3.9667969e+00
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.3867188e-01  1.0976562e+00  3.1250000e-02  8.2519531e-02 -6.4746094e-01
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2600000e+02
+
+      final l2 norm of the residuals    2.1796875e+00
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -3.2750000e+01  3.3937500e+01 -9.0156250e+00  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7470000e+03
+
+      final l2 norm of the residuals    3.7578125e+00
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  3.6865234e-02 -9.4384766e-01  6.9628906e-01  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9257812e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400000e+03
+
+      final l2 norm of the residuals    9.7656250e-03
+
+      number of function evaluations          23
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0009766e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.2000000e+02  1.0000000e+02
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    4.7683716e-05
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  2.8610229e-06  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0293750e+02
+
+      final l2 norm of the residuals    1.4901161e-04
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -9.5367432e-06  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9150000e+02
+
+      final l2 norm of the residuals    4.9218750e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -9.9902344e-01  3.3294678e-02  4.8945312e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4664062e+01
+
+      final l2 norm of the residuals    5.3644180e-07
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+       5.1641464e-04 -5.1617622e-05  3.1924248e-04  3.1924248e-04
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2710000e+03
+
+      final l2 norm of the residuals    1.7881393e-06
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.1167526e-03 -1.1169910e-04  5.5265427e-04  5.5265427e-04
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.0000000e+02 -1.0000000e+02  0.0000000e+00  1.0000000e+02
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0015625e+01
+
+      final l2 norm of the residuals    7.0000000e+00
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           3
+
+      final approximate solution
+
+       1.1484375e+01 -8.9941406e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432000e+04
+
+      final l2 norm of the residuals    7.0000000e+00
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1382812e+01 -8.9990234e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01 -2.0000000e+02
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4570312e+00
+
+      final l2 norm of the residuals    9.0454102e-02
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.1970215e-02  1.1191406e+00  2.3574219e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6125000e+01
+
+      final l2 norm of the residuals    4.8671875e+00
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.8591309e-01  3.1540000e+03 -2.1820000e+03
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8400000e+02
+
+      final l2 norm of the residuals    4.0156250e+00
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.0566406e-01  5.3343750e+01  3.7531250e+01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2998047e-02
+
+      final l2 norm of the residuals    1.7700195e-02
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.9494629e-01  1.5026855e-01  1.1145020e-01  1.1816406e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9785156e+00
+
+      final l2 norm of the residuals    2.9434204e-02
+
+      number of function evaluations          26
+
+      number of Jacobian evaluations          18
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.5764160e-02  1.1898438e+01  3.3632812e+00  2.4296875e+00
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9968750e+01
+
+      final l2 norm of the residuals    3.3020020e-02
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.0222168e-02  8.5562500e+01  1.2312500e+01  6.6171875e+00
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.0004272e-02  4.0000000e+03  2.5000000e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.0007324e-01  4.0000000e+04  2.5000000e+03
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    1.2963867e-01
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -8.9111328e-02  1.0126953e+00 -5.3344727e-02  1.6247559e-01  7.9956055e-02
+       1.7822266e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4360000e+03
+
+      final l2 norm of the residuals    1.0540771e-01
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -4.8332214e-03  9.6240234e-01  2.5366211e-01 -4.8583984e-02 -1.1059570e-01
+       4.9145508e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    9.3566895e-02
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -4.8370361e-02  1.0146484e+00  5.8326721e-03  1.5884399e-02  3.1982422e-01
+       1.9958496e-01 -3.0615234e-01  2.0214844e-01 -1.6860962e-03
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088000e+04
+
+      final l2 norm of the residuals    3.6562500e+00
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.4477539e-01  6.5869141e-01  1.6113281e+00  1.9472656e+00 -1.1000000e+01
+       8.6093750e+00  6.0859375e+00 -7.0976562e+00  7.0556641e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    1.5490723e-01
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.4364719e-05  1.0312500e+00  8.7890625e-03 -1.7318726e-02  4.0626526e-04
+       1.1982422e+00 -1.8395996e-01 -8.6474609e-01  1.0083008e-01 -3.4759521e-02
+       3.3105469e-01 -9.0866089e-03
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9216000e+04
+
+      final l2 norm of the residuals    1.5244141e+00
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.2626953e-01  1.2529297e+00 -1.1810303e-01  5.6835938e+00 -8.7500000e+00
+      -4.9921875e+00  1.3195312e+01  1.6578125e+01  4.5000000e+00 -4.5187500e+01
+       1.9218750e+00  2.2250000e+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2093750e+01
+
+      final l2 norm of the residuals    1.1557341e-04
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4500000e+01
+
+      final l2 norm of the residuals    1.1195312e+01
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5366211e-01  2.6635742e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8160000e+03
+
+      final l2 norm of the residuals    1.2960000e+03
+
+      number of function evaluations         203
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.3382812e+01  5.9843750e+00  5.4453125e+00  2.9101562e+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+02  5.0000000e+01 -5.0000000e+01 -1.0000000e+01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+03  5.0000000e+02 -5.0000000e+02 -1.0000000e+02
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8857422e+00
+
+      final l2 norm of the residuals    1.8808594e+00
+
+      number of function evaluations           2
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.1074219e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9628906e-01
+
+      final l2 norm of the residuals    1.0198975e-01
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       8.3862305e-02  2.2375488e-01  3.0444336e-01  4.7436523e-01  5.2783203e-01
+       7.0654297e-01  7.7929688e-01  9.2138672e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.7041016e-01
+
+      final l2 norm of the residuals    8.5021973e-02
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.7077637e-02  2.1215820e-01  2.5537109e-01  4.2407227e-01  5.0292969e-01
+       5.7958984e-01  7.4560547e-01  7.9785156e-01  9.3359375e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8408203e-01
+
+      final l2 norm of the residuals    9.5947266e-02
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.8481445e-02  1.7553711e-01  2.5366211e-01  3.7158203e-01  4.2700195e-01
+       5.9228516e-01  6.0058594e-01  7.7490234e-01  8.1982422e-01  9.3945312e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6531250e+01
+
+      final l2 norm of the residuals    6.4697266e-02
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0224609e+00  1.0224609e+00  1.0224609e+00  1.0224609e+00  1.0224609e+00
+       1.0224609e+00  1.0224609e+00  1.0224609e+00  1.0224609e+00  7.6562500e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         201
+
+      number of Jacobian evaluations         200
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3500000e+01
+
+      final l2 norm of the residuals    5.2099609e-01
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1386719e+00  1.0058594e+00  1.0117188e+00  1.0048828e+00  1.0048828e+00
+       1.0068359e+00  1.0097656e+00  1.0078125e+00  1.0058594e+00  1.0048828e+00
+       1.0048828e+00  1.0058594e+00  1.0048828e+00  1.0039062e+00  1.0029297e+00
+       9.9511719e-01  1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0029297e+00
+       1.0039062e+00  1.0087891e+00  1.0058594e+00  1.0048828e+00  1.0048828e+00
+       1.0029297e+00  1.0048828e+00  1.0039062e+00  1.0039062e+00  6.5869141e-01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2800000e+02
+
+      final l2 norm of the residuals    3.3593750e-01
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0156250e+00  1.0048828e+00  1.0039062e+00  1.0058594e+00  1.0039062e+00
+       1.0039062e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00
+       1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00
+       1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0058594e+00
+       1.0048828e+00  1.0048828e+00  1.0058594e+00  1.0048828e+00  1.0048828e+00
+       1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00
+       1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00
+       1.0048828e+00  1.0048828e+00  1.0048828e+00  1.0048828e+00  8.5107422e-01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3652344e-01
+
+      final l2 norm of the residuals    1.2001038e-02
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       3.7207031e-01  1.6357422e+00 -1.1611328e+00  1.2176514e-02  2.3635864e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4453125e+00
+
+      final l2 norm of the residuals    4.0112305e-01
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1562500e+00  2.1484375e-01  5.1953125e-01  5.5664062e-01  4.0625000e-01
+       2.4843750e+00  1.3691406e+00  5.3242188e+00  2.4414062e+00  4.5976562e+00
+       5.6562500e+00
+
 summary of 53 calls to lmdif1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     1   2.2402344e+00
+    1    5   50     6     3     1   6.7109375e+00
+    2    5   10     4     2     2   1.7900391e+00
+    2    5   50     5     2     2   3.9667969e+00
+    3    5   10     4     2     2   2.1796875e+00
+    3    5   50     6     4     2   3.7578125e+00
+    4    2    2    15    11     2   0.0000000e+00
+    4    2    2    23    16     2   9.7656250e-03
+    4    2    2   201   200     5             inf
+    5    3    3     9     7     2   4.7683716e-05
+    5    3    3    20    15     2   1.4901161e-04
+    5    3    3     7     4     3   4.9218750e+00
+    6    4    4    17    16     3   5.3644180e-07
+    6    4    4   201   200     5   1.7881393e-06
+    6    4    4   201   200     5             inf
+    7    2    2     6     3     3   7.0000000e+00
+    7    2    2    11     8     1   7.0000000e+00
+    7    2    2   201   200     5             nan
+    8    3   15     5     4     3   9.0454102e-02
+    8    3   15   201   200     5   4.8671875e+00
+    8    3   15     8     4     1   4.0156250e+00
+    9    4   11    12     7     2   1.7700195e-02
+    9    4   11    26    18     1   2.9434204e-02
+    9    4   11    13    11     2   3.3020020e-02
+   10    3   16   201   200     5             nan
+   10    3   16   201   200     5             nan
+   11    6   31    10     7     2   1.2963867e-01
+   11    6   31    16    11     2   1.0540771e-01
+   11    6   31   201   200     5             nan
+   11    9   31    13    11     2   9.3566895e-02
+   11    9   31    11     7     2   3.6562500e+00
+   11    9   31   201   200     5             nan
+   11   12   31     7     5     2   1.5490723e-01
+   11   12   31    10     9     2   1.5244141e+00
+   11   12   31   201   200     5             nan
+   12    3   10     5     4     2   1.1557341e-04
+   13    2   10    11     7     1   1.1195312e+01
+   14    4   20   203   200     5   1.2960000e+03
+   14    4   20   201   200     5             nan
+   14    4   20   201   200     5             nan
+   15    1    8     2     1     1   1.8808594e+00
+   15    1    8   201   200     5             nan
+   15    1    8   201   200     5             nan
+   15    8    8     4     2     2   1.0198975e-01
+   15    9    9     4     2     2   8.5021973e-02
+   15   10   10     5     2     2   9.5947266e-02
+   16   10   10     6     3     2   6.4697266e-02
+   16   10   10   201   200     5             inf
+   16   10   10   201   200     5             inf
+   16   30   30     5     2     2   5.2099609e-01
+   16   40   40    10     7     2   3.3593750e-01
+   17    5   33     7     4     2   1.2001038e-02
+   18   11   65     5     3     2   4.0112305e-01
diff --git a/examples/ref/hlmsdrvc.ref b/examples/ref/hlmsdrvc.ref
new file mode 100644
index 0000000..02b22d1
--- /dev/null
+++ b/examples/ref/hlmsdrvc.ref
@@ -0,0 +1,1148 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2343750e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0039062e+00 -9.9902344e-01 -1.0019531e+00 -1.0000000e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0546875e+00
+
+      final l2 norm of the residuals    6.6875000e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.0175781e+00 -9.9951172e-01 -9.9316406e-01 -1.0029297e+00 -9.9560547e-01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9150000e+02
+
+      final l2 norm of the residuals    2.9150000e+02
+
+      number of function evaluations         600
+
+      number of jacobian evaluations         599
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1000000e+03
+
+      final l2 norm of the residuals    3.1000000e+03
+
+      number of function evaluations         600
+
+      number of jacobian evaluations         599
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2600000e+02
+
+      final l2 norm of the residuals    2.1796875e+00
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  3.3250000e+01 -1.2656250e+02  7.8375000e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7470000e+03
+
+      final l2 norm of the residuals    3.6855469e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.5693359e+00 -3.8320312e+00  2.0976562e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9257812e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400000e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         300
+
+      number of jacobian evaluations         299
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.2000000e+02  1.0000000e+02
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0293750e+02
+
+      final l2 norm of the residuals    2.4414062e-04
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.7166138e-05  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9150000e+02
+
+      final l2 norm of the residuals    5.9604645e-06
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -2.3841858e-07  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4664062e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          15
+
+      exit parameter                           4
+
+      final approximate solution
+
+       9.0003014e-05 -9.0003014e-06  3.7550926e-05  3.7550926e-05
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2710000e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          18
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.1265278e-04 -1.1265278e-05  2.1100044e-05  2.1100044e-05
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         499
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.0000000e+02 -1.0000000e+02  0.0000000e+00  1.0000000e+02
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0015625e+01
+
+      final l2 norm of the residuals    7.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1375000e+01 -9.0527344e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432000e+04
+
+      final l2 norm of the residuals    7.0000000e+00
+
+      number of function evaluations         300
+
+      number of jacobian evaluations         297
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.1625000e+01 -8.8671875e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         300
+
+      number of jacobian evaluations         299
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01 -2.0000000e+02
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4570312e+00
+
+      final l2 norm of the residuals    9.0454102e-02
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.2336426e-02  1.1308594e+00  2.3457031e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6125000e+01
+
+      final l2 norm of the residuals    5.3320312e+00
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         399
+
+      exit parameter                           5
+
+      final approximate solution
+
+       8.5937500e-02 -5.9500000e+01 -1.5390625e+01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8400000e+02
+
+      final l2 norm of the residuals    4.1757812e+00
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           3
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.4033203e-01 -1.0656000e+04  1.0000000e+02
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2998047e-02
+
+      final l2 norm of the residuals    1.7532349e-02
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9250488e-01  1.9506836e-01  1.2237549e-01  1.3793945e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9785156e+00
+
+      final l2 norm of the residuals    3.3172607e-02
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.6997070e-01 -8.7734375e+00 -1.3445312e+01 -8.1171875e+00
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9968750e+01
+
+      final l2 norm of the residuals    4.2999268e-02
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       2.7929688e-01  5.9718750e+01  7.2250000e+01  2.9781250e+01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         399
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.0004272e-02  4.0000000e+03  2.5000000e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         399
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.0007324e-01  4.0000000e+04  2.5000000e+03
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    4.6813965e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5914917e-02  1.0126953e+00 -2.4389648e-01  1.2958984e+00 -1.5585938e+00
+       1.0117188e+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4360000e+03
+
+      final l2 norm of the residuals    5.0567627e-02
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5129089e-02  1.0117188e+00 -2.2900391e-01  1.2519531e+00 -1.5048828e+00
+       9.9072266e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         700
+
+      number of jacobian evaluations         699
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    8.5601807e-03
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.4972687e-04  9.9951172e-01  5.9967041e-03  3.1298828e-01 -3.0395508e-02
+       3.0004883e-01 -8.7829590e-02 -1.6760254e-01  2.2338867e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088000e+04
+
+      final l2 norm of the residuals    5.8398438e+00
+
+      number of function evaluations        1000
+
+      number of jacobian evaluations         998
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.3081055e-01  1.0556641e+00  1.0820312e+00 -5.6015625e+00  1.9687500e+01
+      -2.9312500e+01  1.7593750e+01  1.7480469e+00 -4.1328125e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations        1000
+
+      number of jacobian evaluations         999
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4765625e+00
+
+      final l2 norm of the residuals    5.7563782e-03
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -9.7453594e-05  1.0000000e+00 -5.2719116e-03  3.7792969e-01 -1.2512207e-01
+       2.0837402e-01  2.0837402e-01 -2.6147461e-01  5.4412842e-02  1.3879395e-01
+      -7.9345703e-02  4.0771484e-02
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9216000e+04
+
+      final l2 norm of the residuals    1.9216000e+04
+
+      number of function evaluations        1300
+
+      number of jacobian evaluations        1299
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+       1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01  1.0000000e+01
+       1.0000000e+01  1.0000000e+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations        1300
+
+      number of jacobian evaluations        1299
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02  1.0000000e+02
+       1.0000000e+02  1.0000000e+02
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2093750e+01
+
+      final l2 norm of the residuals    1.1557341e-04
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4500000e+01
+
+      final l2 norm of the residuals    1.1179688e+01
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.4633789e-01  2.6977539e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8160000e+03
+
+      final l2 norm of the residuals    2.8160000e+03
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         250
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+01  5.0000000e+00 -5.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         499
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+02  5.0000000e+01 -5.0000000e+01 -1.0000000e+01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         499
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5000000e+03  5.0000000e+02 -5.0000000e+02 -1.0000000e+02
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8857422e+00
+
+      final l2 norm of the residuals    1.8857422e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         200
+
+      number of jacobian evaluations         199
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals            nan
+
+      final l2 norm of the residuals              nan
+
+      number of function evaluations         200
+
+      number of jacobian evaluations         199
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9628906e-01
+
+      final l2 norm of the residuals    1.3464355e-01
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       7.4584961e-02  2.4011230e-01  2.5952148e-01  5.2832031e-01  4.7143555e-01
+       7.3974609e-01  7.5976562e-01  9.2480469e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.7041016e-01
+
+      final l2 norm of the residuals    9.0698242e-02
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       7.2937012e-02  2.0349121e-01  2.6977539e-01  4.1137695e-01  5.0000000e-01
+       5.8789062e-01  7.3046875e-01  7.9638672e-01  9.2675781e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8408203e-01
+
+      final l2 norm of the residuals    1.4599609e-01
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.3110352e-02  1.8859863e-01  2.2094727e-01  4.1992188e-01  3.7402344e-01
+       6.2500000e-01  5.8056641e-01  7.7783203e-01  8.1103516e-01  9.3652344e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6531250e+01
+
+      final l2 norm of the residuals    1.6342163e-02
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.6923828e-01  9.6972656e-01  9.6972656e-01  9.7021484e-01  9.6972656e-01
+       9.6972656e-01  9.7021484e-01  9.7070312e-01  9.7119141e-01  1.3027344e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations        1100
+
+      number of jacobian evaluations        1099
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+       5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00  5.0000000e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals            inf
+
+      final l2 norm of the residuals              inf
+
+      number of function evaluations        1100
+
+      number of jacobian evaluations        1099
+
+      exit parameter                           5
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3500000e+01
+
+      final l2 norm of the residuals    3.3349609e-01
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.6777344e-01  1.0029297e+00  1.0097656e+00  1.0117188e+00  1.0175781e+00
+       1.0146484e+00  1.0214844e+00  1.0234375e+00  1.0205078e+00  1.0253906e+00
+       1.0175781e+00  1.0058594e+00  1.0185547e+00  1.0019531e+00  1.0166016e+00
+       1.0156250e+00  1.0175781e+00  1.0136719e+00  1.0136719e+00  1.0136719e+00
+       1.0175781e+00  1.0195312e+00  1.0234375e+00  1.0244141e+00  1.0234375e+00
+       1.0253906e+00  1.0273438e+00  1.0253906e+00  1.0253906e+00  5.0000000e-01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2800000e+02
+
+      final l2 norm of the residuals    2.8076172e-01
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0019531e+00  1.0019531e+00  1.0039062e+00  1.0253906e+00  1.0253906e+00
+       1.0361328e+00  1.0273438e+00  1.0195312e+00  1.0117188e+00  1.0458984e+00
+       1.0156250e+00  1.0136719e+00  1.0166016e+00  1.0156250e+00  1.0283203e+00
+       1.0332031e+00  1.0302734e+00  1.0214844e+00  1.0234375e+00  1.0185547e+00
+       1.0136719e+00  1.0117188e+00  1.0156250e+00  1.0068359e+00  1.0136719e+00
+       1.0029297e+00  1.0019531e+00  9.9707031e-01  9.9609375e-01  9.9853516e-01
+       9.9023438e-01  9.9853516e-01  9.9853516e-01  9.9023438e-01  1.0019531e+00
+       1.0117188e+00  1.0097656e+00  1.0117188e+00  1.0175781e+00  5.0000000e-01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3652344e-01
+
+      final l2 norm of the residuals    1.1817932e-02
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       3.6938477e-01  1.5009766e+00 -1.0244141e+00  1.1726379e-02  2.4642944e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4453125e+00
+
+      final l2 norm of the residuals    4.4750977e-01
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           3
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1494141e+00  1.9116211e-01  5.3613281e-01  5.2441406e-01  3.9184570e-01
+       2.5312500e+00  1.6171875e+00  4.3125000e+00  2.4765625e+00  4.5976562e+00
+       5.6640625e+00
+
 summary of 53 calls to lmstr1
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     3   2.2343750e+00
+    1    5   50     3     2     2   6.6875000e+00
+    2    5   10   600   599     5   2.9150000e+02
+    2    5   50   600   599     5   3.1000000e+03
+    3    5   10     4     2     2   2.1796875e+00
+    3    5   50     7     2     2   3.6855469e+00
+    4    2    2    21    15     2   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2   300   299     5             inf
+    5    3    3    10     7     2   0.0000000e+00
+    5    3    3    18    13     2   2.4414062e-04
+    5    3    3    16    13     2   5.9604645e-06
+    6    4    4    16    15     4   0.0000000e+00
+    6    4    4    19    18     4   0.0000000e+00
+    6    4    4   500   499     5             inf
+    7    2    2     5     3     2   7.0000000e+00
+    7    2    2   300   297     5   7.0000000e+00
+    7    2    2   300   299     5             nan
+    8    3   15     5     4     3   9.0454102e-02
+    8    3   15   400   399     5   5.3320312e+00
+    8    3   15     4     3     3   4.1757812e+00
+    9    4   11     7     5     1   1.7532349e-02
+    9    4   11    10     6     1   3.3172607e-02
+    9    4   11     7     6     2   4.2999268e-02
+   10    3   16   400   399     5             nan
+   10    3   16   400   399     5             nan
+   11    6   31     6     4     2   4.6813965e-02
+   11    6   31    10     9     2   5.0567627e-02
+   11    6   31   700   699     5             nan
+   11    9   31     7     5     2   8.5601807e-03
+   11    9   31  1000   998     5   5.8398438e+00
+   11    9   31  1000   999     5             nan
+   11   12   31     8     6     2   5.7563782e-03
+   11   12   31  1300  1299     5   1.9216000e+04
+   11   12   31  1300  1299     5             nan
+   12    3   10     5     4     2   1.1557341e-04
+   13    2   10    10     6     1   1.1179688e+01
+   14    4   20   500   250     5   2.8160000e+03
+   14    4   20   500   499     5             nan
+   14    4   20   500   499     5             nan
+   15    1    8     1     1     4   1.8857422e+00
+   15    1    8   200   199     5             nan
+   15    1    8   200   199     5             nan
+   15    8    8     4     2     2   1.3464355e-01
+   15    9    9     4     2     2   9.0698242e-02
+   15   10   10     5     2     2   1.4599609e-01
+   16   10   10     9     6     2   1.6342163e-02
+   16   10   10  1100  1099     5             inf
+   16   10   10  1100  1099     5             inf
+   16   30   30     5     2     2   3.3349609e-01
+   16   40   40     4     2     2   2.8076172e-01
+   17    5   33     5     3     2   1.1817932e-02
+   18   11   65     5     3     2   4.4750977e-01
diff --git a/examples/ref/htchkderc.ref b/examples/ref/htchkderc.ref
new file mode 100644
index 0000000..d9e9c6a
--- /dev/null
+++ b/examples/ref/htchkderc.ref
@@ -0,0 +1,22 @@
+
+      fvec
+
+           -1.181641      -1.429688      -1.606445
+           -1.745117       -1.84082      -1.920898
+           -1.983398      -2.023438       -2.46875
+           -2.828125      -3.472656        -4.4375
+           -6.046875      -9.265625      -18.92188
+      fvecp - fvec
+
+         -0.01660156     -0.0078125  -0.0009765625
+          0.00390625    0.008789062     0.01074219
+          0.01367188     0.01757812     0.02929688
+          0.04882812      0.0703125       0.109375
+           0.1679688      0.2890625        0.65625
+      err
+
+                   0              0              0
+                   0              0              0
+                   0              0              0
+                   0              0              0
+                   0              0              0
diff --git a/examples/ref/htfdjac2c.ref b/examples/ref/htfdjac2c.ref
new file mode 100644
index 0000000..7cfecf5
--- /dev/null
+++ b/examples/ref/htfdjac2c.ref
@@ -0,0 +1,29 @@
+
+      fvec
+
+           -1.181641      -1.429688      -1.606445
+           -1.745117       -1.84082      -1.920898
+           -1.983398      -2.023438       -2.46875
+           -2.828125      -3.472656        -4.4375
+           -6.046875      -9.265625      -18.92188
+      fvecp - fvec
+
+         -0.01660156     -0.0078125  -0.0009765625
+          0.00390625    0.008789062     0.01074219
+          0.01367188     0.01757812     0.02929688
+          0.04882812      0.0703125       0.109375
+           0.1679688      0.2890625        0.65625
+      errd
+
+                   0              0              0
+                   0              0              0
+                   0              0              0
+                   0              0              0
+                   0              0              0
+      err
+
+                   0              0              0
+                   0              0              0
+                   0              0              0
+                   0              0              0
+                   0              0              0
diff --git a/examples/ref/hthybrd1c.ref b/examples/ref/hthybrd1c.ref
new file mode 100644
index 0000000..49c1feb
--- /dev/null
+++ b/examples/ref/hthybrd1c.ref
@@ -0,0 +1,7 @@
+     final L2 norm of the residuals     0.005523682
+     exit parameter                          3
+     final approximates solution
+
+          -0.5703125     -0.6816406     -0.7016602
+          -0.7041016     -0.7016602     -0.6918945
+          -0.6665039     -0.5966797     -0.4169922
diff --git a/examples/ref/hthybrdc.ref b/examples/ref/hthybrdc.ref
new file mode 100644
index 0000000..1eddda1
--- /dev/null
+++ b/examples/ref/hthybrdc.ref
@@ -0,0 +1,11 @@
+     final l2 norm of the residuals     0.005523682
+
+     number of function evaluations           8
+
+     exit parameter                           3
+
+     final approximate solution
+
+          -0.5703125     -0.6816406     -0.7016602
+          -0.7041016     -0.7016602     -0.6918945
+          -0.6665039     -0.5966797     -0.4169922
diff --git a/examples/ref/hthybrj1c.ref b/examples/ref/hthybrj1c.ref
new file mode 100644
index 0000000..44610a6
--- /dev/null
+++ b/examples/ref/hthybrj1c.ref
@@ -0,0 +1,9 @@
+      final l2 norm of the residuals    0.005523682
+
+      exit parameter                         3
+
+      final approximate solution
+
+          -0.5703125     -0.6816406     -0.7016602
+          -0.7041016     -0.7016602     -0.6918945
+          -0.6665039     -0.5966797     -0.4169922
diff --git a/examples/ref/hthybrjc.ref b/examples/ref/hthybrjc.ref
new file mode 100644
index 0000000..c872428
--- /dev/null
+++ b/examples/ref/hthybrjc.ref
@@ -0,0 +1,14 @@
+     final l2 norm of the residuals    0.005523682
+
+     number of function evaluations         5
+
+     number of jacobian evaluations         1
+
+     exit parameter                         3
+
+     final approximate solution
+
+
+          -0.5703125     -0.6816406     -0.7016602
+          -0.7041016     -0.7016602     -0.6918945
+          -0.6665039     -0.5966797     -0.4169922
diff --git a/examples/ref/htlmder1c.ref b/examples/ref/htlmder1c.ref
new file mode 100644
index 0000000..e663d26
--- /dev/null
+++ b/examples/ref/htlmder1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09039307
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08227539       1.129883       2.345703
diff --git a/examples/ref/htlmderc.ref b/examples/ref/htlmderc.ref
new file mode 100644
index 0000000..efde768
--- /dev/null
+++ b/examples/ref/htlmderc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09039307
+
+      number of function evaluations         5
+
+      number of Jacobian evaluations         4
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08227539       1.129883       2.345703
+      covariance
+
+        0.0001535416    0.002880096   -0.002668381
+         0.002880096     0.09472656    -0.09100342
+        -0.002668381    -0.09100342     0.08782959
diff --git a/examples/ref/htlmdif1c.ref b/examples/ref/htlmdif1c.ref
new file mode 100644
index 0000000..c588141
--- /dev/null
+++ b/examples/ref/htlmdif1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals      0.0904541
+
+      exit parameter                         3
+
+      final approximate solution
+
+      0.08197021       1.119141       2.357422
diff --git a/examples/ref/htlmdifc.ref b/examples/ref/htlmdifc.ref
new file mode 100644
index 0000000..2c378d9
--- /dev/null
+++ b/examples/ref/htlmdifc.ref
@@ -0,0 +1,14 @@
+      final l2 norm of the residuals      0.0904541
+
+      number of function evaluations        17
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08197021       1.119141       2.357422
+      covariance
+
+        0.0001525879    0.002954483   -0.002780914
+         0.002954483      0.1014404    -0.09899902
+        -0.002780914    -0.09899902     0.09692383
diff --git a/examples/ref/htlmstr1c.ref b/examples/ref/htlmstr1c.ref
new file mode 100644
index 0000000..1a17e6a
--- /dev/null
+++ b/examples/ref/htlmstr1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals      0.0904541
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08233643       1.130859       2.345703
diff --git a/examples/ref/htlmstrc.ref b/examples/ref/htlmstrc.ref
new file mode 100644
index 0000000..c4d6769
--- /dev/null
+++ b/examples/ref/htlmstrc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals      0.0904541
+
+      number of function evaluations         5
+
+      number of Jacobian evaluations         4
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08233643       1.130859       2.345703
+      covariance
+
+        0.0001517534    0.002840042   -0.002630234
+         0.002840042     0.09368896    -0.08996582
+        -0.002630234    -0.08996582     0.08673096
diff --git a/examples/ref/hybdrv.ref b/examples/ref/hybdrv.ref
new file mode 100644
index 0000000..b4f7243
--- /dev/null
+++ b/examples/ref/hybdrv.ref
@@ -0,0 +1,1094 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  0.4919350D+01
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          22
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  0.1340063D+04
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  0.1430001D+06
+
+      final l2 norm of the residuals    0.5373479D-12
+
+      number of function evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  0.1466288D+02
+
+      final l2 norm of the residuals    0.1658388D-33
+
+      number of function evaluations         108
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -0.1717233D-17  0.1717233D-18  0.4885792D-17  0.4885792D-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  0.1270984D+04
+
+      final l2 norm of the residuals    0.9820406D-35
+
+      number of function evaluations         112
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1137339D-17 -0.1137339D-18  0.1509232D-17  0.1509232D-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  0.1268879D+06
+
+      final l2 norm of the residuals    0.4843140D-34
+
+      number of function evaluations         143
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.2071579D-17 -0.2071579D-18  0.3365608D-17  0.3365608D-17
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  0.1065487D+01
+
+      final l2 norm of the residuals    0.1712421D-08
+
+      number of function evaluations         181
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1098159D-04  0.9106147D+01
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  0.1000000D+01
+
+      final l2 norm of the residuals    0.3744485D-07
+
+      number of function evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1098159D-04  0.9106147D+01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  0.8550557D+04
+
+      final l2 norm of the residuals    0.3998844D-10
+
+      number of function evaluations          94
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9679740D+00  0.9471391D+00 -0.9695163D+00  0.9512477D+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  0.7349823D+07
+
+      final l2 norm of the residuals    0.1285689D-11
+
+      number of function evaluations         234
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9679740D+00  0.9471391D+00 -0.9695163D+00  0.9512477D+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  0.7273070D+10
+
+      final l2 norm of the residuals    0.4568910D-09
+
+      number of function evaluations         494
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9679740D+00  0.9471391D+00 -0.9695163D+00  0.9512477D+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  0.5000000D+02
+
+      final l2 norm of the residuals    0.2753440D-12
+
+      number of function evaluations          27
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01 -0.1612103D-13 -0.8125674D-34
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  0.1029563D+03
+
+      final l2 norm of the residuals    0.2251025D-09
+
+      number of function evaluations          32
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1388634D-10  0.0000000D+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  0.9912618D+03
+
+      final l2 norm of the residuals    0.1610831D-12
+
+      number of function evaluations          40
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1238719D-14  0.0000000D+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  0.6848587D+02
+
+      final l2 norm of the residuals    0.3208563D-12
+
+      number of function evaluations          96
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572509D-01  0.1012435D+01 -0.2329916D+00  0.1260430D+01 -0.1513729D+01
+       0.9929964D+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  0.3531259D+07
+
+      final l2 norm of the residuals    0.2333047D-10
+
+      number of function evaluations         310
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572509D-01  0.1012435D+01 -0.2329916D+00  0.1260430D+01 -0.1513729D+01
+       0.9929964D+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  0.8878955D+02
+
+      final l2 norm of the residuals    0.3267200D-14
+
+      number of function evaluations         167
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1530704D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  0.1015108D+08
+
+      final l2 norm of the residuals    0.1716655D-11
+
+      number of function evaluations         175
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1530704D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  0.2257066D+00
+
+      final l2 norm of the residuals    0.3540441D-11
+
+      number of function evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8375126D-01  0.3127293D+00  0.5000000D+00  0.6872707D+00  0.9162487D+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  0.4117243D+07
+
+      final l2 norm of the residuals    0.1158079D-11
+
+      number of function evaluations         259
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.6872707D+00  0.9162487D+00  0.5000000D+00  0.8375126D-01  0.3127293D+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  0.5636130D+12
+
+      final l2 norm of the residuals    0.4076007D-09
+
+      number of function evaluations         536
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5000000D+00  0.6872707D+00  0.8375126D-01  0.3127293D+00  0.9162487D+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  0.2154720D+00
+
+      final l2 norm of the residuals    0.6867966D-09
+
+      number of function evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.6687659D-01  0.3666823D+00  0.2887407D+00  0.7112593D+00  0.6333177D+00
+       0.9331234D+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  0.1307925D+09
+
+      final l2 norm of the residuals    0.1003427D-11
+
+      number of function evaluations         173
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9331234D+00  0.2887407D+00  0.6687659D-01  0.7112593D+00  0.3666823D+00
+       0.6333177D+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  0.1875579D+15
+
+      final l2 norm of the residuals    0.1182988D-10
+
+      number of function evaluations         266
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3666823D+00  0.6333177D+00  0.7112593D+00  0.6687659D-01  0.9331234D+00
+       0.2887407D+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  0.1837679D+00
+
+      final l2 norm of the residuals    0.2398700D-08
+
+      number of function evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5806915D-01  0.2351716D+00  0.3380441D+00  0.5000000D+00  0.6619559D+00
+       0.7648284D+00  0.9419309D+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  0.4269328D+10
+
+      final l2 norm of the residuals    0.9095716D-09
+
+      number of function evaluations         630
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3380441D+00  0.5000000D+00  0.2351716D+00  0.7648284D+00  0.9419309D+00
+       0.5806915D-01  0.6619559D+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  0.6414317D+17
+
+      final l2 norm of the residuals    0.2491665D+15
+
+      number of function evaluations         180
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -0.3267366D+02 -0.2996210D+02 -0.8587775D+02  0.2222113D+02  0.5957249D+02
+      -0.1038026D+01  0.8600843D+02
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  0.1965139D+00
+
+      final l2 norm of the residuals    0.6440509D-01
+
+      number of function evaluations         120
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.4985640D-01  0.1986351D+00  0.2698288D+00  0.4992723D+00  0.5007277D+00
+       0.7301712D+00  0.8013649D+00  0.9501437D+00
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  0.1699499D+00
+
+      final l2 norm of the residuals    0.1889808D-08
+
+      number of function evaluations          41
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.4420535D-01  0.1994907D+00  0.2356191D+00  0.4160469D+00  0.5000000D+00
+       0.5839531D+00  0.7643809D+00  0.8005093D+00  0.9557947D+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  0.1653022D+02
+
+      final l2 norm of the residuals    0.1925301D-13
+
+      number of function evaluations          31
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  0.9765624D+07
+
+      final l2 norm of the residuals    0.4440892D-15
+
+      number of function evaluations          31
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  0.9765625D+17
+
+      final l2 norm of the residuals    0.1299849D-12
+
+      number of function evaluations          40
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  0.8347604D+02
+
+      final l2 norm of the residuals    0.1390247D-12
+
+      number of function evaluations         120
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  0.1280264D+03
+
+      final l2 norm of the residuals    0.1055840D-12
+
+      number of function evaluations         153
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  0.2808058D-01
+
+      final l2 norm of the residuals    0.2514039D-14
+
+      number of function evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  0.5255526D+00
+
+      final l2 norm of the residuals    0.1726095D-12
+
+      number of function evaluations          19
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  0.1065739D+03
+
+      final l2 norm of the residuals    0.4177561D-09
+
+      number of function evaluations          52
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  0.1279297D+00
+
+      final l2 norm of the residuals    0.2775558D-16
+
+      number of function evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1528139D+00
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  0.2562500D+01
+
+      final l2 norm of the residuals    0.5551115D-16
+
+      number of function evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1528139D+00
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  0.8361172D+03
+
+      final l2 norm of the residuals    0.5551115D-16
+
+      number of function evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1528139D+00
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  0.2518270D+00
+
+      final l2 norm of the residuals    0.5009132D-14
+
+      number of function evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  0.6116833D+01
+
+      final l2 norm of the residuals    0.2188310D-12
+
+      number of function evaluations          19
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  0.1269309D+04
+
+      final l2 norm of the residuals    0.3022340D-14
+
+      number of function evaluations          39
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  0.8411753D-01
+
+      final l2 norm of the residuals    0.5296400D-02
+
+      number of function evaluations         130
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.5526168D-01  0.5695771D-01  0.5889083D-01  0.6113625D-01  0.6377876D-01
+       0.6700506D-01  0.2079408D+00  0.1642667D+00  0.8644045D-01  0.9133610D-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  0.2030519D+02
+
+      final l2 norm of the residuals    0.5916907D-10
+
+      number of function evaluations          84
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3439629D-01  0.3503232D-01  0.3571920D-01  0.3646522D-01  0.3728091D-01
+       0.3817986D-01  0.3918014D-01  0.4030650D-01  0.1797202D+00  0.1562409D+00
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  0.9336937D+02
+
+      final l2 norm of the residuals    0.1824033D-08
+
+      number of function evaluations          85
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1888395D+02  0.2516777D+02  0.1888528D+02  0.1888602D+02  0.1888684D+02
+       0.1888774D+02  0.1888874D+02  0.1888986D+02  0.1902928D+02  0.1900580D+02
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  0.2240213D+07
+
+      final l2 norm of the residuals    0.5886077D-11
+
+      number of function evaluations          31
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  0.5223438D+08
+
+      final l2 norm of the residuals    0.9391515D-12
+
+      number of function evaluations          35
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  0.1592365D+12
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          84
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  0.4582576D+01
+
+      final l2 norm of the residuals    0.1493879D-07
+
+      number of function evaluations          21
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5707221D+00 -0.6818070D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00
+      -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  0.6391009D+03
+
+      final l2 norm of the residuals    0.5056867D-08
+
+      number of function evaluations          59
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00
+      -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  0.6333758D+05
+
+      final l2 norm of the residuals    0.9878833D-10
+
+      number of function evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00
+      -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  0.1897367D+02
+
+      final l2 norm of the residuals    0.2057898D-08
+
+      number of function evaluations          30
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00
+      -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  0.1713092D+05
+
+      final l2 norm of the residuals    0.7953611D-08
+
+      number of function evaluations          45
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00
+      -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  0.1594986D+08
+
+      final l2 norm of the residuals    0.4526426D-09
+
+      number of function evaluations          58
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00
+      -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00
+1summary of  55 calls to hybrd1
+
+ nprob   n    nfev  info  final l2 norm
+
+   1     2     22     1   0.0000000D+00
+   1     2      9     1   0.0000000D+00
+   1     2      9     1   0.5373479D-12
+   2     4    108     4   0.1658388D-33
+   2     4    112     4   0.9820406D-35
+   2     4    143     4   0.4843140D-34
+   3     2    181     1   0.1712421D-08
+   3     2     11     1   0.3744485D-07
+   4     4     94     1   0.3998844D-10
+   4     4    234     1   0.1285689D-11
+   4     4    494     1   0.4568910D-09
+   5     3     27     1   0.2753440D-12
+   5     3     32     1   0.2251025D-09
+   5     3     40     1   0.1610831D-12
+   6     6     96     1   0.3208563D-12
+   6     6    310     1   0.2333047D-10
+   6     9    167     1   0.3267200D-14
+   6     9    175     1   0.1716655D-11
+   7     5     17     1   0.3540441D-11
+   7     5    259     1   0.1158079D-11
+   7     5    536     1   0.4076007D-09
+   7     6     25     1   0.6867966D-09
+   7     6    173     1   0.1003427D-11
+   7     6    266     1   0.1182988D-10
+   7     7     20     1   0.2398700D-08
+   7     7    630     1   0.9095716D-09
+   7     7    180     4   0.2491665D+15
+   7     8    120     4   0.6440509D-01
+   7     9     41     1   0.1889808D-08
+   8    10     31     1   0.1925301D-13
+   8    10     31     1   0.4440892D-15
+   8    10     40     1   0.1299849D-12
+   8    30    120     1   0.1390247D-12
+   8    40    153     1   0.1055840D-12
+   9    10     16     1   0.2514039D-14
+   9    10     19     1   0.1726095D-12
+   9    10     52     1   0.4177561D-09
+  10     1      7     1   0.2775558D-16
+  10     1      9     1   0.5551115D-16
+  10     1     16     1   0.5551115D-16
+  10    10     16     1   0.5009132D-14
+  10    10     19     1   0.2188310D-12
+  10    10     39     1   0.3022340D-14
+  11    10    130     4   0.5296400D-02
+  11    10     84     1   0.5916907D-10
+  11    10     85     1   0.1824033D-08
+  12    10     31     1   0.5886077D-11
+  12    10     35     1   0.9391515D-12
+  12    10     84     1   0.0000000D+00
+  13    10     21     1   0.1493879D-07
+  13    10     59     1   0.5056867D-08
+  13    10     42     1   0.9878833D-10
+  14    10     30     1   0.2057898D-08
+  14    10     45     1   0.7953611D-08
+  14    10     58     1   0.4526426D-09
diff --git a/examples/ref/hybdrvc.ref b/examples/ref/hybdrvc.ref
new file mode 100644
index 0000000..8a24c98
--- /dev/null
+++ b/examples/ref/hybdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    5.3734794e-13
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    1.6583881e-34
+
+      number of function evaluations          96
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.7172327e-18  1.7172327e-19  4.8857917e-18  4.8857917e-18
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    9.8204058e-36
+
+      number of function evaluations         100
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.1373388e-18 -1.1373388e-19  1.5092319e-18  1.5092319e-18
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    3.5326233e-35
+
+      number of function evaluations         127
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6474368e-18 -1.6474368e-19  2.8757752e-18  2.8757752e-18
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654866e+00
+
+      final l2 norm of the residuals    1.7124214e-09
+
+      number of function evaluations         169
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    3.7444845e-08
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5505574e+03
+
+      final l2 norm of the residuals    3.9988440e-11
+
+      number of function evaluations          86
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.3498230e+06
+
+      final l2 norm of the residuals    1.2856890e-12
+
+      number of function evaluations         198
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.2730700e+09
+
+      final l2 norm of the residuals    4.5689102e-10
+
+      number of function evaluations         342
+
+      number of Jacobian evaluations          38
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    2.7534401e-13
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.6121030e-14 -8.1256745e-35
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    2.2510251e-10
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.3886338e-11  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    1.6108311e-13
+
+      number of function evaluations          28
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.2387194e-15  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8485872e+01
+
+      final l2 norm of the residuals    3.2085628e-13
+
+      number of function evaluations          60
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  3.5312586e+06
+
+      final l2 norm of the residuals    2.3330469e-11
+
+      number of function evaluations         244
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8789552e+01
+
+      final l2 norm of the residuals    3.2672000e-15
+
+      number of function evaluations          95
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  1.0151080e+07
+
+      final l2 norm of the residuals    1.7166545e-12
+
+      number of function evaluations         112
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570657e-01
+
+      final l2 norm of the residuals    3.5404408e-12
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751256e-02  3.1272930e-01  5.0000000e-01  6.8727070e-01  9.1624874e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  4.1172432e+06
+
+      final l2 norm of the residuals    1.1580794e-12
+
+      number of function evaluations         139
+
+      number of Jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.8727070e-01  9.1624874e-01  5.0000000e-01  8.3751256e-02  3.1272930e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  5.6361303e+11
+
+      final l2 norm of the residuals    8.6364763e-10
+
+      number of function evaluations         216
+
+      number of Jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.8727070e-01  3.1272930e-01  8.3751257e-02  9.1624874e-01  5.0000000e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1547198e-01
+
+      final l2 norm of the residuals    6.8679664e-10
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876591e-02  3.6668230e-01  2.8874067e-01  7.1125933e-01  6.3331770e-01
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.3079247e+08
+
+      final l2 norm of the residuals    1.0034267e-12
+
+      number of function evaluations          95
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.3312341e-01  2.8874067e-01  6.6876591e-02  7.1125933e-01  3.6668230e-01
+       6.3331770e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.8755789e+14
+
+      final l2 norm of the residuals    8.4793498e-12
+
+      number of function evaluations         137
+
+      number of Jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.8874067e-01  6.3331770e-01  7.1125933e-01  9.3312341e-01  3.6668230e-01
+       6.6876591e-02
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8376789e-01
+
+      final l2 norm of the residuals    2.3987001e-09
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8069150e-02  2.3517161e-01  3.3804410e-01  5.0000000e-01  6.6195591e-01
+       7.6482839e-01  9.4193085e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  4.2693282e+09
+
+      final l2 norm of the residuals    9.0957159e-10
+
+      number of function evaluations         294
+
+      number of Jacobian evaluations          48
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.3804409e-01  5.0000000e-01  2.3517161e-01  7.6482839e-01  9.4193085e-01
+       5.8069150e-02  6.6195591e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  6.4143166e+16
+
+      final l2 norm of the residuals    3.2740173e+14
+
+      number of function evaluations          64
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -5.8426648e+01 -8.6451000e+00 -8.8719883e+01 -9.9793839e+00  7.3220548e+01
+       3.1247878e+01  8.7157466e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    6.4405091e-02
+
+      number of function evaluations          56
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.9856402e-02  1.9863513e-01  2.6982883e-01  4.9927232e-01  5.0072773e-01
+       7.3017122e-01  8.0136492e-01  9.5014366e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    1.8898075e-09
+
+      number of function evaluations          23
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.9253009e-14
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    4.4408921e-16
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    1.2998488e-13
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.3902475e-13
+
+      number of function evaluations          30
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    1.0558402e-13
+
+      number of function evaluations          33
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.8080582e-02
+
+      final l2 norm of the residuals    2.5140385e-15
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2555258e-01
+
+      final l2 norm of the residuals    1.7260946e-13
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0657390e+02
+
+      final l2 norm of the residuals    4.1775615e-10
+
+      number of function evaluations          42
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    2.7755576e-17
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    5.5511151e-17
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3611719e+02
+
+      final l2 norm of the residuals    5.5511151e-17
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5182701e-01
+
+      final l2 norm of the residuals    5.0091317e-15
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1168330e+00
+
+      final l2 norm of the residuals    2.1883100e-13
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2693089e+03
+
+      final l2 norm of the residuals    3.0223404e-15
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  8.4117534e-02
+
+      final l2 norm of the residuals    5.2964002e-03
+
+      number of function evaluations          60
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.5261680e-02  5.6957710e-02  5.8890834e-02  6.1136252e-02  6.3778763e-02
+       6.7005062e-02  2.0794077e-01  1.6426674e-01  8.6440450e-02  9.1336101e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0305195e+01
+
+      final l2 norm of the residuals    5.9169065e-11
+
+      number of function evaluations          34
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.4396289e-02  3.5032316e-02  3.5719196e-02  3.6465224e-02  3.7280912e-02
+       3.8179863e-02  3.9180141e-02  4.0306503e-02  1.7972019e-01  1.5624088e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3369375e+01
+
+      final l2 norm of the residuals    1.8240335e-09
+
+      number of function evaluations          45
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8883952e+01  2.5167774e+01  1.8885275e+01  1.8886021e+01  1.8886837e+01
+       1.8887736e+01  1.8888736e+01  1.8889862e+01  1.9029276e+01  1.9005797e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  2.2402135e+06
+
+      final l2 norm of the residuals    5.8860770e-12
+
+      number of function evaluations          21
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  5.2234376e+07
+
+      final l2 norm of the residuals    9.3915146e-13
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  1.5923646e+11
+
+      final l2 norm of the residuals    8.9546999e-13
+
+      number of function evaluations          42
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5825757e+00
+
+      final l2 norm of the residuals    1.4938794e-08
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3910093e+02
+
+      final l2 norm of the residuals    5.0568673e-09
+
+      number of function evaluations          49
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3337583e+04
+
+      final l2 norm of the residuals    9.8788330e-11
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8973666e+01
+
+      final l2 norm of the residuals    2.0578981e-09
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7130922e+04
+
+      final l2 norm of the residuals    7.9536112e-09
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.5949860e+07
+
+      final l2 norm of the residuals    4.5264262e-10
+
+      number of function evaluations          38
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
 summary of 55 calls to hybrd1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      7      1     1   0.0000000e+00
+   1     2      7      1     1   5.3734794e-13
+   2     4     96      3     4   1.6583881e-34
+   2     4    100      3     4   9.8204058e-36
+   2     4    127      7     4   3.5326233e-35
+   3     2    169      6     1   1.7124214e-09
+   3     2      9      1     1   3.7444845e-08
+   4     4     86      2     1   3.9988440e-11
+   4     4    198      9     1   1.2856890e-12
+   4     4    342     38     1   4.5689102e-10
+   5     3     18      3     1   2.7534401e-13
+   5     3     20      4     1   2.2510251e-10
+   5     3     28      4     1   1.6108311e-13
+   6     6     60      6     1   3.2085628e-13
+   6     6    244     11     1   2.3330469e-11
+   6     9     95      8     1   3.2672000e-15
+   6     9    112      7     1   1.7166545e-12
+   7     5     12      1     1   3.5404408e-12
+   7     5    139     24     1   1.1580794e-12
+   7     5    216     42     1   8.6364763e-10
+   7     6     13      2     1   6.8679664e-10
+   7     6     95     13     1   1.0034267e-12
+   7     6    137     24     1   8.4793498e-12
+   7     7     13      1     1   2.3987001e-09
+   7     7    294     48     1   9.0957159e-10
+   7     7     64     10     4   3.2740173e+14
+   7     8     56      8     4   6.4405091e-02
+   7     9     23      2     1   1.8898075e-09
+   8    10     11      2     1   1.9253009e-14
+   8    10     11      2     1   4.4408921e-16
+   8    10     20      2     1   1.2998488e-13
+   8    30     30      3     1   1.3902475e-13
+   8    40     33      3     1   1.0558402e-13
+   9    10      6      1     1   2.5140385e-15
+   9    10      9      1     1   1.7260946e-13
+   9    10     42      1     1   4.1775615e-10
+  10     1      6      1     1   2.7755576e-17
+  10     1      8      1     1   5.5511151e-17
+  10     1     15      1     1   5.5511151e-17
+  10    10      6      1     1   5.0091317e-15
+  10    10      9      1     1   2.1883100e-13
+  10    10     19      2     1   3.0223404e-15
+  11    10     60      7     4   5.2964002e-03
+  11    10     34      5     1   5.9169065e-11
+  11    10     45      4     1   1.8240335e-09
+  12    10     21      1     1   5.8860770e-12
+  12    10     25      1     1   9.3915146e-13
+  12    10     42      4     1   8.9546999e-13
+  13    10     11      1     1   1.4938794e-08
+  13    10     49      1     1   5.0568673e-09
+  13    10     22      2     1   9.8788330e-11
+  14    10     20      1     1   2.0578981e-09
+  14    10     25      2     1   7.9536112e-09
+  14    10     38      2     1   4.5264262e-10
diff --git a/examples/ref/hyjdrv.ref b/examples/ref/hyjdrv.ref
new file mode 100644
index 0000000..8654c00
--- /dev/null
+++ b/examples/ref/hyjdrv.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  0.4919350D+01
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  0.1340063D+04
+
+      final l2 norm of the residuals    0.2886580D-13
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  0.1430001D+06
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  0.1466288D+02
+
+      final l2 norm of the residuals    0.6046010D-34
+
+      number of function evaluations         105
+
+      number of jacobian evaluations           6
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.2695067D-17 -0.2695067D-18  0.3749757D-17  0.3749757D-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  0.1270984D+04
+
+      final l2 norm of the residuals    0.5013400D-34
+
+      number of function evaluations         124
+
+      number of jacobian evaluations           6
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.2961048D-17 -0.2961048D-18  0.3392094D-17  0.3392094D-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  0.1268879D+06
+
+      final l2 norm of the residuals    0.2112179D-33
+
+      number of function evaluations         143
+
+      number of jacobian evaluations          13
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -0.1125674D-16  0.1125674D-17 -0.6482313D-17 -0.6482313D-17
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  0.1065487D+01
+
+      final l2 norm of the residuals    0.1712673D-08
+
+      number of function evaluations         169
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1098159D-04  0.9106147D+01
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  0.1000000D+01
+
+      final l2 norm of the residuals    0.3744062D-07
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1098159D-04  0.9106147D+01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  0.8550557D+04
+
+      final l2 norm of the residuals    0.3983947D-10
+
+      number of function evaluations          86
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9679740D+00  0.9471391D+00 -0.9695163D+00  0.9512477D+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  0.7349823D+07
+
+      final l2 norm of the residuals    0.3771377D-09
+
+      number of function evaluations         202
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9679740D+00  0.9471391D+00 -0.9695163D+00  0.9512477D+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  0.7273070D+10
+
+      final l2 norm of the residuals    0.3478935D-10
+
+      number of function evaluations         386
+
+      number of jacobian evaluations          35
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9679740D+00  0.9471391D+00 -0.9695163D+00  0.9512477D+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  0.5000000D+02
+
+      final l2 norm of the residuals    0.2753440D-12
+
+      number of function evaluations          18
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01 -0.1612103D-13  0.0000000D+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  0.1029563D+03
+
+      final l2 norm of the residuals    0.2250995D-09
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1388617D-10  0.0000000D+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  0.9912618D+03
+
+      final l2 norm of the residuals    0.7202777D-09
+
+      number of function evaluations          37
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.3234657D-10  0.0000000D+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  0.6848587D+02
+
+      final l2 norm of the residuals    0.3591108D-12
+
+      number of function evaluations          60
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572509D-01  0.1012435D+01 -0.2329916D+00  0.1260430D+01 -0.1513729D+01
+       0.9929964D+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  0.3531259D+07
+
+      final l2 norm of the residuals    0.3971695D-13
+
+      number of function evaluations         140
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572509D-01  0.1012435D+01 -0.2329916D+00  0.1260430D+01 -0.1513729D+01
+       0.9929964D+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  0.8878955D+02
+
+      final l2 norm of the residuals    0.5300605D-11
+
+      number of function evaluations          92
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1530704D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  0.1015108D+08
+
+      final l2 norm of the residuals    0.3823081D-01
+
+      number of function evaluations         290
+
+      number of jacobian evaluations          12
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.3119912D+00  0.1089342D+01  0.1379293D+01 -0.1175426D+02  0.6265968D+02
+      -0.1636005D+03  0.2326239D+03 -0.1697823D+03  0.5076762D+02
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  0.2257066D+00
+
+      final l2 norm of the residuals    0.6045759D-12
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8375126D-01  0.3127293D+00  0.5000000D+00  0.6872707D+00  0.9162487D+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  0.4117243D+07
+
+      final l2 norm of the residuals    0.3782524D-10
+
+      number of function evaluations         134
+
+      number of jacobian evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8375126D-01  0.5000000D+00  0.3127293D+00  0.9162487D+00  0.6872707D+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  0.5636130D+12
+
+      final l2 norm of the residuals    0.1381501D-09
+
+      number of function evaluations         244
+
+      number of jacobian evaluations          47
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.6872707D+00  0.5000000D+00  0.8375126D-01  0.3127293D+00  0.9162487D+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  0.2154720D+00
+
+      final l2 norm of the residuals    0.1434346D-10
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.6687659D-01  0.3666823D+00  0.2887407D+00  0.7112593D+00  0.6333177D+00
+       0.9331234D+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  0.1307925D+09
+
+      final l2 norm of the residuals    0.9427397D-10
+
+      number of function evaluations          91
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9331234D+00  0.3666823D+00  0.6687659D-01  0.7112593D+00  0.2887407D+00
+       0.6333177D+00
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  0.1875579D+15
+
+      final l2 norm of the residuals    0.1953644D-09
+
+      number of function evaluations         137
+
+      number of jacobian evaluations          19
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.6687659D-01  0.7112593D+00  0.2887407D+00  0.9331234D+00  0.6333177D+00
+       0.3666823D+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  0.1837679D+00
+
+      final l2 norm of the residuals    0.1935566D-09
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5806915D-01  0.2351716D+00  0.3380441D+00  0.5000000D+00  0.6619559D+00
+       0.7648284D+00  0.9419309D+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  0.4269328D+10
+
+      final l2 norm of the residuals    0.6180272D-10
+
+      number of function evaluations         326
+
+      number of jacobian evaluations          49
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3380441D+00  0.2351716D+00  0.9419309D+00  0.7648284D+00  0.6619559D+00
+       0.5806915D-01  0.5000000D+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  0.6414317D+17
+
+      final l2 norm of the residuals    0.6655717D+13
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          12
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -0.4649136D+02 -0.1039521D+02 -0.7517577D+01  0.1217934D+02  0.4297678D+02
+       0.2373113D+02  0.4306104D+02
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  0.1965139D+00
+
+      final l2 norm of the residuals    0.6440512D-01
+
+      number of function evaluations          56
+
+      number of jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.4985640D-01  0.1986351D+00  0.2698288D+00  0.4992723D+00  0.5007277D+00
+       0.7301712D+00  0.8013649D+00  0.9501436D+00
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  0.1699499D+00
+
+      final l2 norm of the residuals    0.2699639D-08
+
+      number of function evaluations          22
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.4420535D-01  0.1994907D+00  0.2356191D+00  0.4160469D+00  0.5000000D+00
+       0.5839531D+00  0.7643809D+00  0.8005093D+00  0.9557947D+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  0.1653022D+02
+
+      final l2 norm of the residuals    0.1114710D-13
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  0.9765624D+07
+
+      final l2 norm of the residuals    0.8685322D-14
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  0.9765625D+17
+
+      final l2 norm of the residuals    0.1007921D-13
+
+      number of function evaluations          17
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  0.8347604D+02
+
+      final l2 norm of the residuals    0.1213683D-12
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  0.1280264D+03
+
+      final l2 norm of the residuals    0.1115411D-12
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  0.2808058D-01
+
+      final l2 norm of the residuals    0.2514039D-14
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  0.5255526D+00
+
+      final l2 norm of the residuals    0.1726010D-12
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  0.1065739D+03
+
+      final l2 norm of the residuals    0.4175448D-09
+
+      number of function evaluations          42
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  0.1279297D+00
+
+      final l2 norm of the residuals    0.2775558D-16
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1528139D+00
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  0.2562500D+01
+
+      final l2 norm of the residuals    0.5551115D-16
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1528139D+00
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  0.8361172D+03
+
+      final l2 norm of the residuals    0.2775558D-16
+
+      number of function evaluations          15
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1528139D+00
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  0.2518270D+00
+
+      final l2 norm of the residuals    0.4992924D-14
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  0.6116833D+01
+
+      final l2 norm of the residuals    0.2188257D-12
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  0.1269309D+04
+
+      final l2 norm of the residuals    0.3062380D-14
+
+      number of function evaluations          19
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4316498D-01 -0.8157716D-01 -0.1144857D+00 -0.1409736D+00 -0.1599087D+00
+      -0.1698772D+00 -0.1690900D+00 -0.1552495D+00 -0.1253559D+00 -0.7541653D-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  0.8411753D-01
+
+      final l2 norm of the residuals    0.5296392D-02
+
+      number of function evaluations          60
+
+      number of jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.5526154D-01  0.5695755D-01  0.5889067D-01  0.6113606D-01  0.6377856D-01
+       0.6700482D-01  0.2079410D+00  0.1642671D+00  0.8643948D-01  0.9133506D-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  0.2030519D+02
+
+      final l2 norm of the residuals    0.5916701D-10
+
+      number of function evaluations          34
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3439629D-01  0.3503232D-01  0.3571920D-01  0.3646522D-01  0.3728091D-01
+       0.3817986D-01  0.3918014D-01  0.4030650D-01  0.1797202D+00  0.1562409D+00
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  0.9336937D+02
+
+      final l2 norm of the residuals    0.1513856D-08
+
+      number of function evaluations          44
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1888395D+02  0.2516777D+02  0.1888528D+02  0.1888602D+02  0.1888684D+02
+       0.1888774D+02  0.1888874D+02  0.1888986D+02  0.1902928D+02  0.1900580D+02
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  0.2240213D+07
+
+      final l2 norm of the residuals    0.5357531D-11
+
+      number of function evaluations          21
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  0.5223438D+08
+
+      final l2 norm of the residuals    0.1259162D-09
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  0.1592365D+12
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          38
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  0.4582576D+01
+
+      final l2 norm of the residuals    0.1493879D-07
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5707221D+00 -0.6818070D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00
+      -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  0.6391009D+03
+
+      final l2 norm of the residuals    0.5192934D-08
+
+      number of function evaluations          49
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00
+      -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  0.6333758D+05
+
+      final l2 norm of the residuals    0.9878903D-10
+
+      number of function evaluations          22
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5707221D+00 -0.6818069D+00 -0.7022101D+00 -0.7055106D+00 -0.7049062D+00
+      -0.7014966D+00 -0.6918893D+00 -0.6657965D+00 -0.5960351D+00 -0.4164123D+00
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  0.1897367D+02
+
+      final l2 norm of the residuals    0.2057897D-08
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00
+      -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  0.1713092D+05
+
+      final l2 norm of the residuals    0.7953613D-08
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00
+      -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  0.1594986D+08
+
+      final l2 norm of the residuals    0.4526431D-09
+
+      number of function evaluations          38
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.4283029D+00 -0.4765964D+00 -0.5196525D+00 -0.5580993D+00 -0.5925062D+00
+      -0.6245037D+00 -0.6232395D+00 -0.6213938D+00 -0.6204536D+00 -0.5864693D+00
+1summary of  55 calls to hybrj1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000D+00
+   1     2      7      1     1   0.2886580D-13
+   1     2      7      1     1   0.0000000D+00
+   2     4    105      6     4   0.6046010D-34
+   2     4    124      6     4   0.5013400D-34
+   2     4    143     13     4   0.2112179D-33
+   3     2    169      6     1   0.1712673D-08
+   3     2      9      1     1   0.3744062D-07
+   4     4     86      2     1   0.3983947D-10
+   4     4    202      8     1   0.3771377D-09
+   4     4    386     35     1   0.3478935D-10
+   5     3     18      3     1   0.2753440D-12
+   5     3     20      4     1   0.2250995D-09
+   5     3     37      8     1   0.7202777D-09
+   6     6     60      6     1   0.3591108D-12
+   6     6    140      6     1   0.3971695D-13
+   6     9     92      4     1   0.5300605D-11
+   6     9    290     12     4   0.3823081D-01
+   7     5     10      1     1   0.6045759D-12
+   7     5    134     25     1   0.3782524D-10
+   7     5    244     47     1   0.1381501D-09
+   7     6     13      2     1   0.1434346D-10
+   7     6     91     13     1   0.9427397D-10
+   7     6    137     19     1   0.1953644D-09
+   7     7     11      1     1   0.1935566D-09
+   7     7    326     49     1   0.6180272D-10
+   7     7     53     12     4   0.6655717D+13
+   7     8     56      8     4   0.6440512D-01
+   7     9     22      2     1   0.2699639D-08
+   8    10     11      2     1   0.1114710D-13
+   8    10     11      2     1   0.8685322D-14
+   8    10     17      2     1   0.1007921D-13
+   8    30     12      2     1   0.1213683D-12
+   8    40     12      2     1   0.1115411D-12
+   9    10      6      1     1   0.2514039D-14
+   9    10      9      1     1   0.1726010D-12
+   9    10     42      1     1   0.4175448D-09
+  10     1      6      1     1   0.2775558D-16
+  10     1      8      1     1   0.5551115D-16
+  10     1     15      1     1   0.2775558D-16
+  10    10      6      1     1   0.4992924D-14
+  10    10      9      1     1   0.2188257D-12
+  10    10     19      2     1   0.3062380D-14
+  11    10     60      7     4   0.5296392D-02
+  11    10     34      5     1   0.5916701D-10
+  11    10     44      4     1   0.1513856D-08
+  12    10     21      1     1   0.5357531D-11
+  12    10     25      1     1   0.1259162D-09
+  12    10     38      2     1   0.0000000D+00
+  13    10     11      1     1   0.1493879D-07
+  13    10     49      1     1   0.5192934D-08
+  13    10     22      2     1   0.9878903D-10
+  14    10     20      1     1   0.2057897D-08
+  14    10     25      2     1   0.7953613D-08
+  14    10     38      2     1   0.4526431D-09
diff --git a/examples/ref/hyjdrvc.ref b/examples/ref/hyjdrvc.ref
new file mode 100644
index 0000000..4cd4b37
--- /dev/null
+++ b/examples/ref/hyjdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    2.8865799e-14
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    6.0460100e-35
+
+      number of function evaluations         105
+
+      number of jacobian evaluations           6
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.6950668e-18 -2.6950668e-19  3.7497570e-18  3.7497570e-18
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    5.1548784e-35
+
+      number of function evaluations         118
+
+      number of jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.9249006e-18 -2.9249006e-19  3.4433850e-18  3.4433850e-18
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    1.6136521e-34
+
+      number of function evaluations         175
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -9.6794799e-18  9.6794799e-19 -5.7104418e-18 -5.7104418e-18
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654866e+00
+
+      final l2 norm of the residuals    1.7126732e-09
+
+      number of function evaluations         169
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    3.7440617e-08
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5505574e+03
+
+      final l2 norm of the residuals    3.9839466e-11
+
+      number of function evaluations          86
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.3498230e+06
+
+      final l2 norm of the residuals    3.7713773e-10
+
+      number of function evaluations         202
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797403e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.2730700e+09
+
+      final l2 norm of the residuals    3.4789348e-11
+
+      number of function evaluations         386
+
+      number of jacobian evaluations          35
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    2.7534405e-13
+
+      number of function evaluations          18
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.6121033e-14  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    2.2509949e-10
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.3886171e-11  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    7.2027771e-10
+
+      number of function evaluations          37
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  3.2346572e-11  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8485872e+01
+
+      final l2 norm of the residuals    3.5911084e-13
+
+      number of function evaluations          60
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  3.5312586e+06
+
+      final l2 norm of the residuals    3.9716952e-14
+
+      number of function evaluations         140
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8789552e+01
+
+      final l2 norm of the residuals    5.3006054e-12
+
+      number of function evaluations          92
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307039e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  1.0151080e+07
+
+      final l2 norm of the residuals    3.8230808e-02
+
+      number of function evaluations         290
+
+      number of jacobian evaluations          12
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.1199119e-01  1.0893424e+00  1.3792932e+00 -1.1754265e+01  6.2659676e+01
+      -1.6360049e+02  2.3262392e+02 -1.6978231e+02  5.0767617e+01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570657e-01
+
+      final l2 norm of the residuals    6.0457589e-13
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751256e-02  3.1272930e-01  5.0000000e-01  6.8727070e-01  9.1624874e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  4.1172432e+06
+
+      final l2 norm of the residuals    3.7825240e-11
+
+      number of function evaluations         134
+
+      number of jacobian evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751257e-02  5.0000000e-01  3.1272930e-01  9.1624874e-01  6.8727070e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  5.6361303e+11
+
+      final l2 norm of the residuals    1.3374486e-10
+
+      number of function evaluations         241
+
+      number of jacobian evaluations          49
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.1272930e-01  6.8727070e-01  8.3751257e-02  5.0000000e-01  9.1624874e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1547198e-01
+
+      final l2 norm of the residuals    1.4343465e-11
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876591e-02  3.6668230e-01  2.8874067e-01  7.1125933e-01  6.3331770e-01
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.3079247e+08
+
+      final l2 norm of the residuals    9.4273970e-11
+
+      number of function evaluations          91
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.3312341e-01  3.6668230e-01  6.6876591e-02  7.1125933e-01  2.8874067e-01
+       6.3331770e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.8755789e+14
+
+      final l2 norm of the residuals    4.8578341e-11
+
+      number of function evaluations         161
+
+      number of jacobian evaluations          19
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876591e-02  9.3312341e-01  2.8874067e-01  6.3331770e-01  7.1125933e-01
+       3.6668230e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8376789e-01
+
+      final l2 norm of the residuals    1.9355663e-10
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8069150e-02  2.3517161e-01  3.3804409e-01  5.0000000e-01  6.6195591e-01
+       7.6482839e-01  9.4193085e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  4.2693282e+09
+
+      final l2 norm of the residuals    9.4850560e-10
+
+      number of function evaluations         287
+
+      number of jacobian evaluations          45
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8069150e-02  7.6482839e-01  5.0000000e-01  3.3804410e-01  9.4193085e-01
+       2.3517161e-01  6.6195591e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  6.4143166e+16
+
+      final l2 norm of the residuals    6.6689395e+12
+
+      number of function evaluations          48
+
+      number of jacobian evaluations          11
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -4.6510183e+01 -1.0476168e+01 -7.3372811e+00  1.2103936e+01  4.3027770e+01
+       2.3762797e+01  4.3039762e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    6.4405122e-02
+
+      number of function evaluations          56
+
+      number of jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.9856400e-02  1.9863513e-01  2.6982882e-01  4.9927230e-01  5.0072770e-01
+       7.3017118e-01  8.0136487e-01  9.5014360e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    2.6996389e-09
+
+      number of function evaluations          22
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.1147104e-14
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    8.6853223e-15
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    1.0079211e-14
+
+      number of function evaluations          17
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.2136830e-13
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    1.1154112e-13
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.8080582e-02
+
+      final l2 norm of the residuals    2.5140385e-15
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2555258e-01
+
+      final l2 norm of the residuals    1.7260101e-13
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0657390e+02
+
+      final l2 norm of the residuals    4.1754484e-10
+
+      number of function evaluations          42
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    3.3306691e-16
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    5.5511151e-17
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3611719e+02
+
+      final l2 norm of the residuals    2.7755576e-17
+
+      number of function evaluations          24
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5182701e-01
+
+      final l2 norm of the residuals    8.5698726e-12
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1168330e+00
+
+      final l2 norm of the residuals    2.7315309e-12
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2693089e+03
+
+      final l2 norm of the residuals    7.9371720e-14
+
+      number of function evaluations          48
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  8.4117534e-02
+
+      final l2 norm of the residuals    5.2963921e-03
+
+      number of function evaluations          60
+
+      number of jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.5261544e-02  5.6957555e-02  5.8890667e-02  6.1136063e-02  6.3778558e-02
+       6.7004825e-02  2.0794103e-01  1.6426711e-01  8.6439479e-02  9.1335063e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0305195e+01
+
+      final l2 norm of the residuals    5.9167010e-11
+
+      number of function evaluations          34
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.4396289e-02  3.5032316e-02  3.5719196e-02  3.6465224e-02  3.7280912e-02
+       3.8179863e-02  3.9180141e-02  4.0306503e-02  1.7972019e-01  1.5624088e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3369375e+01
+
+      final l2 norm of the residuals    1.5138556e-09
+
+      number of function evaluations          44
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8883952e+01  2.5167774e+01  1.8885275e+01  1.8886021e+01  1.8886837e+01
+       1.8887736e+01  1.8888736e+01  1.8889862e+01  1.9029276e+01  1.9005797e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  2.2402135e+06
+
+      final l2 norm of the residuals    5.3575313e-12
+
+      number of function evaluations          21
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  5.2234376e+07
+
+      final l2 norm of the residuals    1.2591618e-10
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  1.5923646e+11
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          38
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5825757e+00
+
+      final l2 norm of the residuals    1.4938794e-08
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3910093e+02
+
+      final l2 norm of the residuals    5.1929336e-09
+
+      number of function evaluations          49
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3337583e+04
+
+      final l2 norm of the residuals    9.8789030e-11
+
+      number of function evaluations          22
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8973666e+01
+
+      final l2 norm of the residuals    2.0578971e-09
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7130922e+04
+
+      final l2 norm of the residuals    7.9536129e-09
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.5949860e+07
+
+      final l2 norm of the residuals    4.5264308e-10
+
+      number of function evaluations          38
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
 summary of 55 calls to hybrj1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      7      1     1   2.8865799e-14
+   1     2      7      1     1   0.0000000e+00
+   2     4    105      6     4   6.0460100e-35
+   2     4    118      7     4   5.1548784e-35
+   2     4    175     16     4   1.6136521e-34
+   3     2    169      6     1   1.7126732e-09
+   3     2      9      1     1   3.7440617e-08
+   4     4     86      2     1   3.9839466e-11
+   4     4    202      8     1   3.7713773e-10
+   4     4    386     35     1   3.4789348e-11
+   5     3     18      3     1   2.7534405e-13
+   5     3     20      4     1   2.2509949e-10
+   5     3     37      8     1   7.2027771e-10
+   6     6     60      6     1   3.5911084e-13
+   6     6    140      6     1   3.9716952e-14
+   6     9     92      4     1   5.3006054e-12
+   6     9    290     12     4   3.8230808e-02
+   7     5     10      1     1   6.0457589e-13
+   7     5    134     25     1   3.7825240e-11
+   7     5    241     49     1   1.3374486e-10
+   7     6     13      2     1   1.4343465e-11
+   7     6     91     13     1   9.4273970e-11
+   7     6    161     19     1   4.8578341e-11
+   7     7     11      1     1   1.9355663e-10
+   7     7    287     45     1   9.4850560e-10
+   7     7     48     11     4   6.6689395e+12
+   7     8     56      8     4   6.4405122e-02
+   7     9     22      2     1   2.6996389e-09
+   8    10     11      2     1   1.1147104e-14
+   8    10     11      2     1   8.6853223e-15
+   8    10     17      2     1   1.0079211e-14
+   8    30     12      2     1   1.2136830e-13
+   8    40     12      2     1   1.1154112e-13
+   9    10      6      1     1   2.5140385e-15
+   9    10      9      1     1   1.7260101e-13
+   9    10     42      1     1   4.1754484e-10
+  10     1      6      1     1   3.3306691e-16
+  10     1      8      1     1   5.5511151e-17
+  10     1     24      2     1   2.7755576e-17
+  10    10      8      1     1   8.5698726e-12
+  10    10      9      1     1   2.7315309e-12
+  10    10     48      3     1   7.9371720e-14
+  11    10     60      7     4   5.2963921e-03
+  11    10     34      5     1   5.9167010e-11
+  11    10     44      4     1   1.5138556e-09
+  12    10     21      1     1   5.3575313e-12
+  12    10     25      1     1   1.2591618e-10
+  12    10     38      2     1   0.0000000e+00
+  13    10     11      1     1   1.4938794e-08
+  13    10     49      1     1   5.1929336e-09
+  13    10     22      2     1   9.8789030e-11
+  14    10     20      1     1   2.0578971e-09
+  14    10     25      2     1   7.9536129e-09
+  14    10     38      2     1   4.5264308e-10
diff --git a/examples/ref/ibmdpdr.ref b/examples/ref/ibmdpdr.ref
new file mode 100644
index 0000000..4b3c39b
--- /dev/null
+++ b/examples/ref/ibmdpdr.ref
@@ -0,0 +1,42 @@
+1MACHAR constants
+
+
+ ibeta =     2
+
+ it    =    53
+
+ irnd  =     5
+
+ ngrd  =     0
+
+ machep =   -52
+
+ negep =   -53
+
+ iexp =    11
+
+ minexp = -1022
+
+ maxexp =  1024
+
+ eps =  0.2220446D-15
+
+ epsneg =  0.1110223D-15
+
+ xmin =  0.2225074-307
+
+ xmax =  0.1797693+309
+
+
+
+ dpmpar constants and relative differences
+
+
+ epsmch =  0.2220446D-15
+ rerr(1) =  0.0000000D+00
+
+ dwarf =  0.2225074-307
+ rerr(2) =  0.0000000D+00
+
+ giant =  0.1797693+309
+ rerr(3) =  0.0000000D+00
diff --git a/examples/ref/ibmdpdrc.ref b/examples/ref/ibmdpdrc.ref
new file mode 100644
index 0000000..57a013e
--- /dev/null
+++ b/examples/ref/ibmdpdrc.ref
@@ -0,0 +1,42 @@
+
 MACHAR constants
+
+
+ ibeta =     2
+
+ it    =    53
+
+ irnd  =     5
+
+ ngrd  =     0
+
+ machep =   -52
+
+ negep =   -53
+
+ iexp =    11
+
+ minexp = -1022
+
+ maxexp =  1024
+
+ eps =  2.2204460e-16
+
+ epsneg =  1.1102230e-16
+
+ xmin = 2.2250739e-308
+
+ xmax = 1.7976931e+308
+
+
+
+ DPMPAR constants and relative differences
+
+
+ epsmch =  2.2204460e-16
+ rerr(1) =  0.0000000e+00
+
+ dwarf = 2.2250739e-308
+ rerr(2) =  0.0000000e+00
+
+ giant = 1.7976931e+308
+ rerr(3) =  0.0000000e+00
diff --git a/examples/ref/lchkdrvc.ref b/examples/ref/lchkdrvc.ref
new file mode 100644
index 0000000..a895f86
--- /dev/null
+++ b/examples/ref/lchkdrvc.ref
@@ -0,0 +1,311 @@
+
+
+
+      problem    1      with dimension    2   is  F
+
+
+      first function vector   
+
+       2.0770000e+00 -2.8292900e+00
+
+
+      function difference vector
+
+      -1.6048551e-08  4.7636896e-07
+
+
+      error vector
+
+       3.6441652e-02  1.0000000e+00
+
+
+
+      problem    2      with dimension    4   is  F
+
+
+      first function vector   
+
+      -8.1070000e+00 -1.6859953e+00  1.8741610e+00  1.5952160e+01
+
+
+      function difference vector
+
+       2.1387637e-07 -2.5123287e-08 -3.5781055e-08  4.7541143e-07
+
+
+      error vector
+
+       1.0000000e+00  1.0000000e+00  5.6784314e-02  1.0000000e+00
+
+
+
+      problem    3      with dimension    2   is  F
+
+
+      first function vector   
+
+       1.0777100e+03  3.0019279e-01
+
+
+      function difference vector
+
+       3.2148063e-05 -7.0575175e-09
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    4      with dimension    4   is  T
+
+
+      first function vector   
+
+      -5.4127112e+03 -1.9649458e+03 -4.8718278e+03 -1.7769432e+03
+
+
+      function difference vector
+
+       2.3220785e-04  5.3351694e-05  2.0899135e-04  4.8083460e-05
+
+
+      error vector
+
+       9.8314445e-01  1.0000000e+00  9.6587806e-01  1.0000000e+00
+
+
+
+      problem    5      with dimension    3   is  F
+
+
+      first function vector   
+
+      -5.0987696e+01 -1.1441658e+00  1.2300000e-01
+
+
+      function difference vector
+
+       1.8328421e-08 -1.3196221e-07  1.8328428e-09
+
+
+      error vector
+
+       1.0000000e+00  0.0000000e+00  1.0000000e+00
+
+
+
+      problem    6      with dimension    9   is  F
+
+
+      first function vector   
+
+      -5.7930631e+00 -3.3390751e+01 -3.4683179e+01 -3.6368725e+01 -3.7947668e+01
+      -3.9431326e+01 -4.0834243e+01 -4.2170791e+01 -4.3453299e+01
+
+
+      function difference vector
+
+       4.5150085e-07  8.2526081e-07  1.0470759e-06  1.2208782e-06  1.3636127e-06
+       1.4852995e-06  1.5920150e-06  1.6876970e-06  1.7750240e-06
+
+
+      error vector
+
+       0.0000000e+00  4.4776909e-02  5.8948123e-02  7.0484722e-02  7.9955256e-02
+       8.8016532e-02  9.5043433e-02  1.0127560e-01  1.0687673e-01
+
+
+
+      problem    7      with dimension    7   is  F
+
+
+      first function vector   
+
+       3.5142857e-02 -4.5634667e-02  2.1936396e-01  2.1302816e-01  2.5865828e-01
+       2.3088814e-01  5.9195986e-02
+
+
+      function difference vector
+
+       1.5424831e-08  2.0602874e-08  2.3769456e-08  5.3491546e-08  9.7040762e-08
+       1.5766330e-07  2.1121844e-07
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    8      with dimension   10   is  T
+
+
+      first function vector   
+
+      -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00
+      -5.3770000e+00 -5.6230000e+00 -5.3770000e+00 -5.6230000e+00 -9.9928526e-01
+
+
+      function difference vector
+
+       8.0123543e-08  8.3789228e-08  8.0123543e-08  8.3789228e-08  8.0123543e-08
+       8.3789228e-08  8.0123543e-08  8.3789228e-08  8.0123543e-08  1.0650436e-10
+
+
+      error vector
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+      problem    9      with dimension   10   is  F
+
+
+      first function vector   
+
+      -3.8266208e-01  4.8185552e-01 -5.0497059e-01  4.8364359e-01 -5.0327111e-01
+       4.8731586e-01 -4.9982317e-01  4.9409864e-01 -4.9324735e-01  3.8308496e-01
+
+
+      function difference vector
+
+       5.7745994e-09 -7.0787115e-09  7.6314004e-09 -7.0535194e-09  7.6581295e-09
+      -7.0385017e-09  7.6852619e-09 -7.0470895e-09  6.4950392e-09 -2.8185304e-09
+
+
+      error vector
+
+       3.4189481e-02  1.6205676e-01  2.4769060e-02  8.2442013e-02  1.6527366e-02
+       7.4836913e-02  1.8515282e-02  1.0342218e-01  3.2259557e-02  1.2358623e-01
+
+
+
+      problem   10      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.6796677e-01  4.6728538e-02 -2.2043167e-01  1.7378706e-02 -2.2845451e-01
+       2.8983382e-02 -2.0089459e-01  6.9050605e-02 -1.5510284e-01  1.1399106e-01
+
+
+      function difference vector
+
+       3.2947051e-09  8.1481072e-10  5.4136278e-09  2.3810444e-09  6.4019805e-09
+       2.7647869e-09  6.1660951e-09  1.8821412e-09  4.6452768e-09  9.1337315e-10
+
+
+      error vector
+
+       0.0000000e+00  8.3217918e-03  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  4.4819193e-02
+
+
+
+      problem   11      with dimension   10   is  F
+
+
+      first function vector   
+
+       1.4839305e-01 -4.6502477e-02  1.4892203e-01  3.0207835e-03  1.4945101e-01
+       5.2544044e-02  1.4997998e-01  1.0206730e-01  1.5050896e-01  1.5159056e-01
+
+
+      function difference vector
+
+       3.2845368e-09  1.8641646e-09  3.2687728e-09  3.3339513e-09  3.2530085e-09
+       4.8037387e-09  3.2372434e-09  6.2735230e-09  3.2214782e-09  7.7433100e-09
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   12      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.0878876e+05 -2.1757715e+05 -3.2636603e+05 -4.3515443e+05 -5.4394331e+05
+      -6.5273170e+05 -7.6152058e+05 -8.7030898e+05 -9.7909786e+05 -1.0878862e+06
+
+
+      function difference vector
+
+       2.2496541e-03  4.4992989e-03  6.7489363e-03  8.9985810e-03  1.1248218e-02
+       1.3497863e-02  1.5747500e-02  1.7997145e-02  2.0246784e-02  2.2496427e-02
+
+
+      error vector
+
+       2.0279172e-02  2.0279078e-02  2.0279130e-02  2.0279094e-02  2.0279122e-02
+       2.0279099e-02  2.0279119e-02  2.0279101e-02  2.0279116e-02  2.0279103e-02
+
+
+
+      problem   13      with dimension   10   is  T
+
+
+      first function vector   
+
+      -3.1372580e+00  1.9974200e-01 -2.2602580e+00  1.9974200e-01 -2.2602580e+00
+       1.9974200e-01 -2.2602580e+00  1.9974200e-01 -2.2602580e+00 -2.0462580e+00
+
+
+      function difference vector
+
+       9.9234522e-08  3.4846602e-08  8.6166204e-08  3.4846602e-08  8.6166204e-08
+       3.4846602e-08  8.6166204e-08  3.4846602e-08  8.6166204e-08  6.8314610e-08
+
+
+      error vector
+
+       1.0000000e+00  8.3229083e-01  1.0000000e+00  8.3229083e-01  1.0000000e+00
+       8.3229083e-01  1.0000000e+00  8.3229083e-01  1.0000000e+00  9.5783592e-01
+
+
+
+      problem   14      with dimension   10   is  F
+
+
+      first function vector   
+
+      -8.2193683e+00 -4.4028887e+00 -8.2496263e+00 -4.4331467e+00 -8.2798843e+00
+      -4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252757e+00
+
+
+      function difference vector
+
+       3.5987758e-07  2.1860611e-07  3.9058166e-07  2.4931019e-07  4.2128574e-07
+       2.8001427e-07  4.3113925e-07  2.8001427e-07  4.3113925e-07  2.5916370e-07
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
 summary of  14 tests of chkder
+
+ nprob   n    status     errmin         errmax
+
+   1     2      F     3.6441652e-02  1.0000000e+00
+   2     4      F     5.6784314e-02  1.0000000e+00
+   3     2      F     0.0000000e+00  0.0000000e+00
+   4     4      T     9.6587806e-01  1.0000000e+00
+   5     3      F     0.0000000e+00  1.0000000e+00
+   6     9      F     0.0000000e+00  1.0687673e-01
+   7     7      F     0.0000000e+00  0.0000000e+00
+   8    10      T     1.0000000e+00  1.0000000e+00
+   9    10      F     1.6527366e-02  1.6205676e-01
+  10    10      F     0.0000000e+00  4.4819193e-02
+  11    10      F     0.0000000e+00  0.0000000e+00
+  12    10      F     2.0279078e-02  2.0279172e-02
+  13    10      T     8.3229083e-01  1.0000000e+00
+  14    10      F     0.0000000e+00  0.0000000e+00
diff --git a/examples/ref/lhybdrvc.ref b/examples/ref/lhybdrvc.ref
new file mode 100644
index 0000000..951fbc1
--- /dev/null
+++ b/examples/ref/lhybdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    2.8865799e-14
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    1.7248154e-35
+
+      number of function evaluations          99
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -5.5380471e-19  5.5380471e-20  1.5756630e-18  1.5756630e-18
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    6.4285886e-34
+
+      number of function evaluations          98
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+       9.2020488e-18 -9.2020488e-19  1.2210938e-17  1.2210938e-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    1.2083140e-36
+
+      number of function evaluations         115
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.7269979e-19 -2.7269979e-20  5.3169716e-19  5.3169716e-19
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654866e+00
+
+      final l2 norm of the residuals    1.7124937e-09
+
+      number of function evaluations         169
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    3.7444845e-08
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5505574e+03
+
+      final l2 norm of the residuals    3.9995537e-11
+
+      number of function evaluations          86
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.3498230e+06
+
+      final l2 norm of the residuals    1.0674690e-12
+
+      number of function evaluations         198
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.2730700e+09
+
+      final l2 norm of the residuals    1.0565335e-10
+
+      number of function evaluations         343
+
+      number of Jacobian evaluations          37
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    2.7534492e-13
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.6121092e-14  8.8262433e-35
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    2.2510285e-10
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.3886359e-11  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    1.6108310e-13
+
+      number of function evaluations          28
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.2387174e-15  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8485872e+01
+
+      final l2 norm of the residuals    2.9097502e-13
+
+      number of function evaluations          60
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  3.5312586e+06
+
+      final l2 norm of the residuals    2.3352558e-11
+
+      number of function evaluations         244
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8789552e+01
+
+      final l2 norm of the residuals    1.9095012e-14
+
+      number of function evaluations          95
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  1.0151080e+07
+
+      final l2 norm of the residuals    1.0715733e-12
+
+      number of function evaluations         113
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570657e-01
+
+      final l2 norm of the residuals    3.5398198e-12
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751256e-02  3.1272930e-01  5.0000000e-01  6.8727070e-01  9.1624874e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  4.1172432e+06
+
+      final l2 norm of the residuals    1.6645967e-10
+
+      number of function evaluations         165
+
+      number of Jacobian evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751257e-02  5.0000000e-01  3.1272930e-01  9.1624874e-01  6.8727070e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  5.6361303e+11
+
+      final l2 norm of the residuals    1.7870140e-11
+
+      number of function evaluations         239
+
+      number of Jacobian evaluations          43
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.1624874e-01  5.0000000e-01  8.3751257e-02  3.1272930e-01  6.8727070e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1547198e-01
+
+      final l2 norm of the residuals    6.7528897e-10
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876591e-02  3.6668230e-01  2.8874067e-01  7.1125933e-01  6.3331770e-01
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.3079247e+08
+
+      final l2 norm of the residuals    1.4303551e-12
+
+      number of function evaluations          98
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.3312341e-01  3.6668230e-01  6.6876591e-02  7.1125933e-01  2.8874067e-01
+       6.3331770e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.8755789e+14
+
+      final l2 norm of the residuals    9.7369059e-12
+
+      number of function evaluations         170
+
+      number of Jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.8874067e-01  6.3331770e-01  7.1125933e-01  3.6668230e-01  6.6876591e-02
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8376789e-01
+
+      final l2 norm of the residuals    2.3987001e-09
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8069150e-02  2.3517161e-01  3.3804410e-01  5.0000000e-01  6.6195591e-01
+       7.6482839e-01  9.4193085e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  4.2693282e+09
+
+      final l2 norm of the residuals    3.2253189e-10
+
+      number of function evaluations         320
+
+      number of Jacobian evaluations          55
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.3517161e-01  7.6482839e-01  5.8069150e-02  5.0000000e-01  9.4193085e-01
+       3.3804409e-01  6.6195591e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  6.4143166e+16
+
+      final l2 norm of the residuals    2.5128001e+13
+
+      number of function evaluations          43
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.2796856e+01 -5.8523189e+01  1.4444492e+01  1.7338156e+01 -1.6972360e+01
+       5.9164077e+01  3.8018847e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    6.4405088e-02
+
+      number of function evaluations          56
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.9856399e-02  1.9863513e-01  2.6982883e-01  4.9927232e-01  5.0072772e-01
+       7.3017122e-01  8.0136492e-01  9.5014366e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    1.8898070e-09
+
+      number of function evaluations          23
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    8.4617642e-15
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    2.7217452e-15
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    3.3306691e-15
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.8294939e-13
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    2.0896866e-13
+
+      number of function evaluations          34
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.8080582e-02
+
+      final l2 norm of the residuals    2.5126461e-15
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2555258e-01
+
+      final l2 norm of the residuals    1.7258603e-13
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0657390e+02
+
+      final l2 norm of the residuals    4.1734352e-10
+
+      number of function evaluations          42
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    2.7755576e-17
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    5.5511151e-17
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3611719e+02
+
+      final l2 norm of the residuals    5.5511151e-17
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5182701e-01
+
+      final l2 norm of the residuals    5.0091317e-15
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1168330e+00
+
+      final l2 norm of the residuals    2.1883100e-13
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2693089e+03
+
+      final l2 norm of the residuals    3.0185784e-15
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  8.4117534e-02
+
+      final l2 norm of the residuals    5.2964025e-03
+
+      number of function evaluations          60
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.5261727e-02  5.6957755e-02  5.8890887e-02  6.1136301e-02  6.3778832e-02
+       6.7005147e-02  2.0794071e-01  1.6426668e-01  8.6440675e-02  9.1336217e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0305195e+01
+
+      final l2 norm of the residuals    5.9150407e-11
+
+      number of function evaluations          34
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.4396289e-02  3.5032316e-02  3.5719196e-02  3.6465224e-02  3.7280912e-02
+       3.8179863e-02  3.9180141e-02  4.0306503e-02  1.7972019e-01  1.5624088e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3369375e+01
+
+      final l2 norm of the residuals    1.8285245e-09
+
+      number of function evaluations          45
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8883952e+01  2.5167774e+01  1.8885275e+01  1.8886021e+01  1.8886837e+01
+       1.8887736e+01  1.8888736e+01  1.8889862e+01  1.9029276e+01  1.9005797e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  2.2402135e+06
+
+      final l2 norm of the residuals    4.7700156e-12
+
+      number of function evaluations          21
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  5.2234376e+07
+
+      final l2 norm of the residuals    2.5968629e-11
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  1.5923646e+11
+
+      final l2 norm of the residuals    1.0701963e-13
+
+      number of function evaluations          37
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5825757e+00
+
+      final l2 norm of the residuals    1.4938794e-08
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3910093e+02
+
+      final l2 norm of the residuals    4.9947085e-09
+
+      number of function evaluations          49
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3337583e+04
+
+      final l2 norm of the residuals    9.8788317e-11
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8973666e+01
+
+      final l2 norm of the residuals    2.0578981e-09
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7130922e+04
+
+      final l2 norm of the residuals    7.9536085e-09
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.5949860e+07
+
+      final l2 norm of the residuals    4.5264247e-10
+
+      number of function evaluations          38
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
 summary of 55 calls to hybrd1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      7      1     1   2.8865799e-14
+   1     2      7      1     1   0.0000000e+00
+   2     4     99      3     4   1.7248154e-35
+   2     4     98      3     4   6.4285886e-34
+   2     4    115      4     4   1.2083140e-36
+   3     2    169      6     1   1.7124937e-09
+   3     2      9      1     1   3.7444845e-08
+   4     4     86      2     1   3.9995537e-11
+   4     4    198      9     1   1.0674690e-12
+   4     4    343     37     1   1.0565335e-10
+   5     3     18      3     1   2.7534492e-13
+   5     3     20      4     1   2.2510285e-10
+   5     3     28      4     1   1.6108310e-13
+   6     6     60      6     1   2.9097502e-13
+   6     6    244     11     1   2.3352558e-11
+   6     9     95      8     1   1.9095012e-14
+   6     9    113      7     1   1.0715733e-12
+   7     5     12      1     1   3.5398198e-12
+   7     5    165     25     1   1.6645967e-10
+   7     5    239     43     1   1.7870140e-11
+   7     6     13      2     1   6.7528897e-10
+   7     6     98     13     1   1.4303551e-12
+   7     6    170     24     1   9.7369059e-12
+   7     7     13      1     1   2.3987001e-09
+   7     7    320     55     1   3.2253189e-10
+   7     7     43      9     4   2.5128001e+13
+   7     8     56      8     4   6.4405088e-02
+   7     9     23      2     1   1.8898070e-09
+   8    10     11      2     1   8.4617642e-15
+   8    10     11      2     1   2.7217452e-15
+   8    10     18      2     1   3.3306691e-15
+   8    30     12      2     1   1.8294939e-13
+   8    40     34      3     1   2.0896866e-13
+   9    10      6      1     1   2.5126461e-15
+   9    10      9      1     1   1.7258603e-13
+   9    10     42      1     1   4.1734352e-10
+  10     1      6      1     1   2.7755576e-17
+  10     1      8      1     1   5.5511151e-17
+  10     1     15      1     1   5.5511151e-17
+  10    10      6      1     1   5.0091317e-15
+  10    10      9      1     1   2.1883100e-13
+  10    10     19      2     1   3.0185784e-15
+  11    10     60      7     4   5.2964025e-03
+  11    10     34      5     1   5.9150407e-11
+  11    10     45      4     1   1.8285245e-09
+  12    10     21      1     1   4.7700156e-12
+  12    10     25      1     1   2.5968629e-11
+  12    10     37      4     1   1.0701963e-13
+  13    10     11      1     1   1.4938794e-08
+  13    10     49      1     1   4.9947085e-09
+  13    10     22      2     1   9.8788317e-11
+  14    10     20      1     1   2.0578981e-09
+  14    10     25      2     1   7.9536085e-09
+  14    10     38      2     1   4.5264247e-10
diff --git a/examples/ref/lhyjdrvc.ref b/examples/ref/lhyjdrvc.ref
new file mode 100644
index 0000000..0638337
--- /dev/null
+++ b/examples/ref/lhyjdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    1.5672781e-33
+
+      number of function evaluations         107
+
+      number of jacobian evaluations           5
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.0882665e-17 -3.0882665e-18  1.7588605e-17  1.7588605e-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    9.9748795e-34
+
+      number of function evaluations         132
+
+      number of jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.4658970e-17 -2.4658970e-18  1.4024653e-17  1.4024653e-17
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    1.1443109e-35
+
+      number of function evaluations         148
+
+      number of jacobian evaluations          11
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2216683e-18 -1.2216683e-19 -6.7243150e-19 -6.7243150e-19
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654866e+00
+
+      final l2 norm of the residuals    1.7126733e-09
+
+      number of function evaluations         169
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    3.7440617e-08
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981593e-05  9.1061467e+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5505574e+03
+
+      final l2 norm of the residuals    3.9845528e-11
+
+      number of function evaluations          86
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.3498230e+06
+
+      final l2 norm of the residuals    3.7715808e-10
+
+      number of function evaluations         202
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797403e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.2730700e+09
+
+      final l2 norm of the residuals    3.4730030e-11
+
+      number of function evaluations         386
+
+      number of jacobian evaluations          35
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797402e-01  9.4713914e-01 -9.6951631e-01  9.5124767e-01
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    2.7534405e-13
+
+      number of function evaluations          18
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.6121033e-14  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    2.2509949e-10
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.3886171e-11  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    7.2027771e-10
+
+      number of function evaluations          37
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  3.2346572e-11  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8485872e+01
+
+      final l2 norm of the residuals    3.6849814e-13
+
+      number of function evaluations          60
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  3.5312586e+06
+
+      final l2 norm of the residuals    7.2239834e-14
+
+      number of function evaluations         140
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725086e-02  1.0124349e+00 -2.3299163e-01  1.2604301e+00 -1.5137289e+00
+       9.9299643e-01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8789552e+01
+
+      final l2 norm of the residuals    8.0147779e-12
+
+      number of function evaluations          92
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307039e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  1.0151080e+07
+
+      final l2 norm of the residuals    3.8553032e-02
+
+      number of function evaluations         310
+
+      number of jacobian evaluations          13
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.0762853e-01  1.0875797e+00  1.3062859e+00 -1.0943084e+01  5.8469829e+01
+      -1.5262799e+02  2.1713637e+02 -1.5857692e+02  4.7476975e+01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570657e-01
+
+      final l2 norm of the residuals    6.0450835e-13
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751256e-02  3.1272930e-01  5.0000000e-01  6.8727070e-01  9.1624874e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  4.1172432e+06
+
+      final l2 norm of the residuals    2.9381451e-10
+
+      number of function evaluations         135
+
+      number of jacobian evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751257e-02  5.0000000e-01  3.1272930e-01  9.1624874e-01  6.8727070e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  5.6361303e+11
+
+      final l2 norm of the residuals    1.7411953e-10
+
+      number of function evaluations         269
+
+      number of jacobian evaluations          53
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.0000000e-01  3.1272930e-01  8.3751257e-02  6.8727070e-01  9.1624874e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1547198e-01
+
+      final l2 norm of the residuals    1.4343386e-11
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876591e-02  3.6668230e-01  2.8874067e-01  7.1125933e-01  6.3331770e-01
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.3079247e+08
+
+      final l2 norm of the residuals    1.2227706e-10
+
+      number of function evaluations          91
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.3312341e-01  3.6668230e-01  6.6876591e-02  7.1125933e-01  2.8874067e-01
+       6.3331770e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.8755789e+14
+
+      final l2 norm of the residuals    6.2931742e-10
+
+      number of function evaluations         169
+
+      number of jacobian evaluations          21
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876591e-02  3.6668230e-01  2.8874067e-01  7.1125933e-01  9.3312341e-01
+       6.3331770e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8376789e-01
+
+      final l2 norm of the residuals    1.9360470e-10
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8069150e-02  2.3517161e-01  3.3804409e-01  5.0000000e-01  6.6195591e-01
+       7.6482839e-01  9.4193085e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  4.2693282e+09
+
+      final l2 norm of the residuals    1.3121086e-10
+
+      number of function evaluations         330
+
+      number of jacobian evaluations          49
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6195591e-01  3.3804409e-01  5.0000000e-01  2.3517161e-01  9.4193085e-01
+       5.8069150e-02  7.6482839e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  6.4143166e+16
+
+      final l2 norm of the residuals    6.4143166e+16
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+01  2.5000000e+01  3.7500000e+01  5.0000000e+01  6.2500000e+01
+       7.5000000e+01  8.7500000e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    6.4405122e-02
+
+      number of function evaluations          56
+
+      number of jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.9856400e-02  1.9863513e-01  2.6982882e-01  4.9927230e-01  5.0072770e-01
+       7.3017118e-01  8.0136487e-01  9.5014360e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    2.9424978e-10
+
+      number of function evaluations          23
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.9280838e-14
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    7.6605389e-15
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    8.3451559e-15
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    3.8278068e-14
+
+      number of function evaluations          24
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  1.0673735e+00
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    3.6669811e-14
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.8080582e-02
+
+      final l2 norm of the residuals    2.5155475e-15
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2555258e-01
+
+      final l2 norm of the residuals    1.7260578e-13
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0657390e+02
+
+      final l2 norm of the residuals    4.1776156e-10
+
+      number of function evaluations          42
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    3.3306691e-16
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    5.5511151e-17
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3611719e+02
+
+      final l2 norm of the residuals    2.7755576e-17
+
+      number of function evaluations          24
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5182701e-01
+
+      final l2 norm of the residuals    8.5698726e-12
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1168330e+00
+
+      final l2 norm of the residuals    2.7315309e-12
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2693089e+03
+
+      final l2 norm of the residuals    7.9371720e-14
+
+      number of function evaluations          48
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577157e-02 -1.1448571e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908998e-01 -1.5524954e-01 -1.2535589e-01 -7.5416534e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  8.4117534e-02
+
+      final l2 norm of the residuals    5.2963921e-03
+
+      number of function evaluations          60
+
+      number of jacobian evaluations           7
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.5261544e-02  5.6957555e-02  5.8890667e-02  6.1136063e-02  6.3778558e-02
+       6.7004825e-02  2.0794103e-01  1.6426711e-01  8.6439479e-02  9.1335063e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0305195e+01
+
+      final l2 norm of the residuals    5.9165753e-11
+
+      number of function evaluations          34
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.4396289e-02  3.5032316e-02  3.5719196e-02  3.6465224e-02  3.7280912e-02
+       3.8179863e-02  3.9180141e-02  4.0306503e-02  1.7972019e-01  1.5624088e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3369375e+01
+
+      final l2 norm of the residuals    1.5145216e-09
+
+      number of function evaluations          44
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8883952e+01  2.5167774e+01  1.8885275e+01  1.8886021e+01  1.8886837e+01
+       1.8887736e+01  1.8888736e+01  1.8889862e+01  1.9029276e+01  1.9005797e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  2.2402135e+06
+
+      final l2 norm of the residuals    5.3575313e-12
+
+      number of function evaluations          21
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  5.2234376e+07
+
+      final l2 norm of the residuals    2.4031356e-11
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  1.5923646e+11
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          37
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5825757e+00
+
+      final l2 norm of the residuals    1.4938794e-08
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3910093e+02
+
+      final l2 norm of the residuals    4.9607067e-09
+
+      number of function evaluations          49
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3337583e+04
+
+      final l2 norm of the residuals    9.8789030e-11
+
+      number of function evaluations          22
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072213e-01 -6.8180695e-01 -7.0221008e-01 -7.0551063e-01 -7.0490616e-01
+      -7.0149661e-01 -6.9188932e-01 -6.6579651e-01 -5.9603511e-01 -4.1641226e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8973666e+01
+
+      final l2 norm of the residuals    2.0579003e-09
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7130922e+04
+
+      final l2 norm of the residuals    7.9536129e-09
+
+      number of function evaluations          25
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.5949860e+07
+
+      final l2 norm of the residuals    4.5264308e-10
+
+      number of function evaluations          38
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2830286e-01 -4.7659642e-01 -5.1965246e-01 -5.5809932e-01 -5.9250616e-01
+      -6.2450368e-01 -6.2323947e-01 -6.2139384e-01 -6.2045360e-01 -5.8646927e-01
+
 summary of 55 calls to hybrj1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      7      1     1   0.0000000e+00
+   1     2      7      1     1   0.0000000e+00
+   2     4    107      5     4   1.5672781e-33
+   2     4    132      8     4   9.9748795e-34
+   2     4    148     11     4   1.1443109e-35
+   3     2    169      6     1   1.7126733e-09
+   3     2      9      1     1   3.7440617e-08
+   4     4     86      2     1   3.9845528e-11
+   4     4    202      8     1   3.7715808e-10
+   4     4    386     35     1   3.4730030e-11
+   5     3     18      3     1   2.7534405e-13
+   5     3     20      4     1   2.2509949e-10
+   5     3     37      8     1   7.2027771e-10
+   6     6     60      6     1   3.6849814e-13
+   6     6    140      6     1   7.2239834e-14
+   6     9     92      4     1   8.0147779e-12
+   6     9    310     13     4   3.8553032e-02
+   7     5     10      1     1   6.0450835e-13
+   7     5    135     25     1   2.9381451e-10
+   7     5    269     53     1   1.7411953e-10
+   7     6     13      2     1   1.4343386e-11
+   7     6     91     13     1   1.2227706e-10
+   7     6    169     21     1   6.2931742e-10
+   7     7     11      1     1   1.9360470e-10
+   7     7    330     49     1   1.3121086e-10
+   7     7     11      2     4   6.4143166e+16
+   7     8     56      8     4   6.4405122e-02
+   7     9     23      2     1   2.9424978e-10
+   8    10     11      2     1   1.9280838e-14
+   8    10     11      2     1   7.6605389e-15
+   8    10     14      2     1   8.3451559e-15
+   8    30     24      3     1   3.8278068e-14
+   8    40     12      2     1   3.6669811e-14
+   9    10      6      1     1   2.5155475e-15
+   9    10      9      1     1   1.7260578e-13
+   9    10     42      1     1   4.1776156e-10
+  10     1      6      1     1   3.3306691e-16
+  10     1      8      1     1   5.5511151e-17
+  10     1     24      2     1   2.7755576e-17
+  10    10      8      1     1   8.5698726e-12
+  10    10      9      1     1   2.7315309e-12
+  10    10     48      3     1   7.9371720e-14
+  11    10     60      7     4   5.2963921e-03
+  11    10     34      5     1   5.9165753e-11
+  11    10     44      4     1   1.5145216e-09
+  12    10     21      1     1   5.3575313e-12
+  12    10     25      1     1   2.4031356e-11
+  12    10     37      2     1   0.0000000e+00
+  13    10     11      1     1   1.4938794e-08
+  13    10     49      1     1   4.9607067e-09
+  13    10     22      2     1   9.8789030e-11
+  14    10     20      1     1   2.0579003e-09
+  14    10     25      2     1   7.9536129e-09
+  14    10     38      2     1   4.5264308e-10
diff --git a/examples/ref/libmdpdrc.ref b/examples/ref/libmdpdrc.ref
new file mode 100644
index 0000000..57a013e
--- /dev/null
+++ b/examples/ref/libmdpdrc.ref
@@ -0,0 +1,42 @@
+
 MACHAR constants
+
+
+ ibeta =     2
+
+ it    =    53
+
+ irnd  =     5
+
+ ngrd  =     0
+
+ machep =   -52
+
+ negep =   -53
+
+ iexp =    11
+
+ minexp = -1022
+
+ maxexp =  1024
+
+ eps =  2.2204460e-16
+
+ epsneg =  1.1102230e-16
+
+ xmin = 2.2250739e-308
+
+ xmax = 1.7976931e+308
+
+
+
+ DPMPAR constants and relative differences
+
+
+ epsmch =  2.2204460e-16
+ rerr(1) =  0.0000000e+00
+
+ dwarf = 2.2250739e-308
+ rerr(2) =  0.0000000e+00
+
+ giant = 1.7976931e+308
+ rerr(3) =  0.0000000e+00
diff --git a/examples/ref/llmddrvc.ref b/examples/ref/llmddrvc.ref
new file mode 100644
index 0000000..b669044
--- /dev/null
+++ b/examples/ref/llmddrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622577e+00
+
+      final l2 norm of the residuals    6.7082039e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152187e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.5206175e+02  7.6530877e+01 -2.0536805e+02  3.8765438e+01  3.1212351e+01
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016004e+03
+
+      final l2 norm of the residuals    3.4826302e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -6.1160193e+00 -2.5580097e+00  1.7684011e+02 -7.7900483e-01 -1.0322851e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603968e+02
+
+      final l2 norm of the residuals    1.9097274e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.1643152e+02  1.5463419e+02 -5.7715762e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917294e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0767127e+02  7.4450459e+01 -1.0966575e+02  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    9.9365231e-17
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -6.2433016e-18  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.0446789e-19
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  6.5639108e-21  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    3.1387778e-29
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -1.9721523e-30  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    9.5458248e-36
+
+      number of function evaluations          61
+
+      number of jacobian evaluations          60
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.0651470e-18 -2.0651470e-19  3.3042352e-19  3.3042352e-19
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    9.5458248e-34
+
+      number of function evaluations          61
+
+      number of jacobian evaluations          60
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.0651470e-17 -2.0651470e-18  3.3042352e-18  3.3042352e-18
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    3.7288378e-34
+
+      number of function evaluations          65
+
+      number of jacobian evaluations          64
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2907169e-17 -1.2907169e-18  2.0651470e-18  2.0651470e-18
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012496e+01
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412484e+01 -8.9682791e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413005e+01 -8.9679604e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412782e+01 -8.9680511e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561363e+00
+
+      final l2 norm of the residuals    9.0635960e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2410577e-02  1.1330367e+00  2.3436946e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141853e+01
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          37
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5884803e+08 -1.6437867e+08
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411468e+02
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5894617e+08 -1.6446491e+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891510e-02
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280781e-01  1.9126265e-01  1.2305280e-01  1.3605322e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2052193e-02
+
+      number of function evaluations          78
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+       7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959062e+01
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations         499
+
+      number of jacobian evaluations         378
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280785e-01  1.9126176e-01  1.2305263e-01  1.3605281e-01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153467e+04
+
+      final l2 norm of the residuals    9.3779451e+00
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           3
+
+      final approximate solution
+
+       5.6096365e-03  6.1813463e+03  3.4522363e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682169e+06
+
+      final l2 norm of the residuals    7.8216536e+02
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         345
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.6268603e-11  3.2511687e+04  8.8398921e+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724962e-02  1.0124349e+00 -2.3299172e-01  1.2604310e+00 -1.5137303e+00
+       9.9299727e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331258e+03
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725190e-02  1.0124349e+00 -2.3299155e-01  1.2604293e+00 -1.5137278e+00
+       9.9299573e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425604e+05
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724702e-02  1.0124349e+00 -2.3299192e-01  1.2604329e+00 -1.5137332e+00
+       9.9299902e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307133e-05  9.9978970e-01  1.4763963e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044031e+00 -3.1436122e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691093e+06
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           8
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6026609e-09  1.0000016e+00 -5.6393215e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472711e+00  7.2884348e+00 -1.0271848e+01  9.0741135e+00
+      -4.5413754e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220759e+04
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          12
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6371023e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          28
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.6380605e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585650e+01
+
+      final l2 norm of the residuals    1.1151779e+01
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5781993e-01  2.5782998e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154384e+03
+
+      final l2 norm of the residuals    2.9295429e+02
+
+      number of function evaluations         254
+
+      number of jacobian evaluations         236
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1591263e+01  1.3202492e+01 -4.0357420e-01  2.3673639e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507335e+05
+
+      final l2 norm of the residuals    2.9295427e+02
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1595927e+01  1.3204187e+01 -4.0341736e-01  2.3677114e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211252e+07
+
+      final l2 norm of the residuals    2.9295431e+02
+
+      number of function evaluations         237
+
+      number of jacobian evaluations         221
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1590260e+01  1.3202063e+01 -4.0368994e-01  2.3666374e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862380e+00
+
+      final l2 norm of the residuals    1.8862380e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833444e+09
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9303236e-02
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.3153665e-02  1.9309164e-01  2.6632859e-01  4.9999933e-01  5.0000067e-01
+       7.3367141e-01  8.0690836e-01  9.5684634e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    2.4716937e-16
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647100e-02
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9620267e-02  1.6670878e-01  2.3917102e-01  3.9888529e-01  3.9888367e-01
+       6.0111633e-01  6.0111471e-01  7.6082898e-01  8.3329122e-01  9.4037973e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.4043334e-15
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    1.5655719e-14
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          33
+
+      number of jacobian evaluations          31
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.2018260e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  1.0673735e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    2.3920028e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756402e-01
+
+      final l2 norm of the residuals    7.3924926e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541005e-01  1.9358465e+00 -1.4646868e+00  1.2867534e-02  2.2122701e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468654e+00
+
+      final l2 norm of the residuals    2.0034404e-01
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099766e+00  4.3155248e-01  6.3366126e-01  5.9942856e-01  7.5417977e-01
+       9.0430008e-01  1.3657995e+00  4.8237320e+00  2.3986848e+00  4.5688755e+00
+       5.6753421e+00
+
 summary of 53 calls to lmder1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     3   2.2360680e+00
+    1    5   50     3     2     2   6.7082039e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     3     2     1   3.4826302e+00
+    3    5   10     3     2     1   1.9097274e+00
+    3    5   50     3     2     1   3.6917294e+00
+    4    2    2    21    16     4   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2     6     4     2   0.0000000e+00
+    5    3    3    11     8     2   9.9365231e-17
+    5    3    3    20    15     2   1.0446789e-19
+    5    3    3    19    16     2   3.1387778e-29
+    6    4    4    61    60     4   9.5458248e-36
+    6    4    4    61    60     4   9.5458248e-34
+    6    4    4    65    64     4   3.7288378e-34
+    7    2    2    14     8     1   6.9988752e+00
+    7    2    2    19    12     1   6.9988752e+00
+    7    2    2    24    17     1   6.9988752e+00
+    8    3   15     6     5     1   9.0635960e-02
+    8    3   15    37    36     1   4.1747687e+00
+    8    3   15    14    13     1   4.1747687e+00
+    9    4   11    18    16     1   1.7535838e-02
+    9    4   11    78    70     1   3.2052193e-02
+    9    4   11   499   378     1   1.7535838e-02
+   10    3   16   126   116     3   9.3779451e+00
+   10    3   16   400   345     5   7.8216536e+02
+   11    6   31     8     7     1   4.7829594e-02
+   11    6   31    14    13     1   4.7829594e-02
+   11    6   31    15    14     1   4.7829594e-02
+   11    9   31     8     7     2   1.1831146e-03
+   11    9   31    19    15     1   1.1831146e-03
+   11    9   31    19    16     3   1.1831146e-03
+   11   12   31     9     8     3   2.1731040e-05
+   11   12   31    13    12     3   2.1731040e-05
+   11   12   31    34    28     2   2.1731040e-05
+   12    3   10     7     6     2   0.0000000e+00
+   13    2   10    21    12     1   1.1151779e+01
+   14    4   20   254   236     1   2.9295429e+02
+   14    4   20    53    42     1   2.9295427e+02
+   14    4   20   237   221     1   2.9295431e+02
+   15    1    8     1     1     4   1.8862380e+00
+   15    1    8    29    28     1   1.8842482e+00
+   15    1    8    47    46     1   1.8842482e+00
+   15    8    8    39    20     1   5.9303236e-02
+   15    9    9    12     9     2   2.4716937e-16
+   15   10   10    25    12     1   8.0647100e-02
+   16   10   10    14    12     2   1.4043334e-15
+   16   10   10    13     8     2   1.5655719e-14
+   16   10   10    33    31     2   0.0000000e+00
+   16   30   30    19    14     2   1.2018260e-13
+   16   40   40    19    14     2   2.3920028e-13
+   17    5   33    18    15     1   7.3924926e-03
+   18   11   65    16    12     1   2.0034404e-01
diff --git a/examples/ref/llmfdrvc.ref b/examples/ref/llmfdrvc.ref
new file mode 100644
index 0000000..a5f6444
--- /dev/null
+++ b/examples/ref/llmfdrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.9999996e-01 -9.9999996e-01 -9.9999996e-01 -9.9999996e-01 -1.0000000e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622577e+00
+
+      final l2 norm of the residuals    6.7082039e+00
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.0000002e+00 -1.0000002e+00 -1.0000002e+00 -1.0000002e+00 -1.0000002e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152187e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.5206175e+02  7.6530877e+01 -2.0536805e+02  3.8765438e+01  3.1212351e+01
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016004e+03
+
+      final l2 norm of the residuals    3.4826302e+00
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -6.1160193e+00 -2.5580097e+00  1.7684011e+02 -7.7900483e-01 -1.0322851e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603968e+02
+
+      final l2 norm of the residuals    1.9097274e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.1643152e+02  1.5463419e+02 -5.7715762e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917294e+00
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0767127e+02  7.4450459e+01 -1.0966575e+02  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    1.1102230e-15
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    1.3617202e-16
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  8.5559402e-18  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    7.2719545e-18
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  4.5691038e-19  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    9.9455596e-23
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  6.2489794e-24  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    2.1508559e-20
+
+      number of function evaluations         240
+
+      number of Jacobian evaluations         190
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.2374861e-10 -1.2374861e-11  5.8690829e-11  5.8690829e-11
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    2.1587117e-21
+
+      number of function evaluations         240
+
+      number of Jacobian evaluations         191
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.7162766e-11 -3.7162766e-12  1.1875139e-11  1.1875139e-11
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    7.8811902e-21
+
+      number of function evaluations         237
+
+      number of Jacobian evaluations         191
+
+      exit parameter                           5
+
+      final approximate solution
+
+       7.4954967e-11 -7.4954967e-12  3.5439603e-11  3.5439603e-11
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012496e+01
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412484e+01 -8.9682792e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413005e+01 -8.9679604e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          24
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412782e+01 -8.9680511e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561363e+00
+
+      final l2 norm of the residuals    9.0635960e-02
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2410576e-02  1.1330366e+00  2.3436947e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141853e+01
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          38
+
+      number of Jacobian evaluations          37
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.0828205e+08 -1.0919876e+08
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411468e+02
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.6764232e+08 -1.7528864e+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891510e-02
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280781e-01  1.9126257e-01  1.2305279e-01  1.3605318e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2052194e-02
+
+      number of function evaluations          79
+
+      number of Jacobian evaluations          71
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099593e+05 -1.4075863e+01 -5.9284996e+06 -3.6982058e+06
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959062e+01
+
+      final l2 norm of the residuals    3.0707862e-02
+
+      number of function evaluations         229
+
+      number of Jacobian evaluations         193
+
+      exit parameter                           5
+
+      final approximate solution
+
+       4.0685435e-03  5.8260892e+02  7.2743530e+00  4.9135616e+00
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153467e+04
+
+      final l2 norm of the residuals    9.3779451e+00
+
+      number of function evaluations         126
+
+      number of Jacobian evaluations         116
+
+      exit parameter                           2
+
+      final approximate solution
+
+       5.6096369e-03  6.1813463e+03  3.4522363e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682169e+06
+
+      final l2 norm of the residuals    6.2375992e+04
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.3823520e+00 -3.6636342e+03 -2.2573583e+01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    5.1046620e-02
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.4493719e-24  1.0136384e+00 -2.4430321e-01  1.3737702e+00 -1.6856387e+00
+       1.0980967e+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331258e+03
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725255e-02  1.0124349e+00 -2.3299163e-01  1.2604292e+00 -1.5137275e+00
+       9.9299547e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425604e+05
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724723e-02  1.0124349e+00 -2.3299193e-01  1.2604328e+00 -1.5137331e+00
+       9.9299891e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    1.1832136e-03
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.3681377e-22  9.9978965e-01  1.4782171e-02  1.4630835e-01  1.0010048e+00
+      -2.6181923e+00  4.1050775e+00 -3.1441177e+00  1.0527879e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          26
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5290606e-05  9.9978963e-01  1.4766904e-02  1.4631540e-01  1.0009311e+00
+      -2.6179665e+00  4.1046775e+00 -3.1437774e+00  1.0526666e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691093e+06
+
+      final l2 norm of the residuals    1.1831150e-03
+
+      number of function evaluations          24
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.4332188e-05  9.9978970e-01  1.4765451e-02  1.4633609e-01  1.0008520e+00
+      -2.6178053e+00  4.1045015e+00 -3.1436793e+00  1.0526454e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    2.1731280e-05
+
+      number of function evaluations          21
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       2.0133365e-23  1.0000016e+00 -5.6206518e-04  3.4777121e-01 -1.5622938e-01
+       1.0501348e+00 -3.2388104e+00  7.2717967e+00 -1.0251227e+01  9.0584445e+00
+      -4.5347064e+00  1.0107940e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220759e+04
+
+      final l2 norm of the residuals    2.1733081e-05
+
+      number of function evaluations          27
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.2918209e-07  1.0000015e+00 -5.5361077e-04  3.4766251e-01 -1.5556428e-01
+       1.0478688e+00 -3.2342222e+00  7.2662586e+00 -1.0247529e+01  9.0574745e+00
+      -4.5349128e+00  1.0109234e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    2.1731909e-05
+
+      number of function evaluations          48
+
+      number of Jacobian evaluations          33
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.3907483e-08  1.0000018e+00 -5.7119520e-04  3.4792363e-01 -1.5745791e-01
+       1.0558189e+00 -3.2551293e+00  7.3018361e+00 -1.0286723e+01  9.0844775e+00
+      -4.5454923e+00  1.0127231e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    1.8410966e-16
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585650e+01
+
+      final l2 norm of the residuals    1.1151779e+01
+
+      number of function evaluations          21
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5781993e-01  2.5782998e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154384e+03
+
+      final l2 norm of the residuals    2.9295677e+02
+
+      number of function evaluations         212
+
+      number of Jacobian evaluations         198
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.1562190e+01  1.3192071e+01 -3.9973104e-01  2.4106731e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507335e+05
+
+      final l2 norm of the residuals    2.9295427e+02
+
+      number of function evaluations          47
+
+      number of Jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1595744e+01  1.3204118e+01 -4.0344625e-01  2.3675342e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211252e+07
+
+      final l2 norm of the residuals    2.9295443e+02
+
+      number of function evaluations         212
+
+      number of Jacobian evaluations         197
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.1586046e+01  1.3200484e+01 -4.0299712e-01  2.3719713e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862380e+00
+
+      final l2 norm of the residuals    1.8862380e+00
+
+      number of function evaluations           2
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.0000001e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833444e+09
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          29
+
+      number of Jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          47
+
+      number of Jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9303236e-02
+
+      number of function evaluations          39
+
+      number of Jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.3153667e-02  1.9309164e-01  2.6632860e-01  4.9999934e-01  5.0000067e-01
+       7.3367141e-01  8.0690837e-01  9.5684634e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    2.0176409e-16
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647100e-02
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9620272e-02  1.6670879e-01  2.3917103e-01  3.9888530e-01  3.9888367e-01
+       6.0111634e-01  6.0111472e-01  7.6082899e-01  8.3329123e-01  9.4037974e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.4691286e-02 -5.4691286e-02 -5.4691286e-02 -5.4691286e-02 -5.4691286e-02
+      -5.4691286e-02 -5.4691286e-02 -5.4691286e-02 -5.4691286e-02  1.1546913e+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    3.3306691e-16
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    4.7687924e-15
+
+      number of function evaluations          37
+
+      number of Jacobian evaluations          35
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    2.3920048e-13
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756402e-01
+
+      final l2 norm of the residuals    7.3924926e-03
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541007e-01  1.9358485e+00 -1.4646887e+00  1.2867538e-02  2.2122693e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468654e+00
+
+      final l2 norm of the residuals    2.0034404e-01
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099766e+00  4.3155248e-01  6.3366126e-01  5.9942856e-01  7.5417977e-01
+       9.0430007e-01  1.3657995e+00  4.8237320e+00  2.3986848e+00  4.5688755e+00
+       5.6753421e+00
+
 summary of 53 calls to lmdif1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     1   2.2360680e+00
+    1    5   50     4     3     1   6.7082039e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     5     2     1   3.4826302e+00
+    3    5   10     3     2     1   1.9097274e+00
+    3    5   50     4     2     1   3.6917294e+00
+    4    2    2    22    16     2   0.0000000e+00
+    4    2    2     8     5     2   1.1102230e-15
+    4    2    2     7     5     2   0.0000000e+00
+    5    3    3    11     8     2   1.3617202e-16
+    5    3    3    20    15     2   7.2719545e-18
+    5    3    3    19    16     2   9.9455596e-23
+    6    4    4   240   190     5   2.1508559e-20
+    6    4    4   240   191     5   2.1587117e-21
+    6    4    4   237   191     5   7.8811902e-21
+    7    2    2    14     8     1   6.9988752e+00
+    7    2    2    19    12     1   6.9988752e+00
+    7    2    2    24    17     1   6.9988752e+00
+    8    3   15     6     5     1   9.0635960e-02
+    8    3   15    38    37     1   4.1747687e+00
+    8    3   15    13    12     1   4.1747687e+00
+    9    4   11    18    16     1   1.7535838e-02
+    9    4   11    79    71     1   3.2052194e-02
+    9    4   11   229   193     5   3.0707862e-02
+   10    3   16   126   116     2   9.3779451e+00
+   10    3   16     4     3     4   6.2375992e+04
+   11    6   31     8     7     1   5.1046620e-02
+   11    6   31    14    13     1   4.7829594e-02
+   11    6   31    15    14     1   4.7829594e-02
+   11    9   31     7     6     1   1.1832136e-03
+   11    9   31    26    15     2   1.1831146e-03
+   11    9   31    24    17     2   1.1831150e-03
+   11   12   31    21     9     2   2.1731280e-05
+   11   12   31    27    13     2   2.1733081e-05
+   11   12   31    48    33     2   2.1731909e-05
+   12    3   10     7     6     2   1.8410966e-16
+   13    2   10    21    12     1   1.1151779e+01
+   14    4   20   212   198     5   2.9295677e+02
+   14    4   20    47    36     1   2.9295427e+02
+   14    4   20   212   197     5   2.9295443e+02
+   15    1    8     2     1     1   1.8862380e+00
+   15    1    8    29    28     1   1.8842482e+00
+   15    1    8    47    46     1   1.8842482e+00
+   15    8    8    39    20     1   5.9303236e-02
+   15    9    9    12     9     2   2.0176409e-16
+   15   10   10    25    12     1   8.0647100e-02
+   16   10   10     7     5     1   1.0000000e+00
+   16   10   10    13     8     2   3.3306691e-16
+   16   10   10    37    35     2   4.7687924e-15
+   16   30   30    11    10     2   0.0000000e+00
+   16   40   40    11    10     2   2.3920048e-13
+   17    5   33    18    15     1   7.3924926e-03
+   18   11   65    16    12     1   2.0034404e-01
diff --git a/examples/ref/llmsdrvc.ref b/examples/ref/llmsdrvc.ref
new file mode 100644
index 0000000..c46ba34
--- /dev/null
+++ b/examples/ref/llmsdrvc.ref
@@ -0,0 +1,1148 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622577e+00
+
+      final l2 norm of the residuals    6.7082039e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152187e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5870517e+02 -1.5729225e+01  1.3072979e+02 -7.3646127e+00 -1.1796696e+02
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016004e+03
+
+      final l2 norm of the residuals    3.4826302e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.0599798e+01  7.6675815e+01  8.4636891e+01  3.8837907e+01 -1.3063681e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603968e+02
+
+      final l2 norm of the residuals    1.9097274e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  5.7248808e+02 -2.7281786e+02 -8.1586533e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917294e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.4537178e+02  1.4389437e+02 -3.5227154e+01  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    9.9365244e-17
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -6.2433024e-18  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.0446789e-19
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  6.5639108e-21  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    3.1387778e-29
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -1.9721523e-30  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    6.1093279e-34
+
+      number of function evaluations          58
+
+      number of jacobian evaluations          57
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6521176e-17 -1.6521176e-18  2.6433882e-18  2.6433882e-18
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    9.5458248e-34
+
+      number of function evaluations          61
+
+      number of jacobian evaluations          60
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.0651470e-17 -2.0651470e-18  3.3042352e-18  3.3042352e-18
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    3.7288378e-34
+
+      number of function evaluations          65
+
+      number of jacobian evaluations          64
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2907169e-17 -1.2907169e-18  2.0651470e-18  2.0651470e-18
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012496e+01
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412484e+01 -8.9682791e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413005e+01 -8.9679604e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412782e+01 -8.9680511e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561363e+00
+
+      final l2 norm of the residuals    9.0635960e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2410577e-02  1.1330367e+00  2.3436946e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141853e+01
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          37
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5884803e+08 -1.6437867e+08
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411468e+02
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5894617e+08 -1.6446491e+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891510e-02
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280781e-01  1.9126265e-01  1.2305280e-01  1.3605322e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2052193e-02
+
+      number of function evaluations          78
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+       7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959062e+01
+
+      final l2 norm of the residuals    1.7535940e-02
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         376
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.9286773e-01  1.8990725e-01  1.2279431e-01  1.3542725e-01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153467e+04
+
+      final l2 norm of the residuals    9.3779451e+00
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           2
+
+      final approximate solution
+
+       5.6096365e-03  6.1813463e+03  3.4522363e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682169e+06
+
+      final l2 norm of the residuals    7.8927743e+02
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         345
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.7557093e-11  3.3287943e+04  8.9534987e+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724962e-02  1.0124349e+00 -2.3299172e-01  1.2604310e+00 -1.5137303e+00
+       9.9299727e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331258e+03
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725190e-02  1.0124349e+00 -2.3299155e-01  1.2604293e+00 -1.5137278e+00
+       9.9299573e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425604e+05
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724702e-02  1.0124349e+00 -2.3299192e-01  1.2604329e+00 -1.5137332e+00
+       9.9299902e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307133e-05  9.9978970e-01  1.4763963e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044031e+00 -3.1436122e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691093e+06
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           8
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6026605e-09  1.0000016e+00 -5.6393215e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472711e+00  7.2884348e+00 -1.0271848e+01  9.0741135e+00
+      -4.5413754e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220759e+04
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.6380605e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          28
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.6380605e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585650e+01
+
+      final l2 norm of the residuals    1.1151779e+01
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5781993e-01  2.5782998e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154384e+03
+
+      final l2 norm of the residuals    2.9295429e+02
+
+      number of function evaluations         254
+
+      number of jacobian evaluations         236
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1591248e+01  1.3202487e+01 -4.0357478e-01  2.3673623e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507335e+05
+
+      final l2 norm of the residuals    2.9295427e+02
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1595927e+01  1.3204187e+01 -4.0341736e-01  2.3677114e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211252e+07
+
+      final l2 norm of the residuals    2.9295430e+02
+
+      number of function evaluations         240
+
+      number of jacobian evaluations         224
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1590584e+01  1.3202187e+01 -4.0365220e-01  2.3668541e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862380e+00
+
+      final l2 norm of the residuals    1.8862380e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833444e+09
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9303236e-02
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.3153665e-02  1.9309164e-01  2.6632859e-01  4.9999933e-01  5.0000067e-01
+       7.3367141e-01  8.0690836e-01  9.5684634e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    1.6583999e-16
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647100e-02
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9620267e-02  1.6670878e-01  2.3917102e-01  3.9888529e-01  3.9888367e-01
+       6.0111633e-01  6.0111471e-01  7.6082898e-01  8.3329122e-01  9.4037973e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    7.0023307e-15
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    1.5321480e-14
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    4.3426612e-15
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          26
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    2.0332546e-14
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  1.0673735e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    2.0730691e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756402e-01
+
+      final l2 norm of the residuals    7.3924926e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541005e-01  1.9358465e+00 -1.4646868e+00  1.2867534e-02  2.2122701e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468654e+00
+
+      final l2 norm of the residuals    2.0034404e-01
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099766e+00  4.3155248e-01  6.3366126e-01  5.9942856e-01  7.5417977e-01
+       9.0430008e-01  1.3657995e+00  4.8237320e+00  2.3986848e+00  4.5688755e+00
+       5.6753421e+00
+
 summary of 53 calls to lmstr1
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     2   2.2360680e+00
+    1    5   50     3     2     3   6.7082039e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     3     2     1   3.4826302e+00
+    3    5   10     3     2     1   1.9097274e+00
+    3    5   50     3     2     1   3.6917294e+00
+    4    2    2    21    16     4   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2     6     4     2   0.0000000e+00
+    5    3    3    11     8     2   9.9365244e-17
+    5    3    3    20    15     2   1.0446789e-19
+    5    3    3    19    16     2   3.1387778e-29
+    6    4    4    58    57     4   6.1093279e-34
+    6    4    4    61    60     4   9.5458248e-34
+    6    4    4    65    64     4   3.7288378e-34
+    7    2    2    14     8     1   6.9988752e+00
+    7    2    2    19    12     1   6.9988752e+00
+    7    2    2    24    17     1   6.9988752e+00
+    8    3   15     6     5     1   9.0635960e-02
+    8    3   15    37    36     1   4.1747687e+00
+    8    3   15    14    13     1   4.1747687e+00
+    9    4   11    18    16     1   1.7535838e-02
+    9    4   11    78    70     1   3.2052193e-02
+    9    4   11   500   376     5   1.7535940e-02
+   10    3   16   126   116     2   9.3779451e+00
+   10    3   16   400   345     5   7.8927743e+02
+   11    6   31     8     7     1   4.7829594e-02
+   11    6   31    14    13     1   4.7829594e-02
+   11    6   31    15    14     1   4.7829594e-02
+   11    9   31     8     7     2   1.1831146e-03
+   11    9   31    19    15     1   1.1831146e-03
+   11    9   31    19    16     3   1.1831146e-03
+   11   12   31     9     8     3   2.1731040e-05
+   11   12   31    13    12     2   2.1731040e-05
+   11   12   31    34    28     2   2.1731040e-05
+   12    3   10     7     6     2   0.0000000e+00
+   13    2   10    21    12     1   1.1151779e+01
+   14    4   20   254   236     1   2.9295429e+02
+   14    4   20    53    42     1   2.9295427e+02
+   14    4   20   240   224     1   2.9295430e+02
+   15    1    8     1     1     4   1.8862380e+00
+   15    1    8    29    28     1   1.8842482e+00
+   15    1    8    47    46     1   1.8842482e+00
+   15    8    8    39    20     1   5.9303236e-02
+   15    9    9    12     9     2   1.6583999e-16
+   15   10   10    25    12     1   8.0647100e-02
+   16   10   10    14    12     2   7.0023307e-15
+   16   10   10    13     8     2   1.5321480e-14
+   16   10   10    29    26     2   4.3426612e-15
+   16   30   30    19    14     2   2.0332546e-14
+   16   40   40    19    14     2   2.0730691e-13
+   17    5   33    18    15     1   7.3924926e-03
+   18   11   65    16    12     1   2.0034404e-01
diff --git a/examples/ref/lmddrv.ref b/examples/ref/lmddrv.ref
new file mode 100644
index 0000000..3047aa9
--- /dev/null
+++ b/examples/ref/lmddrv.ref
@@ -0,0 +1,1149 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.5000000D+01
+
+      final l2 norm of the residuals    0.2236068D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.8062258D+01
+
+      final l2 norm of the residuals    0.6708204D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.2915219D+03
+
+      final l2 norm of the residuals    0.1463850D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1677968D+03 -0.8339841D+02  0.2211100D+03 -0.4119920D+02 -0.3275936D+02
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.3101600D+04
+
+      final l2 norm of the residuals    0.3482630D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.2030000D+02 -0.9650000D+01 -0.1652452D+03 -0.4325000D+01  0.1105331D+03
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.1260397D+03
+
+      final l2 norm of the residuals    0.1909727D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01 -0.2103615D+03  0.3212042D+02  0.8113457D+02  0.1000000D+01
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.1748950D+04
+
+      final l2 norm of the residuals    0.3691729D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.3321495D+03 -0.4396852D+03  0.1636969D+03  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.4919350D+01
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1340063D+04
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1430001D+06
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.5000000D+02
+
+      final l2 norm of the residuals    0.9936523D-16
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01 -0.6243302D-17  0.0000000D+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.1029563D+03
+
+      final l2 norm of the residuals    0.1044679D-18
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.6563911D-20  0.0000000D+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.9912618D+03
+
+      final l2 norm of the residuals    0.3138778D-28
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01 -0.1972152D-29  0.0000000D+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1466288D+02
+
+      final l2 norm of the residuals    0.6109328D-33
+
+      number of function evaluations          59
+
+      number of jacobian evaluations          58
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1652118D-16 -0.1652118D-17  0.2643388D-17  0.2643388D-17
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1270984D+04
+
+      final l2 norm of the residuals    0.9103608D-39
+
+      number of function evaluations          72
+
+      number of jacobian evaluations          71
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.2016745D-19 -0.2016745D-20  0.3226792D-20  0.3226792D-20
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1268879D+06
+
+      final l2 norm of the residuals    0.2330524D-34
+
+      number of function evaluations          68
+
+      number of jacobian evaluations          67
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.3226792D-17 -0.3226792D-18  0.5162867D-18  0.5162867D-18
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.2001250D+02
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141248D+02 -0.8968279D+00
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1243283D+05
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141300D+02 -0.8967960D+00
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1142645D+08
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141278D+02 -0.8968051D+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.6456136D+01
+
+      final l2 norm of the residuals    0.9063596D-01
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.3614185D+02
+
+      final l2 norm of the residuals    0.4174769D+01
+
+      number of function evaluations          37
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8406667D+00 -0.1588480D+09 -0.1643787D+09
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.3841147D+03
+
+      final l2 norm of the residuals    0.4174769D+01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8406667D+00 -0.1589462D+09 -0.1644649D+09
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.7289151D-01
+
+      final l2 norm of the residuals    0.1753584D-01
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1928078D+00  0.1912627D+00  0.1230528D+00  0.1360532D+00
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.2979370D+01
+
+      final l2 norm of the residuals    0.3205219D-01
+
+      number of function evaluations          78
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.7286755D+06 -0.1407588D+02 -0.3297780D+08 -0.2057159D+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.2995906D+02
+
+      final l2 norm of the residuals    0.1753584D-01
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         380
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.1927984D+00  0.1914737D+00  0.1230925D+00  0.1361510D+00
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  0.4115347D+05
+
+      final l2 norm of the residuals    0.9377945D+01
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.5609636D-02  0.6181346D+04  0.3452236D+03
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  0.4168217D+07
+
+      final l2 norm of the residuals    0.7946453D+03
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         346
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.1287545D-10  0.3389213D+05  0.9041072D+03
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572496D-01  0.1012435D+01 -0.2329917D+00  0.1260431D+01 -0.1513730D+01
+       0.9929973D+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.6433126D+04
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572519D-01  0.1012435D+01 -0.2329915D+00  0.1260429D+01 -0.1513728D+01
+       0.9929957D+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.6742560D+06
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572470D-01  0.1012435D+01 -0.2329919D+00  0.1260433D+01 -0.1513733D+01
+       0.9929990D+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1530706D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.1208813D+05
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1530713D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.1269109D+07
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1530704D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.2173104D-04
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           9
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.6638060D-08  0.1000002D+01 -0.5639322D-03  0.3478205D+00 -0.1567315D+00
+       0.1052815D+01 -0.3247271D+01  0.7288435D+01 -0.1027185D+02  0.9074114D+01
+      -0.4541375D+01  0.1012012D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.1922076D+05
+
+      final l2 norm of the residuals    0.2173104D-04
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          12
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.6637102D-08  0.1000002D+01 -0.5639322D-03  0.3478205D+00 -0.1567315D+00
+       0.1052815D+01 -0.3247271D+01  0.7288435D+01 -0.1027185D+02  0.9074114D+01
+      -0.4541375D+01  0.1012012D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.2018918D+07
+
+      final l2 norm of the residuals    0.2173104D-04
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          28
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.6638060D-08  0.1000002D+01 -0.5639322D-03  0.3478205D+00 -0.1567315D+00
+       0.1052815D+01 -0.3247271D+01  0.7288435D+01 -0.1027185D+02  0.9074114D+01
+      -0.4541375D+01  0.1012012D+01
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  0.3211158D+02
+
+      final l2 norm of the residuals    0.2419675D-15
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+02  0.1000000D+01
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  0.6458565D+02
+
+      final l2 norm of the residuals    0.1115178D+02
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.2578199D+00  0.2578300D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.2815438D+04
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations         254
+
+      number of jacobian evaluations         236
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159126D+02  0.1320249D+02 -0.4035744D+00  0.2367363D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.5550734D+06
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159593D+02  0.1320419D+02 -0.4034174D+00  0.2367711D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.6121125D+08
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations         237
+
+      number of jacobian evaluations         221
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159026D+02  0.1320206D+02 -0.4036878D+00  0.2366652D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.1886238D+01
+
+      final l2 norm of the residuals    0.1886238D+01
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.5000000D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.5383344D+10
+
+      final l2 norm of the residuals    0.1884248D+01
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9817315D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.1180887D+19
+
+      final l2 norm of the residuals    0.1884248D+01
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9817315D+00
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  0.1965139D+00
+
+      final l2 norm of the residuals    0.5930324D-01
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.4315366D-01  0.1930916D+00  0.2663286D+00  0.4999993D+00  0.5000007D+00
+       0.7336714D+00  0.8069084D+00  0.9568463D+00
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  0.1699499D+00
+
+      final l2 norm of the residuals    0.1760084D-15
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.4420535D-01  0.1994907D+00  0.2356191D+00  0.4160469D+00  0.5000000D+00
+       0.5839531D+00  0.7643809D+00  0.8005093D+00  0.9557947D+00
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.1837478D+00
+
+      final l2 norm of the residuals    0.8064710D-01
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5962027D-01  0.1667088D+00  0.2391710D+00  0.3988853D+00  0.3988837D+00
+       0.6011163D+00  0.6011147D+00  0.7608290D+00  0.8332912D+00  0.9403797D+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.1653022D+02
+
+      final l2 norm of the residuals    0.8662586D-14
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.9765624D+07
+
+      final l2 norm of the residuals    0.5000936D-14
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.9765625D+17
+
+      final l2 norm of the residuals    0.5329071D-14
+
+      number of function evaluations          22
+
+      number of jacobian evaluations          20
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  0.8347604D+02
+
+      final l2 norm of the residuals    0.1482786D-12
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.1067374D+01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  0.1280264D+03
+
+      final l2 norm of the residuals    0.2024535D-12
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  0.9375640D+00
+
+      final l2 norm of the residuals    0.7392493D-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3754100D+00  0.1935847D+01 -0.1464687D+01  0.1286753D-01  0.2212270D-01
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  0.1446865D+01
+
+      final l2 norm of the residuals    0.2003440D+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1309977D+01  0.4315525D+00  0.6336613D+00  0.5994286D+00  0.7541798D+00
+       0.9043001D+00  0.1365799D+01  0.4823732D+01  0.2398685D+01  0.4568876D+01
+       0.5675342D+01
+1summary of  53 calls to lmder1
+
+ nprob   n    m   nfev  njev  info  final l2 norm
+
+    1    5   10     3     2     3   0.2236068D+01
+    1    5   50     3     2     3   0.6708204D+01
+    2    5   10     3     2     1   0.1463850D+01
+    2    5   50     3     2     1   0.3482630D+01
+    3    5   10     3     2     1   0.1909727D+01
+    3    5   50     3     2     1   0.3691729D+01
+    4    2    2    21    16     4   0.0000000D+00
+    4    2    2     8     5     2   0.0000000D+00
+    4    2    2     6     4     2   0.0000000D+00
+    5    3    3    11     8     2   0.9936523D-16
+    5    3    3    20    15     2   0.1044679D-18
+    5    3    3    19    16     2   0.3138778D-28
+    6    4    4    59    58     4   0.6109328D-33
+    6    4    4    72    71     4   0.9103608D-39
+    6    4    4    68    67     4   0.2330524D-34
+    7    2    2    14     8     1   0.6998875D+01
+    7    2    2    19    12     1   0.6998875D+01
+    7    2    2    24    17     1   0.6998875D+01
+    8    3   15     6     5     1   0.9063596D-01
+    8    3   15    37    36     1   0.4174769D+01
+    8    3   15    14    13     1   0.4174769D+01
+    9    4   11    18    16     1   0.1753584D-01
+    9    4   11    78    70     1   0.3205219D-01
+    9    4   11   500   380     5   0.1753584D-01
+   10    3   16   126   116     2   0.9377945D+01
+   10    3   16   400   346     5   0.7946453D+03
+   11    6   31     8     7     1   0.4782959D-01
+   11    6   31    14    13     1   0.4782959D-01
+   11    6   31    15    14     1   0.4782959D-01
+   11    9   31     8     7     3   0.1183115D-02
+   11    9   31    19    15     1   0.1183115D-02
+   11    9   31    19    16     3   0.1183115D-02
+   11   12   31    10     9     3   0.2173104D-04
+   11   12   31    13    12     3   0.2173104D-04
+   11   12   31    34    28     2   0.2173104D-04
+   12    3   10     7     6     2   0.2419675D-15
+   13    2   10    21    12     1   0.1115178D+02
+   14    4   20   254   236     1   0.2929543D+03
+   14    4   20    53    42     1   0.2929543D+03
+   14    4   20   237   221     1   0.2929543D+03
+   15    1    8     1     1     4   0.1886238D+01
+   15    1    8    29    28     1   0.1884248D+01
+   15    1    8    47    46     1   0.1884248D+01
+   15    8    8    39    20     1   0.5930324D-01
+   15    9    9    12     9     2   0.1760084D-15
+   15   10   10    25    12     1   0.8064710D-01
+   16   10   10    14    12     2   0.8662586D-14
+   16   10   10    13     8     2   0.5000936D-14
+   16   10   10    22    20     2   0.5329071D-14
+   16   30   30    19    14     2   0.1482786D-12
+   16   40   40    19    14     2   0.2024535D-12
+   17    5   33    18    15     1   0.7392493D-02
+   18   11   65    16    12     1   0.2003440D+00
diff --git a/examples/ref/lmddrvc.ref b/examples/ref/lmddrvc.ref
new file mode 100644
index 0000000..5ed4bb8
--- /dev/null
+++ b/examples/ref/lmddrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622577e+00
+
+      final l2 norm of the residuals    6.7082039e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152187e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.6779682e+02 -8.3398409e+01  2.2111004e+02 -4.1199205e+01 -3.2759364e+01
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016004e+03
+
+      final l2 norm of the residuals    3.4826302e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.0299999e+01 -9.6499995e+00 -1.6524520e+02 -4.3249998e+00  1.1053306e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603968e+02
+
+      final l2 norm of the residuals    1.9097274e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -2.1036153e+02  3.2120421e+01  8.1134568e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917294e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  3.3214949e+02 -4.3968519e+02  1.6369688e+02  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    9.9365231e-17
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -6.2433016e-18  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.0446789e-19
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  6.5639108e-21  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    3.1387778e-29
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -1.9721523e-30  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    6.1093279e-34
+
+      number of function evaluations          59
+
+      number of jacobian evaluations          58
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6521176e-17 -1.6521176e-18  2.6433882e-18  2.6433882e-18
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    9.1036079e-40
+
+      number of function evaluations          72
+
+      number of jacobian evaluations          71
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.0167451e-20 -2.0167451e-21  3.2267922e-21  3.2267922e-21
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    2.3305236e-35
+
+      number of function evaluations          68
+
+      number of jacobian evaluations          67
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.2267922e-18 -3.2267922e-19  5.1628675e-19  5.1628675e-19
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012496e+01
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412484e+01 -8.9682791e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413005e+01 -8.9679604e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412782e+01 -8.9680511e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561363e+00
+
+      final l2 norm of the residuals    9.0635960e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2410577e-02  1.1330367e+00  2.3436946e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141853e+01
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          37
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5884803e+08 -1.6437867e+08
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411468e+02
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5894617e+08 -1.6446491e+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891510e-02
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280781e-01  1.9126265e-01  1.2305280e-01  1.3605322e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2052193e-02
+
+      number of function evaluations          78
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+       7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959062e+01
+
+      final l2 norm of the residuals    1.7535840e-02
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         380
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.9279841e-01  1.9147368e-01  1.2309248e-01  1.3615096e-01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153467e+04
+
+      final l2 norm of the residuals    9.3779451e+00
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           2
+
+      final approximate solution
+
+       5.6096365e-03  6.1813463e+03  3.4522363e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682169e+06
+
+      final l2 norm of the residuals    7.9499127e+02
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         346
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.2615990e-11  3.3931995e+04  9.0468249e+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724962e-02  1.0124349e+00 -2.3299172e-01  1.2604310e+00 -1.5137303e+00
+       9.9299727e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331258e+03
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725190e-02  1.0124349e+00 -2.3299155e-01  1.2604293e+00 -1.5137278e+00
+       9.9299573e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425604e+05
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724702e-02  1.0124349e+00 -2.3299192e-01  1.2604329e+00 -1.5137332e+00
+       9.9299902e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5307064e-05  9.9978970e-01  1.4763963e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044031e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5307133e-05  9.9978970e-01  1.4763963e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044031e+00 -3.1436122e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691093e+06
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           9
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6380605e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220759e+04
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          12
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6371022e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          28
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.6380605e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    2.4196750e-16
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585650e+01
+
+      final l2 norm of the residuals    1.1151779e+01
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5781993e-01  2.5782998e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154384e+03
+
+      final l2 norm of the residuals    2.9295429e+02
+
+      number of function evaluations         254
+
+      number of jacobian evaluations         236
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1591259e+01  1.3202491e+01 -4.0357435e-01  2.3673635e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507335e+05
+
+      final l2 norm of the residuals    2.9295427e+02
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1595927e+01  1.3204187e+01 -4.0341736e-01  2.3677114e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211252e+07
+
+      final l2 norm of the residuals    2.9295431e+02
+
+      number of function evaluations         237
+
+      number of jacobian evaluations         221
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1590260e+01  1.3202063e+01 -4.0368778e-01  2.3666523e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862380e+00
+
+      final l2 norm of the residuals    1.8862380e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833444e+09
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9303236e-02
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.3153665e-02  1.9309164e-01  2.6632859e-01  4.9999933e-01  5.0000067e-01
+       7.3367141e-01  8.0690836e-01  9.5684634e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    1.7600835e-16
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647100e-02
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9620267e-02  1.6670878e-01  2.3917102e-01  3.9888529e-01  3.9888367e-01
+       6.0111633e-01  6.0111471e-01  7.6082898e-01  8.3329122e-01  9.4037973e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    8.6625859e-15
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    5.0009355e-15
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    8.3739082e-15
+
+      number of function evaluations          22
+
+      number of jacobian evaluations          20
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.4827859e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  1.0673735e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    2.0245354e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756402e-01
+
+      final l2 norm of the residuals    7.3924926e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541005e-01  1.9358465e+00 -1.4646868e+00  1.2867534e-02  2.2122701e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468654e+00
+
+      final l2 norm of the residuals    2.0034404e-01
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099766e+00  4.3155248e-01  6.3366126e-01  5.9942856e-01  7.5417977e-01
+       9.0430008e-01  1.3657995e+00  4.8237320e+00  2.3986848e+00  4.5688755e+00
+       5.6753421e+00
+
 summary of 53 calls to lmder1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     3   2.2360680e+00
+    1    5   50     3     2     3   6.7082039e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     3     2     1   3.4826302e+00
+    3    5   10     3     2     1   1.9097274e+00
+    3    5   50     3     2     1   3.6917294e+00
+    4    2    2    21    16     4   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2     6     4     2   0.0000000e+00
+    5    3    3    11     8     2   9.9365231e-17
+    5    3    3    20    15     2   1.0446789e-19
+    5    3    3    19    16     2   3.1387778e-29
+    6    4    4    59    58     4   6.1093279e-34
+    6    4    4    72    71     4   9.1036079e-40
+    6    4    4    68    67     4   2.3305236e-35
+    7    2    2    14     8     1   6.9988752e+00
+    7    2    2    19    12     1   6.9988752e+00
+    7    2    2    24    17     1   6.9988752e+00
+    8    3   15     6     5     1   9.0635960e-02
+    8    3   15    37    36     1   4.1747687e+00
+    8    3   15    14    13     1   4.1747687e+00
+    9    4   11    18    16     1   1.7535838e-02
+    9    4   11    78    70     1   3.2052193e-02
+    9    4   11   500   380     5   1.7535840e-02
+   10    3   16   126   116     2   9.3779451e+00
+   10    3   16   400   346     5   7.9499127e+02
+   11    6   31     8     7     1   4.7829594e-02
+   11    6   31    14    13     1   4.7829594e-02
+   11    6   31    15    14     1   4.7829594e-02
+   11    9   31     8     7     3   1.1831146e-03
+   11    9   31    19    15     1   1.1831146e-03
+   11    9   31    19    16     3   1.1831146e-03
+   11   12   31    10     9     3   2.1731040e-05
+   11   12   31    13    12     3   2.1731040e-05
+   11   12   31    34    28     2   2.1731040e-05
+   12    3   10     7     6     2   2.4196750e-16
+   13    2   10    21    12     1   1.1151779e+01
+   14    4   20   254   236     1   2.9295429e+02
+   14    4   20    53    42     1   2.9295427e+02
+   14    4   20   237   221     1   2.9295431e+02
+   15    1    8     1     1     4   1.8862380e+00
+   15    1    8    29    28     1   1.8842482e+00
+   15    1    8    47    46     1   1.8842482e+00
+   15    8    8    39    20     1   5.9303236e-02
+   15    9    9    12     9     2   1.7600835e-16
+   15   10   10    25    12     1   8.0647100e-02
+   16   10   10    14    12     2   8.6625859e-15
+   16   10   10    13     8     2   5.0009355e-15
+   16   10   10    22    20     2   8.3739082e-15
+   16   30   30    19    14     2   1.4827859e-13
+   16   40   40    19    14     2   2.0245354e-13
+   17    5   33    18    15     1   7.3924926e-03
+   18   11   65    16    12     1   2.0034404e-01
diff --git a/examples/ref/lmfdrv.ref b/examples/ref/lmfdrv.ref
new file mode 100644
index 0000000..ebfbffa
--- /dev/null
+++ b/examples/ref/lmfdrv.ref
@@ -0,0 +1,1149 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.5000000D+01
+
+      final l2 norm of the residuals    0.2236068D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.8062258D+01
+
+      final l2 norm of the residuals    0.6708204D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.9999999D+00 -0.9999999D+00 -0.9999999D+00 -0.9999999D+00 -0.9999999D+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.2915219D+03
+
+      final l2 norm of the residuals    0.1463850D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1677968D+03 -0.8339841D+02  0.2211100D+03 -0.4119920D+02 -0.3275936D+02
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.3101600D+04
+
+      final l2 norm of the residuals    0.3482630D+01
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.2030000D+02 -0.9650000D+01 -0.1652452D+03 -0.4325000D+01  0.1105331D+03
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.1260397D+03
+
+      final l2 norm of the residuals    0.1909727D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01 -0.2103615D+03  0.3212042D+02  0.8113457D+02  0.1000000D+01
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.1748950D+04
+
+      final l2 norm of the residuals    0.3691729D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.1103866D+03 -0.1465594D+03  0.5473401D+02  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.4919350D+01
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          22
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1340063D+04
+
+      final l2 norm of the residuals    0.2220446D-14
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1430001D+06
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.5000000D+02
+
+      final l2 norm of the residuals    0.2268944D-15
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1425620D-16  0.0000000D+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.1029563D+03
+
+      final l2 norm of the residuals    0.1129685D-16
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.7098021D-18  0.0000000D+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.9912618D+03
+
+      final l2 norm of the residuals    0.4337144D-21
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01 -0.2725108D-22  0.0000000D+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1466288D+02
+
+      final l2 norm of the residuals    0.3872589D-20
+
+      number of function evaluations         241
+
+      number of jacobian evaluations         190
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.5263054D-10 -0.5263054D-11  0.2465982D-10  0.2465982D-10
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1270984D+04
+
+      final l2 norm of the residuals    0.2716944D-20
+
+      number of function evaluations         239
+
+      number of jacobian evaluations         191
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.4417018D-10 -0.4417018D-11  0.2043853D-10  0.2043853D-10
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1268879D+06
+
+      final l2 norm of the residuals    0.7100324D-20
+
+      number of function evaluations         237
+
+      number of jacobian evaluations         191
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.7114478D-10 -0.7114478D-11  0.3363832D-10  0.3363832D-10
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.2001250D+02
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141248D+02 -0.8968279D+00
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1243283D+05
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141300D+02 -0.8967960D+00
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1142645D+08
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141278D+02 -0.8968051D+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.6456136D+01
+
+      final l2 norm of the residuals    0.9063596D-01
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.3614185D+02
+
+      final l2 norm of the residuals    0.4174769D+01
+
+      number of function evaluations          42
+
+      number of jacobian evaluations          41
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8406667D+00 -0.2370848D+09 -0.2404887D+09
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.3841147D+03
+
+      final l2 norm of the residuals    0.4174769D+01
+
+      number of function evaluations          12
+
+      number of jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8406667D+00 -0.6605876D+08 -0.6952091D+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.7289151D-01
+
+      final l2 norm of the residuals    0.1753584D-01
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1928078D+00  0.1912628D+00  0.1230528D+00  0.1360533D+00
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.2979370D+01
+
+      final l2 norm of the residuals    0.3205219D-01
+
+      number of function evaluations          77
+
+      number of jacobian evaluations          68
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1829225D+06 -0.1407587D+02 -0.8278551D+07 -0.5164171D+07
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.2995906D+02
+
+      final l2 norm of the residuals    0.3070912D-01
+
+      number of function evaluations         229
+
+      number of jacobian evaluations         193
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.3731182D-02  0.6367392D+03  0.7288615D+01  0.4922700D+01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  0.4115347D+05
+
+      final l2 norm of the residuals    0.9377945D+01
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5609635D-02  0.6181347D+04  0.3452236D+03
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  0.4168217D+07
+
+      final l2 norm of the residuals    0.6237599D+05
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1382352D+01 -0.3663634D+04 -0.2257365D+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.5104662D-01
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1389015D-23  0.1013638D+01 -0.2443034D+00  0.1373771D+01 -0.1685639D+01
+       0.1098097D+01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.6433126D+04
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572519D-01  0.1012435D+01 -0.2329916D+00  0.1260430D+01 -0.1513728D+01
+       0.9929959D+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.6742560D+06
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572475D-01  0.1012435D+01 -0.2329918D+00  0.1260432D+01 -0.1513732D+01
+       0.9929986D+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.1183214D-02
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1403007D-21  0.9997896D+00  0.1478229D-01  0.1463070D+00  0.1001012D+01
+      -0.2618209D+01  0.4105100D+01 -0.3144132D+01  0.1052792D+01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.1208813D+05
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          17
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.1502306D-04  0.9997897D+00  0.1476368D-01  0.1463488D+00  0.1000792D+01
+      -0.2617666D+01  0.4104329D+01 -0.3143570D+01  0.1052617D+01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.1269109D+07
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations          28
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.1532379D-04  0.9997897D+00  0.1476311D-01  0.1463525D+00  0.1000778D+01
+      -0.2617638D+01  0.4104296D+01 -0.3143549D+01  0.1052612D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.2173128D-04
+
+      number of function evaluations          22
+
+      number of jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.1847464D-22  0.1000002D+01 -0.5664287D-03  0.3478755D+00 -0.1572557D+00
+       0.1055543D+01 -0.3255800D+01  0.7305175D+01 -0.1029263D+02  0.9089961D+01
+      -0.4548150D+01  0.1013255D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.1922076D+05
+
+      final l2 norm of the residuals    0.2173188D-04
+
+      number of function evaluations          26
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9744480D-07  0.1000002D+01 -0.5599460D-03  0.3477832D+00 -0.1565911D+00
+       0.1052712D+01 -0.3248142D+01  0.7291658D+01 -0.1027712D+02  0.9078802D+01
+      -0.4543583D+01  0.1012444D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.2018918D+07
+
+      final l2 norm of the residuals    0.2173286D-04
+
+      number of function evaluations          54
+
+      number of jacobian evaluations          30
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.2091129D-07  0.1000002D+01 -0.5571966D-03  0.3477159D+00 -0.1559411D+00
+       0.1049321D+01 -0.3237501D+01  0.7270621D+01 -0.1025071D+02  0.9058370D+01
+      -0.4534698D+01  0.1010782D+01
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  0.3211158D+02
+
+      final l2 norm of the residuals    0.1841097D-15
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+02  0.1000000D+01
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  0.6458565D+02
+
+      final l2 norm of the residuals    0.1115178D+02
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.2578199D+00  0.2578300D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.2815438D+04
+
+      final l2 norm of the residuals    0.2929571D+03
+
+      number of function evaluations         212
+
+      number of jacobian evaluations         197
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -0.1155962D+02  0.1319117D+02 -0.4017151D+00  0.2392897D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.5550734D+06
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159575D+02  0.1320412D+02 -0.4035077D+00  0.2367059D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.6121125D+08
+
+      final l2 norm of the residuals    0.2929544D+03
+
+      number of function evaluations         212
+
+      number of jacobian evaluations         197
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -0.1158645D+02  0.1320063D+02 -0.4032512D+00  0.2370161D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.1886238D+01
+
+      final l2 norm of the residuals    0.1886238D+01
+
+      number of function evaluations           2
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5000000D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.5383344D+10
+
+      final l2 norm of the residuals    0.1884248D+01
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9817315D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.1180887D+19
+
+      final l2 norm of the residuals    0.1884248D+01
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9817315D+00
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  0.1965139D+00
+
+      final l2 norm of the residuals    0.5930324D-01
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.4315367D-01  0.1930916D+00  0.2663286D+00  0.4999993D+00  0.5000007D+00
+       0.7336714D+00  0.8069084D+00  0.9568463D+00
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  0.1699499D+00
+
+      final l2 norm of the residuals    0.1087510D-15
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.4420535D-01  0.1994907D+00  0.2356191D+00  0.4160469D+00  0.5000000D+00
+       0.5839531D+00  0.7643809D+00  0.8005093D+00  0.9557947D+00
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.1837478D+00
+
+      final l2 norm of the residuals    0.8064710D-01
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5962027D-01  0.1667088D+00  0.2391710D+00  0.3988853D+00  0.3988837D+00
+       0.6011163D+00  0.6011147D+00  0.7608290D+00  0.8332912D+00  0.9403797D+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.1653022D+02
+
+      final l2 norm of the residuals    0.1000000D+01
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01
+      -0.5469128D-01 -0.5469128D-01 -0.5469128D-01 -0.5469128D-01  0.1154691D+02
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.9765624D+07
+
+      final l2 norm of the residuals    0.1465494D-13
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.9765625D+17
+
+      final l2 norm of the residuals    0.1000000D+01
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          32
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02
+      -0.5465648D-02 -0.5465648D-02 -0.5465648D-02 -0.5465648D-02  0.1105466D+02
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  0.8347604D+02
+
+      final l2 norm of the residuals    0.4304688D-13
+
+      number of function evaluations          11
+
+      number of jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  0.1280264D+03
+
+      final l2 norm of the residuals    0.3695687D-12
+
+      number of function evaluations          11
+
+      number of jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  0.9375640D+00
+
+      final l2 norm of the residuals    0.7392493D-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3754100D+00  0.1935845D+01 -0.1464685D+01  0.1286753D-01  0.2212271D-01
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  0.1446865D+01
+
+      final l2 norm of the residuals    0.2003440D+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1309977D+01  0.4315525D+00  0.6336613D+00  0.5994286D+00  0.7541798D+00
+       0.9043001D+00  0.1365799D+01  0.4823732D+01  0.2398685D+01  0.4568876D+01
+       0.5675342D+01
+1summary of  53 calls to lmdif1
+
+ nprob   n    m   nfev  njev  info  final l2 norm
+
+    1    5   10     3     2     1   0.2236068D+01
+    1    5   50     3     2     1   0.6708204D+01
+    2    5   10     3     2     1   0.1463850D+01
+    2    5   50     5     2     1   0.3482630D+01
+    3    5   10     3     2     1   0.1909727D+01
+    3    5   50     3     2     1   0.3691729D+01
+    4    2    2    22    16     2   0.0000000D+00
+    4    2    2     8     5     2   0.2220446D-14
+    4    2    2     7     5     2   0.0000000D+00
+    5    3    3    11     8     2   0.2268944D-15
+    5    3    3    20    15     2   0.1129685D-16
+    5    3    3    19    16     2   0.4337144D-21
+    6    4    4   241   190     5   0.3872589D-20
+    6    4    4   239   191     5   0.2716944D-20
+    6    4    4   237   191     5   0.7100324D-20
+    7    2    2    14     8     1   0.6998875D+01
+    7    2    2    19    12     1   0.6998875D+01
+    7    2    2    24    17     1   0.6998875D+01
+    8    3   15     6     5     1   0.9063596D-01
+    8    3   15    42    41     1   0.4174769D+01
+    8    3   15    12    11     1   0.4174769D+01
+    9    4   11    18    16     1   0.1753584D-01
+    9    4   11    77    68     1   0.3205219D-01
+    9    4   11   229   193     5   0.3070912D-01
+   10    3   16   126   116     1   0.9377945D+01
+   10    3   16     4     3     4   0.6237599D+05
+   11    6   31     8     7     1   0.5104662D-01
+   11    6   31    14    13     1   0.4782959D-01
+   11    6   31    15    14     1   0.4782959D-01
+   11    9   31     9     8     1   0.1183214D-02
+   11    9   31    29    17     2   0.1183115D-02
+   11    9   31    28    16     2   0.1183115D-02
+   11   12   31    22    11     2   0.2173128D-04
+   11   12   31    26    13     2   0.2173188D-04
+   11   12   31    54    30     2   0.2173286D-04
+   12    3   10     7     6     2   0.1841097D-15
+   13    2   10    21    12     1   0.1115178D+02
+   14    4   20   212   197     5   0.2929571D+03
+   14    4   20    47    36     1   0.2929543D+03
+   14    4   20   212   197     5   0.2929544D+03
+   15    1    8     2     1     1   0.1886238D+01
+   15    1    8    29    28     1   0.1884248D+01
+   15    1    8    47    46     1   0.1884248D+01
+   15    8    8    39    20     1   0.5930324D-01
+   15    9    9    12     9     2   0.1087510D-15
+   15   10   10    25    12     1   0.8064710D-01
+   16   10   10     7     5     1   0.1000000D+01
+   16   10   10    13     8     2   0.1465494D-13
+   16   10   10    34    32     1   0.1000000D+01
+   16   30   30    11    10     2   0.4304688D-13
+   16   40   40    11    10     2   0.3695687D-12
+   17    5   33    18    15     1   0.7392493D-02
+   18   11   65    16    12     1   0.2003440D+00
diff --git a/examples/ref/lmfdrvc.ref b/examples/ref/lmfdrvc.ref
new file mode 100644
index 0000000..bf9faee
--- /dev/null
+++ b/examples/ref/lmfdrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -9.9999996e-01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622577e+00
+
+      final l2 norm of the residuals    6.7082039e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.9999989e-01 -9.9999989e-01 -9.9999989e-01 -9.9999989e-01 -9.9999989e-01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152187e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.6779682e+02 -8.3398409e+01  2.2111004e+02 -4.1199205e+01 -3.2759364e+01
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016004e+03
+
+      final l2 norm of the residuals    3.4826302e+00
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.0299999e+01 -9.6499995e+00 -1.6524520e+02 -4.3249998e+00  1.1053306e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603968e+02
+
+      final l2 norm of the residuals    1.9097274e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -2.1036153e+02  3.2120421e+01  8.1134568e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917294e+00
+
+      number of function evaluations           3
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.1038660e+02 -1.4655944e+02  5.4734012e+01  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    2.2204460e-15
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    2.2689445e-16
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.4256199e-17  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.1296851e-17
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  7.0980209e-19  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    4.3371437e-22
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -2.7251077e-23  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    1.1138530e-23
+
+      number of function evaluations         235
+
+      number of Jacobian evaluations         192
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.5434075e-12 -2.5434075e-13  6.9489054e-13  6.9489054e-13
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    2.6976056e-21
+
+      number of function evaluations         236
+
+      number of Jacobian evaluations         192
+
+      exit parameter                           5
+
+      final approximate solution
+
+       4.4007789e-11 -4.4007789e-12  2.0384062e-11  2.0384062e-11
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    1.5238485e-22
+
+      number of function evaluations         239
+
+      number of Jacobian evaluations         191
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.0422573e-11 -1.0422573e-12  4.9279439e-12  4.9279439e-12
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012496e+01
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412484e+01 -8.9682791e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413005e+01 -8.9679604e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          24
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412782e+01 -8.9680511e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561363e+00
+
+      final l2 norm of the residuals    9.0635960e-02
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2410577e-02  1.1330367e+00  2.3436946e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141853e+01
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          42
+
+      number of Jacobian evaluations          41
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -2.3708475e+08 -2.4048867e+08
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411468e+02
+
+      final l2 norm of the residuals    4.1747688e+00
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066669e-01 -6.6058762e+07 -6.9520911e+07
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891510e-02
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280781e-01  1.9126276e-01  1.2305282e-01  1.3605327e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2052194e-02
+
+      number of function evaluations          77
+
+      number of Jacobian evaluations          68
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8292249e+05 -1.4075873e+01 -8.2785511e+06 -5.1641708e+06
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959062e+01
+
+      final l2 norm of the residuals    3.0709117e-02
+
+      number of function evaluations         229
+
+      number of Jacobian evaluations         193
+
+      exit parameter                           5
+
+      final approximate solution
+
+       3.7311815e-03  6.3673921e+02  7.2886152e+00  4.9226995e+00
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153467e+04
+
+      final l2 norm of the residuals    9.3779451e+00
+
+      number of function evaluations         126
+
+      number of Jacobian evaluations         116
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.6096351e-03  6.1813465e+03  3.4522364e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682169e+06
+
+      final l2 norm of the residuals    6.2375992e+04
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.3823518e+00 -3.6636342e+03 -2.2573652e+01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    5.1046620e-02
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.3890151e-24  1.0136384e+00 -2.4430338e-01  1.3737707e+00 -1.6856393e+00
+       1.0980970e+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331258e+03
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725188e-02  1.0124349e+00 -2.3299165e-01  1.2604296e+00 -1.5137281e+00
+       9.9299589e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425604e+05
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724754e-02  1.0124349e+00 -2.3299184e-01  1.2604324e+00 -1.5137325e+00
+       9.9299862e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    1.1832136e-03
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.4030070e-22  9.9978965e-01  1.4782292e-02  1.4630699e-01  1.0010116e+00
+      -2.6182093e+00  4.1050998e+00 -3.1441324e+00  1.0527917e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          29
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5023065e-05  9.9978972e-01  1.4763678e-02  1.4634881e-01  1.0007919e+00
+      -2.6176662e+00  4.1043288e+00 -3.1435698e+00  1.0526171e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691093e+06
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          28
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5323786e-05  9.9978966e-01  1.4763113e-02  1.4635249e-01  1.0007779e+00
+      -2.6176380e+00  4.1042958e+00 -3.1435495e+00  1.0526118e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    2.1731283e-05
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.8474637e-23  1.0000017e+00 -5.6642870e-04  3.4787546e-01 -1.5725570e-01
+       1.0555429e+00 -3.2558004e+00  7.3051748e+00 -1.0292631e+01  9.0899607e+00
+      -4.5481497e+00  1.0132549e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220759e+04
+
+      final l2 norm of the residuals    2.1731881e-05
+
+      number of function evaluations          26
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7444800e-08  1.0000015e+00 -5.5994597e-04  3.4778325e-01 -1.5659113e-01
+       1.0527117e+00 -3.2481418e+00  7.2916582e+00 -1.0277116e+01  9.0788016e+00
+      -4.5435831e+00  1.0124440e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    2.1732863e-05
+
+      number of function evaluations          54
+
+      number of Jacobian evaluations          30
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -2.0911286e-08  1.0000015e+00 -5.5719655e-04  3.4771593e-01 -1.5594105e-01
+       1.0493206e+00 -3.2375007e+00  7.2706212e+00 -1.0250707e+01  9.0583704e+00
+      -4.5346979e+00  1.0107819e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    1.8410966e-16
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585650e+01
+
+      final l2 norm of the residuals    1.1151779e+01
+
+      number of function evaluations          21
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5781993e-01  2.5782998e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154384e+03
+
+      final l2 norm of the residuals    2.9295706e+02
+
+      number of function evaluations         212
+
+      number of Jacobian evaluations         197
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.1559622e+01  1.3191168e+01 -4.0171512e-01  2.3928971e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507335e+05
+
+      final l2 norm of the residuals    2.9295427e+02
+
+      number of function evaluations          47
+
+      number of Jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1595745e+01  1.3204119e+01 -4.0350771e-01  2.3670586e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211252e+07
+
+      final l2 norm of the residuals    2.9295442e+02
+
+      number of function evaluations         212
+
+      number of Jacobian evaluations         197
+
+      exit parameter                           5
+
+      final approximate solution
+
+      -1.1586455e+01  1.3200626e+01 -4.0325124e-01  2.3701605e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862380e+00
+
+      final l2 norm of the residuals    1.8862380e+00
+
+      number of function evaluations           2
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.0000001e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833444e+09
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          29
+
+      number of Jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          47
+
+      number of Jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9303236e-02
+
+      number of function evaluations          39
+
+      number of Jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.3153666e-02  1.9309164e-01  2.6632860e-01  4.9999934e-01  5.0000067e-01
+       7.3367141e-01  8.0690837e-01  9.5684634e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    1.0875102e-16
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647100e-02
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9620271e-02  1.6670879e-01  2.3917103e-01  3.9888529e-01  3.9888367e-01
+       6.0111634e-01  6.0111472e-01  7.6082899e-01  8.3329123e-01  9.4037974e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02
+      -5.4691280e-02 -5.4691280e-02 -5.4691280e-02 -5.4691280e-02  1.1546913e+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    1.4654944e-14
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations          34
+
+      number of Jacobian evaluations          32
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03
+      -5.4656479e-03 -5.4656479e-03 -5.4656479e-03 -5.4656479e-03  1.1054656e+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    4.3046885e-14
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    3.6956867e-13
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756402e-01
+
+      final l2 norm of the residuals    7.3924926e-03
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541004e-01  1.9358453e+00 -1.4646855e+00  1.2867531e-02  2.2122706e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468654e+00
+
+      final l2 norm of the residuals    2.0034404e-01
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099766e+00  4.3155248e-01  6.3366126e-01  5.9942855e-01  7.5417976e-01
+       9.0430010e-01  1.3657995e+00  4.8237321e+00  2.3986847e+00  4.5688756e+00
+       5.6753421e+00
+
 summary of 53 calls to lmdif1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     1   2.2360680e+00
+    1    5   50     3     2     1   6.7082039e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     5     2     1   3.4826302e+00
+    3    5   10     3     2     1   1.9097274e+00
+    3    5   50     3     2     1   3.6917294e+00
+    4    2    2    22    16     2   0.0000000e+00
+    4    2    2     8     5     2   2.2204460e-15
+    4    2    2     7     5     2   0.0000000e+00
+    5    3    3    11     8     2   2.2689445e-16
+    5    3    3    20    15     2   1.1296851e-17
+    5    3    3    19    16     2   4.3371437e-22
+    6    4    4   235   192     5   1.1138530e-23
+    6    4    4   236   192     5   2.6976056e-21
+    6    4    4   239   191     5   1.5238485e-22
+    7    2    2    14     8     1   6.9988752e+00
+    7    2    2    19    12     1   6.9988752e+00
+    7    2    2    24    17     1   6.9988752e+00
+    8    3   15     6     5     1   9.0635960e-02
+    8    3   15    42    41     1   4.1747687e+00
+    8    3   15    12    11     1   4.1747688e+00
+    9    4   11    18    16     1   1.7535838e-02
+    9    4   11    77    68     1   3.2052194e-02
+    9    4   11   229   193     5   3.0709117e-02
+   10    3   16   126   116     1   9.3779451e+00
+   10    3   16     4     3     4   6.2375992e+04
+   11    6   31     8     7     1   5.1046620e-02
+   11    6   31    14    13     1   4.7829594e-02
+   11    6   31    15    14     1   4.7829594e-02
+   11    9   31     9     8     1   1.1832136e-03
+   11    9   31    29    17     2   1.1831146e-03
+   11    9   31    28    16     2   1.1831146e-03
+   11   12   31    22    11     2   2.1731283e-05
+   11   12   31    26    13     2   2.1731881e-05
+   11   12   31    54    30     2   2.1732863e-05
+   12    3   10     7     6     2   1.8410966e-16
+   13    2   10    21    12     1   1.1151779e+01
+   14    4   20   212   197     5   2.9295706e+02
+   14    4   20    47    36     1   2.9295427e+02
+   14    4   20   212   197     5   2.9295442e+02
+   15    1    8     2     1     1   1.8862380e+00
+   15    1    8    29    28     1   1.8842482e+00
+   15    1    8    47    46     1   1.8842482e+00
+   15    8    8    39    20     1   5.9303236e-02
+   15    9    9    12     9     2   1.0875102e-16
+   15   10   10    25    12     1   8.0647100e-02
+   16   10   10     7     5     1   1.0000000e+00
+   16   10   10    13     8     2   1.4654944e-14
+   16   10   10    34    32     1   1.0000000e+00
+   16   30   30    11    10     2   4.3046885e-14
+   16   40   40    11    10     2   3.6956867e-13
+   17    5   33    18    15     1   7.3924926e-03
+   18   11   65    16    12     1   2.0034404e-01
diff --git a/examples/ref/lmsdrv.ref b/examples/ref/lmsdrv.ref
new file mode 100644
index 0000000..bd01801
--- /dev/null
+++ b/examples/ref/lmsdrv.ref
@@ -0,0 +1,1149 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.5000000D+01
+
+      final l2 norm of the residuals    0.2236068D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.8062258D+01
+
+      final l2 norm of the residuals    0.6708204D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01 -0.1000000D+01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.2915219D+03
+
+      final l2 norm of the residuals    0.1463850D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.2561515D+03 -0.1557990D+02  0.1294492D+03 -0.7289948D+01 -0.1168073D+03
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.3101600D+04
+
+      final l2 norm of the residuals    0.3482630D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9059980D+02  0.7667581D+02  0.8463689D+02  0.3883791D+02 -0.1306368D+03
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  0.1260397D+03
+
+      final l2 norm of the residuals    0.1909727D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01  0.2146513D+03 -0.1024194D+03 -0.3046700D+02  0.1000000D+01
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  0.1748950D+04
+
+      final l2 norm of the residuals    0.3691729D+01
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1000000D+01 -0.1453733D+03  0.1438958D+03 -0.3522752D+02  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.4919350D+01
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1340063D+04
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1430001D+06
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.5000000D+02
+
+      final l2 norm of the residuals    0.9936524D-16
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01 -0.6243302D-17  0.0000000D+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.1029563D+03
+
+      final l2 norm of the residuals    0.1044679D-18
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.6563911D-20  0.0000000D+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  0.9912618D+03
+
+      final l2 norm of the residuals    0.3138778D-28
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01 -0.1972152D-29  0.0000000D+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1466288D+02
+
+      final l2 norm of the residuals    0.6109328D-33
+
+      number of function evaluations          58
+
+      number of jacobian evaluations          57
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1652118D-16 -0.1652118D-17  0.2643388D-17  0.2643388D-17
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1270984D+04
+
+      final l2 norm of the residuals    0.9545825D-33
+
+      number of function evaluations          61
+
+      number of jacobian evaluations          60
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.2065147D-16 -0.2065147D-17  0.3304235D-17  0.3304235D-17
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  0.1268879D+06
+
+      final l2 norm of the residuals    0.3728838D-33
+
+      number of function evaluations          65
+
+      number of jacobian evaluations          64
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.1290717D-16 -0.1290717D-17  0.2065147D-17  0.2065147D-17
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.2001250D+02
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141248D+02 -0.8968279D+00
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1243283D+05
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141300D+02 -0.8967960D+00
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  0.1142645D+08
+
+      final l2 norm of the residuals    0.6998875D+01
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1141278D+02 -0.8968051D+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.6456136D+01
+
+      final l2 norm of the residuals    0.9063596D-01
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.3614185D+02
+
+      final l2 norm of the residuals    0.4174769D+01
+
+      number of function evaluations          37
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8406667D+00 -0.1588480D+09 -0.1643787D+09
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  0.3841147D+03
+
+      final l2 norm of the residuals    0.4174769D+01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.8406667D+00 -0.1589462D+09 -0.1644649D+09
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.7289151D-01
+
+      final l2 norm of the residuals    0.1753584D-01
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1928078D+00  0.1912627D+00  0.1230528D+00  0.1360532D+00
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.2979370D+01
+
+      final l2 norm of the residuals    0.3205219D-01
+
+      number of function evaluations          78
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.7286755D+06 -0.1407588D+02 -0.3297780D+08 -0.2057159D+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  0.2995906D+02
+
+      final l2 norm of the residuals    0.1753584D-01
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         383
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.1928081D+00  0.1912560D+00  0.1230515D+00  0.1360501D+00
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  0.4115347D+05
+
+      final l2 norm of the residuals    0.9377945D+01
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           3
+
+      final approximate solution
+
+       0.5609636D-02  0.6181346D+04  0.3452236D+03
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  0.4168217D+07
+
+      final l2 norm of the residuals    0.8010923D+03
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         353
+
+      exit parameter                           5
+
+      final approximate solution
+
+       0.8798278D-11  0.3464175D+05  0.9148701D+03
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572496D-01  0.1012435D+01 -0.2329917D+00  0.1260431D+01 -0.1513730D+01
+       0.9929973D+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.6433126D+04
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572519D-01  0.1012435D+01 -0.2329915D+00  0.1260429D+01 -0.1513728D+01
+       0.9929957D+00
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  0.6742560D+06
+
+      final l2 norm of the residuals    0.4782959D-01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1572470D-01  0.1012435D+01 -0.2329919D+00  0.1260433D+01 -0.1513733D+01
+       0.9929990D+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1530706D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.1208813D+05
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.1530704D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  0.1269109D+07
+
+      final l2 norm of the residuals    0.1183115D-02
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.1530704D-04  0.9997897D+00  0.1476396D-01  0.1463423D+00  0.1000821D+01
+      -0.2617731D+01  0.4104403D+01 -0.3143612D+01  0.1052626D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.5477226D+01
+
+      final l2 norm of the residuals    0.2173104D-04
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           8
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.6602659D-08  0.1000002D+01 -0.5639321D-03  0.3478205D+00 -0.1567315D+00
+       0.1052815D+01 -0.3247271D+01  0.7288435D+01 -0.1027185D+02  0.9074114D+01
+      -0.4541375D+01  0.1012012D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.1922076D+05
+
+      final l2 norm of the residuals    0.2173104D-04
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -0.6638060D-08  0.1000002D+01 -0.5639322D-03  0.3478205D+00 -0.1567315D+00
+       0.1052815D+01 -0.3247271D+01  0.7288435D+01 -0.1027185D+02  0.9074114D+01
+      -0.4541375D+01  0.1012012D+01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  0.2018918D+07
+
+      final l2 norm of the residuals    0.2173104D-04
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          28
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -0.6637951D-08  0.1000002D+01 -0.5639322D-03  0.3478205D+00 -0.1567315D+00
+       0.1052815D+01 -0.3247271D+01  0.7288435D+01 -0.1027185D+02  0.9074114D+01
+      -0.4541375D+01  0.1012012D+01
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  0.3211158D+02
+
+      final l2 norm of the residuals    0.0000000D+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+02  0.1000000D+01
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  0.6458565D+02
+
+      final l2 norm of the residuals    0.1115178D+02
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.2578199D+00  0.2578300D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.2815438D+04
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations         254
+
+      number of jacobian evaluations         236
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159125D+02  0.1320249D+02 -0.4035748D+00  0.2367362D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.5550734D+06
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159593D+02  0.1320419D+02 -0.4034174D+00  0.2367711D+00
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  0.6121125D+08
+
+      final l2 norm of the residuals    0.2929543D+03
+
+      number of function evaluations         237
+
+      number of jacobian evaluations         221
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -0.1159026D+02  0.1320206D+02 -0.4036925D+00  0.2366620D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.1886238D+01
+
+      final l2 norm of the residuals    0.1886238D+01
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       0.5000000D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.5383344D+10
+
+      final l2 norm of the residuals    0.1884248D+01
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9817315D+00
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  0.1180887D+19
+
+      final l2 norm of the residuals    0.1884248D+01
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.9817315D+00
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  0.1965139D+00
+
+      final l2 norm of the residuals    0.5930324D-01
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.4315366D-01  0.1930916D+00  0.2663286D+00  0.4999993D+00  0.5000007D+00
+       0.7336714D+00  0.8069084D+00  0.9568463D+00
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  0.1699499D+00
+
+      final l2 norm of the residuals    0.2828182D-15
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.4420535D-01  0.1994907D+00  0.2356191D+00  0.4160469D+00  0.5000000D+00
+       0.5839531D+00  0.7643809D+00  0.8005093D+00  0.9557947D+00
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.1837478D+00
+
+      final l2 norm of the residuals    0.8064710D-01
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.5962027D-01  0.1667088D+00  0.2391710D+00  0.3988853D+00  0.3988837D+00
+       0.6011163D+00  0.6011147D+00  0.7608290D+00  0.8332912D+00  0.9403797D+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.1653022D+02
+
+      final l2 norm of the residuals    0.1023575D-14
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.9765624D+07
+
+      final l2 norm of the residuals    0.3996803D-14
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  0.9765625D+17
+
+      final l2 norm of the residuals    0.2010699D-14
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          26
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00
+       0.9794303D+00  0.9794303D+00  0.9794303D+00  0.9794303D+00  0.1205697D+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  0.8347604D+02
+
+      final l2 norm of the residuals    0.1889283D-12
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00
+       0.9977542D+00  0.9977542D+00  0.9977542D+00  0.9977542D+00  0.1067374D+01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  0.1280264D+03
+
+      final l2 norm of the residuals    0.2045771D-12
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01  0.1000000D+01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  0.9375640D+00
+
+      final l2 norm of the residuals    0.7392493D-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.3754100D+00  0.1935847D+01 -0.1464687D+01  0.1286753D-01  0.2212270D-01
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  0.1446865D+01
+
+      final l2 norm of the residuals    0.2003440D+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       0.1309977D+01  0.4315525D+00  0.6336613D+00  0.5994286D+00  0.7541798D+00
+       0.9043001D+00  0.1365799D+01  0.4823732D+01  0.2398685D+01  0.4568876D+01
+       0.5675342D+01
+1summary of  53 calls to lmstr1
+
+ nprob   n    m   nfev  njev  info  final l2 norm
+
+    1    5   10     3     2     2   0.2236068D+01
+    1    5   50     3     2     3   0.6708204D+01
+    2    5   10     3     2     1   0.1463850D+01
+    2    5   50     3     2     1   0.3482630D+01
+    3    5   10     3     2     1   0.1909727D+01
+    3    5   50     3     2     1   0.3691729D+01
+    4    2    2    21    16     4   0.0000000D+00
+    4    2    2     8     5     2   0.0000000D+00
+    4    2    2     6     4     2   0.0000000D+00
+    5    3    3    11     8     2   0.9936524D-16
+    5    3    3    20    15     2   0.1044679D-18
+    5    3    3    19    16     2   0.3138778D-28
+    6    4    4    58    57     4   0.6109328D-33
+    6    4    4    61    60     4   0.9545825D-33
+    6    4    4    65    64     4   0.3728838D-33
+    7    2    2    14     8     1   0.6998875D+01
+    7    2    2    19    12     1   0.6998875D+01
+    7    2    2    24    17     1   0.6998875D+01
+    8    3   15     6     5     1   0.9063596D-01
+    8    3   15    37    36     1   0.4174769D+01
+    8    3   15    14    13     1   0.4174769D+01
+    9    4   11    18    16     1   0.1753584D-01
+    9    4   11    78    70     1   0.3205219D-01
+    9    4   11   500   383     5   0.1753584D-01
+   10    3   16   126   116     3   0.9377945D+01
+   10    3   16   400   353     5   0.8010923D+03
+   11    6   31     8     7     1   0.4782959D-01
+   11    6   31    14    13     1   0.4782959D-01
+   11    6   31    15    14     1   0.4782959D-01
+   11    9   31     8     7     3   0.1183115D-02
+   11    9   31    20    16     3   0.1183115D-02
+   11    9   31    19    16     2   0.1183115D-02
+   11   12   31     9     8     3   0.2173104D-04
+   11   12   31    13    12     2   0.2173104D-04
+   11   12   31    34    28     3   0.2173104D-04
+   12    3   10     7     6     2   0.0000000D+00
+   13    2   10    21    12     1   0.1115178D+02
+   14    4   20   254   236     1   0.2929543D+03
+   14    4   20    53    42     1   0.2929543D+03
+   14    4   20   237   221     1   0.2929543D+03
+   15    1    8     1     1     4   0.1886238D+01
+   15    1    8    29    28     1   0.1884248D+01
+   15    1    8    47    46     1   0.1884248D+01
+   15    8    8    39    20     1   0.5930324D-01
+   15    9    9    12     9     2   0.2828182D-15
+   15   10   10    25    12     1   0.8064710D-01
+   16   10   10    14    12     2   0.1023575D-14
+   16   10   10    13     8     2   0.3996803D-14
+   16   10   10    29    26     2   0.2010699D-14
+   16   30   30    19    14     2   0.1889283D-12
+   16   40   40    19    14     2   0.2045771D-12
+   17    5   33    18    15     1   0.7392493D-02
+   18   11   65    16    12     1   0.2003440D+00
diff --git a/examples/ref/lmsdrvc.ref b/examples/ref/lmsdrvc.ref
new file mode 100644
index 0000000..ccea1df
--- /dev/null
+++ b/examples/ref/lmsdrvc.ref
@@ -0,0 +1,1148 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622577e+00
+
+      final l2 norm of the residuals    6.7082039e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00 -1.0000000e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152187e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5615151e+02 -1.5579896e+01  1.2944922e+02 -7.2899480e+00 -1.1680735e+02
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016004e+03
+
+      final l2 norm of the residuals    3.4826302e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.0599798e+01  7.6675815e+01  8.4636891e+01  3.8837907e+01 -1.3063681e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603968e+02
+
+      final l2 norm of the residuals    1.9097274e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  2.1465133e+02 -1.0241940e+02 -3.0466997e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917294e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00 -1.4537326e+02  1.4389584e+02 -3.5227516e+01  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193496e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300005e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    9.9365244e-17
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -6.2433024e-18  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.0446789e-19
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  6.5639108e-21  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126182e+02
+
+      final l2 norm of the residuals    3.1387778e-29
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -1.9721523e-30  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    6.1093279e-34
+
+      number of function evaluations          58
+
+      number of jacobian evaluations          57
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.6521176e-17 -1.6521176e-18  2.6433882e-18  2.6433882e-18
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709839e+03
+
+      final l2 norm of the residuals    9.5458248e-34
+
+      number of function evaluations          61
+
+      number of jacobian evaluations          60
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.0651470e-17 -2.0651470e-18  3.3042352e-18  3.3042352e-18
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688790e+05
+
+      final l2 norm of the residuals    3.7288378e-34
+
+      number of function evaluations          65
+
+      number of jacobian evaluations          64
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2907169e-17 -1.2907169e-18  2.0651470e-18  2.0651470e-18
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012496e+01
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412484e+01 -8.9682791e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413005e+01 -8.9679604e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9988752e+00
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412782e+01 -8.9680511e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561363e+00
+
+      final l2 norm of the residuals    9.0635960e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2410577e-02  1.1330367e+00  2.3436946e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141853e+01
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          37
+
+      number of jacobian evaluations          36
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5884803e+08 -1.6437867e+08
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411468e+02
+
+      final l2 norm of the residuals    4.1747687e+00
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066667e-01 -1.5894617e+08 -1.6446491e+08
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891510e-02
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          16
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9280781e-01  1.9126265e-01  1.2305280e-01  1.3605322e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2052193e-02
+
+      number of function evaluations          78
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+       7.2867547e+05 -1.4075880e+01 -3.2977798e+07 -2.0571594e+07
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959062e+01
+
+      final l2 norm of the residuals    1.7535838e-02
+
+      number of function evaluations         500
+
+      number of jacobian evaluations         383
+
+      exit parameter                           5
+
+      final approximate solution
+
+       1.9280811e-01  1.9125601e-01  1.2305155e-01  1.3605015e-01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153467e+04
+
+      final l2 norm of the residuals    9.3779451e+00
+
+      number of function evaluations         126
+
+      number of jacobian evaluations         116
+
+      exit parameter                           3
+
+      final approximate solution
+
+       5.6096365e-03  6.1813463e+03  3.4522363e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682169e+06
+
+      final l2 norm of the residuals    8.0109232e+02
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         353
+
+      exit parameter                           5
+
+      final approximate solution
+
+       8.7982782e-12  3.4641751e+04  9.1487011e+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724962e-02  1.0124349e+00 -2.3299172e-01  1.2604310e+00 -1.5137303e+00
+       9.9299727e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331258e+03
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725190e-02  1.0124349e+00 -2.3299155e-01  1.2604293e+00 -1.5137278e+00
+       9.9299573e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425604e+05
+
+      final l2 norm of the residuals    4.7829594e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5724702e-02  1.0124349e+00 -2.3299192e-01  1.2604329e+00 -1.5137332e+00
+       9.9299902e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           7
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5307064e-05  9.9978970e-01  1.4763963e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044031e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          20
+
+      number of jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5307036e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691093e+06
+
+      final l2 norm of the residuals    1.1831146e-03
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5307037e-05  9.9978970e-01  1.4763964e-02  1.4634233e-01  1.0008211e+00
+      -2.6177311e+00  4.1044032e+00 -3.1436123e+00  1.0526264e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772256e+00
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           8
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6026593e-09  1.0000016e+00 -5.6393215e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472711e+00  7.2884348e+00 -1.0271848e+01  9.0741135e+00
+      -4.5413754e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220759e+04
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.6380605e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    2.1731040e-05
+
+      number of function evaluations          34
+
+      number of jacobian evaluations          28
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.6379511e-09  1.0000016e+00 -5.6393221e-04  3.4782054e-01 -1.5673150e-01
+       1.0528152e+00 -3.2472712e+00  7.2884349e+00 -1.0271848e+01  9.0741136e+00
+      -4.5413755e+00  1.0120119e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585650e+01
+
+      final l2 norm of the residuals    1.1151779e+01
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5781993e-01  2.5782998e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154384e+03
+
+      final l2 norm of the residuals    2.9295429e+02
+
+      number of function evaluations         254
+
+      number of jacobian evaluations         236
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1591247e+01  1.3202487e+01 -4.0357483e-01  2.3673622e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507335e+05
+
+      final l2 norm of the residuals    2.9295427e+02
+
+      number of function evaluations          53
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1595927e+01  1.3204187e+01 -4.0341736e-01  2.3677114e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211252e+07
+
+      final l2 norm of the residuals    2.9295431e+02
+
+      number of function evaluations         237
+
+      number of jacobian evaluations         221
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1590261e+01  1.3202063e+01 -4.0369246e-01  2.3666200e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862380e+00
+
+      final l2 norm of the residuals    1.8862380e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833444e+09
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          28
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842482e+00
+
+      number of function evaluations          47
+
+      number of jacobian evaluations          46
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8173149e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9303236e-02
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.3153665e-02  1.9309164e-01  2.6632859e-01  4.9999933e-01  5.0000067e-01
+       7.3367141e-01  8.0690836e-01  9.5684634e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994993e-01
+
+      final l2 norm of the residuals    2.8281819e-16
+
+      number of function evaluations          12
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205346e-02  1.9949067e-01  2.3561911e-01  4.1604691e-01  5.0000000e-01
+       5.8395309e-01  7.6438089e-01  8.0050933e-01  9.5579465e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647100e-02
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9620267e-02  1.6670878e-01  2.3917102e-01  3.9888529e-01  3.9888367e-01
+       6.0111633e-01  6.0111471e-01  7.6082898e-01  8.3329122e-01  9.4037973e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.0235751e-15
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    3.9968029e-15
+
+      number of function evaluations          13
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656250e+16
+
+      final l2 norm of the residuals    2.0106994e-15
+
+      number of function evaluations          29
+
+      number of jacobian evaluations          26
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01
+       9.7943030e-01  9.7943030e-01  9.7943030e-01  9.7943030e-01  1.2056970e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.8892829e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01
+       9.9775422e-01  9.9775422e-01  9.9775422e-01  9.9775422e-01  1.0673735e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802636e+02
+
+      final l2 norm of the residuals    2.0457705e-13
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756402e-01
+
+      final l2 norm of the residuals    7.3924926e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541005e-01  1.9358465e+00 -1.4646868e+00  1.2867534e-02  2.2122701e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468654e+00
+
+      final l2 norm of the residuals    2.0034404e-01
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.3099766e+00  4.3155248e-01  6.3366126e-01  5.9942856e-01  7.5417977e-01
+       9.0430008e-01  1.3657995e+00  4.8237320e+00  2.3986848e+00  4.5688755e+00
+       5.6753421e+00
+
 summary of 53 calls to lmstr1
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     2   2.2360680e+00
+    1    5   50     3     2     3   6.7082039e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     3     2     1   3.4826302e+00
+    3    5   10     3     2     1   1.9097274e+00
+    3    5   50     3     2     1   3.6917294e+00
+    4    2    2    21    16     4   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2     6     4     2   0.0000000e+00
+    5    3    3    11     8     2   9.9365244e-17
+    5    3    3    20    15     2   1.0446789e-19
+    5    3    3    19    16     2   3.1387778e-29
+    6    4    4    58    57     4   6.1093279e-34
+    6    4    4    61    60     4   9.5458248e-34
+    6    4    4    65    64     4   3.7288378e-34
+    7    2    2    14     8     1   6.9988752e+00
+    7    2    2    19    12     1   6.9988752e+00
+    7    2    2    24    17     1   6.9988752e+00
+    8    3   15     6     5     1   9.0635960e-02
+    8    3   15    37    36     1   4.1747687e+00
+    8    3   15    14    13     1   4.1747687e+00
+    9    4   11    18    16     1   1.7535838e-02
+    9    4   11    78    70     1   3.2052193e-02
+    9    4   11   500   383     5   1.7535838e-02
+   10    3   16   126   116     3   9.3779451e+00
+   10    3   16   400   353     5   8.0109232e+02
+   11    6   31     8     7     1   4.7829594e-02
+   11    6   31    14    13     1   4.7829594e-02
+   11    6   31    15    14     1   4.7829594e-02
+   11    9   31     8     7     3   1.1831146e-03
+   11    9   31    20    16     3   1.1831146e-03
+   11    9   31    19    16     2   1.1831146e-03
+   11   12   31     9     8     3   2.1731040e-05
+   11   12   31    13    12     2   2.1731040e-05
+   11   12   31    34    28     3   2.1731040e-05
+   12    3   10     7     6     2   0.0000000e+00
+   13    2   10    21    12     1   1.1151779e+01
+   14    4   20   254   236     1   2.9295429e+02
+   14    4   20    53    42     1   2.9295427e+02
+   14    4   20   237   221     1   2.9295431e+02
+   15    1    8     1     1     4   1.8862380e+00
+   15    1    8    29    28     1   1.8842482e+00
+   15    1    8    47    46     1   1.8842482e+00
+   15    8    8    39    20     1   5.9303236e-02
+   15    9    9    12     9     2   2.8281819e-16
+   15   10   10    25    12     1   8.0647100e-02
+   16   10   10    14    12     2   1.0235751e-15
+   16   10   10    13     8     2   3.9968029e-15
+   16   10   10    29    26     2   2.0106994e-15
+   16   30   30    19    14     2   1.8892829e-13
+   16   40   40    19    14     2   2.0457705e-13
+   17    5   33    18    15     1   7.3924926e-03
+   18   11   65    16    12     1   2.0034404e-01
diff --git a/examples/ref/ltchkderc.ref b/examples/ref/ltchkderc.ref
new file mode 100644
index 0000000..b5ede83
--- /dev/null
+++ b/examples/ref/ltchkderc.ref
@@ -0,0 +1,22 @@
+
+      fvec
+
+           -1.181606      -1.429655      -1.606344
+           -1.745269      -1.840654      -1.921586
+           -1.984141      -2.022537      -2.468977
+           -2.827562      -3.473582      -4.437612
+           -6.047662      -9.267761      -18.91806
+      fvecp - fvec
+
+       -7.724666e-09  -3.432406e-09  -2.034843e-10
+        2.313685e-09   4.331078e-09   5.984096e-09
+        7.363281e-09    8.53147e-09   1.488591e-08
+         2.33585e-08   3.522012e-08   5.301255e-08
+         8.26666e-08   1.419747e-07    3.19899e-07
+      err
+
+           0.1141397     0.09943516     0.09674474
+          0.09980447      0.1073116      0.1220445
+           0.1526814              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/ltfdjac2c.ref b/examples/ref/ltfdjac2c.ref
new file mode 100644
index 0000000..f5c43e2
--- /dev/null
+++ b/examples/ref/ltfdjac2c.ref
@@ -0,0 +1,29 @@
+
+      fvec
+
+           -1.181606      -1.429655      -1.606344
+           -1.745269      -1.840654      -1.921586
+           -1.984141      -2.022537      -2.468977
+           -2.827562      -3.473582      -4.437612
+           -6.047662      -9.267761      -18.91806
+      fvecp - fvec
+
+       -7.724666e-09  -3.432406e-09  -2.034843e-10
+        2.313685e-09   4.331078e-09   5.984096e-09
+        7.363281e-09    8.53147e-09   1.488591e-08
+         2.33585e-08   3.522012e-08   5.301255e-08
+         8.26666e-08   1.419747e-07    3.19899e-07
+      errd
+
+                   1              1              1
+                   1       0.995393              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
+      err
+
+                   1              1              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/lthybrd1c.ref b/examples/ref/lthybrd1c.ref
new file mode 100644
index 0000000..27a8c48
--- /dev/null
+++ b/examples/ref/lthybrd1c.ref
@@ -0,0 +1,7 @@
+     final L2 norm of the residuals    1.192636e-08
+     exit parameter                          1
+     final approximates solution
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/lthybrdc.ref b/examples/ref/lthybrdc.ref
new file mode 100644
index 0000000..43c1f6e
--- /dev/null
+++ b/examples/ref/lthybrdc.ref
@@ -0,0 +1,11 @@
+     final l2 norm of the residuals    1.192636e-08
+
+     number of function evaluations          14
+
+     exit parameter                           1
+
+     final approximate solution
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/lthybrj1c.ref b/examples/ref/lthybrj1c.ref
new file mode 100644
index 0000000..07e5df4
--- /dev/null
+++ b/examples/ref/lthybrj1c.ref
@@ -0,0 +1,9 @@
+      final l2 norm of the residuals   1.192636e-08
+
+      exit parameter                         1
+
+      final approximate solution
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/lthybrjc.ref b/examples/ref/lthybrjc.ref
new file mode 100644
index 0000000..5230f8b
--- /dev/null
+++ b/examples/ref/lthybrjc.ref
@@ -0,0 +1,14 @@
+     final l2 norm of the residuals   1.192636e-08
+
+     number of function evaluations        11
+
+     number of jacobian evaluations         1
+
+     exit parameter                         1
+
+     final approximate solution
+
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/ltlmder1c.ref b/examples/ref/ltlmder1c.ref
new file mode 100644
index 0000000..82f918e
--- /dev/null
+++ b/examples/ref/ltlmder1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
diff --git a/examples/ref/ltlmderc.ref b/examples/ref/ltlmderc.ref
new file mode 100644
index 0000000..d025513
--- /dev/null
+++ b/examples/ref/ltlmderc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations         6
+
+      number of Jacobian evaluations         5
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
+      covariance
+
+        0.0001531202    0.002869941   -0.002656662
+         0.002869941     0.09480935    -0.09098995
+        -0.002656662    -0.09098995     0.08778727
diff --git a/examples/ref/ltlmdif1c.ref b/examples/ref/ltlmdif1c.ref
new file mode 100644
index 0000000..a432b90
--- /dev/null
+++ b/examples/ref/ltlmdif1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+      0.08241058       1.133037       2.343695
diff --git a/examples/ref/ltlmdifc.ref b/examples/ref/ltlmdifc.ref
new file mode 100644
index 0000000..5f174e2
--- /dev/null
+++ b/examples/ref/ltlmdifc.ref
@@ -0,0 +1,14 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations        21
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
+      covariance
+
+        0.0001531203    0.002869942   -0.002656663
+         0.002869942     0.09480938    -0.09098998
+        -0.002656663    -0.09098998      0.0877873
diff --git a/examples/ref/ltlmstr1c.ref b/examples/ref/ltlmstr1c.ref
new file mode 100644
index 0000000..82f918e
--- /dev/null
+++ b/examples/ref/ltlmstr1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
diff --git a/examples/ref/ltlmstrc.ref b/examples/ref/ltlmstrc.ref
new file mode 100644
index 0000000..d025513
--- /dev/null
+++ b/examples/ref/ltlmstrc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations         6
+
+      number of Jacobian evaluations         5
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
+      covariance
+
+        0.0001531202    0.002869941   -0.002656662
+         0.002869941     0.09480935    -0.09098995
+        -0.002656662    -0.09098995     0.08778727
diff --git a/examples/ref/schkdrvc.ref b/examples/ref/schkdrvc.ref
new file mode 100644
index 0000000..672de47
--- /dev/null
+++ b/examples/ref/schkdrvc.ref
@@ -0,0 +1,311 @@
+
+
+
+      problem    1      with dimension    2   is  F
+
+
+      first function vector   
+
+       2.0770001e+00 -2.8292906e+00
+
+
+      function difference vector
+
+      -3.7193298e-04  1.1035204e-02
+
+
+      error vector
+
+       8.2365036e-02  8.3581984e-01
+
+
+
+      problem    2      with dimension    4   is  F
+
+
+      first function vector   
+
+      -8.1070004e+00 -1.6859951e+00  1.8741612e+00  1.5952158e+01
+
+
+      function difference vector
+
+       4.9562454e-03 -5.8221817e-04 -8.2933903e-04  1.1022568e-02
+
+
+      error vector
+
+       1.0000000e+00  1.0000000e+00  1.2842835e-01  9.2242539e-01
+
+
+
+      problem    3      with dimension    2   is  F
+
+
+      first function vector   
+
+       1.0777100e+03  3.0019280e-01
+
+
+      function difference vector
+
+       7.4499512e-01 -1.6349554e-04
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    4      with dimension    4   is  T
+
+
+      first function vector   
+
+      -5.4127114e+03 -1.9649459e+03 -4.8718281e+03 -1.7769432e+03
+
+
+      function difference vector
+
+       5.3779297e+00  1.2358398e+00  4.8403320e+00  1.1137695e+00
+
+
+      error vector
+
+       9.2019463e-01  1.0000000e+00  9.2583168e-01  1.0000000e+00
+
+
+
+      problem    5      with dimension    3   is  F
+
+
+      first function vector   
+
+      -5.0987698e+01 -1.1441660e+00  1.2300000e-01
+
+
+      function difference vector
+
+       4.2343140e-04 -3.0577183e-03  4.2468309e-05
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  1.0000000e+00
+
+
+
+      problem    6      with dimension    9   is  F
+
+
+      first function vector   
+
+      -5.7930632e+00 -3.3390751e+01 -3.4683182e+01 -3.6368725e+01 -3.7947666e+01
+      -3.9431324e+01 -4.0834240e+01 -4.2170792e+01 -4.3453300e+01
+
+
+      function difference vector
+
+       1.0456562e-02  1.9123077e-02  2.4261475e-02  2.8285980e-02  3.1589508e-02
+       3.4408569e-02  3.6880493e-02  3.9100647e-02  4.1122437e-02
+
+
+      error vector
+
+       0.0000000e+00  1.0118186e-01  1.3322668e-01  1.5934974e-01  1.8083851e-01
+       1.9908608e-01  2.1500312e-01  2.2902226e-01  2.4173902e-01
+
+
+
+      problem    7      with dimension    7   is  F
+
+
+      first function vector   
+
+       3.5142865e-02 -4.5634698e-02  2.1936406e-01  2.1302824e-01  2.5865841e-01
+       2.3088835e-01  5.9196357e-02
+
+
+      function difference vector
+
+       3.5738945e-04  4.7776103e-04  5.5180490e-04  1.2420118e-03  2.2545755e-03
+       3.6663264e-03  4.9198084e-03
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00
+
+
+
+      problem    8      with dimension   10   is  T
+
+
+      first function vector   
+
+      -5.6230001e+00 -5.3769999e+00 -5.6230001e+00 -5.3769999e+00 -5.6230001e+00
+      -5.3769999e+00 -5.6230001e+00 -5.3769999e+00 -5.6230001e+00 -9.9928528e-01
+
+
+      function difference vector
+
+       1.8568039e-03  1.9416809e-03  1.8568039e-03  1.9416809e-03  1.8568039e-03
+       1.9416809e-03  1.8568039e-03  1.9416809e-03  1.8568039e-03  2.5033951e-06
+
+
+      error vector
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  0.0000000e+00
+
+
+
+      problem    9      with dimension   10   is  F
+
+
+      first function vector   
+
+      -3.8266212e-01  4.8185554e-01 -5.0497061e-01  4.8364362e-01 -5.0327110e-01
+       4.8731589e-01 -4.9982318e-01  4.9409863e-01 -4.9324730e-01  3.8308498e-01
+
+
+      function difference vector
+
+       1.3381243e-04 -1.6403198e-04  1.7684698e-04 -1.6343594e-04  1.7738342e-04
+      -1.6307831e-04  1.7806888e-04 -1.6328692e-04  1.5047193e-04 -6.5296888e-05
+
+
+      error vector
+
+       7.7286750e-02  3.6626393e-01  5.5991054e-02  1.8636526e-01  3.7315384e-02
+       1.6918576e-01  4.1837122e-02  2.3379742e-01  7.2901577e-02  2.7944452e-01
+
+
+
+      problem   10      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.6796678e-01  4.6728544e-02 -2.2043169e-01  1.7378714e-02 -2.2845450e-01
+       2.8983397e-02 -2.0089458e-01  6.9050625e-02 -1.5510282e-01  1.1399107e-01
+
+
+      function difference vector
+
+       7.6338649e-05  1.8876046e-05  1.2545288e-04  5.5165961e-05  1.4831126e-04
+       6.4063817e-05  1.4287233e-04  4.3608248e-05  1.0761619e-04  2.1159649e-05
+
+
+      error vector
+
+       0.0000000e+00  1.8855684e-02  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  1.0135500e-01
+
+
+
+      problem   11      with dimension   10   is  F
+
+
+      first function vector   
+
+       1.4839309e-01 -4.6502445e-02  1.4892209e-01  3.0207883e-03  1.4945090e-01
+       5.2543905e-02  1.4997971e-01  1.0206725e-01  1.5050900e-01  1.5159014e-01
+
+
+      function difference vector
+
+       7.5802207e-05  4.2930245e-05  7.5504184e-05  7.7023869e-05  7.5027347e-05
+       1.1135638e-04  7.5027347e-05  1.4521182e-04  7.4073672e-05  1.7954409e-04
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
+
+
+      problem   12      with dimension   10   is  F
+
+
+      first function vector   
+
+      -1.0878875e+05 -2.1757712e+05 -3.2636600e+05 -4.3515438e+05 -5.4394325e+05
+      -6.5273162e+05 -7.6152050e+05 -8.7030888e+05 -9.7909769e+05 -1.0878861e+06
+
+
+      function difference vector
+
+       5.2101562e+01  1.0420312e+02  1.5631250e+02  2.0840625e+02  2.6050000e+02
+       3.1262500e+02  3.6475000e+02  4.1681250e+02  4.6887500e+02  5.2100000e+02
+
+
+      error vector
+
+       4.5876272e-02  4.5875799e-02  4.5869421e-02  4.5875601e-02  4.5879330e-02
+       4.5869261e-02  4.5862090e-02  4.5875505e-02  4.5885939e-02  4.5879237e-02
+
+
+
+      problem   13      with dimension   10   is  T
+
+
+      first function vector   
+
+      -3.1372583e+00  1.9974256e-01 -2.2602584e+00  1.9974256e-01 -2.2602584e+00
+       1.9974256e-01 -2.2602584e+00  1.9974256e-01 -2.2602584e+00 -2.0462575e+00
+
+
+      function difference vector
+
+       2.2993088e-03  8.0680847e-04  1.9965172e-03  8.0680847e-04  1.9965172e-03
+       8.0680847e-04  1.9965172e-03  8.0680847e-04  1.9965172e-03  1.5823841e-03
+
+
+      error vector
+
+       1.0000000e+00  6.8162960e-01  1.0000000e+00  6.8162960e-01  1.0000000e+00
+       6.8162960e-01  1.0000000e+00  6.8162960e-01  1.0000000e+00  9.9744910e-01
+
+
+
+      problem   14      with dimension   10   is  F
+
+
+      first function vector   
+
+      -8.2193689e+00 -4.4028883e+00 -8.2496271e+00 -4.4331465e+00 -8.2798843e+00
+      -4.4634047e+00 -8.1720133e+00 -4.4634047e+00 -8.1720133e+00 -4.3252754e+00
+
+
+      function difference vector
+
+       8.3370209e-03  5.0635338e-03  9.0484619e-03  5.7749748e-03  9.7589493e-03
+       6.4864159e-03  9.9868774e-03  6.4864159e-03  9.9868774e-03  6.0033798e-03
+
+
+      error vector
+
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+       0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00  0.0000000e+00
+
 summary of  14 tests of chkder
+
+ nprob   n    status     errmin         errmax
+
+   1     2      F     8.2365036e-02  8.3581984e-01
+   2     4      F     1.2842835e-01  1.0000000e+00
+   3     2      F     0.0000000e+00  0.0000000e+00
+   4     4      T     9.2019463e-01  1.0000000e+00
+   5     3      F     0.0000000e+00  1.0000000e+00
+   6     9      F     0.0000000e+00  2.4173902e-01
+   7     7      F     0.0000000e+00  0.0000000e+00
+   8    10      T     0.0000000e+00  1.0000000e+00
+   9    10      F     3.7315384e-02  3.6626393e-01
+  10    10      F     0.0000000e+00  1.0135500e-01
+  11    10      F     0.0000000e+00  0.0000000e+00
+  12    10      F     4.5862090e-02  4.5885939e-02
+  13    10      T     6.8162960e-01  1.0000000e+00
+  14    10      F     0.0000000e+00  0.0000000e+00
diff --git a/examples/ref/shybdrvc.ref b/examples/ref/shybdrvc.ref
new file mode 100644
index 0000000..f790df0
--- /dev/null
+++ b/examples/ref/shybdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9193501e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.4300006e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    1.5549184e-16
+
+      number of function evaluations          53
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.5753046e-09  1.5753046e-10  4.5913842e-09  4.5913842e-09
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2709838e+03
+
+      final l2 norm of the residuals    2.8144827e-17
+
+      number of function evaluations          61
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9527913e-09 -1.9527913e-10  2.5538518e-09  2.5538518e-09
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2688791e+05
+
+      final l2 norm of the residuals    9.4115770e-17
+
+      number of function evaluations          67
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.0011638e-09 -4.0011638e-10  4.6503628e-09  4.6503628e-09
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654867e+00
+
+      final l2 norm of the residuals    1.3041419e-07
+
+      number of function evaluations         166
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981595e-05  9.1061468e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    8.2734023e-06
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981500e-05  9.1061487e+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5505576e+03
+
+      final l2 norm of the residuals    9.5140949e-06
+
+      number of function evaluations          78
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797884e-01  9.4714844e-01 -9.6951151e-01  9.5123833e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.3498230e+06
+
+      final l2 norm of the residuals    2.7211872e-05
+
+      number of function evaluations         153
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797347e-01  9.4713813e-01 -9.6951681e-01  9.5124871e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.2730701e+09
+
+      final l2 norm of the residuals    1.1292311e-05
+
+      number of function evaluations         261
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797311e-01  9.4713736e-01 -9.6951723e-01  9.5124942e-01
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    3.9367433e-06
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999994e-01  2.4450128e-07 -1.3564453e-15
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    9.2124429e-07
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999994e-01 -4.4135504e-08  9.7555961e-18
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9126184e+02
+
+      final l2 norm of the residuals    1.2282692e-07
+
+      number of function evaluations          51
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  7.7175173e-09  1.1848855e-13
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8485870e+01
+
+      final l2 norm of the residuals    6.0666152e-06
+
+      number of function evaluations          67
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725369e-02  1.0124348e+00 -2.3299237e-01  1.2604319e+00 -1.5137317e+00
+       9.9299741e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  3.5312585e+06
+
+      final l2 norm of the residuals    1.6459311e+01
+
+      number of function evaluations          90
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -2.8812926e+00  1.0873652e+01 -1.2288150e+01  2.5643299e+01 -4.4287178e+01
+       2.8034943e+01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8789551e+01
+
+      final l2 norm of the residuals    1.1804732e-03
+
+      number of function evaluations         129
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.4731798e-03  9.9933147e-01  2.9052624e-02  4.0073055e-04  1.5935067e+00
+      -3.8702135e+00  5.5327001e+00 -3.9793146e+00  1.2483358e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  1.0151079e+07
+
+      final l2 norm of the residuals    5.3987587e+01
+
+      number of function evaluations          70
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.6411495e+00  3.0561060e+01 -9.5884109e+01  2.0685359e+02 -2.7513443e+02
+       4.0453635e+02 -6.9807312e+02  6.7073407e+02 -2.3327190e+02
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570655e-01
+
+      final l2 norm of the residuals    3.0695301e-06
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3750911e-02  3.1273001e-01  4.9999925e-01  6.8727130e-01  9.1624850e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  4.1172450e+06
+
+      final l2 norm of the residuals    1.4986605e-06
+
+      number of function evaluations         119
+
+      number of Jacobian evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751321e-02  3.1272894e-01  6.8727040e-01  5.0000042e-01  9.1624886e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  5.6361314e+11
+
+      final l2 norm of the residuals    4.6573590e+08
+
+      number of function evaluations          65
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -8.7592608e-01 -5.2862137e+01  4.1392284e+01  4.3927780e+01  4.4449455e+01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1547182e-01
+
+      final l2 norm of the residuals    2.0102592e-05
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876546e-02  3.6668932e-01  2.8873348e-01  7.1125305e-01  6.3332415e-01
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.3079254e+08
+
+      final l2 norm of the residuals    1.9487459e-05
+
+      number of function evaluations          66
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.8873873e-01  9.3312323e-01  3.6668804e-01  6.6875584e-02  6.3331324e-01
+       7.1126115e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.8755800e+14
+
+      final l2 norm of the residuals    1.7774957e+14
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1231697e+01  2.3038582e+01  4.0234558e+01  5.9294502e+01  7.3570175e+01
+       8.3340881e+01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8376790e-01
+
+      final l2 norm of the residuals    1.0666718e-05
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8070701e-02  2.3516858e-01  3.3804706e-01  4.9999875e-01  6.6195601e-01
+       7.6482880e-01  9.4193006e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  4.2693284e+09
+
+      final l2 norm of the residuals    4.2693284e+09
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+00  2.5000000e+00  3.7500000e+00  5.0000000e+00  6.2500000e+00
+       7.5000000e+00  8.7500000e+00
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  6.4143172e+16
+
+      final l2 norm of the residuals    6.4143172e+16
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.2500000e+01  2.5000000e+01  3.7500000e+01  5.0000000e+01  6.2500000e+01
+       7.5000000e+01  8.7500000e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    6.4920083e-02
+
+      number of function evaluations          45
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.1471338e-02  1.9807488e-01  2.7040380e-01  5.0511068e-01  4.9597305e-01
+       7.3118556e-01  8.0297345e-01  9.5045084e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.6994981e-01
+
+      final l2 norm of the residuals    1.0916410e-04
+
+      number of function evaluations          18
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4197164e-02  1.9953178e-01  2.3556828e-01  4.1609466e-01  4.9996135e-01
+       5.8395451e-01  7.6439464e-01  8.0050129e-01  9.5579600e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    4.4707458e-06
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999946e-01  9.9999946e-01  9.9999946e-01  9.9999946e-01  9.9999946e-01
+       9.9999946e-01  9.9999946e-01  9.9999946e-01  9.9999946e-01  1.0000048e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations          33
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.1509103e-01 -1.1508475e-01 -1.1508603e-01 -1.1508778e-01 -1.1508711e-01
+      -1.1508659e-01 -1.1508745e-01 -1.1508780e-01 -1.1508723e-01  1.2150873e+01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656252e+16
+
+      final l2 norm of the residuals    9.7656252e+16
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.7161998e-05
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01
+       9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01
+       9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01
+       9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01
+       9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01
+       9.9999440e-01  9.9999440e-01  9.9999440e-01  9.9999440e-01  1.0001686e+00
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2802637e+02
+
+      final l2 norm of the residuals    3.0235657e-05
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01
+       9.9873394e-01  9.9873394e-01  9.9873394e-01  9.9873394e-01  1.0506511e+00
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.8080592e-02
+
+      final l2 norm of the residuals    2.0028850e-08
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164987e-02 -8.1577167e-02 -1.1448573e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908999e-01 -1.5524954e-01 -1.2535590e-01 -7.5416535e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2555257e-01
+
+      final l2 norm of the residuals    6.7585084e-08
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164991e-02 -8.1577189e-02 -1.1448579e-01 -1.4097369e-01 -1.5990885e-01
+      -1.6987740e-01 -1.6909018e-01 -1.5524971e-01 -1.2535603e-01 -7.5416617e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0657391e+02
+
+      final l2 norm of the residuals    9.8602250e-06
+
+      number of function evaluations          31
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3168999e-02 -8.1584916e-02 -1.1449504e-01 -1.4097954e-01 -1.5990651e-01
+      -1.6986884e-01 -1.6907977e-01 -1.5523884e-01 -1.2534785e-01 -7.5412512e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3611719e+02
+
+      final l2 norm of the residuals    1.4901161e-08
+
+      number of function evaluations          14
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281390e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5182697e-01
+
+      final l2 norm of the residuals    1.9168827e-08
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577159e-02 -1.1448572e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908997e-01 -1.5524952e-01 -1.2535587e-01 -7.5416513e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1168327e+00
+
+      final l2 norm of the residuals    5.8406397e-07
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164998e-02 -8.1577197e-02 -1.1448579e-01 -1.4097370e-01 -1.5990886e-01
+      -1.6987741e-01 -1.6909020e-01 -1.5524973e-01 -1.2535603e-01 -7.5416610e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2693087e+03
+
+      final l2 norm of the residuals    1.5432589e-08
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577159e-02 -1.1448572e-01 -1.4097358e-01 -1.5990870e-01
+      -1.6987720e-01 -1.6908999e-01 -1.5524954e-01 -1.2535587e-01 -7.5416528e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  8.4120534e-02
+
+      final l2 norm of the residuals    5.3142733e-03
+
+      number of function evaluations          67
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.5369183e-02  5.7086289e-02  5.9046667e-02  6.1328571e-02  6.3881919e-02
+       6.7237578e-02  2.0792514e-01  1.6400783e-01  8.7385967e-02  9.1098309e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0305195e+01
+
+      final l2 norm of the residuals    2.8176619e-06
+
+      number of function evaluations          28
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.2964712e-02  4.3976635e-02  4.5093656e-02  4.6339113e-02  4.7743205e-02
+       4.9357653e-02  5.1239945e-02  1.9520886e-01  1.6497894e-01  6.0149502e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3369370e+01
+
+      final l2 norm of the residuals    1.5691033e-02
+
+      number of function evaluations          37
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8912127e+01  2.5193624e+01  1.8910522e+01  1.8915770e+01  1.8924824e+01
+       1.9090677e+01  1.8933659e+01  1.8941313e+01  1.8984051e+01  1.8932606e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  2.2402135e+06
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          44
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+       1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  5.2234376e+07
+
+      final l2 norm of the residuals    4.9092266e+05
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.1703512e+01  1.1665982e-01 -6.3146033e+02 -5.8982849e-01  3.3040405e+02
+      -1.5025178e+03  4.2257257e+02  1.4545090e+01 -3.5027106e+02  9.3841687e+02
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  1.5923646e+11
+
+      final l2 norm of the residuals    5.6049429e+03
+
+      number of function evaluations          27
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.0965344e+03  7.2777893e+02 -4.2828740e+03 -1.3187314e+03 -8.5446289e+01
+      -2.0954412e+03  1.7478848e+03  1.3359832e+03  4.6405585e+02  3.7205737e+02
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5825758e+00
+
+      final l2 norm of the residuals    3.8072812e-05
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7071590e-01 -6.8180329e-01 -7.0220965e-01 -7.0551234e-01 -7.0490927e-01
+      -7.0150012e-01 -6.9189209e-01 -6.6579729e-01 -5.9603453e-01 -4.1641471e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3910095e+02
+
+      final l2 norm of the residuals    2.9802322e-07
+
+      number of function evaluations          60
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072210e-01 -6.8180692e-01 -7.0221007e-01 -7.0551068e-01 -7.0490617e-01
+      -7.0149660e-01 -6.9188929e-01 -6.6579652e-01 -5.9603512e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3337582e+04
+
+      final l2 norm of the residuals    9.4964244e-06
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072300e-01 -6.8180704e-01 -7.0221013e-01 -7.0551068e-01 -7.0490628e-01
+      -7.0149696e-01 -6.9189012e-01 -6.6579801e-01 -5.9603685e-01 -4.1641277e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8973665e+01
+
+      final l2 norm of the residuals    2.0957385e-04
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2831260e-01 -4.7659481e-01 -5.1965940e-01 -5.5810648e-01 -5.9250420e-01
+      -6.2449384e-01 -6.2322783e-01 -6.2138480e-01 -6.2045062e-01 -5.8648789e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7130922e+04
+
+      final l2 norm of the residuals    2.3235139e-04
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2833534e-01 -4.7656971e-01 -5.1965076e-01 -5.5809981e-01 -5.9250998e-01
+      -6.2451160e-01 -6.2323725e-01 -6.2138838e-01 -6.2044895e-01 -5.8646911e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.5949860e+07
+
+      final l2 norm of the residuals    7.3460091e-05
+
+      number of function evaluations          31
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2831323e-01 -4.7658759e-01 -5.1965231e-01 -5.5809963e-01 -5.9250820e-01
+      -6.2450194e-01 -6.2323916e-01 -6.2139487e-01 -6.2045264e-01 -5.8646935e-01
+
 summary of 55 calls to hybrd1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      8      1     1   0.0000000e+00
+   1     2      8      1     1   0.0000000e+00
+   2     4     53      3     4   1.5549184e-16
+   2     4     61      3     1   2.8144827e-17
+   2     4     67      4     4   9.4115770e-17
+   3     2    166      6     1   1.3041419e-07
+   3     2      7      1     1   8.2734023e-06
+   4     4     78      2     1   9.5140949e-06
+   4     4    153      5     1   2.7211872e-05
+   4     4    261     17     1   1.1292311e-05
+   5     3     16      3     1   3.9367433e-06
+   5     3     17      4     1   9.2124429e-07
+   5     3     51     10     1   1.2282692e-07
+   6     6     67      6     1   6.0666152e-06
+   6     6     90     11     4   1.6459311e+01
+   6     9    129     17     1   1.1804732e-03
+   6     9     70      8     1   5.3987587e+01
+   7     5     10      1     1   3.0695301e-06
+   7     5    119     25     1   1.4986605e-06
+   7     5     65     11     4   4.6573590e+08
+   7     6     10      2     1   2.0102592e-05
+   7     6     66     13     1   1.9487459e-05
+   7     6     17      2     1   1.7774957e+14
+   7     7      8      2     1   1.0666718e-05
+   7     7     11      2     4   4.2693284e+09
+   7     7     11      2     4   6.4143172e+16
+   7     8     45      8     4   6.4920083e-02
+   7     9     18      2     1   1.0916410e-04
+   8    10     14      3     1   4.4707458e-06
+   8    10     33      6     4   1.0000000e+00
+   8    10     11      2     4   9.7656252e+16
+   8    30     13      2     1   1.7161998e-05
+   8    40     15      3     1   3.0235657e-05
+   9    10      4      1     1   2.0028850e-08
+   9    10      6      1     1   6.7585084e-08
+   9    10     31      1     1   9.8602250e-06
+  10     1      5      1     1   0.0000000e+00
+  10     1      6      1     1   0.0000000e+00
+  10     1     14      1     1   1.4901161e-08
+  10    10      4      1     1   1.9168827e-08
+  10    10      6      1     1   5.8406397e-07
+  10    10     17      2     1   1.5432589e-08
+  11    10     67     11     4   5.3142733e-03
+  11    10     28      5     1   2.8176619e-06
+  11    10     37      9     1   1.5691033e-02
+  12    10     44      5     1   0.0000000e+00
+  12    10     20      3     4   4.9092266e+05
+  12    10     27      4     4   5.6049429e+03
+  13    10      7      1     1   3.8072812e-05
+  13    10     60      3     1   2.9802322e-07
+  13    10     19      2     1   9.4964244e-06
+  14    10     11      1     1   2.0957385e-04
+  14    10     20      2     1   2.3235139e-04
+  14    10     31      2     1   7.3460091e-05
diff --git a/examples/ref/shyjdrvc.ref b/examples/ref/shyjdrvc.ref
new file mode 100644
index 0000000..46cba26
--- /dev/null
+++ b/examples/ref/shyjdrvc.ref
@@ -0,0 +1,1204 @@
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  4.9193501e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    3.0994415e-05
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000031e+00
+
+
+
+
+      problem    1      dimension    2
+
+
+      initial l2 norm of the residuals  1.4300006e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    9.1213967e-18
+
+      number of function evaluations          64
+
+      number of jacobian evaluations           5
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -1.3178475e-09  1.3178475e-10 -1.4441786e-09 -1.4441786e-09
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2709838e+03
+
+      final l2 norm of the residuals    4.3054092e-17
+
+      number of function evaluations          57
+
+      number of jacobian evaluations           3
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -2.7626124e-09  2.7626124e-10 -3.1425580e-09 -3.1425580e-09
+
+
+
+
+      problem    2      dimension    4
+
+
+      initial l2 norm of the residuals  1.2688791e+05
+
+      final l2 norm of the residuals    3.3167945e-18
+
+      number of function evaluations          70
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.4365831e-09 -1.4365831e-10  4.3874487e-10  4.3874487e-10
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0654867e+00
+
+      final l2 norm of the residuals    4.7594266e-08
+
+      number of function evaluations         168
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981594e-05  9.1061468e+00
+
+
+
+
+      problem    3      dimension    2
+
+
+      initial l2 norm of the residuals  1.0000000e+00
+
+      final l2 norm of the residuals    8.1905828e-06
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0981501e-05  9.1061487e+00
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  8.5505576e+03
+
+      final l2 norm of the residuals    1.4612488e-05
+
+      number of function evaluations          84
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6796274e-01  9.4711733e-01 -9.6952754e-01  9.5126945e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.3498230e+06
+
+      final l2 norm of the residuals    7.0295471e-05
+
+      number of function evaluations         192
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6802872e-01  9.4724482e-01 -9.6946198e-01  9.5114231e-01
+
+
+
+
+      problem    4      dimension    4
+
+
+      initial l2 norm of the residuals  7.2730701e+09
+
+      final l2 norm of the residuals    8.0397449e-06
+
+      number of function evaluations         352
+
+      number of jacobian evaluations          27
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.6797252e-01  9.4713622e-01 -9.6951789e-01  9.5125073e-01
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    3.2887851e-06
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999994e-01  2.0321841e-07  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    3.6600181e-08
+
+      number of function evaluations          19
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  2.2996574e-09  0.0000000e+00
+
+
+
+
+      problem    5      dimension    3
+
+
+      initial l2 norm of the residuals  9.9126184e+02
+
+      final l2 norm of the residuals    5.3028920e-08
+
+      number of function evaluations          36
+
+      number of jacobian evaluations           8
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  3.3319054e-09  0.0000000e+00
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  6.8485870e+01
+
+      final l2 norm of the residuals    1.4315057e-06
+
+      number of function evaluations          58
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725432e-02  1.0124347e+00 -2.3299037e-01  1.2604253e+00 -1.5137230e+00
+       9.9299335e-01
+
+
+
+
+      problem    6      dimension    6
+
+
+      initial l2 norm of the residuals  3.5312585e+06
+
+      final l2 norm of the residuals    4.5457618e-06
+
+      number of function evaluations          72
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5725890e-02  1.0124348e+00 -2.3299146e-01  1.2604259e+00 -1.5137224e+00
+       9.9299222e-01
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  8.8789551e+01
+
+      final l2 norm of the residuals    4.4975568e-06
+
+      number of function evaluations          85
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5297170e-05  9.9978960e-01  1.4771627e-02  1.4625373e-01  1.0012460e+00
+      -2.6187584e+00  4.1057220e+00 -3.1444709e+00  1.0528497e+00
+
+
+
+
+      problem    6      dimension    9
+
+
+      initial l2 norm of the residuals  1.0151079e+07
+
+      final l2 norm of the residuals    6.6859561e-01
+
+      number of function evaluations         106
+
+      number of jacobian evaluations          10
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.6702427e-01  2.7569652e+00 -5.9141953e+01  5.3408136e+02 -2.0914543e+03
+       4.2389595e+03 -4.6103960e+03  2.5420134e+03 -5.5105341e+02
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  2.2570655e-01
+
+      final l2 norm of the residuals    3.6521178e-05
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3755739e-02  3.1272420e-01  5.0000000e-01  6.8727583e-01  9.1624427e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  4.1172450e+06
+
+      final l2 norm of the residuals    7.1370760e-06
+
+      number of function evaluations         135
+
+      number of jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.3751582e-02  5.0000221e-01  6.8726915e-01  3.1272793e-01  9.1624916e-01
+
+
+
+
+      problem    7      dimension    5
+
+
+      initial l2 norm of the residuals  5.6361314e+11
+
+      final l2 norm of the residuals    4.7142170e+08
+
+      number of function evaluations         108
+
+      number of jacobian evaluations          14
+
+      exit parameter                           4
+
+      final approximate solution
+
+      -5.4530479e+01 -7.9413409e+00  1.3895516e+01 -1.3231560e+01  5.5531525e+01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  2.1547182e-01
+
+      final l2 norm of the residuals    1.7030106e-06
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       6.6876598e-02  3.6668319e-01  2.8873965e-01  7.1126038e-01  6.3331681e-01
+       9.3312341e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.3079254e+08
+
+      final l2 norm of the residuals    5.2770069e-06
+
+      number of function evaluations          70
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.6668503e-01  6.3331521e-01  6.6876583e-02  7.1126193e-01  9.3312341e-01
+       2.8873792e-01
+
+
+
+
+      problem    7      dimension    6
+
+
+      initial l2 norm of the residuals  1.8755800e+14
+
+      final l2 norm of the residuals    1.8755800e+14
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.4285715e+01  2.8571430e+01  4.2857147e+01  5.7142860e+01  7.1428574e+01
+       8.5714294e+01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  1.8376790e-01
+
+      final l2 norm of the residuals    1.7317556e-04
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8082171e-02  2.3512772e-01  3.3809543e-01  4.9995753e-01  6.6196579e-01
+       7.6484597e-01  9.4192535e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  4.2693284e+09
+
+      final l2 norm of the residuals    1.1527198e-05
+
+      number of function evaluations         252
+
+      number of jacobian evaluations          44
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.0000238e-01  2.3517540e-01  3.3804002e-01  5.8068056e-02  6.6195565e-01
+       7.6482743e-01  9.4193107e-01
+
+
+
+
+      problem    7      dimension    7
+
+
+      initial l2 norm of the residuals  6.4143172e+16
+
+      final l2 norm of the residuals    5.1379834e+13
+
+      number of function evaluations          46
+
+      number of jacobian evaluations          12
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.9905979e+01  5.5982544e+01  3.6108978e+01  3.5824638e+01 -6.4949944e+01
+       5.2997307e+01  5.5733734e+01
+
+
+
+
+      problem    7      dimension    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    6.4404607e-02
+
+      number of function evaluations          56
+
+      number of jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.9856197e-02  1.9863509e-01  2.6982883e-01  4.9927196e-01  5.0072867e-01
+       7.3017186e-01  8.0136555e-01  9.5014453e-01
+
+
+
+
+      problem    7      dimension    9
+
+
+      initial l2 norm of the residuals  1.6994981e-01
+
+      final l2 norm of the residuals    3.3593704e-05
+
+      number of function evaluations          18
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.4206861e-02  1.9948216e-01  2.3563011e-01  4.1604108e-01  4.9999818e-01
+       5.8396095e-01  7.6436365e-01  8.0052453e-01  9.5579231e-01
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    4.5024199e-06
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999934e-01  9.9999934e-01  9.9999934e-01  9.9999934e-01  9.9999934e-01
+       9.9999934e-01  9.9999934e-01  9.9999934e-01  9.9999934e-01  1.0000054e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    1.5078915e-06
+
+      number of function evaluations          36
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999940e-01  9.9999940e-01  9.9999940e-01  9.9999940e-01  9.9999940e-01
+       9.9999940e-01  9.9999940e-01  9.9999940e-01  9.9999940e-01  1.0000058e+00
+
+
+
+
+      problem    8      dimension   10
+
+
+      initial l2 norm of the residuals  9.7656252e+16
+
+      final l2 norm of the residuals    9.7656252e+16
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           2
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+       5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01  5.0000000e+01
+
+
+
+
+      problem    8      dimension   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    8.9945761e-06
+
+      number of function evaluations          18
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00
+       1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00
+       1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00
+       1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00
+       1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00
+       1.0000083e+00  1.0000083e+00  1.0000083e+00  1.0000083e+00  9.9975842e-01
+
+
+
+
+      problem    8      dimension   40
+
+
+      initial l2 norm of the residuals  1.2802637e+02
+
+      final l2 norm of the residuals    3.4050012e-05
+
+      number of function evaluations          16
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01
+       9.9877089e-01  9.9877089e-01  9.9877089e-01  9.9877089e-01  1.0491517e+00
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  2.8080592e-02
+
+      final l2 norm of the residuals    2.6579430e-08
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164987e-02 -8.1577167e-02 -1.1448573e-01 -1.4097360e-01 -1.5990871e-01
+      -1.6987722e-01 -1.6909000e-01 -1.5524955e-01 -1.2535590e-01 -7.5416543e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  5.2555257e-01
+
+      final l2 norm of the residuals    6.7943475e-08
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164991e-02 -8.1577182e-02 -1.1448578e-01 -1.4097369e-01 -1.5990885e-01
+      -1.6987740e-01 -1.6909018e-01 -1.5524971e-01 -1.2535603e-01 -7.5416610e-02
+
+
+
+
+      problem    9      dimension   10
+
+
+      initial l2 norm of the residuals  1.0657391e+02
+
+      final l2 norm of the residuals    7.0747551e-06
+
+      number of function evaluations          30
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3165427e-02 -8.1577897e-02 -1.1448573e-01 -1.4097078e-01 -1.5990174e-01
+      -1.6987063e-01 -1.6908687e-01 -1.5524666e-01 -1.2535365e-01 -7.5415403e-02
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  1.2792969e-01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  2.5625000e+00
+
+      final l2 norm of the residuals    1.4901161e-08
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281390e-01
+
+
+
+
+      problem   10      dimension    1
+
+
+      initial l2 norm of the residuals  8.3611719e+02
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          23
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5281388e-01
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  2.5182697e-01
+
+      final l2 norm of the residuals    4.5146109e-08
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164983e-02 -8.1577159e-02 -1.1448572e-01 -1.4097358e-01 -1.5990871e-01
+      -1.6987722e-01 -1.6909000e-01 -1.5524955e-01 -1.2535587e-01 -7.5416528e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  6.1168327e+00
+
+      final l2 norm of the residuals    3.9818809e-07
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3164961e-02 -8.1577122e-02 -1.1448567e-01 -1.4097354e-01 -1.5990870e-01
+      -1.6987725e-01 -1.6909009e-01 -1.5524970e-01 -1.2535606e-01 -7.5416662e-02
+
+
+
+
+      problem   10      dimension   10
+
+
+      initial l2 norm of the residuals  1.2693087e+03
+
+      final l2 norm of the residuals    9.8533917e-07
+
+      number of function evaluations          45
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.3165080e-02 -8.1577346e-02 -1.1448593e-01 -1.4097366e-01 -1.5990855e-01
+      -1.6987684e-01 -1.6908954e-01 -1.5524912e-01 -1.2535559e-01 -7.5416386e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  8.4120534e-02
+
+      final l2 norm of the residuals    5.2958368e-03
+
+      number of function evaluations          57
+
+      number of jacobian evaluations           8
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.5279694e-02  5.6983635e-02  5.8922779e-02  6.1167419e-02  6.3826047e-02
+       6.7071036e-02  2.0796692e-01  1.6418971e-01  8.6474232e-02  9.1640025e-02
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  2.0305195e+01
+
+      final l2 norm of the residuals    1.5992504e-06
+
+      number of function evaluations          31
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.4395915e-02  3.5031989e-02  3.5718851e-02  3.6464818e-02  3.7280425e-02
+       3.8179357e-02  3.9179917e-02  4.0306460e-02  1.7972031e-01  1.5624082e-01
+
+
+
+
+      problem   11      dimension   10
+
+
+      initial l2 norm of the residuals  9.3369370e+01
+
+      final l2 norm of the residuals    8.9314650e-05
+
+      number of function evaluations          31
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.8883986e+01  2.5167809e+01  1.8885305e+01  1.8886059e+01  1.8886923e+01
+       1.8887789e+01  1.8888823e+01  1.8889912e+01  1.9029278e+01  1.9005856e+01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  2.2402135e+06
+
+      final l2 norm of the residuals    3.9703064e-03
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999946e-01  9.9999893e-01  9.9999845e-01  9.9999791e-01  9.9999738e-01
+       9.9999684e-01  9.9999630e-01  9.9999583e-01  9.9999529e-01  9.9999475e-01
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  5.2234376e+07
+
+      final l2 norm of the residuals    4.8075180e-04
+
+      number of function evaluations          37
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000001e+00  1.0000001e+00  1.0000002e+00  1.0000002e+00  1.0000004e+00
+       1.0000004e+00  1.0000005e+00  1.0000005e+00  1.0000006e+00  1.0000006e+00
+
+
+
+
+      problem   12      dimension   10
+
+
+      initial l2 norm of the residuals  1.5923646e+11
+
+      final l2 norm of the residuals    4.5143771e-03
+
+      number of function evaluations          58
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.9999940e-01  9.9999881e-01  9.9999821e-01  9.9999762e-01  9.9999702e-01
+       9.9999642e-01  9.9999583e-01  9.9999523e-01  9.9999464e-01  9.9999404e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  4.5825758e+00
+
+      final l2 norm of the residuals    3.8122751e-05
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7071590e-01 -6.8180329e-01 -7.0220959e-01 -7.0551234e-01 -7.0490927e-01
+      -7.0150012e-01 -6.9189209e-01 -6.6579729e-01 -5.9603453e-01 -4.1641474e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3910095e+02
+
+      final l2 norm of the residuals    4.9511334e-07
+
+      number of function evaluations          29
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072216e-01 -6.8180698e-01 -7.0221007e-01 -7.0551062e-01 -7.0490611e-01
+      -7.0149660e-01 -6.9188929e-01 -6.6579652e-01 -5.9603512e-01 -4.1641226e-01
+
+
+
+
+      problem   13      dimension   10
+
+
+      initial l2 norm of the residuals  6.3337582e+04
+
+      final l2 norm of the residuals    9.2025020e-06
+
+      number of function evaluations          19
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.7072300e-01 -6.8180704e-01 -7.0221013e-01 -7.0551068e-01 -7.0490628e-01
+      -7.0149696e-01 -6.9189006e-01 -6.6579795e-01 -5.9603685e-01 -4.1641280e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.8973665e+01
+
+      final l2 norm of the residuals    2.0989163e-04
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2831272e-01 -4.7659484e-01 -5.1965940e-01 -5.5810654e-01 -5.9250426e-01
+      -6.2449384e-01 -6.2322783e-01 -6.2138474e-01 -6.2045062e-01 -5.8648789e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.7130922e+04
+
+      final l2 norm of the residuals    2.3286082e-04
+
+      number of function evaluations          20
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2833540e-01 -4.7656971e-01 -5.1965076e-01 -5.5809981e-01 -5.9250993e-01
+      -6.2451166e-01 -6.2323731e-01 -6.2138826e-01 -6.2044889e-01 -5.8646911e-01
+
+
+
+
+      problem   14      dimension   10
+
+
+      initial l2 norm of the residuals  1.5949860e+07
+
+      final l2 norm of the residuals    7.3764968e-05
+
+      number of function evaluations          31
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -4.2831326e-01 -4.7658756e-01 -5.1965231e-01 -5.5809957e-01 -5.9250820e-01
+      -6.2450194e-01 -6.2323922e-01 -6.2139493e-01 -6.2045258e-01 -5.8646935e-01
+
 summary of 55 calls to hybrj1
+
+ nprob   n    nfev   njev  info  final l2 norm
+
+   1     2     16      3     1   0.0000000e+00
+   1     2      7      1     1   3.0994415e-05
+   1     2      8      1     1   0.0000000e+00
+   2     4     64      5     4   9.1213967e-18
+   2     4     57      3     4   4.3054092e-17
+   2     4     70      3     1   3.3167945e-18
+   3     2    168      6     1   4.7594266e-08
+   3     2      7      1     1   8.1905828e-06
+   4     4     84      2     1   1.4612488e-05
+   4     4    192      7     1   7.0295471e-05
+   4     4    352     27     1   8.0397449e-06
+   5     3     16      3     1   3.2887851e-06
+   5     3     19      4     1   3.6600181e-08
+   5     3     36      8     1   5.3028920e-08
+   6     6     58      6     1   1.4315057e-06
+   6     6     72      7     1   4.5457618e-06
+   6     9     85      6     1   4.4975568e-06
+   6     9    106     10     1   6.6859561e-01
+   7     5      7      1     1   3.6521178e-05
+   7     5    135     24     1   7.1370760e-06
+   7     5    108     14     4   4.7142170e+08
+   7     6     10      2     1   1.7030106e-06
+   7     6     70     14     1   5.2770069e-06
+   7     6     11      2     4   1.8755800e+14
+   7     7      9      1     1   1.7317556e-04
+   7     7    252     44     1   1.1527198e-05
+   7     7     46     12     4   5.1379834e+13
+   7     8     56      8     4   6.4404607e-02
+   7     9     18      2     1   3.3593704e-05
+   8    10      9      2     1   4.5024199e-06
+   8    10     36      6     1   1.5078915e-06
+   8    10     11      2     4   9.7656252e+16
+   8    30     18      3     1   8.9945761e-06
+   8    40     16      3     1   3.4050012e-05
+   9    10      4      1     1   2.6579430e-08
+   9    10      6      1     1   6.7943475e-08
+   9    10     30      1     1   7.0747551e-06
+  10     1      5      1     1   0.0000000e+00
+  10     1      6      1     1   1.4901161e-08
+  10     1     23      2     1   0.0000000e+00
+  10    10      6      1     1   4.5146109e-08
+  10    10      6      1     1   3.9818809e-07
+  10    10     45      3     1   9.8533917e-07
+  11    10     57      8     4   5.2958368e-03
+  11    10     31      5     1   1.5992504e-06
+  11    10     31      4     1   8.9314650e-05
+  12    10     20      1     1   3.9703064e-03
+  12    10     37      2     1   4.8075180e-04
+  12    10     58      5     1   4.5143771e-03
+  13    10      7      1     1   3.8122751e-05
+  13    10     29      2     1   4.9511334e-07
+  13    10     19      2     1   9.2025020e-06
+  14    10     11      1     1   2.0989163e-04
+  14    10     20      2     1   2.3286082e-04
+  14    10     31      2     1   7.3764968e-05
diff --git a/examples/ref/sibmdpdrc.ref b/examples/ref/sibmdpdrc.ref
new file mode 100644
index 0000000..a775382
--- /dev/null
+++ b/examples/ref/sibmdpdrc.ref
@@ -0,0 +1,42 @@
+
 MACHAR constants
+
+
+ ibeta =     2
+
+ it    =    24
+
+ irnd  =     5
+
+ ngrd  =     0
+
+ machep =   -23
+
+ negep =   -24
+
+ iexp =     8
+
+ minexp =  -126
+
+ maxexp =   128
+
+ eps =  1.1920929e-07
+
+ epsneg =  5.9604645e-08
+
+ xmin =  1.1754944e-38
+
+ xmax =  3.4028235e+38
+
+
+
+ DPMPAR constants and relative differences
+
+
+ epsmch =  1.1920929e-07
+ rerr(1) =  0.0000000e+00
+
+ dwarf =  1.1754944e-38
+ rerr(2) =  0.0000000e+00
+
+ giant =  3.4028235e+38
+ rerr(3) =  0.0000000e+00
diff --git a/examples/ref/slmddrvc.ref b/examples/ref/slmddrvc.ref
new file mode 100644
index 0000000..2257bee
--- /dev/null
+++ b/examples/ref/slmddrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -9.9999952e-01 -1.0000007e+00 -1.0000000e+00 -9.9999988e-01 -9.9999988e-01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622559e+00
+
+      final l2 norm of the residuals    6.7082019e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.0000035e+00 -1.0000026e+00 -9.9999678e-01 -9.9999905e-01 -9.9999702e-01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152188e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -2.2588153e+02 -1.1244076e+02  1.3659315e+01 -5.5720322e+01  1.2656184e+02
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016003e+03
+
+      final l2 norm of the residuals    3.4826331e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -5.4328296e+02 -2.7114148e+02  2.5691464e+02 -1.3507065e+02  1.7102687e+02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603967e+02
+
+      final l2 norm of the residuals    1.9097276e+00
+
+      number of function evaluations           4
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  2.0025868e+02 -1.5069496e+01 -8.8783112e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917312e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  2.1951398e+02 -6.2690464e+01 -6.2731403e+01  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193501e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300006e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    4.4930580e-08
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  2.8230716e-09  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.1145794e-09
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -7.0031092e-11  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126184e+02
+
+      final l2 norm of the residuals    5.6543193e-14
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  3.5527137e-15  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    2.3305191e-39
+
+      number of function evaluations          68
+
+      number of jacobian evaluations          67
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.2267928e-20 -3.2267928e-21  5.1628926e-21  5.1628926e-21
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709838e+03
+
+      final l2 norm of the residuals    6.1098873e-18
+
+      number of function evaluations          39
+
+      number of jacobian evaluations          35
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.0955804e-09 -2.0955804e-10  8.5170071e-10  8.5170071e-10
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688791e+05
+
+      final l2 norm of the residuals    2.6869068e-17
+
+      number of function evaluations          38
+
+      number of jacobian evaluations          37
+
+      exit parameter                           4
+
+      final approximate solution
+
+       3.4647418e-09 -3.4647418e-10  5.5436100e-10  5.5436100e-10
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012497e+01
+
+      final l2 norm of the residuals    6.9989629e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1467421e+01 -8.9349121e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988751e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1413025e+01 -8.9679456e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9989057e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1433799e+01 -8.9629227e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561362e+00
+
+      final l2 norm of the residuals    9.0635926e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.2411841e-02  1.1330799e+00  2.3436494e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141850e+01
+
+      final l2 norm of the residuals    4.1761765e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4089166e-01 -6.1763335e+03 -4.2086240e+03
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411469e+02
+
+      final l2 norm of the residuals    4.1747694e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066647e-01 -8.5064220e+06 -8.7856800e+06
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891504e-02
+
+      final l2 norm of the residuals    1.7536076e-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9289611e-01  1.8919709e-01  1.2262850e-01  1.3510437e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2069419e-02
+
+      number of function evaluations          45
+
+      number of jacobian evaluations          37
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.5692028e+01 -1.3921324e+01 -7.0222900e+02 -4.3778134e+02
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959064e+01
+
+      final l2 norm of the residuals    4.2413365e-02
+
+      number of function evaluations          27
+
+      number of jacobian evaluations          22
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.2699429e-01  1.9289895e+03  3.5498347e+03  1.4433916e+03
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153469e+04
+
+      final l2 norm of the residuals    9.4535589e+00
+
+      number of function evaluations         121
+
+      number of jacobian evaluations         113
+
+      exit parameter                           2
+
+      final approximate solution
+
+       5.6651235e-03  6.1731343e+03  3.4494714e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682162e+06
+
+      final l2 norm of the residuals    7.8565161e+02
+
+      number of function evaluations         400
+
+      number of jacobian evaluations         346
+
+      exit parameter                           5
+
+      final approximate solution
+
+       2.1614894e-11  3.2887129e+04  8.8951385e+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    4.7829498e-02
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5717413e-02  1.0124357e+00 -2.3299858e-01  1.2604904e+00 -1.5138190e+00
+       9.9305004e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331255e+03
+
+      final l2 norm of the residuals    4.7829639e-02
+
+      number of function evaluations          11
+
+      number of jacobian evaluations          10
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5674235e-02  1.0124398e+00 -2.3302884e-01  1.2607987e+00 -1.5142854e+00
+       9.9333340e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425606e+05
+
+      final l2 norm of the residuals    4.7829773e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5724849e-02  1.0124350e+00 -2.3299317e-01  1.2604369e+00 -1.5137382e+00
+       9.9300092e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    1.1828617e-03
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.4855133e-05  9.9978983e-01  1.4757290e-02  1.4641514e-01  1.0005054e+00
+      -2.6170321e+00  4.1035690e+00 -3.1431003e+00  1.0524997e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1829071e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.4970014e-05  9.9979007e-01  1.4766950e-02  1.4629370e-01  1.0010304e+00
+      -2.6181364e+00  4.1048002e+00 -3.1438017e+00  1.0526609e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691092e+06
+
+      final l2 norm of the residuals    1.1831208e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.3805926e-05  9.9978852e-01  1.4741883e-02  1.4663905e-01  9.9946523e-01
+      -2.6147170e+00  4.1008682e+00 -3.1415048e+00  1.0521210e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    2.0561098e-05
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -6.2324688e-09  1.0000014e+00 -5.3333642e-04  3.4717202e-01 -1.5083563e-01
+       1.0236337e+00 -3.1602321e+00  7.1247549e+00 -1.0076208e+01  8.9298401e+00
+      -4.4814916e+00  1.0013056e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220758e+04
+
+      final l2 norm of the residuals    1.9776897e-05
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -8.5890861e-08  1.0000015e+00 -5.8637606e-04  3.4815130e-01 -1.5882498e-01
+       1.0598881e+00 -3.2607327e+00  7.3020487e+00 -1.0276423e+01  9.0701962e+00
+      -4.5371962e+00  1.0108839e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    1.0051661e+01
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       2.7567571e-01  1.0304637e+00  3.5803875e-01 -1.3093984e-01  8.8270845e+00
+      -9.2631538e+01  4.7920035e+02 -1.3673835e+03  2.2844734e+03 -2.2304595e+03
+       1.1819130e+03 -2.6373825e+02
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585655e+01
+
+      final l2 norm of the residuals    1.1151858e+01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5829586e-01  2.5753188e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154382e+03
+
+      final l2 norm of the residuals    2.9317929e+02
+
+      number of function evaluations         171
+
+      number of jacobian evaluations         161
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1275230e+01  1.3089792e+01 -4.2264831e-01  2.2736965e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507331e+05
+
+      final l2 norm of the residuals    2.9298224e+02
+
+      number of function evaluations          27
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1700173e+01  1.3243497e+01 -4.1554391e-01  2.2582424e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211256e+07
+
+      final l2 norm of the residuals    2.9338193e+02
+
+      number of function evaluations          82
+
+      number of jacobian evaluations          75
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1160712e+01  1.3042220e+01 -4.2213714e-01  2.3013921e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862381e+00
+
+      final l2 norm of the residuals    1.8862381e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833446e+09
+
+      final l2 norm of the residuals    1.8842582e+00
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8180389e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842576e+00
+
+      number of function evaluations          43
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8180157e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9314549e-02
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.3417875e-02  1.9331421e-01  2.6631495e-01  4.9977866e-01  5.0022137e-01
+       7.3368502e-01  8.0668586e-01  9.5658213e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994981e-01
+
+      final l2 norm of the residuals    2.0906749e-07
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205330e-02  1.9949065e-01  2.3561913e-01  4.1604686e-01  5.0000006e-01
+       5.8395302e-01  7.6438093e-01  8.0050927e-01  9.5579463e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647513e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9669994e-02  1.6677600e-01  2.3921290e-01  3.9873391e-01  3.9908117e-01
+       6.0091877e-01  6.0126609e-01  7.6078707e-01  8.3322400e-01  9.4032997e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    2.6927846e-06
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943038e-01  9.7943038e-01  9.7943038e-01  9.7943038e-01  9.7943038e-01
+       9.7943038e-01  9.7943038e-01  9.7943038e-01  9.7943038e-01  1.2056965e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    1.8506258e-06
+
+      number of function evaluations          12
+
+      number of jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000011e+00  1.0000011e+00  1.0000011e+00  1.0000011e+00  1.0000011e+00
+       1.0000011e+00  1.0000011e+00  1.0000011e+00  1.0000011e+00  9.9999088e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656252e+16
+
+      final l2 norm of the residuals    9.9999863e-01
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          19
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.7449272e-01  1.7449291e-01  1.7449301e-01  1.7449285e-01  1.7449301e-01
+       1.7449291e-01  1.7449276e-01  1.7449296e-01  1.7449291e-01  9.2550716e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8032632e-02  5.8079064e-02  5.8082432e-02  5.8081180e-02  5.8076262e-02
+       5.8084339e-02  5.8082074e-02  5.8078259e-02  5.8086991e-02  5.8079958e-02
+       5.8082193e-02  5.8080465e-02  5.8080256e-02  5.8082253e-02  5.8080703e-02
+       5.8080018e-02  5.8079183e-02  5.8080971e-02  5.8082074e-02  5.8079869e-02
+       5.8080137e-02  5.8081180e-02  5.8081448e-02  5.8080465e-02  5.8080405e-02
+       5.8080524e-02  5.8080643e-02  5.8080852e-02  5.8080882e-02  2.9257614e+01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802637e+02
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9019017e-01  1.9026804e-01  1.9027019e-01  1.9026044e-01  1.9025868e-01
+       1.9025177e-01  1.9027010e-01  1.9027081e-01  1.9027758e-01  1.9026250e-01
+       1.9027060e-01  1.9026637e-01  1.9027019e-01  1.9025967e-01  1.9026160e-01
+       1.9026306e-01  1.9026107e-01  1.9026375e-01  1.9026193e-01  1.9026220e-01
+       1.9026378e-01  1.9026217e-01  1.9026375e-01  1.9026235e-01  1.9026411e-01
+       1.9026300e-01  1.9026360e-01  1.9026390e-01  1.9026372e-01  1.9026381e-01
+       1.9026315e-01  1.9026348e-01  1.9026312e-01  1.9026357e-01  1.9026378e-01
+       1.9026408e-01  1.9026351e-01  1.9026351e-01  1.9026360e-01  3.3389500e+01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756407e-01
+
+      final l2 norm of the residuals    7.3924954e-03
+
+      number of function evaluations          17
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541008e-01  1.9358472e+00 -1.4646875e+00  1.2867537e-02  2.2122702e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468656e+00
+
+      final l2 norm of the residuals    2.0034410e-01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          11
+
+      exit parameter                           3
+
+      final approximate solution
+
+       1.3099747e+00  4.3154839e-01  6.3365942e-01  5.9943390e-01  7.5416678e-01
+       9.0433115e-01  1.3658434e+00  4.8234978e+00  2.3986933e+00  4.5688639e+00
+       5.6753392e+00
+
 summary of 53 calls to lmder1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     3   2.2360680e+00
+    1    5   50     3     2     2   6.7082019e+00
+    2    5   10     3     2     1   1.4638501e+00
+    2    5   50     6     3     1   3.4826331e+00
+    3    5   10     4     2     1   1.9097276e+00
+    3    5   50     3     2     1   3.6917312e+00
+    4    2    2    21    16     4   0.0000000e+00
+    4    2    2     8     5     2   0.0000000e+00
+    4    2    2     6     4     2   0.0000000e+00
+    5    3    3    10     7     2   4.4930580e-08
+    5    3    3    19    14     2   1.1145794e-09
+    5    3    3    18    15     2   5.6543193e-14
+    6    4    4    68    67     4   2.3305191e-39
+    6    4    4    39    35     4   6.1098873e-18
+    6    4    4    38    37     4   2.6869068e-17
+    7    2    2     8     5     1   6.9989629e+00
+    7    2    2    16    11     1   6.9988751e+00
+    7    2    2    19    15     1   6.9989057e+00
+    8    3   15     6     5     3   9.0635926e-02
+    8    3   15     7     6     1   4.1761765e+00
+    8    3   15     5     4     1   4.1747694e+00
+    9    4   11     8     6     1   1.7536076e-02
+    9    4   11    45    37     1   3.2069419e-02
+    9    4   11    27    22     1   4.2413365e-02
+   10    3   16   121   113     2   9.4535589e+00
+   10    3   16   400   346     5   7.8565161e+02
+   11    6   31     7     6     3   4.7829498e-02
+   11    6   31    11    10     1   4.7829639e-02
+   11    6   31    15    14     2   4.7829773e-02
+   11    9   31     7     6     2   1.1828617e-03
+   11    9   31    18    14     2   1.1829071e-03
+   11    9   31    18    14     2   1.1831208e-03
+   11   12   31    11     9     2   2.0561098e-05
+   11   12   31    16    12     2   1.9776897e-05
+   11   12   31    16    10     2   1.0051661e+01
+   12    3   10     6     5     2   0.0000000e+00
+   13    2   10    15     9     1   1.1151858e+01
+   14    4   20   171   161     1   2.9317929e+02
+   14    4   20    27    20     1   2.9298224e+02
+   14    4   20    82    75     1   2.9338193e+02
+   15    1    8     1     1     4   1.8862381e+00
+   15    1    8    25    24     1   1.8842582e+00
+   15    1    8    43    42     1   1.8842576e+00
+   15    8    8    24    13     2   5.9314549e-02
+   15    9    9    11     8     2   2.0906749e-07
+   15   10   10    15     7     1   8.0647513e-02
+   16   10   10    13    11     2   2.6927846e-06
+   16   10   10    12    10     2   1.8506258e-06
+   16   10   10    21    19     1   9.9999863e-01
+   16   30   30     5     2     1   1.0000000e+00
+   16   40   40     5     2     1   1.0000000e+00
+   17    5   33    17    14     1   7.3924954e-03
+   18   11   65    15    11     3   2.0034410e-01
diff --git a/examples/ref/slmfdrvc.ref b/examples/ref/slmfdrvc.ref
new file mode 100644
index 0000000..6747c2b
--- /dev/null
+++ b/examples/ref/slmfdrvc.ref
@@ -0,0 +1,1151 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360680e+00
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -9.9976343e-01 -9.9976349e-01 -9.9976385e-01 -9.9969363e-01 -9.9976343e-01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622559e+00
+
+      final l2 norm of the residuals    6.7082057e+00
+
+      number of function evaluations           4
+
+      number of Jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.0024935e+00 -1.0024942e+00 -1.0006326e+00 -1.0024887e+00 -1.0018734e+00
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152188e+02
+
+      final l2 norm of the residuals    1.4697045e+00
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1321195e+02 -1.3362515e+00 -2.2255301e+01  1.2408030e+02 -1.0798904e+02
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016003e+03
+
+      final l2 norm of the residuals    3.4826636e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -8.1100816e-01  2.1100849e-01 -5.1226735e-01  3.9031878e-01  7.8829423e-02
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603967e+02
+
+      final l2 norm of the residuals    1.9097391e+00
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.7034796e+02  3.3046219e+01 -1.0991441e+02  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6919355e+00
+
+      number of function evaluations          11
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  3.2585971e-03  1.4245026e+00 -1.0622244e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193501e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    1.1920929e-06
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  9.9999988e-01
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300006e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    5.4542014e-08
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  3.4269760e-09  1.2747846e-19
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    4.7826476e-10
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -3.0013325e-11  5.8786309e-14
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126184e+02
+
+      final l2 norm of the residuals    1.3740234e-11
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -8.6330942e-13  2.3879553e-17
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    1.7848865e-14
+
+      number of function evaluations          41
+
+      number of Jacobian evaluations          32
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.1286673e-07 -1.1286673e-08  5.3202360e-08  5.3202360e-08
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709838e+03
+
+      final l2 norm of the residuals    1.4786386e-13
+
+      number of function evaluations          45
+
+      number of Jacobian evaluations          36
+
+      exit parameter                           2
+
+      final approximate solution
+
+       3.0675008e-07 -3.0675007e-08  9.7326804e-08  9.7326804e-08
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688791e+05
+
+      final l2 norm of the residuals    8.5951308e-16
+
+      number of function evaluations          49
+
+      number of Jacobian evaluations          43
+
+      exit parameter                           4
+
+      final approximate solution
+
+       2.4757183e-08 -2.4757183e-09  1.1695818e-08  1.1695818e-08
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012497e+01
+
+      final l2 norm of the residuals    6.9989924e+00
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1466326e+01 -8.9261216e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988756e+00
+
+      number of function evaluations          16
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412451e+01 -8.9683729e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9989395e+00
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1371325e+01 -8.9990902e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561362e+00
+
+      final l2 norm of the residuals    9.0635955e-02
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.2428202e-02  1.1335746e+00  2.3431785e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141850e+01
+
+      final l2 norm of the residuals    4.1753497e+00
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4062588e-01 -1.4753039e+04 -1.0396338e+04
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411469e+02
+
+      final l2 norm of the residuals    4.1747766e+00
+
+      number of function evaluations           5
+
+      number of Jacobian evaluations           4
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.4060788e-01 -1.5793479e+06 -2.8772775e+05
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891504e-02
+
+      final l2 norm of the residuals    1.7535927e-02
+
+      number of function evaluations           8
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9283542e-01  1.9171472e-01  1.2368494e-01  1.3618235e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2103930e-02
+
+      number of function evaluations          38
+
+      number of Jacobian evaluations          32
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.3304453e+00 -1.3606566e+01 -2.3319855e+02 -1.4522066e+02
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959064e+01
+
+      final l2 norm of the residuals    1.7535923e-02
+
+      number of function evaluations          67
+
+      number of Jacobian evaluations          53
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9281533e-01  1.9019927e-01  1.2245105e-01  1.3560534e-01
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153469e+04
+
+      final l2 norm of the residuals    1.2981203e+01
+
+      number of function evaluations         156
+
+      number of Jacobian evaluations         148
+
+      exit parameter                           2
+
+      final approximate solution
+
+       6.1575812e-03  6.1038892e+03  3.4260889e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682162e+06
+
+      final l2 norm of the residuals    2.7072710e+01
+
+      number of function evaluations         212
+
+      number of Jacobian evaluations         197
+
+      exit parameter                           5
+
+      final approximate solution
+
+       7.2689634e-03  5.9671484e+03  3.3795099e+02
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    1.7147580e-01
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.0529997e-12  9.4508231e-01  4.9917105e-01 -9.4340652e-01  1.0483757e+00
+      -1.7248490e-06
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331255e+03
+
+      final l2 norm of the residuals    4.7845893e-02
+
+      number of function evaluations          17
+
+      number of Jacobian evaluations          12
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.6249392e-02  1.0119015e+00 -2.2741006e-01  1.2410009e+00 -1.4899821e+00
+       9.8242831e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425606e+05
+
+      final l2 norm of the residuals    4.7832731e-02
+
+      number of function evaluations          20
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.6138526e-02  1.0122237e+00 -2.3128112e-01  1.2541332e+00 -1.5060322e+00
+       9.8918515e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    2.9982859e-03
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       2.2261744e-13  9.9998349e-01 -2.2112695e-04  3.4135413e-01  3.1021335e-03
+      -1.1904036e-01  8.2775009e-01 -9.8064518e-01  4.8518914e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    2.6633304e-03
+
+      number of function evaluations          24
+
+      number of Jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.4058310e-11  9.9964702e-01 -6.8555662e-04  3.6403978e-01 -8.3234496e-02
+       2.4364498e-03  7.8125983e-01 -1.0146316e+00  5.0877088e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691092e+06
+
+      final l2 norm of the residuals    5.3021852e-03
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations          17
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.8041793e-03  1.0005498e+00  2.0613239e-05  3.2092401e-01 -3.6350120e-02
+       2.7701476e-01  5.0431057e-03 -2.8397775e-01  2.6987892e-01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    3.0702035e-04
+
+      number of function evaluations          13
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.5300955e-13  1.0000889e+00 -1.0739048e-03  3.3758509e-01 -1.2078556e-02
+       1.6773212e-01 -3.8757101e-02 -2.1288041e-02  2.0308548e-01 -4.6106383e-02
+      -1.4558227e-01  1.1382063e-01
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220758e+04
+
+      final l2 norm of the residuals    1.5569972e-01
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -2.0832296e-02  1.0155444e+00 -2.5162458e-02  3.3915204e-01 -4.6169701e-01
+      -2.7113163e+00  1.1249305e+01 -1.6682754e+00 -2.5566235e+01  2.3591436e+01
+       2.3864892e-01 -4.4921432e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    7.4688956e-02
+
+      number of function evaluations          29
+
+      number of Jacobian evaluations          21
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.7378242e-03  9.8752105e-01 -1.5454113e-03 -2.3181227e-01  1.1366383e+01
+      -4.4994061e+01  1.4100939e+01  2.9605533e+02 -8.0071252e+02  9.4164886e+02
+      -5.3977161e+02  1.2311846e+02
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    3.0225415e-08
+
+      number of function evaluations           6
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  9.9999990e+00  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585655e+01
+
+      final l2 norm of the residuals    1.1151854e+01
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5829187e-01  2.5753096e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154382e+03
+
+      final l2 norm of the residuals    2.9329004e+02
+
+      number of function evaluations         163
+
+      number of Jacobian evaluations         151
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1205066e+01  1.3064331e+01 -4.1485760e-01  1.9371355e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507331e+05
+
+      final l2 norm of the residuals    2.9296634e+02
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1665783e+01  1.3230092e+01 -4.0100783e-01  2.5383824e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211256e+07
+
+      final l2 norm of the residuals    2.9299112e+02
+
+      number of function evaluations          30
+
+      number of Jacobian evaluations          25
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1481577e+01  1.3161572e+01 -4.5015016e-01  2.1535961e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862381e+00
+
+      final l2 norm of the residuals    1.8862375e+00
+
+      number of function evaluations           2
+
+      number of Jacobian evaluations           1
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.0012302e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833446e+09
+
+      final l2 norm of the residuals    1.8842816e+00
+
+      number of function evaluations          25
+
+      number of Jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8186415e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842816e+00
+
+      number of function evaluations          43
+
+      number of Jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8186445e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9324905e-02
+
+      number of function evaluations          22
+
+      number of Jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.3774646e-02  1.9385180e-01  2.6664251e-01  5.0025666e-01  5.0066817e-01
+       7.3403645e-01  8.0721664e-01  9.5695710e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994981e-01
+
+      final l2 norm of the residuals    1.3888700e-07
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205330e-02  1.9949068e-01  2.3561908e-01  4.1604689e-01  5.0000000e-01
+       5.8395308e-01  7.6438093e-01  8.0050927e-01  9.5579463e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647901e-02
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9763812e-02  1.6687962e-01  2.3938300e-01  3.9893362e-01  3.9908576e-01
+       6.0114175e-01  6.0132498e-01  7.6102966e-01  8.3343679e-01  9.4050324e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    1.0000138e+00
+
+      number of function evaluations           7
+
+      number of Jacobian evaluations           5
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -2.1667862e-01 -2.1667862e-01 -2.1667863e-01 -2.1667863e-01 -2.1667868e-01
+      -2.1667862e-01 -2.1667862e-01 -2.1667862e-01 -2.1667865e-01  1.3166784e+01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    4.0815039e-06
+
+      number of function evaluations          12
+
+      number of Jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000021e+00  1.0000021e+00  1.0000021e+00  1.0000021e+00  1.0000021e+00
+       1.0000021e+00  1.0000021e+00  1.0000021e+00  1.0000021e+00  9.9997872e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656252e+16
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations          21
+
+      number of Jacobian evaluations          19
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -6.8188533e-02 -6.8188563e-02 -6.8188526e-02 -6.8188563e-02 -6.8188526e-02
+      -6.8188563e-02 -6.8188563e-02 -6.8188563e-02 -6.8188563e-02  1.1681928e+01
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    5.9604645e-07
+
+      number of function evaluations           9
+
+      number of Jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01
+       9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01
+       9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01
+       9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01
+       9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01
+       9.9998963e-01  9.9998963e-01  9.9998963e-01  9.9998963e-01  1.0003003e+00
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802637e+02
+
+      final l2 norm of the residuals    6.7171022e-06
+
+      number of function evaluations          10
+
+      number of Jacobian evaluations           9
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00
+       1.0000079e+00  1.0000079e+00  1.0000079e+00  1.0000079e+00  9.9969280e-01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756407e-01
+
+      final l2 norm of the residuals    7.3931883e-03
+
+      number of function evaluations          19
+
+      number of Jacobian evaluations          16
+
+      exit parameter                           3
+
+      final approximate solution
+
+       3.7554947e-01  1.9523901e+00 -1.4813358e+00  1.2900786e-02  2.2056615e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468656e+00
+
+      final l2 norm of the residuals    2.0034409e-01
+
+      number of function evaluations          15
+
+      number of Jacobian evaluations          11
+
+      exit parameter                           3
+
+      final approximate solution
+
+       1.3099626e+00  4.3151525e-01  6.3364059e-01  5.9937352e-01  7.5407225e-01
+       9.0467232e-01  1.3654983e+00  4.8238635e+00  2.3986797e+00  4.5688705e+00
+       5.6753511e+00
+
 summary of 53 calls to lmdif1: 
+
+
+
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     4     3     1   2.2360680e+00
+    1    5   50     4     3     1   6.7082057e+00
+    2    5   10     6     2     2   1.4697045e+00
+    2    5   50     7     4     1   3.4826636e+00
+    3    5   10     6     2     1   1.9097391e+00
+    3    5   50    11     6     2   3.6919355e+00
+    4    2    2    22    16     2   0.0000000e+00
+    4    2    2     8     5     2   1.1920929e-06
+    4    2    2     7     5     2   0.0000000e+00
+    5    3    3    10     7     2   5.4542014e-08
+    5    3    3    19    14     2   4.7826476e-10
+    5    3    3    20    15     2   1.3740234e-11
+    6    4    4    41    32     2   1.7848865e-14
+    6    4    4    45    36     2   1.4786386e-13
+    6    4    4    49    43     4   8.5951308e-16
+    7    2    2     8     4     1   6.9989924e+00
+    7    2    2    16    11     1   6.9988756e+00
+    7    2    2    19    15     1   6.9989395e+00
+    8    3   15     6     5     1   9.0635955e-02
+    8    3   15    10     9     1   4.1753497e+00
+    8    3   15     5     4     3   4.1747766e+00
+    9    4   11     8     6     1   1.7535927e-02
+    9    4   11    38    32     1   3.2103930e-02
+    9    4   11    67    53     1   1.7535923e-02
+   10    3   16   156   148     2   1.2981203e+01
+   10    3   16   212   197     5   2.7072710e+01
+   11    6   31     7     6     1   1.7147580e-01
+   11    6   31    17    12     2   4.7845893e-02
+   11    6   31    20    16     2   4.7832731e-02
+   11    9   31    15     6     2   2.9982859e-03
+   11    9   31    24    15     2   2.6633304e-03
+   11    9   31    22    17     2   5.3021852e-03
+   11   12   31    13     9     2   3.0702035e-04
+   11   12   31    25    16     2   1.5569972e-01
+   11   12   31    29    21     2   7.4688956e-02
+   12    3   10     6     5     2   3.0225415e-08
+   13    2   10    15     9     1   1.1151854e+01
+   14    4   20   163   151     1   2.9329004e+02
+   14    4   20    25    20     1   2.9296634e+02
+   14    4   20    30    25     1   2.9299112e+02
+   15    1    8     2     1     1   1.8862375e+00
+   15    1    8    25    24     1   1.8842816e+00
+   15    1    8    43    42     1   1.8842816e+00
+   15    8    8    22    13     2   5.9324905e-02
+   15    9    9    12     8     2   1.3888700e-07
+   15   10   10    15     7     1   8.0647901e-02
+   16   10   10     7     5     3   1.0000138e+00
+   16   10   10    12    10     2   4.0815039e-06
+   16   10   10    21    19     3   1.0000000e+00
+   16   30   30     9     8     2   5.9604645e-07
+   16   40   40    10     9     2   6.7171022e-06
+   17    5   33    19    16     3   7.3931883e-03
+   18   11   65    15    11     3   2.0034409e-01
diff --git a/examples/ref/slmsdrvc.ref b/examples/ref/slmsdrvc.ref
new file mode 100644
index 0000000..7c7b13d
--- /dev/null
+++ b/examples/ref/slmsdrvc.ref
@@ -0,0 +1,1148 @@
+
+
+
+
+      problem    1      dimensions    5   10
+
+
+      initial l2 norm of the residuals  5.0000000e+00
+
+      final l2 norm of the residuals    2.2360678e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.0000002e+00 -9.9999988e-01 -9.9999988e-01 -9.9999988e-01 -9.9999988e-01
+
+
+
+
+      problem    1      dimensions    5   50
+
+
+      initial l2 norm of the residuals  8.0622559e+00
+
+      final l2 norm of the residuals    6.7082019e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -9.9999952e-01 -1.0000005e+00 -1.0000000e+00 -1.0000000e+00 -9.9999964e-01
+
+
+
+
+      problem    2      dimensions    5   10
+
+
+      initial l2 norm of the residuals  2.9152188e+02
+
+      final l2 norm of the residuals    1.4638501e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.0851965e+02  4.1267426e+02 -4.9210529e+02  2.0683719e+02 -9.6951630e+01
+
+
+
+
+      problem    2      dimensions    5   50
+
+
+      initial l2 norm of the residuals  3.1016003e+03
+
+      final l2 norm of the residuals    3.4826310e+00
+
+      number of function evaluations           9
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       4.1943604e+02  1.7581781e+02 -2.7622058e+02  8.8408958e+01 -5.9203209e+01
+
+
+
+
+      problem    3      dimensions    5   10
+
+
+      initial l2 norm of the residuals  1.2603967e+02
+
+      final l2 norm of the residuals    1.9097275e+00
+
+      number of function evaluations           3
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  3.2299553e+01 -1.3648456e+02  8.6257767e+01  1.0000000e+00
+
+
+
+
+      problem    3      dimensions    5   50
+
+
+      initial l2 norm of the residuals  1.7489500e+03
+
+      final l2 norm of the residuals    3.6917305e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           3
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.0000000e+00  1.7138905e+02 -2.1971686e+02  7.9100845e+01  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  4.9193501e+00
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations          21
+
+      number of jacobian evaluations          16
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.3400631e+03
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           5
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    4      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.4300006e+05
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           4
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  5.0000000e+01
+
+      final l2 norm of the residuals    4.4930580e-08
+
+      number of function evaluations          10
+
+      number of jacobian evaluations           7
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  2.8230716e-09  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  1.0295630e+02
+
+      final l2 norm of the residuals    1.1145794e-09
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00 -7.0031092e-11  0.0000000e+00
+
+
+
+
+      problem    5      dimensions    3    3
+
+
+      initial l2 norm of the residuals  9.9126184e+02
+
+      final l2 norm of the residuals    1.1308639e-13
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  7.1054274e-15  0.0000000e+00
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.4662878e+01
+
+      final l2 norm of the residuals    2.8699966e-39
+
+      number of function evaluations          70
+
+      number of jacobian evaluations          67
+
+      exit parameter                           4
+
+      final approximate solution
+
+       4.3987462e-20 -4.3987462e-21  1.5360878e-20  1.5360878e-20
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2709838e+03
+
+      final l2 norm of the residuals    4.3201266e-16
+
+      number of function evaluations          32
+
+      number of jacobian evaluations          31
+
+      exit parameter                           4
+
+      final approximate solution
+
+       1.1087157e-08 -1.1087157e-09  1.7739458e-09  1.7739457e-09
+
+
+
+
+      problem    6      dimensions    4    4
+
+
+      initial l2 norm of the residuals  1.2688791e+05
+
+      final l2 norm of the residuals    6.1333960e-17
+
+      number of function evaluations          45
+
+      number of jacobian evaluations          39
+
+      exit parameter                           2
+
+      final approximate solution
+
+       3.4415706e-09 -3.4415706e-10  5.7483118e-10  5.7483118e-10
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  2.0012497e+01
+
+      final l2 norm of the residuals    6.9989629e+00
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1467422e+01 -8.9349121e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.2432834e+04
+
+      final l2 norm of the residuals    6.9988751e+00
+
+      number of function evaluations          16
+
+      number of jacobian evaluations          11
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1412983e+01 -8.9679766e-01
+
+
+
+
+      problem    7      dimensions    2    2
+
+
+      initial l2 norm of the residuals  1.1426455e+07
+
+      final l2 norm of the residuals    6.9989057e+00
+
+      number of function evaluations          19
+
+      number of jacobian evaluations          15
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.1433800e+01 -8.9629221e-01
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  6.4561362e+00
+
+      final l2 norm of the residuals    9.0635970e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           3
+
+      final approximate solution
+
+       8.2411885e-02  1.1330806e+00  2.3436489e+00
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.6141850e+01
+
+      final l2 norm of the residuals    4.1761765e+00
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4089172e-01 -6.1763193e+03 -4.2086387e+03
+
+
+
+
+      problem    8      dimensions    3   15
+
+
+      initial l2 norm of the residuals  3.8411469e+02
+
+      final l2 norm of the residuals    4.1747694e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           4
+
+      exit parameter                           1
+
+      final approximate solution
+
+       8.4066653e-01 -8.5064220e+06 -8.7856840e+06
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  7.2891504e-02
+
+      final l2 norm of the residuals    1.7536076e-02
+
+      number of function evaluations           8
+
+      number of jacobian evaluations           6
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9289610e-01  1.8919730e-01  1.2262843e-01  1.3510448e-01
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9793701e+00
+
+      final l2 norm of the residuals    3.2069419e-02
+
+      number of function evaluations          45
+
+      number of jacobian evaluations          37
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.5689885e+01 -1.3921293e+01 -7.0213147e+02 -4.3772058e+02
+
+
+
+
+      problem    9      dimensions    4   11
+
+
+      initial l2 norm of the residuals  2.9959064e+01
+
+      final l2 norm of the residuals    4.2497460e-02
+
+      number of function evaluations          28
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+       7.9770422e-01  1.1258904e+03  3.8749358e+03  1.5724391e+03
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1153469e+04
+
+      final l2 norm of the residuals    9.4501982e+00
+
+      number of function evaluations         121
+
+      number of jacobian evaluations         113
+
+      exit parameter                           2
+
+      final approximate solution
+
+       5.6615476e-03  6.1736577e+03  3.4496469e+02
+
+
+
+
+      problem   10      dimensions    3   16
+
+
+      initial l2 norm of the residuals  4.1682162e+06
+
+      final l2 norm of the residuals    8.6503448e+02
+
+      number of function evaluations         210
+
+      number of jacobian evaluations         166
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.2790576e-13  4.3503070e+04  1.0339773e+03
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    4.7829513e-02
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5785452e-02  1.0124278e+00 -2.3294121e-01  1.2599717e+00 -1.5130415e+00
+       9.9258274e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.4331255e+03
+
+      final l2 norm of the residuals    4.7829743e-02
+
+      number of function evaluations          11
+
+      number of jacobian evaluations          10
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.5674004e-02  1.0124398e+00 -2.3302841e-01  1.2607979e+00 -1.5142845e+00
+       9.9333328e-01
+
+
+
+
+      problem   11      dimensions    6   31
+
+
+      initial l2 norm of the residuals  6.7425606e+05
+
+      final l2 norm of the residuals    4.7829483e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          14
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5728218e-02  1.0124344e+00 -2.3298804e-01  1.2604046e+00 -1.5136923e+00
+       9.9297494e-01
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    1.1828358e-03
+
+      number of function evaluations           7
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5260997e-05  9.9978966e-01  1.4763309e-02  1.4633828e-01  1.0008550e+00
+      -2.6178274e+00  4.1045370e+00 -3.1437044e+00  1.0526515e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2088127e+04
+
+      final l2 norm of the residuals    1.1821783e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          14
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.5707890e-05  9.9979013e-01  1.4759362e-02  1.4636689e-01  1.0007401e+00
+      -2.6176071e+00  4.1043191e+00 -3.1435957e+00  1.0526295e+00
+
+
+
+
+      problem   11      dimensions    9   31
+
+
+      initial l2 norm of the residuals  1.2691092e+06
+
+      final l2 norm of the residuals    1.1831152e-03
+
+      number of function evaluations          18
+
+      number of jacobian evaluations          15
+
+      exit parameter                           3
+
+      final approximate solution
+
+      -1.5323640e-05  9.9978966e-01  1.4769566e-02  1.4627734e-01  1.0011417e+00
+      -2.6185443e+00  4.1055059e+00 -3.1443701e+00  1.0528333e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  5.4772258e+00
+
+      final l2 norm of the residuals    1.8917617e-05
+
+      number of function evaluations          14
+
+      number of jacobian evaluations          10
+
+      exit parameter                           2
+
+      final approximate solution
+
+       2.7236624e-08  1.0000017e+00 -5.7436200e-04  3.4799814e-01 -1.5793957e-01
+       1.0569109e+00 -3.2540383e+00  7.2908320e+00 -1.0261942e+01  9.0569487e+00
+      -4.5299549e+00  1.0091665e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  1.9220758e+04
+
+      final l2 norm of the residuals    2.0489091e-05
+
+      number of function evaluations          23
+
+      number of jacobian evaluations          16
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -1.3459449e-09  1.0000014e+00 -5.4893835e-04  3.4771207e-01 -1.5713821e-01
+       1.0601681e+00 -3.2817526e+00  7.3718801e+00 -1.0388937e+01  9.1702709e+00
+      -4.5843325e+00  1.0200843e+00
+
+
+
+
+      problem   11      dimensions   12   31
+
+
+      initial l2 norm of the residuals  2.0189180e+06
+
+      final l2 norm of the residuals    1.9193252e-05
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          18
+
+      exit parameter                           2
+
+      final approximate solution
+
+      -7.2524244e-09  1.0000015e+00 -5.5030826e-04  3.4753999e-01 -1.5410925e-01
+       1.0391998e+00 -3.2043118e+00  7.2027102e+00 -1.0163090e+01  8.9890957e+00
+      -4.5040555e+00  1.0049767e+00
+
+
+
+
+      problem   12      dimensions    3   10
+
+
+      initial l2 norm of the residuals  3.2111584e+01
+
+      final l2 norm of the residuals    0.0000000e+00
+
+      number of function evaluations           6
+
+      number of jacobian evaluations           5
+
+      exit parameter                           2
+
+      final approximate solution
+
+       1.0000000e+00  1.0000000e+01  1.0000000e+00
+
+
+
+
+      problem   13      dimensions    2   10
+
+
+      initial l2 norm of the residuals  6.4585655e+01
+
+      final l2 norm of the residuals    1.1151857e+01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations           9
+
+      exit parameter                           1
+
+      final approximate solution
+
+       2.5829542e-01  2.5753230e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  2.8154382e+03
+
+      final l2 norm of the residuals    2.9332809e+02
+
+      number of function evaluations         163
+
+      number of jacobian evaluations         153
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1185437e+01  1.3057540e+01 -3.9446104e-01  2.5670618e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  5.5507331e+05
+
+      final l2 norm of the residuals    2.9298209e+02
+
+      number of function evaluations          27
+
+      number of jacobian evaluations          20
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1700037e+01  1.3243442e+01 -4.1518396e-01  2.2605659e-01
+
+
+
+
+      problem   14      dimensions    4   20
+
+
+      initial l2 norm of the residuals  6.1211256e+07
+
+      final l2 norm of the residuals    2.9351437e+02
+
+      number of function evaluations          77
+
+      number of jacobian evaluations          70
+
+      exit parameter                           1
+
+      final approximate solution
+
+      -1.1096786e+01  1.3018889e+01 -4.3165925e-01  2.2452404e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.8862381e+00
+
+      final l2 norm of the residuals    1.8862381e+00
+
+      number of function evaluations           1
+
+      number of jacobian evaluations           1
+
+      exit parameter                           4
+
+      final approximate solution
+
+       5.0000000e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  5.3833446e+09
+
+      final l2 norm of the residuals    1.8842582e+00
+
+      number of function evaluations          25
+
+      number of jacobian evaluations          24
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8180389e-01
+
+
+
+
+      problem   15      dimensions    1    8
+
+
+      initial l2 norm of the residuals  1.1808873e+18
+
+      final l2 norm of the residuals    1.8842576e+00
+
+      number of function evaluations          43
+
+      number of jacobian evaluations          42
+
+      exit parameter                           1
+
+      final approximate solution
+
+       9.8180157e-01
+
+
+
+
+      problem   15      dimensions    8    8
+
+
+      initial l2 norm of the residuals  1.9651386e-01
+
+      final l2 norm of the residuals    5.9314556e-02
+
+      number of function evaluations          24
+
+      number of jacobian evaluations          13
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.3417852e-02  1.9331416e-01  2.6631495e-01  4.9977845e-01  5.0022149e-01
+       7.3368502e-01  8.0668581e-01  9.5658213e-01
+
+
+
+
+      problem   15      dimensions    9    9
+
+
+      initial l2 norm of the residuals  1.6994981e-01
+
+      final l2 norm of the residuals    1.8384672e-07
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           8
+
+      exit parameter                           2
+
+      final approximate solution
+
+       4.4205341e-02  1.9949065e-01  2.3561911e-01  4.1604692e-01  4.9999997e-01
+       5.8395314e-01  7.6438087e-01  8.0050933e-01  9.5579463e-01
+
+
+
+
+      problem   15      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.8374783e-01
+
+      final l2 norm of the residuals    8.0647521e-02
+
+      number of function evaluations          15
+
+      number of jacobian evaluations           7
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.9669998e-02  1.6677602e-01  2.3921293e-01  3.9873415e-01  3.9908096e-01
+       6.0091907e-01  6.0126579e-01  7.6078707e-01  8.3322400e-01  9.4033003e-01
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  1.6530216e+01
+
+      final l2 norm of the residuals    7.3323404e-06
+
+      number of function evaluations          13
+
+      number of jacobian evaluations          11
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943157e-01  9.7943157e-01  9.7943157e-01  9.7943157e-01  9.7943157e-01
+       9.7943157e-01  9.7943157e-01  9.7943157e-01  9.7943157e-01  1.2056828e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656240e+06
+
+      final l2 norm of the residuals    2.1490760e-06
+
+      number of function evaluations          11
+
+      number of jacobian evaluations           6
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943056e-01  9.7943056e-01  9.7943056e-01  9.7943056e-01  9.7943056e-01
+       9.7943056e-01  9.7943056e-01  9.7943056e-01  9.7943056e-01  1.2056941e+00
+
+
+
+
+      problem   16      dimensions   10   10
+
+
+      initial l2 norm of the residuals  9.7656252e+16
+
+      final l2 norm of the residuals    3.2186508e-06
+
+      number of function evaluations          27
+
+      number of jacobian evaluations          24
+
+      exit parameter                           2
+
+      final approximate solution
+
+       9.7943068e-01  9.7943068e-01  9.7943068e-01  9.7943068e-01  9.7943068e-01
+       9.7943068e-01  9.7943068e-01  9.7943068e-01  9.7943068e-01  1.2056929e+00
+
+
+
+
+      problem   16      dimensions   30   30
+
+
+      initial l2 norm of the residuals  8.3476044e+01
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       5.8075756e-02  5.8079898e-02  5.8076262e-02  5.8075994e-02  5.8081031e-02
+       5.8079571e-02  5.8078527e-02  5.8078557e-02  5.8077991e-02  5.8077097e-02
+       5.8077246e-02  5.8078468e-02  5.8078647e-02  5.8079422e-02  5.8080673e-02
+       5.8081597e-02  5.8080912e-02  5.8079839e-02  5.8081508e-02  5.8081090e-02
+       5.8080584e-02  5.8079034e-02  5.8078319e-02  5.8078527e-02  5.8077723e-02
+       5.8082163e-02  5.8080882e-02  5.8081627e-02  5.8080912e-02  2.9257618e+01
+
+
+
+
+      problem   16      dimensions   40   40
+
+
+      initial l2 norm of the residuals  1.2802637e+02
+
+      final l2 norm of the residuals    1.0000000e+00
+
+      number of function evaluations           5
+
+      number of jacobian evaluations           2
+
+      exit parameter                           1
+
+      final approximate solution
+
+       1.9025487e-01  1.9025970e-01  1.9025639e-01  1.9025964e-01  1.9025838e-01
+       1.9025806e-01  1.9025996e-01  1.9025758e-01  1.9025901e-01  1.9025990e-01
+       1.9026136e-01  1.9026092e-01  1.9026023e-01  1.9026068e-01  1.9026110e-01
+       1.9026366e-01  1.9026342e-01  1.9026312e-01  1.9026724e-01  1.9026667e-01
+       1.9026598e-01  1.9026518e-01  1.9026449e-01  1.9026557e-01  1.9026402e-01
+       1.9026694e-01  1.9026604e-01  1.9026515e-01  1.9026524e-01  1.9026613e-01
+       1.9026697e-01  1.9026595e-01  1.9026276e-01  1.9026285e-01  1.9026273e-01
+       1.9026479e-01  1.9026396e-01  1.9026420e-01  1.9026211e-01  3.3389492e+01
+
+
+
+
+      problem   17      dimensions    5   33
+
+
+      initial l2 norm of the residuals  9.3756407e-01
+
+      final l2 norm of the residuals    7.3924293e-03
+
+      number of function evaluations          17
+
+      number of jacobian evaluations          14
+
+      exit parameter                           1
+
+      final approximate solution
+
+       3.7541005e-01  1.9358462e+00 -1.4646864e+00  1.2867534e-02  2.2122702e-02
+
+
+
+
+      problem   18      dimensions   11   65
+
+
+      initial l2 norm of the residuals  1.4468656e+00
+
+      final l2 norm of the residuals    2.0034409e-01
+
+      number of function evaluations          15
+
+      number of jacobian evaluations          11
+
+      exit parameter                           3
+
+      final approximate solution
+
+       1.3099747e+00  4.3154839e-01  6.3365942e-01  5.9943390e-01  7.5416678e-01
+       9.0433097e-01  1.3658432e+00  4.8234982e+00  2.3986933e+00  4.5688639e+00
+       5.6753392e+00
+
 summary of 53 calls to lmstr1
+ nprob   n    m   nfev  njev  info  final L2 norm 
+
+    1    5   10     3     2     3   2.2360678e+00
+    1    5   50     3     2     3   6.7082019e+00
+    2    5   10     5     3     1   1.4638501e+00
+    2    5   50     9     3     1   3.4826310e+00
+    3    5   10     3     2     1   1.9097275e+00
+    3    5   50     8     3     1   3.6917305e+00
+    4    2    2    21    16     4   0.0000000e+00
+    4    2    2     7     5     4   0.0000000e+00
+    4    2    2     6     4     2   0.0000000e+00
+    5    3    3    10     7     2   4.4930580e-08
+    5    3    3    19    14     2   1.1145794e-09
+    5    3    3    18    15     2   1.1308639e-13
+    6    4    4    70    67     4   2.8699966e-39
+    6    4    4    32    31     4   4.3201266e-16
+    6    4    4    45    39     2   6.1333960e-17
+    7    2    2     8     5     1   6.9989629e+00
+    7    2    2    16    11     1   6.9988751e+00
+    7    2    2    19    15     1   6.9989057e+00
+    8    3   15     6     5     3   9.0635970e-02
+    8    3   15     7     6     1   4.1761765e+00
+    8    3   15     5     4     1   4.1747694e+00
+    9    4   11     8     6     1   1.7536076e-02
+    9    4   11    45    37     1   3.2069419e-02
+    9    4   11    28    20     1   4.2497460e-02
+   10    3   16   121   113     2   9.4501982e+00
+   10    3   16   210   166     2   8.6503448e+02
+   11    6   31     6     5     1   4.7829513e-02
+   11    6   31    11    10     1   4.7829743e-02
+   11    6   31    15    14     3   4.7829483e-02
+   11    9   31     7     6     2   1.1828358e-03
+   11    9   31    18    14     2   1.1821783e-03
+   11    9   31    18    15     3   1.1831152e-03
+   11   12   31    14    10     2   1.8917617e-05
+   11   12   31    23    16     2   2.0489091e-05
+   11   12   31    25    18     2   1.9193252e-05
+   12    3   10     6     5     2   0.0000000e+00
+   13    2   10    15     9     1   1.1151857e+01
+   14    4   20   163   153     1   2.9332809e+02
+   14    4   20    27    20     1   2.9298209e+02
+   14    4   20    77    70     1   2.9351437e+02
+   15    1    8     1     1     4   1.8862381e+00
+   15    1    8    25    24     1   1.8842582e+00
+   15    1    8    43    42     1   1.8842576e+00
+   15    8    8    24    13     2   5.9314556e-02
+   15    9    9    11     8     2   1.8384672e-07
+   15   10   10    15     7     1   8.0647521e-02
+   16   10   10    13    11     2   7.3323404e-06
+   16   10   10    11     6     2   2.1490760e-06
+   16   10   10    27    24     2   3.2186508e-06
+   16   30   30     5     2     1   1.0000000e+00
+   16   40   40     5     2     1   1.0000000e+00
+   17    5   33    17    14     1   7.3924293e-03
+   18   11   65    15    11     3   2.0034409e-01
diff --git a/examples/ref/stchkderc.ref b/examples/ref/stchkderc.ref
new file mode 100644
index 0000000..34af61d
--- /dev/null
+++ b/examples/ref/stchkderc.ref
@@ -0,0 +1,22 @@
+
+      fvec
+
+           -1.181606      -1.429655      -1.606344
+           -1.745269      -1.840654      -1.921586
+           -1.984141      -2.022537      -2.468976
+           -2.827562      -3.473582      -4.437612
+           -6.047661      -9.267761      -18.91806
+      fvecp - fvec
+
+       -0.0001790524  -7.963181e-05  -4.768372e-06
+        5.352497e-05   9.989738e-05   0.0001385212
+        0.0001702309   0.0001974106   0.0003447533
+        0.0005407333   0.0008158684    0.001227856
+         0.001914024    0.003288269    0.007408142
+      err
+
+           0.2581466      0.2248907              0
+           0.2256959      0.2429258      0.2760358
+           0.3457333              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/stfdjac2c.ref b/examples/ref/stfdjac2c.ref
new file mode 100644
index 0000000..764b578
--- /dev/null
+++ b/examples/ref/stfdjac2c.ref
@@ -0,0 +1,29 @@
+
+      fvec
+
+           -1.181606      -1.429655      -1.606344
+           -1.745269      -1.840654      -1.921586
+           -1.984141      -2.022537      -2.468976
+           -2.827562      -3.473582      -4.437612
+           -6.047661      -9.267761      -18.91806
+      fvecp - fvec
+
+       -0.0001790524  -7.963181e-05  -4.768372e-06
+        5.352497e-05   9.989738e-05   0.0001385212
+        0.0001702309   0.0001974106   0.0003447533
+        0.0005407333   0.0008158684    0.001227856
+         0.001914024    0.003288269    0.007408142
+      errd
+
+                   1              1              0
+                   1              1      0.9949697
+                   1              1              1
+                   1              1              1
+                   1              1              1
+      err
+
+                   1              1              0
+                   1      0.9952511              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/sthybrd1c.ref b/examples/ref/sthybrd1c.ref
new file mode 100644
index 0000000..f702484
--- /dev/null
+++ b/examples/ref/sthybrd1c.ref
@@ -0,0 +1,7 @@
+     final L2 norm of the residuals    3.500863e-05
+     exit parameter                          1
+     final approximates solution
+
+          -0.5706489     -0.6816254     -0.7017328
+          -0.7042154     -0.7013723     -0.6918683
+          -0.6657927     -0.5960336     -0.4164145
diff --git a/examples/ref/sthybrdc.ref b/examples/ref/sthybrdc.ref
new file mode 100644
index 0000000..6468396
--- /dev/null
+++ b/examples/ref/sthybrdc.ref
@@ -0,0 +1,11 @@
+     final l2 norm of the residuals    3.500863e-05
+
+     number of function evaluations          10
+
+     exit parameter                           1
+
+     final approximate solution
+
+          -0.5706489     -0.6816254     -0.7017328
+          -0.7042154     -0.7013723     -0.6918683
+          -0.6657927     -0.5960336     -0.4164145
diff --git a/examples/ref/sthybrj1c.ref b/examples/ref/sthybrj1c.ref
new file mode 100644
index 0000000..f1c26c3
--- /dev/null
+++ b/examples/ref/sthybrj1c.ref
@@ -0,0 +1,9 @@
+      final l2 norm of the residuals   3.519986e-05
+
+      exit parameter                         1
+
+      final approximate solution
+
+          -0.5706488     -0.6816254     -0.7017328
+          -0.7042154     -0.7013724     -0.6918683
+          -0.6657928     -0.5960336     -0.4164144
diff --git a/examples/ref/sthybrjc.ref b/examples/ref/sthybrjc.ref
new file mode 100644
index 0000000..2775770
--- /dev/null
+++ b/examples/ref/sthybrjc.ref
@@ -0,0 +1,14 @@
+     final l2 norm of the residuals   3.519986e-05
+
+     number of function evaluations         7
+
+     number of jacobian evaluations         1
+
+     exit parameter                         1
+
+     final approximate solution
+
+
+          -0.5706488     -0.6816254     -0.7017328
+          -0.7042154     -0.7013724     -0.6918683
+          -0.6657928     -0.5960336     -0.4164144
diff --git a/examples/ref/stlmder1c.ref b/examples/ref/stlmder1c.ref
new file mode 100644
index 0000000..17f3543
--- /dev/null
+++ b/examples/ref/stlmder1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063593
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08241184        1.13308       2.343649
diff --git a/examples/ref/stlmderc.ref b/examples/ref/stlmderc.ref
new file mode 100644
index 0000000..6119aa6
--- /dev/null
+++ b/examples/ref/stlmderc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09063593
+
+      number of function evaluations         6
+
+      number of Jacobian evaluations         5
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08241184        1.13308       2.343649
+      covariance
+
+        0.0001531201     0.00286994    -0.00265666
+          0.00286994     0.09480933    -0.09098993
+         -0.00265666    -0.09098993     0.08778727
diff --git a/examples/ref/stlmdif1c.ref b/examples/ref/stlmdif1c.ref
new file mode 100644
index 0000000..47d1f78
--- /dev/null
+++ b/examples/ref/stlmdif1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+       0.0824282       1.133575       2.343179
diff --git a/examples/ref/stlmdifc.ref b/examples/ref/stlmdifc.ref
new file mode 100644
index 0000000..794dec0
--- /dev/null
+++ b/examples/ref/stlmdifc.ref
@@ -0,0 +1,14 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations        21
+
+      exit parameter                         1
+
+      final approximate solution
+
+           0.0824282       1.133575       2.343179
+      covariance
+
+        0.0001531442    0.002870449   -0.002656704
+         0.002870449     0.09489396    -0.09106711
+        -0.002656704    -0.09106711     0.08785866
diff --git a/examples/ref/stlmstr1c.ref b/examples/ref/stlmstr1c.ref
new file mode 100644
index 0000000..b9e4eeb
--- /dev/null
+++ b/examples/ref/stlmstr1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063597
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08241189       1.133081       2.343649
diff --git a/examples/ref/stlmstrc.ref b/examples/ref/stlmstrc.ref
new file mode 100644
index 0000000..8aa9766
--- /dev/null
+++ b/examples/ref/stlmstrc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09063597
+
+      number of function evaluations         6
+
+      number of Jacobian evaluations         5
+
+      exit parameter                         3
+
+      final approximate solution
+
+          0.08241189       1.133081       2.343649
+      covariance
+
+        0.0001531202    0.002869945   -0.002656665
+         0.002869945      0.0948096    -0.09099019
+        -0.002656665    -0.09099019     0.08778751
diff --git a/examples/ref/tchkder.ref b/examples/ref/tchkder.ref
new file mode 100644
index 0000000..f3c6892
--- /dev/null
+++ b/examples/ref/tchkder.ref
@@ -0,0 +1,24 @@
+
+      FVEC
+
+      -0.1181606D+01 -0.1429655D+01 -0.1606344D+01
+      -0.1745269D+01 -0.1840654D+01 -0.1921586D+01
+      -0.1984141D+01 -0.2022537D+01 -0.2468977D+01
+      -0.2827562D+01 -0.3473582D+01 -0.4437612D+01
+      -0.6047662D+01 -0.9267761D+01 -0.1891806D+02
+
+      FVECP - FVEC
+
+      -0.7724666D-08 -0.3432406D-08 -0.2034843D-09
+       0.2313685D-08  0.4331078D-08  0.5984096D-08
+       0.7363281D-08  0.8531470D-08  0.1488591D-07
+       0.2335850D-07  0.3522012D-07  0.5301255D-07
+       0.8266660D-07  0.1419747D-06  0.3198990D-06
+
+      ERR
+
+       0.1141397D+00  0.9943516D-01  0.9674474D-01
+       0.9980447D-01  0.1073116D+00  0.1220445D+00
+       0.1526814D+00  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01
+       0.1000000D+01  0.1000000D+01  0.1000000D+01
diff --git a/examples/ref/tchkderc.ref b/examples/ref/tchkderc.ref
new file mode 100644
index 0000000..b5ede83
--- /dev/null
+++ b/examples/ref/tchkderc.ref
@@ -0,0 +1,22 @@
+
+      fvec
+
+           -1.181606      -1.429655      -1.606344
+           -1.745269      -1.840654      -1.921586
+           -1.984141      -2.022537      -2.468977
+           -2.827562      -3.473582      -4.437612
+           -6.047662      -9.267761      -18.91806
+      fvecp - fvec
+
+       -7.724666e-09  -3.432406e-09  -2.034843e-10
+        2.313685e-09   4.331078e-09   5.984096e-09
+        7.363281e-09    8.53147e-09   1.488591e-08
+         2.33585e-08   3.522012e-08   5.301255e-08
+         8.26666e-08   1.419747e-07    3.19899e-07
+      err
+
+           0.1141397     0.09943516     0.09674474
+          0.09980447      0.1073116      0.1220445
+           0.1526814              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/tchkderc_box.ref b/examples/ref/tchkderc_box.ref
new file mode 100644
index 0000000..72619f3
--- /dev/null
+++ b/examples/ref/tchkderc_box.ref
@@ -0,0 +1,22 @@
+
+      fvec
+
+          -0.9829917      -1.111746      -1.214351
+           -1.306448      -1.372163      -1.434587
+           -1.486078      -1.518468      -1.820838
+           -1.987333      -2.364425      -2.925063
+           -3.862792      -5.738252      -11.35463
+      fvecp - fvec
+
+       -1.293763e-08   -1.22842e-08  -1.167235e-08
+       -1.110506e-08  -1.058151e-08  -1.009919e-08
+       -9.654869e-09  -9.245207e-09   -7.99478e-09
+       -6.327543e-09  -3.993411e-09  -4.922138e-10
+        5.343114e-09   1.701377e-08   5.202574e-08
+      err
+
+           0.2393293      0.2130632      0.2026053
+           0.2000738      0.2031623      0.2144393
+           0.2422281              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/tfdjac2c.ref b/examples/ref/tfdjac2c.ref
new file mode 100644
index 0000000..f5c43e2
--- /dev/null
+++ b/examples/ref/tfdjac2c.ref
@@ -0,0 +1,29 @@
+
+      fvec
+
+           -1.181606      -1.429655      -1.606344
+           -1.745269      -1.840654      -1.921586
+           -1.984141      -2.022537      -2.468977
+           -2.827562      -3.473582      -4.437612
+           -6.047662      -9.267761      -18.91806
+      fvecp - fvec
+
+       -7.724666e-09  -3.432406e-09  -2.034843e-10
+        2.313685e-09   4.331078e-09   5.984096e-09
+        7.363281e-09    8.53147e-09   1.488591e-08
+         2.33585e-08   3.522012e-08   5.301255e-08
+         8.26666e-08   1.419747e-07    3.19899e-07
+      errd
+
+                   1              1              1
+                   1       0.995393              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
+      err
+
+                   1              1              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
+                   1              1              1
diff --git a/examples/ref/thybrd.ref b/examples/ref/thybrd.ref
new file mode 100644
index 0000000..b17853f
--- /dev/null
+++ b/examples/ref/thybrd.ref
@@ -0,0 +1,11 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+
+      NUMBER OF FUNCTION EVALUATIONS        14
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+      -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+      -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+      -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
diff --git a/examples/ref/thybrd1.ref b/examples/ref/thybrd1.ref
new file mode 100644
index 0000000..11babd0
--- /dev/null
+++ b/examples/ref/thybrd1.ref
@@ -0,0 +1,9 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+      -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+      -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+      -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
diff --git a/examples/ref/thybrd1c.ref b/examples/ref/thybrd1c.ref
new file mode 100644
index 0000000..27a8c48
--- /dev/null
+++ b/examples/ref/thybrd1c.ref
@@ -0,0 +1,7 @@
+     final L2 norm of the residuals    1.192636e-08
+     exit parameter                          1
+     final approximates solution
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/thybrdc.ref b/examples/ref/thybrdc.ref
new file mode 100644
index 0000000..43c1f6e
--- /dev/null
+++ b/examples/ref/thybrdc.ref
@@ -0,0 +1,11 @@
+     final l2 norm of the residuals    1.192636e-08
+
+     number of function evaluations          14
+
+     exit parameter                           1
+
+     final approximate solution
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/thybrj.ref b/examples/ref/thybrj.ref
new file mode 100644
index 0000000..887db95
--- /dev/null
+++ b/examples/ref/thybrj.ref
@@ -0,0 +1,13 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+
+      NUMBER OF FUNCTION EVALUATIONS        11
+
+      NUMBER OF JACOBIAN EVALUATIONS         1
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+      -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+      -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+      -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
diff --git a/examples/ref/thybrj1.ref b/examples/ref/thybrj1.ref
new file mode 100644
index 0000000..11babd0
--- /dev/null
+++ b/examples/ref/thybrj1.ref
@@ -0,0 +1,9 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.1192636D-07
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+      -0.5706545D+00 -0.6816283D+00 -0.7017325D+00
+      -0.7042129D+00 -0.7013690D+00 -0.6918656D+00
+      -0.6657920D+00 -0.5960342D+00 -0.4164121D+00
diff --git a/examples/ref/thybrj1c.ref b/examples/ref/thybrj1c.ref
new file mode 100644
index 0000000..07e5df4
--- /dev/null
+++ b/examples/ref/thybrj1c.ref
@@ -0,0 +1,9 @@
+      final l2 norm of the residuals   1.192636e-08
+
+      exit parameter                         1
+
+      final approximate solution
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/thybrjc.ref b/examples/ref/thybrjc.ref
new file mode 100644
index 0000000..5230f8b
--- /dev/null
+++ b/examples/ref/thybrjc.ref
@@ -0,0 +1,14 @@
+     final l2 norm of the residuals   1.192636e-08
+
+     number of function evaluations        11
+
+     number of jacobian evaluations         1
+
+     exit parameter                         1
+
+     final approximate solution
+
+
+          -0.5706545     -0.6816283     -0.7017325
+          -0.7042129      -0.701369     -0.6918656
+           -0.665792     -0.5960342     -0.4164121
diff --git a/examples/ref/thybrjc_box.ref b/examples/ref/thybrjc_box.ref
new file mode 100644
index 0000000..fda26ac
--- /dev/null
+++ b/examples/ref/thybrjc_box.ref
@@ -0,0 +1,14 @@
+     final l2 norm of the residuals      0.7585268
+
+     number of function evaluations        21
+
+     number of jacobian evaluations         2
+
+     exit parameter                         5
+
+     final approximate solution
+
+
+          -0.4715775           -0.5     -0.6075997
+          -0.6912395      -0.715058     -0.7148161
+           -0.689358      -0.613326     -0.4219724
diff --git a/examples/ref/tlmder.ref b/examples/ref/tlmder.ref
new file mode 100644
index 0000000..1d35b78
--- /dev/null
+++ b/examples/ref/tlmder.ref
@@ -0,0 +1,11 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+
+      NUMBER OF FUNCTION EVALUATIONS         6
+
+      NUMBER OF JACOBIAN EVALUATIONS         5
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
diff --git a/examples/ref/tlmder1.ref b/examples/ref/tlmder1.ref
new file mode 100644
index 0000000..856f10a
--- /dev/null
+++ b/examples/ref/tlmder1.ref
@@ -0,0 +1,7 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
diff --git a/examples/ref/tlmder1c.ref b/examples/ref/tlmder1c.ref
new file mode 100644
index 0000000..82f918e
--- /dev/null
+++ b/examples/ref/tlmder1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
diff --git a/examples/ref/tlmderc.ref b/examples/ref/tlmderc.ref
new file mode 100644
index 0000000..d025513
--- /dev/null
+++ b/examples/ref/tlmderc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations         6
+
+      number of Jacobian evaluations         5
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
+      covariance
+
+        0.0001531202    0.002869941   -0.002656662
+         0.002869941     0.09480935    -0.09098995
+        -0.002656662    -0.09098995     0.08778727
diff --git a/examples/ref/tlmderc_box.ref b/examples/ref/tlmderc_box.ref
new file mode 100644
index 0000000..d1a91e5
--- /dev/null
+++ b/examples/ref/tlmderc_box.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09071386
+
+      number of function evaluations        10
+
+      number of Jacobian evaluations         9
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08371095       1.178309            2.3
+      covariance
+
+        0.0001536684    0.002994926             -0
+         0.002994926      0.1026389             -0
+                  -0             -0              0
diff --git a/examples/ref/tlmdif.ref b/examples/ref/tlmdif.ref
new file mode 100644
index 0000000..7cd8901
--- /dev/null
+++ b/examples/ref/tlmdif.ref
@@ -0,0 +1,9 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+
+      NUMBER OF FUNCTION EVALUATIONS        21
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
diff --git a/examples/ref/tlmdif1.ref b/examples/ref/tlmdif1.ref
new file mode 100644
index 0000000..856f10a
--- /dev/null
+++ b/examples/ref/tlmdif1.ref
@@ -0,0 +1,7 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
diff --git a/examples/ref/tlmdif1c.ref b/examples/ref/tlmdif1c.ref
new file mode 100644
index 0000000..a432b90
--- /dev/null
+++ b/examples/ref/tlmdif1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+      0.08241058       1.133037       2.343695
diff --git a/examples/ref/tlmdifc.ref b/examples/ref/tlmdifc.ref
new file mode 100644
index 0000000..bdcd0d7
--- /dev/null
+++ b/examples/ref/tlmdifc.ref
@@ -0,0 +1,14 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations        21
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
+      covariance
+
+        0.0001531202    0.002869941   -0.002656662
+         0.002869941     0.09480935    -0.09098995
+        -0.002656662    -0.09098995     0.08778728
diff --git a/examples/ref/tlmstr.ref b/examples/ref/tlmstr.ref
new file mode 100644
index 0000000..1d35b78
--- /dev/null
+++ b/examples/ref/tlmstr.ref
@@ -0,0 +1,11 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+
+      NUMBER OF FUNCTION EVALUATIONS         6
+
+      NUMBER OF JACOBIAN EVALUATIONS         5
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
diff --git a/examples/ref/tlmstr1.ref b/examples/ref/tlmstr1.ref
new file mode 100644
index 0000000..856f10a
--- /dev/null
+++ b/examples/ref/tlmstr1.ref
@@ -0,0 +1,7 @@
+      FINAL L2 NORM OF THE RESIDUALS  0.9063596D-01
+
+      EXIT PARAMETER                         1
+
+      FINAL APPROXIMATE SOLUTION
+
+       0.8241058D-01  0.1133037D+01  0.2343695D+01
diff --git a/examples/ref/tlmstr1c.ref b/examples/ref/tlmstr1c.ref
new file mode 100644
index 0000000..82f918e
--- /dev/null
+++ b/examples/ref/tlmstr1c.ref
@@ -0,0 +1,7 @@
+      final l2 norm of the residuals     0.09063596
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
diff --git a/examples/ref/tlmstrc.ref b/examples/ref/tlmstrc.ref
new file mode 100644
index 0000000..d025513
--- /dev/null
+++ b/examples/ref/tlmstrc.ref
@@ -0,0 +1,16 @@
+      final l2 norm of the residuals     0.09063596
+
+      number of function evaluations         6
+
+      number of Jacobian evaluations         5
+
+      exit parameter                         1
+
+      final approximate solution
+
+          0.08241058       1.133037       2.343695
+      covariance
+
+        0.0001531202    0.002869941   -0.002656662
+         0.002869941     0.09480935    -0.09098995
+        -0.002656662    -0.09098995     0.08778727
diff --git a/examples/runtest.cmake b/examples/runtest.cmake
new file mode 100644
index 0000000..84222e6
--- /dev/null
+++ b/examples/runtest.cmake
@@ -0,0 +1,34 @@
+# Replace INTDIR with the value of $ENV{CMAKE_CONFIG_TYPE} that is set
+# by ctest when -C Debug|Releaes|etc is given, and INDIR is passed
+# in from the main cmake run and is the variable that is used
+# by the build system to specify the build directory
+if(NOT "${INTDIR}" STREQUAL ".")
+  set(TEST_ORIG "${TEST}")
+  string(REPLACE "${INTDIR}" "$ENV{CMAKE_CONFIG_TYPE}" TEST "${TEST}")
+  if("$ENV{CMAKE_CONFIG_TYPE}" STREQUAL "")
+    if(NOT EXISTS "${TEST}")
+      message("Warning: CMAKE_CONFIG_TYPE not defined did you forget the -C option for ctest?")
+      message(FATAL_ERROR "Could not find test executable: ${TEST_ORIG}")
+    endif()
+  endif()
+endif()
+set(ARGS )
+set(ARGS OUTPUT_FILE "${OUTPUT}"  ERROR_FILE "${OUTPUT}.err")
+message("Running: ${TEST}")
+message("ARGS= ${ARGS}")
+execute_process(COMMAND "${TEST}" 
+  ${ARGS}
+  RESULT_VARIABLE RET)
+# if the test does not return 0, then fail it
+if(NOT ${RET} EQUAL 0)
+  message(FATAL_ERROR "Test ${TEST} returned ${RET}")
+endif()
+# result with reference
+execute_process(COMMAND "${CMAKE_COMMAND}"
+  -E compare_files  "${OUTPUT}" "${REFERENCE}"
+  RESULT_VARIABLE RET)
+# if the test does not return 0, then fail it
+if(NOT ${RET} EQUAL 0)
+  message(FATAL_ERROR "Test ${TEST} produced a result which is different from the reference}")
+endif()
+message( "Test ${TEST} returned ${RET}")
diff --git a/examples/ssq.h b/examples/ssq.h
new file mode 100644
index 0000000..8a7a9b3
--- /dev/null
+++ b/examples/ssq.h
@@ -0,0 +1,19 @@
+#ifndef __CMINPACK_SSQ_H__
+#define __CMINPACK_SSQ_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void lmdipt(int n, __cminpack_real__ *x, int nprob, __cminpack_real__ factor);
+
+void ssqfcn(int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int nprob);
+
+void ssqjac(int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fjac, int ldfjac, int nprob);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __CMINPACK_SSQ_H__ */
diff --git a/examples/ssqfcn.c b/examples/ssqfcn.c
new file mode 100644
index 0000000..fa78b56
--- /dev/null
+++ b/examples/ssqfcn.c
@@ -0,0 +1,345 @@
+#include <math.h>
+#include "cminpack.h"
+#include "ssq.h"
+#define real __cminpack_real__
+
+void ssqfcn(int m, int n, const real *x, real *fvec, int nprob)
+{
+    /* Initialized data */
+
+    const real v[11] = { 4.,2.,1.,.5,.25,.167,.125,.1,.0833,.0714, .0625 };
+    const real y1[15] = { .14,.18,.22,.25,.29,.32,.35,.39,.37,.58,.73,
+	    .96,1.34,2.1,4.39 };
+    const real y2[11] = { .1957,.1947,.1735,.16,.0844,.0627,.0456,
+	    .0342,.0323,.0235,.0246 };
+    const real y3[16] = { 34780.,28610.,23650.,19630.,16370.,13720.,
+	    11540.,9744.,8261.,7030.,6005.,5147.,4427.,3820.,3307.,2872. };
+    const real y4[33] = { .844,.908,.932,.936,.925,.908,.881,.85,.818,
+	    .784,.751,.718,.685,.658,.628,.603,.58,.558,.538,.522,.506,.49,
+	    .478,.467,.457,.448,.438,.431,.424,.42,.414,.411,.406 };
+    const real y5[65] = { 1.366,1.191,1.112,1.013,.991,.885,.831,.847,
+	    .786,.725,.746,.679,.608,.655,.616,.606,.602,.626,.651,.724,.649,
+	    .649,.694,.644,.624,.661,.612,.558,.533,.495,.5,.423,.395,.375,
+	    .372,.391,.396,.405,.428,.429,.523,.562,.607,.653,.672,.708,.633,
+	    .668,.645,.632,.591,.559,.597,.625,.739,.71,.729,.72,.636,.581,
+	    .428,.292,.162,.098,.054 };
+
+    /* System generated locals */
+    real d__1;
+
+    /* Local variables */
+    static int i, j;
+    static real s1, s2, dx, ti;
+    static int nm1;
+    static real div;
+    static int iev;
+    static real tpi, sum, tmp1, tmp2, tmp3, tmp4, prod, temp;
+
+/*     ********** */
+
+/*     subroutine ssqfcn */
+
+/*     this subroutine defines the functions of eighteen nonlinear */
+/*     least squares problems. the allowable values of (m,n) for */
+/*     functions 1,2 and 3 are variable but with m .ge. n. */
+/*     for functions 4,5,6,7,8,9 and 10 the values of (m,n) are */
+/*     (2,2),(3,3),(4,4),(2,2),(15,3),(11,4) and (16,3), respectively. */
+/*     function 11 (watson) has m = 31 with n usually 6 or 9. */
+/*     however, any n, n = 2,...,31, is permitted. */
+/*     functions 12,13 and 14 have n = 3,2 and 4, respectively, but */
+/*     allow any m .ge. n, with the usual choices being 10,10 and 20. */
+/*     function 15 (chebyquad) allows m and n variable with m .ge. n. */
+/*     function 16 (brown) allows n variable with m = n. */
+/*     for functions 17 and 18, the values of (m,n) are */
+/*     (33,5) and (65,11), respectively. */
+
+/*     the subroutine statement is */
+
+/*       subroutine ssqfcn(m,n,x,fvec,nprob) */
+
+/*     where */
+
+/*       m and n are positive integer input variables. n must not */
+/*         exceed m. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an output array of length m which contains the nprob */
+/*         function evaluated at x. */
+
+/*       nprob is a positive integer input variable which defines the */
+/*         number of the problem. nprob must not exceed 18. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... datan,dcos,dexp,dsin,dsqrt,dsign */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --x;
+
+    /* Function Body */
+
+/*     function routine selector. */
+
+    switch (nprob) {
+
+/*     linear function - full rank. */
+
+        case 1:
+            sum = 0.;
+            for (j = 1; j <= n; ++j) {
+                sum += x[j];
+            }
+            temp = 2. * sum / (real) (m) + 1.;
+            for (i = 1; i <= m; ++i) {
+                fvec[i] = -temp;
+                if (i <= n) {
+                    fvec[i] += x[i];
+                }
+            }
+            break;
+
+/*     linear function - rank 1. */
+
+        case 2:
+            sum = 0.;
+            for (j = 1; j <= n; ++j) {
+                sum += (real) j * x[j];
+            }
+            for (i = 1; i <= m; ++i) {
+                fvec[i] = (real) i * sum - 1.;
+            }
+            break;
+
+/*     linear function - rank 1 with zero columns and rows. */
+
+        case 3:
+            sum = 0.;
+            nm1 = n - 1;
+            if (nm1 >= 2) {
+                for (j = 2; j <= nm1; ++j) {
+                    sum += (real) j * x[j];
+                }
+            }
+            for (i = 1; i <= m; ++i) {
+                fvec[i] = (real) (i - 1) * sum - 1.;
+            }
+            fvec[m] = -1.;
+            break;
+
+/*     rosenbrock function. */
+
+        case 4:
+            fvec[1] = 10. * (x[2] - x[1] * x[1]);
+            fvec[2] = 1. - x[1];
+            break;
+
+/*     helical valley function. */
+
+        case 5:
+            tpi = 8. * atan(1.);
+            tmp1 = x[2] < 0. ? -.25 : .25;
+            if (x[1] > 0.) {
+                tmp1 = atan(x[2] / x[1]) / tpi;
+            }
+            if (x[1] < 0.) {
+                tmp1 = atan(x[2] / x[1]) / tpi + .5;
+            }
+            tmp2 = sqrt(x[1] * x[1] + x[2] * x[2]);
+            fvec[1] = 10. * (x[3] - 10. * tmp1);
+            fvec[2] = 10. * (tmp2 - 1.);
+            fvec[3] = x[3];
+            break;
+
+/*     powell singular function. */
+
+        case 6:
+            fvec[1] = x[1] + 10. * x[2];
+            fvec[2] = sqrt(5.) * (x[3] - x[4]);
+            /* Computing 2nd power */
+            d__1 = x[2] - 2. * x[3];
+            fvec[3] = d__1 * d__1;
+            /* Computing 2nd power */
+            d__1 = x[1] - x[4];
+            fvec[4] = sqrt(10.) * (d__1 * d__1);
+            break;
+
+/*     freudenstein and roth function. */
+
+        case 7:
+            fvec[1] = -13. + x[1] + ((5. - x[2]) * x[2] - 2.) * x[2];
+            fvec[2] = -29. + x[1] + ((1. + x[2]) * x[2] - 14.) * x[2];
+            break;
+
+/*     bard function. */
+
+        case 8:
+            for (i = 1; i <= 15; ++i) {
+                tmp1 = (real) i;
+                tmp2 = (real) (16 - i);
+                tmp3 = tmp1;
+                if (i > 8) {
+                    tmp3 = tmp2;
+                }
+                fvec[i] = y1[i - 1] - (x[1] + tmp1 / (x[2] * tmp2 + x[3] * tmp3));
+            }
+            break;
+
+/*     kowalik and osborne function. */
+
+        case 9:
+            for (i = 1; i <= 11; ++i) {
+                tmp1 = v[i - 1] * (v[i - 1] + x[2]);
+                tmp2 = v[i - 1] * (v[i - 1] + x[3]) + x[4];
+                fvec[i] = y2[i - 1] - x[1] * tmp1 / tmp2;
+            }
+            break;
+
+/*     meyer function. */
+
+        case 10:
+            for (i = 1; i <= 16; ++i) {
+                temp = 5. * (real) i + 45. + x[3];
+                tmp1 = x[2] / temp;
+                tmp2 = exp(tmp1);
+                fvec[i] = x[1] * tmp2 - y3[i - 1];
+            }
+            break;
+
+/*     watson function. */
+
+        case 11:
+            for (i = 1; i <= 29; ++i) {
+                div = (real) i / 29.;
+                s1 = 0.;
+                dx = 1.;
+                for (j = 2; j <= n; ++j) {
+                    s1 += (real) (j - 1) * dx * x[j];
+                    dx = div * dx;
+                }
+                s2 = 0.;
+                dx = 1.;
+                for (j = 1; j <= n; ++j) {
+                    s2 += dx * x[j];
+                    dx = div * dx;
+                }
+                fvec[i] = s1 - s2 * s2 - 1.;
+            }
+            fvec[30] = x[1];
+            fvec[31] = x[2] - x[1] * x[1] - 1.;
+            break;
+
+/*     box 3-dimensional function. */
+
+        case 12:
+            for (i = 1; i <= m; ++i) {
+                temp = (real) i;
+                tmp1 = temp / 10.;
+                fvec[i] = exp(-tmp1 * x[1]) - exp(-tmp1 * x[2]) + (exp(-temp) - exp(-tmp1)) * x[3];
+            }
+            break;
+
+/*     jennrich and sampson function. */
+
+        case 13:
+            for (i = 1; i <= m; ++i) {
+                temp = (real) i;
+                fvec[i] = 2. + 2. * temp - exp(temp * x[1]) - exp(temp * x[2]);
+            }
+            break;
+
+/*     brown and dennis function. */
+
+        case 14:
+            for (i = 1; i <= m; ++i) {
+                temp = (real) i / 5.;
+                tmp1 = x[1] + temp * x[2] - exp(temp);
+                tmp2 = x[3] + sin(temp) * x[4] - cos(temp);
+                fvec[i] = tmp1 * tmp1 + tmp2 * tmp2;
+            }
+            break;
+
+/*     chebyquad function. */
+
+        case 15:
+            for (i = 1; i <= m; ++i) {
+                fvec[i] = 0.;
+            }
+            for (j = 1; j <= n; ++j) {
+                tmp1 = 1.;
+                tmp2 = 2. * x[j] - 1.;
+                temp = 2. * tmp2;
+                for (i = 1; i <= m; ++i) {
+                    fvec[i] += tmp2;
+                    ti = temp * tmp2 - tmp1;
+                    tmp1 = tmp2;
+                    tmp2 = ti;
+                }
+            }
+            dx = 1. / (real) (n);
+            iev = -1;
+            for (i = 1; i <= m; ++i) {
+                fvec[i] = dx * fvec[i];
+                if (iev > 0) {
+                    fvec[i] += 1. / (i * i - 1.);
+                }
+                iev = -iev;
+            }
+            break;
+
+/*     brown almost-linear function. */
+
+        case 16:
+            sum = -((real) (n + 1));
+            prod = 1.;
+            for (j = 1; j <= n; ++j) {
+                sum += x[j];
+                prod = x[j] * prod;
+            }
+            for (i = 1; i <= n; ++i) {
+                fvec[i] = x[i] + sum;
+            }
+            fvec[n] = prod - 1.;
+            break;
+
+/*     osborne 1 function. */
+
+        case 17:
+            for (i = 1; i <= 33; ++i) {
+                temp = 10. * (real) (i - 1);
+                tmp1 = exp(-x[4] * temp);
+                tmp2 = exp(-x[5] * temp);
+                fvec[i] = y4[i - 1] - (x[1] + x[2] * tmp1 + x[3] * tmp2);
+            }
+            break;
+
+/*     osborne 2 function. */
+
+        case 18:
+            for (i = 1; i <= 65; ++i) {
+                temp = (real) (i - 1) / 10.;
+                tmp1 = exp(-x[5] * temp);
+                /* Computing 2nd power */
+                d__1 = temp - x[9];
+                tmp2 = exp(-x[6] * (d__1 * d__1));
+                /* Computing 2nd power */
+                d__1 = temp - x[10];
+                tmp3 = exp(-x[7] * (d__1 * d__1));
+                /* Computing 2nd power */
+                d__1 = temp - x[11];
+                tmp4 = exp(-x[8] * (d__1 * d__1));
+                fvec[i] = y5[i - 1] - (x[1] * tmp1 + x[2] * tmp2 + x[3] * tmp3 + x[4] * tmp4);
+            }
+            break;
+    }
+
+
+/*     last card of subroutine ssqfcn. */
+
+} /* ssqfcn_ */
+
diff --git a/examples/ssqfcn.f b/examples/ssqfcn.f
new file mode 100644
index 0000000..828c8d1
--- /dev/null
+++ b/examples/ssqfcn.f
@@ -0,0 +1,340 @@
+      subroutine ssqfcn(m,n,x,fvec,nprob)
+      integer m,n,nprob
+      double precision x(n),fvec(m)
+c     **********
+c
+c     subroutine ssqfcn
+c
+c     this subroutine defines the functions of eighteen nonlinear
+c     least squares problems. the allowable values of (m,n) for
+c     functions 1,2 and 3 are variable but with m .ge. n.
+c     for functions 4,5,6,7,8,9 and 10 the values of (m,n) are
+c     (2,2),(3,3),(4,4),(2,2),(15,3),(11,4) and (16,3), respectively.
+c     function 11 (watson) has m = 31 with n usually 6 or 9.
+c     however, any n, n = 2,...,31, is permitted.
+c     functions 12,13 and 14 have n = 3,2 and 4, respectively, but
+c     allow any m .ge. n, with the usual choices being 10,10 and 20.
+c     function 15 (chebyquad) allows m and n variable with m .ge. n.
+c     function 16 (brown) allows n variable with m = n.
+c     for functions 17 and 18, the values of (m,n) are
+c     (33,5) and (65,11), respectively.
+c
+c     the subroutine statement is
+c
+c       subroutine ssqfcn(m,n,x,fvec,nprob)
+c
+c     where
+c
+c       m and n are positive integer input variables. n must not
+c         exceed m.
+c
+c       x is an input array of length n.
+c
+c       fvec is an output array of length m which contains the nprob
+c         function evaluated at x.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c     subprograms called
+c
+c       fortran-supplied ... datan,dcos,dexp,dsin,dsqrt,dsign
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iev,ivar,j,nm1
+      double precision c13,c14,c29,c45,div,dx,eight,five,one,prod,sum,
+     *                 s1,s2,temp,ten,ti,tmp1,tmp2,tmp3,tmp4,tpi,two,
+     *                 zero,zp25,zp5
+      double precision v(11),y1(15),y2(11),y3(16),y4(33),y5(65)
+      double precision dfloat
+      data zero,zp25,zp5,one,two,five,eight,ten,c13,c14,c29,c45
+     *     /0.0d0,2.5d-1,5.0d-1,1.0d0,2.0d0,5.0d0,8.0d0,1.0d1,1.3d1,
+     *      1.4d1,2.9d1,4.5d1/
+      data v(1),v(2),v(3),v(4),v(5),v(6),v(7),v(8),v(9),v(10),v(11)
+     *     /4.0d0,2.0d0,1.0d0,5.0d-1,2.5d-1,1.67d-1,1.25d-1,1.0d-1,
+     *      8.33d-2,7.14d-2,6.25d-2/
+      data y1(1),y1(2),y1(3),y1(4),y1(5),y1(6),y1(7),y1(8),y1(9),
+     *     y1(10),y1(11),y1(12),y1(13),y1(14),y1(15)
+     *     /1.4d-1,1.8d-1,2.2d-1,2.5d-1,2.9d-1,3.2d-1,3.5d-1,3.9d-1,
+     *      3.7d-1,5.8d-1,7.3d-1,9.6d-1,1.34d0,2.1d0,4.39d0/
+      data y2(1),y2(2),y2(3),y2(4),y2(5),y2(6),y2(7),y2(8),y2(9),
+     *     y2(10),y2(11)
+     *     /1.957d-1,1.947d-1,1.735d-1,1.6d-1,8.44d-2,6.27d-2,4.56d-2,
+     *      3.42d-2,3.23d-2,2.35d-2,2.46d-2/
+      data y3(1),y3(2),y3(3),y3(4),y3(5),y3(6),y3(7),y3(8),y3(9),
+     *     y3(10),y3(11),y3(12),y3(13),y3(14),y3(15),y3(16)
+     *     /3.478d4,2.861d4,2.365d4,1.963d4,1.637d4,1.372d4,1.154d4,
+     *      9.744d3,8.261d3,7.03d3,6.005d3,5.147d3,4.427d3,3.82d3,
+     *      3.307d3,2.872d3/
+      data y4(1),y4(2),y4(3),y4(4),y4(5),y4(6),y4(7),y4(8),y4(9),
+     *     y4(10),y4(11),y4(12),y4(13),y4(14),y4(15),y4(16),y4(17),
+     *     y4(18),y4(19),y4(20),y4(21),y4(22),y4(23),y4(24),y4(25),
+     *     y4(26),y4(27),y4(28),y4(29),y4(30),y4(31),y4(32),y4(33)
+     *     /8.44d-1,9.08d-1,9.32d-1,9.36d-1,9.25d-1,9.08d-1,8.81d-1,
+     *      8.5d-1,8.18d-1,7.84d-1,7.51d-1,7.18d-1,6.85d-1,6.58d-1,
+     *      6.28d-1,6.03d-1,5.8d-1,5.58d-1,5.38d-1,5.22d-1,5.06d-1,
+     *      4.9d-1,4.78d-1,4.67d-1,4.57d-1,4.48d-1,4.38d-1,4.31d-1,
+     *      4.24d-1,4.2d-1,4.14d-1,4.11d-1,4.06d-1/
+      data y5(1),y5(2),y5(3),y5(4),y5(5),y5(6),y5(7),y5(8),y5(9),
+     *     y5(10),y5(11),y5(12),y5(13),y5(14),y5(15),y5(16),y5(17),
+     *     y5(18),y5(19),y5(20),y5(21),y5(22),y5(23),y5(24),y5(25),
+     *     y5(26),y5(27),y5(28),y5(29),y5(30),y5(31),y5(32),y5(33),
+     *     y5(34),y5(35),y5(36),y5(37),y5(38),y5(39),y5(40),y5(41),
+     *     y5(42),y5(43),y5(44),y5(45),y5(46),y5(47),y5(48),y5(49),
+     *     y5(50),y5(51),y5(52),y5(53),y5(54),y5(55),y5(56),y5(57),
+     *     y5(58),y5(59),y5(60),y5(61),y5(62),y5(63),y5(64),y5(65)
+     *     /1.366d0,1.191d0,1.112d0,1.013d0,9.91d-1,8.85d-1,8.31d-1,
+     *      8.47d-1,7.86d-1,7.25d-1,7.46d-1,6.79d-1,6.08d-1,6.55d-1,
+     *      6.16d-1,6.06d-1,6.02d-1,6.26d-1,6.51d-1,7.24d-1,6.49d-1,
+     *      6.49d-1,6.94d-1,6.44d-1,6.24d-1,6.61d-1,6.12d-1,5.58d-1,
+     *      5.33d-1,4.95d-1,5.0d-1,4.23d-1,3.95d-1,3.75d-1,3.72d-1,
+     *      3.91d-1,3.96d-1,4.05d-1,4.28d-1,4.29d-1,5.23d-1,5.62d-1,
+     *      6.07d-1,6.53d-1,6.72d-1,7.08d-1,6.33d-1,6.68d-1,6.45d-1,
+     *      6.32d-1,5.91d-1,5.59d-1,5.97d-1,6.25d-1,7.39d-1,7.1d-1,
+     *      7.29d-1,7.2d-1,6.36d-1,5.81d-1,4.28d-1,2.92d-1,1.62d-1,
+     *      9.8d-2,5.4d-2/
+      dfloat(ivar) = ivar
+c
+c     function routine selector.
+c
+      go to (10,40,70,110,120,130,140,150,170,190,210,250,270,290,310,
+     *       360,390,410), nprob
+c
+c     linear function - full rank.
+c
+   10 continue
+      sum = zero
+      do 20 j = 1, n
+         sum = sum + x(j)
+   20    continue
+      temp = two*sum/dfloat(m) + one
+      do 30 i = 1, m
+         fvec(i) = -temp
+         if (i .le. n) fvec(i) = fvec(i) + x(i)
+   30    continue
+      go to 430
+c
+c     linear function - rank 1.
+c
+   40 continue
+      sum = zero
+      do 50 j = 1, n
+         sum = sum + dfloat(j)*x(j)
+   50    continue
+      do 60 i = 1, m
+         fvec(i) = dfloat(i)*sum - one
+   60    continue
+      go to 430
+c
+c     linear function - rank 1 with zero columns and rows.
+c
+   70 continue
+      sum = zero
+      nm1 = n - 1
+      if (nm1 .lt. 2) go to 90
+      do 80 j = 2, nm1
+         sum = sum + dfloat(j)*x(j)
+   80    continue
+   90 continue
+      do 100 i = 1, m
+         fvec(i) = dfloat(i-1)*sum - one
+  100    continue
+      fvec(m) = -one
+      go to 430
+c
+c     rosenbrock function.
+c
+  110 continue
+      fvec(1) = ten*(x(2) - x(1)**2)
+      fvec(2) = one - x(1)
+      go to 430
+c
+c     helical valley function.
+c
+  120 continue
+      tpi = eight*datan(one)
+      tmp1 = dsign(zp25,x(2))
+      if (x(1) .gt. zero) tmp1 = datan(x(2)/x(1))/tpi
+      if (x(1) .lt. zero) tmp1 = datan(x(2)/x(1))/tpi + zp5
+      tmp2 = dsqrt(x(1)**2+x(2)**2)
+      fvec(1) = ten*(x(3) - ten*tmp1)
+      fvec(2) = ten*(tmp2 - one)
+      fvec(3) = x(3)
+      go to 430
+c
+c     powell singular function.
+c
+  130 continue
+      fvec(1) = x(1) + ten*x(2)
+      fvec(2) = dsqrt(five)*(x(3) - x(4))
+      fvec(3) = (x(2) - two*x(3))**2
+      fvec(4) = dsqrt(ten)*(x(1) - x(4))**2
+      go to 430
+c
+c     freudenstein and roth function.
+c
+  140 continue
+      fvec(1) = -c13 + x(1) + ((five - x(2))*x(2) - two)*x(2)
+      fvec(2) = -c29 + x(1) + ((one + x(2))*x(2) - c14)*x(2)
+      go to 430
+c
+c     bard function.
+c
+  150 continue
+      do 160 i = 1, 15
+         tmp1 = dfloat(i)
+         tmp2 = dfloat(16-i)
+         tmp3 = tmp1
+         if (i .gt. 8) tmp3 = tmp2
+         fvec(i) = y1(i) - (x(1) + tmp1/(x(2)*tmp2 + x(3)*tmp3))
+  160    continue
+      go to 430
+c
+c     kowalik and osborne function.
+c
+  170 continue
+      do 180 i = 1, 11
+         tmp1 = v(i)*(v(i) + x(2))
+         tmp2 = v(i)*(v(i) + x(3)) + x(4)
+         fvec(i) = y2(i) - x(1)*tmp1/tmp2
+  180    continue
+      go to 430
+c
+c     meyer function.
+c
+  190 continue
+      do 200 i = 1, 16
+         temp = five*dfloat(i) + c45 + x(3)
+         tmp1 = x(2)/temp
+         tmp2 = dexp(tmp1)
+         fvec(i) = x(1)*tmp2 - y3(i)
+  200    continue
+      go to 430
+c
+c     watson function.
+c
+  210 continue
+      do 240 i = 1, 29
+         div = dfloat(i)/c29
+         s1 = zero
+         dx = one
+         do 220 j = 2, n
+            s1 = s1 + dfloat(j-1)*dx*x(j)
+            dx = div*dx
+  220       continue
+         s2 = zero
+         dx = one
+         do 230 j = 1, n
+            s2 = s2 + dx*x(j)
+            dx = div*dx
+  230       continue
+         fvec(i) = s1 - s2**2 - one
+  240    continue
+      fvec(30) = x(1)
+      fvec(31) = x(2) - x(1)**2 - one
+      go to 430
+c
+c     box 3-dimensional function.
+c
+  250 continue
+      do 260 i = 1, m
+         temp = dfloat(i)
+         tmp1 = temp/ten
+         fvec(i) = dexp(-tmp1*x(1)) - dexp(-tmp1*x(2))
+     *             + (dexp(-temp) - dexp(-tmp1))*x(3)
+  260    continue
+      go to 430
+c
+c     jennrich and sampson function.
+c
+  270 continue
+      do 280 i = 1, m
+         temp = dfloat(i)
+         fvec(i) = two + two*temp - dexp(temp*x(1)) - dexp(temp*x(2))
+  280    continue
+      go to 430
+c
+c     brown and dennis function.
+c
+  290 continue
+      do 300 i = 1, m
+         temp = dfloat(i)/five
+         tmp1 = x(1) + temp*x(2) - dexp(temp)
+         tmp2 = x(3) + dsin(temp)*x(4) - dcos(temp)
+         fvec(i) = tmp1**2 + tmp2**2
+  300    continue
+      go to 430
+c
+c     chebyquad function.
+c
+  310 continue
+      do 320 i = 1, m
+         fvec(i) = zero
+  320    continue
+      do 340 j = 1, n
+         tmp1 = one
+         tmp2 = two*x(j) - one
+         temp = two*tmp2
+         do 330 i = 1, m
+            fvec(i) = fvec(i) + tmp2
+            ti = temp*tmp2 - tmp1
+            tmp1 = tmp2
+            tmp2 = ti
+  330       continue
+  340    continue
+      dx = one/dfloat(n)
+      iev = -1
+      do 350 i = 1, m
+         fvec(i) = dx*fvec(i)
+         if (iev .gt. 0) fvec(i) = fvec(i) + one/(dfloat(i)**2 - one)
+         iev = -iev
+  350    continue
+      go to 430
+c
+c     brown almost-linear function.
+c
+  360 continue
+      sum = -dfloat(n+1)
+      prod = one
+      do 370 j = 1, n
+         sum = sum + x(j)
+         prod = x(j)*prod
+  370    continue
+      do 380 i = 1, n
+         fvec(i) = x(i) + sum
+  380    continue
+      fvec(n) = prod - one
+      go to 430
+c
+c     osborne 1 function.
+c
+  390 continue
+      do 400 i = 1, 33
+         temp = ten*dfloat(i-1)
+         tmp1 = dexp(-x(4)*temp)
+         tmp2 = dexp(-x(5)*temp)
+         fvec(i) = y4(i) - (x(1) + x(2)*tmp1 + x(3)*tmp2)
+  400    continue
+      go to 430
+c
+c     osborne 2 function.
+c
+  410 continue
+      do 420 i = 1, 65
+         temp = dfloat(i-1)/ten
+         tmp1 = dexp(-x(5)*temp)
+         tmp2 = dexp(-x(6)*(temp-x(9))**2)
+         tmp3 = dexp(-x(7)*(temp-x(10))**2)
+         tmp4 = dexp(-x(8)*(temp-x(11))**2)
+         fvec(i) = y5(i)
+     *             - (x(1)*tmp1 + x(2)*tmp2 + x(3)*tmp3 + x(4)*tmp4)
+  420    continue
+  430 continue
+      return
+c
+c     last card of subroutine ssqfcn.
+c
+      end
diff --git a/examples/ssqjac.c b/examples/ssqjac.c
new file mode 100644
index 0000000..5df9291
--- /dev/null
+++ b/examples/ssqjac.c
@@ -0,0 +1,390 @@
+#include <math.h>
+#include "cminpack.h"
+#include "ssq.h"
+#define real __cminpack_real__
+
+void ssqjac(int m, int n, const real *x, real *fjac, int ldfjac, int nprob)
+{
+    /* Initialized data */
+
+    const real v[11] = { 4.,2.,1.,.5,.25,.167,.125,.1,.0833,.0714, .0625 };
+
+    /* System generated locals */
+    real d__1;
+
+    /* Local variables */
+    int i, j, k;
+    real s2, dx, ti;
+    int mm1, nm1;
+    real div, tpi, tmp1, tmp2, tmp3, tmp4, prod, temp;
+
+/*     ********** */
+
+/*     subroutine ssqjac */
+
+/*     this subroutine defines the jacobian matrices of eighteen */
+/*     nonlinear least squares problems. the problem dimensions are */
+/*     as described in the prologue comments of ssqfcn. */
+
+/*     the subroutine statement is */
+
+/*       subroutine ssqjac(m,n,x,fjac,ldfjac,nprob) */
+
+/*     where */
+
+/*       m and n are positive int input variables. n must not */
+/*         exceed m. */
+
+/*       x is an input array of length n. */
+
+/*       fjac is an m by n output array which contains the jacobian */
+/*         matrix of the nprob function evaluated at x. */
+
+/*       ldfjac is a positive int input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       nprob is a positive int variable which defines the */
+/*         number of the problem. nprob must not exceed 18. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... datan,dcos,dexp,dsin,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+    fjac -= 1 + ldfjac;
+
+    /* Function Body */
+
+/*     jacobian routine selector. */
+
+    switch (nprob) {
+
+/*     linear function - full rank. */
+
+        case 1:
+            temp = 2. / (real) m;
+            for (j = 1; j <= n; ++j) {
+                for (i = 1; i <= m; ++i) {
+                    fjac[i + j * ldfjac] = -temp;
+                }
+                fjac[j + j * ldfjac] += 1.;
+            }
+            break;
+
+/*     linear function - rank 1. */
+
+        case 2:
+            for (j = 1; j <= n; ++j) {
+                for (i = 1; i <= m; ++i) {
+                    fjac[i + j * ldfjac] = (real) i * (real) j;
+                }
+            }
+            break;
+
+/*     linear function - rank 1 with zero columns and rows. */
+
+        case 3:
+            for (j = 1; j <= n; ++j) {
+                for (i = 1; i <= m; ++i) {
+                    fjac[i + j * ldfjac] = 0.;
+                }
+            }
+#if 0
+    if (nm1 < 2) {
+	goto L120;
+    }
+    for (j = 2; j <= nm1; ++j) {
+	i__2 = mm1;
+	for (i__ = 2; i__ <= mm1; ++i__) {
+	    i__3 = i__ - 1;
+	    fjac[i__ + j * fjac_dim1] = (doublereal) i__3 * (doublereal) j;
+/* L100: */
+	}
+/* L110: */
+    }
+L120:
+#else
+            nm1 = n - 1;
+            mm1 = m - 1;
+            if (nm1 >= 2) {
+                for (j = 2; j <= nm1; ++j) {
+                    for (i = 2; i <= mm1; ++i) {
+                        fjac[i + j * ldfjac] = (real) (i - 1) * (real) j;
+                    }
+                }
+            }
+#endif
+            break;
+
+/*     rosenbrock function. */
+
+        case 4:
+            fjac[1 + 1 * ldfjac] = -20. * x[1];
+            fjac[1 + 2 * ldfjac] = 10.;
+            fjac[2 + 1 * ldfjac] = -1.;
+            fjac[2 + 2 * ldfjac] = 0.;
+            break;
+
+/*     helical valley function. */
+
+        case 5:
+            tpi = 8. * atan(1.);
+            temp = x[1] * x[1] + x[2] * x[2];
+            tmp1 = tpi * temp;
+            tmp2 = sqrt(temp);
+            fjac[1 + 1 * ldfjac] = 100. * x[2] / tmp1;
+            fjac[1 + 2 * ldfjac] = -100. * x[1] / tmp1;
+            fjac[1 + 3 * ldfjac] = 10.;
+            fjac[2 + 1 * ldfjac] = 10. * x[1] / tmp2;
+            fjac[2 + 2 * ldfjac] = 10. * x[2] / tmp2;
+            fjac[2 + 3 * ldfjac] = 0.;
+            fjac[3 + 1 * ldfjac] = 0.;
+            fjac[3 + 2 * ldfjac] = 0.;
+            fjac[3 + 3 * ldfjac] = 1.;
+            break;
+
+/*     powell singular function. */
+
+        case 6:
+            for (j = 1; j <= 4; ++j) {
+                for (i = 1; i <= 4; ++i) {
+                    fjac[i + j * ldfjac] = 0.;
+                }
+            }
+            fjac[1 + 1 * ldfjac] = 1.;
+            fjac[1 + 2 * ldfjac] = 10.;
+            fjac[2 + 3 * ldfjac] = sqrt(5.);
+            fjac[2 + 4 * ldfjac] = -fjac[2 + 3 * ldfjac];
+            fjac[3 + 2 * ldfjac] = 2. * (x[2] - 2. * x[3]);
+            fjac[3 + 3 * ldfjac] = -2. * fjac[3 + 2 * ldfjac];
+            fjac[4 + 1 * ldfjac] = 2. * sqrt(10.) * (x[1] - x[4]);
+            fjac[4 + 4 * ldfjac] = -fjac[4 + 1 * ldfjac];
+            break;
+
+/*     freudenstein and roth function. */
+
+        case 7:
+            fjac[1 + 1 * ldfjac] = 1.;
+            fjac[1 + 2 * ldfjac] = x[2] * (10. - 3. * x[2]) - 2.;
+            fjac[2 + 1 * ldfjac] = 1.;
+            fjac[2 + 2 * ldfjac] = x[2] * (2. + 3. * x[2]) - 14.;
+            break;
+
+/*     bard function. */
+
+        case 8:
+            for (i = 1; i <= 15; ++i) {
+                tmp1 = (real) i;
+                tmp2 = (real) (16 - i);
+                tmp3 = tmp1;
+                if (i > 8) {
+                    tmp3 = tmp2;
+                }
+                /* Computing 2nd power */
+                d__1 = x[2] * tmp2 + x[3] * tmp3;
+                tmp4 = d__1 * d__1;
+                fjac[i + 1 * ldfjac] = -1.;
+                fjac[i + 2 * ldfjac] = tmp1 * tmp2 / tmp4;
+                fjac[i + 3 * ldfjac] = tmp1 * tmp3 / tmp4;
+            }
+            break;
+
+/*     kowalik and osborne function. */
+
+        case 9:
+            for (i = 1; i <= 11; ++i) {
+                tmp1 = v[i - 1] * (v[i - 1] + x[2]);
+                tmp2 = v[i - 1] * (v[i - 1] + x[3]) + x[4];
+                fjac[i + 1 * ldfjac] = -tmp1 / tmp2;
+                fjac[i + 2 * ldfjac] = -v[i - 1] * x[1] / tmp2;
+                fjac[i + 3 * ldfjac] = fjac[i + 1 * ldfjac] * fjac[i + 2 * ldfjac];
+                fjac[i + 4 * ldfjac] = fjac[i + 3 * ldfjac] / v[i - 1];
+            }
+            break;
+
+/*     meyer function. */
+
+        case 10:
+            for (i = 1; i <= 16; ++i) {
+                temp = 5. * (real) i + 45. + x[3];
+                tmp1 = x[2] / temp;
+                tmp2 = exp(tmp1);
+                fjac[i + 1 * ldfjac] = tmp2;
+                fjac[i + 2 * ldfjac] = x[1] * tmp2 / temp;
+                fjac[i + 3 * ldfjac] = -tmp1 * fjac[i + 2 * ldfjac];
+            }
+            break;
+
+/*     watson function. */
+
+        case 11:
+            for (i = 1; i <= 29; ++i) {
+                div = (real) i / 29.;
+                s2 = 0.;
+                dx = 1.;
+                for (j = 1; j <= n; ++j) {
+                    s2 += dx * x[j];
+                    dx = div * dx;
+                }
+                temp = 2. * div * s2;
+                dx = 1. / div;
+                for (j = 1; j <= n; ++j) {
+                    fjac[i + j * ldfjac] = dx * ((real) (j - 1) - temp);
+                    dx = div * dx;
+                }
+            }
+            for (j = 1; j <= n; ++j) {
+                for (i = 30; i <= 31; ++i) {
+                    fjac[i + j * ldfjac] = 0.;
+                }
+            }
+            fjac[30 + 1 * ldfjac] = 1.;
+            fjac[31 + 1 * ldfjac] = -2. * x[1];
+            fjac[31 + 2 * ldfjac] = 1.;
+            break;
+
+/*     box 3-dimensional function. */
+
+        case 12:
+            for (i = 1; i <= m; ++i) {
+                temp = (real) i;
+                tmp1 = temp / 10.;
+                fjac[i + 1 * ldfjac] = -tmp1 * exp(-tmp1 * x[1]);
+                fjac[i + 2 * ldfjac] = tmp1 * exp(-tmp1 * x[2]);
+                fjac[i + 3 * ldfjac] = exp(-temp) - exp(-tmp1);
+            }
+            break;
+
+/*     jennrich and sampson function. */
+
+        case 13:
+            for (i = 1; i <= m; ++i) {
+                temp = (real) i;
+                fjac[i + 1 * ldfjac] = -temp * exp(temp * x[1]);
+                fjac[i + 2 * ldfjac] = -temp * exp(temp * x[2]);
+            }
+            break;
+
+/*     brown and dennis function. */
+
+        case 14:
+            for (i = 1; i <= m; ++i) {
+                temp = (real) i / 5.;
+                ti = sin(temp);
+                tmp1 = x[1] + temp * x[2] - exp(temp);
+                tmp2 = x[3] + ti * x[4] - cos(temp);
+                fjac[i + 1 * ldfjac] = 2. * tmp1;
+                fjac[i + 2 * ldfjac] = temp * fjac[i + 1 * ldfjac];
+                fjac[i + 3 * ldfjac] = 2. * tmp2;
+                fjac[i + 4 * ldfjac] = ti * fjac[i + 3 * ldfjac];
+            }
+            break;
+
+/*     chebyquad function. */
+
+        case 15:
+            dx = 1. / (real) (n);
+            for (j = 1; j <= n; ++j) {
+                tmp1 = 1.;
+                tmp2 = 2. * x[j] - 1.;
+                temp = 2. * tmp2;
+                tmp3 = 0.;
+                tmp4 = 2.;
+                for (i = 1; i <= m; ++i) {
+                    fjac[i + j * ldfjac] = dx * tmp4;
+                    ti = 4. * tmp2 + temp * tmp4 - tmp3;
+                    tmp3 = tmp4;
+                    tmp4 = ti;
+                    ti = temp * tmp2 - tmp1;
+                    tmp1 = tmp2;
+                    tmp2 = ti;
+                }
+            }
+            break;
+
+/*     brown almost-linear function. */
+
+        case 16:
+            prod = 1.;
+            for (j = 1; j <= n; ++j) {
+                prod = x[j] * prod;
+                for (i = 1; i <= n; ++i) {
+                    fjac[i + j * ldfjac] = 1.;
+                }
+                fjac[j + j * ldfjac] = 2.;
+            }
+            for (j = 1; j <= n; ++j) {
+                temp = x[j];
+                if (temp == 0.) {
+                    temp = 1.;
+                    prod = 1.;
+                    for (k = 1; k <= n; ++k) {
+                        if (k != j) {
+                            prod = x[k] * prod;
+                        }
+                    }
+                }
+                fjac[n + j * ldfjac] = prod / temp;
+            }
+            break;
+
+/*     osborne 1 function. */
+
+        case 17:
+            for (i = 1; i <= 33; ++i) {
+                temp = 10. * (real) (i - 1);
+                tmp1 = exp(-x[4] * temp);
+                tmp2 = exp(-x[5] * temp);
+                fjac[i + 1 * ldfjac] = -1.;
+                fjac[i + 2 * ldfjac] = -tmp1;
+                fjac[i + 3 * ldfjac] = -tmp2;
+                fjac[i + 4 * ldfjac] = temp * x[2] * tmp1;
+                fjac[i + 5 * ldfjac] = temp * x[3] * tmp2;
+            }
+            break;
+
+/*     osborne 2 function. */
+
+        case 18:
+            for (i = 1; i <= 65; ++i) {
+                temp = (real) (i - 1) / 10.;
+                tmp1 = exp(-x[5] * temp);
+                /* Computing 2nd power */
+                d__1 = temp - x[9];
+                tmp2 = exp(-x[6] * (d__1 * d__1));
+                /* Computing 2nd power */
+                d__1 = temp - x[10];
+                tmp3 = exp(-x[7] * (d__1 * d__1));
+                /* Computing 2nd power */
+                d__1 = temp - x[11];
+                tmp4 = exp(-x[8] * (d__1 * d__1));
+                fjac[i + 1 * ldfjac] = -tmp1;
+                fjac[i + 2 * ldfjac] = -tmp2;
+                fjac[i + 3 * ldfjac] = -tmp3;
+                fjac[i + 4 * ldfjac] = -tmp4;
+                fjac[i + 5 * ldfjac] = temp * x[1] * tmp1;
+                /* Computing 2nd power */
+                d__1 = temp - x[9];
+                fjac[i + 6 * ldfjac] = x[2] * (d__1 * d__1) * tmp2;
+                /* Computing 2nd power */
+                d__1 = temp - x[10];
+                fjac[i + 7 * ldfjac] = x[3] * (d__1 * d__1) * tmp3;
+                /* Computing 2nd power */
+                d__1 = temp - x[11];
+                fjac[i + 8 * ldfjac] = x[4] * (d__1 * d__1) * tmp4;
+                fjac[i + 9 * ldfjac] = -2. * x[2] * x[6] * (temp - x[9]) * tmp2;
+                fjac[i + 10 * ldfjac] = -2. * x[3] * x[7] * (temp - x[10]) * tmp3;
+                fjac[i + 11 * ldfjac] = -2. * x[4] * x[8] * (temp - x[11]) * tmp4;
+            }
+            break;
+    }
+
+/*     last card of subroutine ssqjac. */
+
+} /* ssqjac_ */
+
diff --git a/examples/ssqjac.f b/examples/ssqjac.f
new file mode 100644
index 0000000..c57b8bd
--- /dev/null
+++ b/examples/ssqjac.f
@@ -0,0 +1,347 @@
+      subroutine ssqjac(m,n,x,fjac,ldfjac,nprob)
+      integer m,n,ldfjac,nprob
+      double precision x(n),fjac(ldfjac,n)
+c     **********
+c
+c     subroutine ssqjac
+c
+c     this subroutine defines the jacobian matrices of eighteen
+c     nonlinear least squares problems. the problem dimensions are
+c     as described in the prologue comments of ssqfcn.
+c
+c     the subroutine statement is
+c
+c       subroutine ssqjac(m,n,x,fjac,ldfjac,nprob)
+c
+c     where
+c
+c       m and n are positive integer input variables. n must not
+c         exceed m.
+c
+c       x is an input array of length n.
+c
+c       fjac is an m by n output array which contains the jacobian
+c         matrix of the nprob function evaluated at x.
+c
+c       ldfjac is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array fjac.
+c
+c       nprob is a positive integer variable which defines the
+c         number of the problem. nprob must not exceed 18.
+c
+c     subprograms called
+c
+c       fortran-supplied ... datan,dcos,dexp,dsin,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ivar,j,k,mm1,nm1
+      double precision c14,c20,c29,c45,c100,div,dx,eight,five,four,
+     *                 one,prod,s2,temp,ten,three,ti,tmp1,tmp2,tmp3,
+     *                 tmp4,tpi,two,zero
+      double precision v(11)
+      double precision dfloat
+      data zero,one,two,three,four,five,eight,ten,c14,c20,c29,c45,c100
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,1.4d1,
+     *      2.0d1,2.9d1,4.5d1,1.0d2/
+      data v(1),v(2),v(3),v(4),v(5),v(6),v(7),v(8),v(9),v(10),v(11)
+     *     /4.0d0,2.0d0,1.0d0,5.0d-1,2.5d-1,1.67d-1,1.25d-1,1.0d-1,
+     *      8.33d-2,7.14d-2,6.25d-2/
+      dfloat(ivar) = ivar
+c
+c     jacobian routine selector.
+c
+      go to (10,40,70,130,140,150,180,190,210,230,250,310,330,350,370,
+     *       400,460,480), nprob
+c
+c     linear function - full rank.
+c
+   10 continue
+      temp = two/dfloat(m)
+      do 30 j = 1, n
+         do 20 i = 1, m
+            fjac(i,j) = -temp
+   20       continue
+         fjac(j,j) = fjac(j,j) + one
+   30    continue
+      go to 500
+c
+c     linear function - rank 1.
+c
+   40 continue
+      do 60 j = 1, n
+         do 50 i = 1, m
+            fjac(i,j) = dfloat(i)*dfloat(j)
+   50       continue
+   60    continue
+      go to 500
+c
+c     linear function - rank 1 with zero columns and rows.
+c
+   70 continue
+      do 90 j = 1, n
+         do 80 i = 1, m
+            fjac(i,j) = zero
+   80       continue
+   90    continue
+      nm1 = n - 1
+      mm1 = m - 1
+      if (nm1 .lt. 2) go to 120
+      do 110 j = 2, nm1
+         do 100 i = 2, mm1
+            fjac(i,j) = dfloat(i-1)*dfloat(j)
+  100       continue
+  110    continue
+  120 continue
+      go to 500
+c
+c     rosenbrock function.
+c
+  130 continue
+      fjac(1,1) = -c20*x(1)
+      fjac(1,2) = ten
+      fjac(2,1) = -one
+      fjac(2,2) = zero
+      go to 500
+c
+c     helical valley function.
+c
+  140 continue
+      tpi = eight*datan(one)
+      temp = x(1)**2 + x(2)**2
+      tmp1 = tpi*temp
+      tmp2 = dsqrt(temp)
+      fjac(1,1) = c100*x(2)/tmp1
+      fjac(1,2) = -c100*x(1)/tmp1
+      fjac(1,3) = ten
+      fjac(2,1) = ten*x(1)/tmp2
+      fjac(2,2) = ten*x(2)/tmp2
+      fjac(2,3) = zero
+      fjac(3,1) = zero
+      fjac(3,2) = zero
+      fjac(3,3) = one
+      go to 500
+c
+c     powell singular function.
+c
+  150 continue
+      do 170 j = 1, 4
+         do 160 i = 1, 4
+            fjac(i,j) = zero
+  160       continue
+  170    continue
+      fjac(1,1) = one
+      fjac(1,2) = ten
+      fjac(2,3) = dsqrt(five)
+      fjac(2,4) = -fjac(2,3)
+      fjac(3,2) = two*(x(2) - two*x(3))
+      fjac(3,3) = -two*fjac(3,2)
+      fjac(4,1) = two*dsqrt(ten)*(x(1) - x(4))
+      fjac(4,4) = -fjac(4,1)
+      go to 500
+c
+c     freudenstein and roth function.
+c
+  180 continue
+      fjac(1,1) = one
+      fjac(1,2) = x(2)*(ten - three*x(2)) - two
+      fjac(2,1) = one
+      fjac(2,2) = x(2)*(two + three*x(2)) - c14
+      go to 500
+c
+c     bard function.
+c
+  190 continue
+      do 200 i = 1, 15
+         tmp1 = dfloat(i)
+         tmp2 = dfloat(16-i)
+         tmp3 = tmp1
+         if (i .gt. 8) tmp3 = tmp2
+         tmp4 = (x(2)*tmp2 + x(3)*tmp3)**2
+         fjac(i,1) = -one
+         fjac(i,2) = tmp1*tmp2/tmp4
+         fjac(i,3) = tmp1*tmp3/tmp4
+  200    continue
+      go to 500
+c
+c     kowalik and osborne function.
+c
+  210 continue
+      do 220 i = 1, 11
+         tmp1 = v(i)*(v(i) + x(2))
+         tmp2 = v(i)*(v(i) + x(3)) + x(4)
+         fjac(i,1) = -tmp1/tmp2
+         fjac(i,2) = -v(i)*x(1)/tmp2
+         fjac(i,3) = fjac(i,1)*fjac(i,2)
+         fjac(i,4) = fjac(i,3)/v(i)
+  220    continue
+      go to 500
+c
+c     meyer function.
+c
+  230 continue
+      do 240 i = 1, 16
+         temp = five*dfloat(i) + c45 + x(3)
+         tmp1 = x(2)/temp
+         tmp2 = dexp(tmp1)
+         fjac(i,1) = tmp2
+         fjac(i,2) = x(1)*tmp2/temp
+         fjac(i,3) = -tmp1*fjac(i,2)
+  240    continue
+      go to 500
+c
+c     watson function.
+c
+  250 continue
+      do 280 i = 1, 29
+         div = dfloat(i)/c29
+         s2 = zero
+         dx = one
+         do 260 j = 1, n
+            s2 = s2 + dx*x(j)
+            dx = div*dx
+  260       continue
+         temp = two*div*s2
+         dx = one/div
+         do 270 j = 1, n
+            fjac(i,j) = dx*(dfloat(j-1) - temp)
+            dx = div*dx
+  270       continue
+  280    continue
+      do 300 j = 1, n
+         do 290 i = 30, 31
+            fjac(i,j) = zero
+  290       continue
+  300    continue
+      fjac(30,1) = one
+      fjac(31,1) = -two*x(1)
+      fjac(31,2) = one
+      go to 500
+c
+c     box 3-dimensional function.
+c
+  310 continue
+      do 320 i = 1, m
+         temp = dfloat(i)
+         tmp1 = temp/ten
+         fjac(i,1) = -tmp1*dexp(-tmp1*x(1))
+         fjac(i,2) = tmp1*dexp(-tmp1*x(2))
+         fjac(i,3) = dexp(-temp) - dexp(-tmp1)
+  320    continue
+      go to 500
+c
+c     jennrich and sampson function.
+c
+  330 continue
+      do 340 i = 1, m
+         temp = dfloat(i)
+         fjac(i,1) = -temp*dexp(temp*x(1))
+         fjac(i,2) = -temp*dexp(temp*x(2))
+  340    continue
+      go to 500
+c
+c     brown and dennis function.
+c
+  350 continue
+      do 360 i = 1, m
+         temp = dfloat(i)/five
+         ti = dsin(temp)
+         tmp1 = x(1) + temp*x(2) - dexp(temp)
+         tmp2 = x(3) + ti*x(4) - dcos(temp)
+         fjac(i,1) = two*tmp1
+         fjac(i,2) = temp*fjac(i,1)
+         fjac(i,3) = two*tmp2
+         fjac(i,4) = ti*fjac(i,3)
+  360    continue
+      go to 500
+c
+c     chebyquad function.
+c
+  370 continue
+      dx = one/dfloat(n)
+      do 390 j = 1, n
+         tmp1 = one
+         tmp2 = two*x(j) - one
+         temp = two*tmp2
+         tmp3 = zero
+         tmp4 = two
+         do 380 i = 1, m
+            fjac(i,j) = dx*tmp4
+            ti = four*tmp2 + temp*tmp4 - tmp3
+            tmp3 = tmp4
+            tmp4 = ti
+            ti = temp*tmp2 - tmp1
+            tmp1 = tmp2
+            tmp2 = ti
+  380       continue
+  390    continue
+      go to 500
+c
+c     brown almost-linear function.
+c
+  400 continue
+      prod = one
+      do 420 j = 1, n
+         prod = x(j)*prod
+         do 410 i = 1, n
+            fjac(i,j) = one
+  410       continue
+         fjac(j,j) = two
+  420    continue
+      do 450 j = 1, n
+         temp = x(j)
+         if (temp .ne. zero) go to 440
+         temp = one
+         prod = one
+         do 430 k = 1, n
+            if (k .ne. j) prod = x(k)*prod
+  430       continue
+  440    continue
+         fjac(n,j) = prod/temp
+  450    continue
+      go to 500
+c
+c     osborne 1 function.
+c
+  460 continue
+      do 470 i = 1, 33
+         temp = ten*dfloat(i-1)
+         tmp1 = dexp(-x(4)*temp)
+         tmp2 = dexp(-x(5)*temp)
+         fjac(i,1) = -one
+         fjac(i,2) = -tmp1
+         fjac(i,3) = -tmp2
+         fjac(i,4) = temp*x(2)*tmp1
+         fjac(i,5) = temp*x(3)*tmp2
+  470    continue
+      go to 500
+c
+c     osborne 2 function.
+c
+  480 continue
+      do 490 i = 1, 65
+         temp = dfloat(i-1)/ten
+         tmp1 = dexp(-x(5)*temp)
+         tmp2 = dexp(-x(6)*(temp-x(9))**2)
+         tmp3 = dexp(-x(7)*(temp-x(10))**2)
+         tmp4 = dexp(-x(8)*(temp-x(11))**2)
+         fjac(i,1) = -tmp1
+         fjac(i,2) = -tmp2
+         fjac(i,3) = -tmp3
+         fjac(i,4) = -tmp4
+         fjac(i,5) = temp*x(1)*tmp1
+         fjac(i,6) = x(2)*(temp - x(9))**2*tmp2
+         fjac(i,7) = x(3)*(temp - x(10))**2*tmp3
+         fjac(i,8) = x(4)*(temp - x(11))**2*tmp4
+         fjac(i,9) = -two*x(2)*x(6)*(temp - x(9))*tmp2
+         fjac(i,10) = -two*x(3)*x(7)*(temp - x(10))*tmp3
+         fjac(i,11) = -two*x(4)*x(8)*(temp - x(11))*tmp4
+  490    continue
+  500 continue
+      return
+c
+c     last card of subroutine ssqjac.
+c
+      end
diff --git a/examples/tchkder_.c b/examples/tchkder_.c
new file mode 100644
index 0000000..c46df38
--- /dev/null
+++ b/examples/tchkder_.c
@@ -0,0 +1,92 @@
+/*      driver for chkder example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec,
+	 real *fjac, const int *ldfjac, int *iflag);
+
+int main()
+{
+  int i, m, n, ldfjac, mode;
+  real x[3], fvec[15], fjac[15*3], xp[3], fvecp[15], 
+    err[15];
+  int one=1, two=2;
+
+  m = 15;
+  n = 3;
+
+  /*      the following values should be suitable for */
+  /*      checking the jacobian matrix. */
+
+  x[1-1] = 9.2e-1;
+  x[2-1] = 1.3e-1;
+  x[3-1] = 5.4e-1;
+
+  ldfjac = 15;
+
+  mode = 1;
+  __minpack_func__(chkder)(&m, &n, x, NULL, NULL, &ldfjac, xp, NULL, &mode, NULL);
+  mode = 2;
+  fcn(&m, &n, x, fvec, NULL, &ldfjac, &one);
+  fcn(&m, &n, x, NULL, fjac, &ldfjac, &two);
+  fcn(&m, &n, xp, fvecp, NULL, &ldfjac, &one);
+  __minpack_func__(chkder)(&m, &n, x, fvec, fjac, &ldfjac, NULL, fvecp, &mode, err);
+
+  for (i=1; i<=m; i++)
+    {
+      fvecp[i-1] = fvecp[i-1] - fvec[i-1];
+    }
+  printf("\n      fvec\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)fvec[i-1]);
+  printf("\n      fvecp - fvec\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)fvecp[i-1]);
+  printf("\n      err\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)err[i-1]);
+  printf("\n");
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec,
+	 real *fjac, const int *ldfjac, int *iflag)
+{
+  /*      subroutine fcn for chkder example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  
+  if (*iflag != 2) 
+
+    for (i=1; i<=15; i++)
+      {
+	tmp1 = i;
+	tmp2 = 16 - i;
+	tmp3 = tmp1;
+	if (i > 8) tmp3 = tmp2;
+	fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+      }
+  else
+    {
+      for (i = 1; i <= 15; i++)
+	{
+	  tmp1 = i;
+	  tmp2 = 16 - i;
+	  
+	  /* error introduced into next statement for illustration. */
+	  /* corrected statement should read    tmp3 = tmp1 . */
+	  
+	  tmp3 = tmp2;
+	  if (i > 8) tmp3 = tmp2;
+	  tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4=tmp4*tmp4;
+	  fjac[i-1+ *ldfjac*(1-1)] = -1.;
+	  fjac[i-1+ *ldfjac*(2-1)] = tmp1*tmp2/tmp4;
+	  fjac[i-1+ *ldfjac*(3-1)] = tmp1*tmp3/tmp4;
+	}
+    }
+  return;
+}
diff --git a/examples/tchkderc.c b/examples/tchkderc.c
new file mode 100644
index 0000000..caa03f0
--- /dev/null
+++ b/examples/tchkderc.c
@@ -0,0 +1,151 @@
+/*      driver for chkder example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+#ifdef BOX_CONSTRAINTS
+    real *xmin;
+    real *xmax;
+#endif
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec,
+	 real *fjac, int ldfjac, int iflag);
+
+int main()
+{
+  int i, ldfjac;
+  real x[3], fvec[15], fjac[15*3], xp[3], fvecp[15], 
+    err[15];
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+#ifdef BOX_CONSTRAINTS
+  real xmin[3] = {0., 0.1, 0.5};
+  real xmax[3] = {2., 1.5, 2.3};
+#endif
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+#ifdef BOX_CONSTRAINTS
+  data.xmin = xmin;
+  data.xmax = xmax;
+#endif
+
+  /*      the following values should be suitable for */
+  /*      checking the jacobian matrix. */
+
+  x[0] = 9.2e-1;
+  x[1] = 1.3e-1;
+  x[2] = 5.4e-1;
+
+  ldfjac = 15;
+
+  /* compute xp from x */
+  __cminpack_func__(chkder)(m, n, x, NULL, NULL, ldfjac, xp, NULL, 1, NULL);
+  /* compute fvec at x (all components of fvec should be != 0).*/
+  fcn(&data, m, n, x, fvec, NULL, ldfjac, 1);
+  /* compute fjac at x */
+  fcn(&data, m, n, x, NULL, fjac, ldfjac, 2);
+  /* compute fvecp at xp (all components of fvecp should be != 0)*/
+  fcn(&data, m, n, xp, fvecp, NULL, ldfjac, 1);
+  /* check Jacobian, put the result in err */
+  __cminpack_func__(chkder)(m, n, x, fvec, fjac, ldfjac, NULL, fvecp, 2, err);
+  /* Output values:
+     err[i] = 1.: i-th gradient is correct
+     err[i] = 0.: i-th gradient is incorrect
+     err[I] > 0.5: i-th gradient is probably correct
+  */
+
+  for (i=0; i<m; ++i)
+    {
+      fvecp[i] = fvecp[i] - fvec[i];
+    }
+  printf("\n      fvec\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)fvec[i]);
+  printf("\n      fvecp - fvec\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)fvecp[i]);
+  printf("\n      err\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)err[i]);
+  printf("\n");
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec,
+	 real *fjac, int ldfjac, int iflag)
+{
+  /*      subroutine fcn for chkder example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  const real *y = ((fcndata_t*)p)->y;
+#ifdef BOX_CONSTRAINTS
+  const real *xmin = ((fcndata_t*)p)->xmin;
+  const real *xmax = ((fcndata_t*)p)->xmax;
+  int j;
+  real xb[3];
+  real jacfac[3];
+
+  for (j = 0; j < 3; ++j) {
+    real xmiddle = (xmin[j]+xmax[j])/2.;
+    real xwidth = (xmax[j]-xmin[j])/2.;
+    real th =  tanh((x[j]-xmiddle)/xwidth);
+    xb[j] = xmiddle + th * xwidth;
+    jacfac[j] = 1. - th * th;
+  }
+  x = xb;
+#endif
+
+  if (iflag == 0) 
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+
+  if (iflag != 2) 
+    {
+      for (i=0; i < 15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+	}
+    }
+  else
+    {
+      for (i=0; i < 15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+#        ifdef TCHKDER_FIXED
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+#        else
+	  /* error introduced into next statement for illustration. */
+	  /* corrected statement should read    tmp3 = (i > 7) ? tmp2 : tmp1 . */
+	  tmp3 = (i > 7) ? tmp2 : tmp2;
+#        endif
+	  tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4;
+	  fjac[i + ldfjac*0] = -1.;
+	  fjac[i + ldfjac*1] = tmp1*tmp2/tmp4;
+	  fjac[i + ldfjac*2] = tmp1*tmp3/tmp4;
+	}
+#    ifdef BOX_CONSTRAINTS
+      for (j = 0; j < 3; ++j) {
+        for (i=0; i < 15; ++i)
+          {
+	    fjac[i + ldfjac*j] *= jacfac[j];
+	  }
+      }
+#    endif
+    }
+  return 0;
+}
diff --git a/examples/testdata/chkder.data b/examples/testdata/chkder.data
new file mode 100644
index 0000000..0dff12e
--- /dev/null
+++ b/examples/testdata/chkder.data
@@ -0,0 +1,15 @@
+    1    2
+    2    4
+    3    2
+    4    4
+    5    3
+    6    9
+    7    7
+    8   10
+    9   10
+   10   10
+   11   10
+   12   10
+   13   10
+   14   10
+    0    0
diff --git a/examples/testdata/hybrd.data b/examples/testdata/hybrd.data
new file mode 100644
index 0000000..9d867c8
--- /dev/null
+++ b/examples/testdata/hybrd.data
@@ -0,0 +1,23 @@
+    1    2    3
+    2    4    3
+    3    2    2
+    4    4    3
+    5    3    3
+    6    6    2
+    6    9    2
+    7    5    3
+    7    6    3
+    7    7    3
+    7    8    1
+    7    9    1
+    8   10    3
+    8   30    1
+    8   40    1
+    9   10    3
+   10    1    3
+   10   10    3
+   11   10    3
+   12   10    3
+   13   10    3
+   14   10    3
+    0    0    0
diff --git a/examples/testdata/lm.data b/examples/testdata/lm.data
new file mode 100644
index 0000000..b3cf138
--- /dev/null
+++ b/examples/testdata/lm.data
@@ -0,0 +1,29 @@
+    1    5   10    1
+    1    5   50    1
+    2    5   10    1
+    2    5   50    1
+    3    5   10    1
+    3    5   50    1
+    4    2    2    3
+    5    3    3    3
+    6    4    4    3
+    7    2    2    3
+    8    3   15    3
+    9    4   11    3
+   10    3   16    2
+   11    6   31    3
+   11    9   31    3
+   11   12   31    3
+   12    3   10    1
+   13    2   10    1
+   14    4   20    3
+   15    1    8    3
+   15    8    8    1
+   15    9    9    1
+   15   10   10    1
+   16   10   10    3
+   16   30   30    1
+   16   40   40    1
+   17    5   33    1
+   18   11   65    1
+    0    0    0    0
diff --git a/examples/tfdjac2_.c b/examples/tfdjac2_.c
new file mode 100644
index 0000000..91c1d85
--- /dev/null
+++ b/examples/tfdjac2_.c
@@ -0,0 +1,107 @@
+/*      driver for fdjac2 example. */
+/*      The test works by running chkder both on the Jacobian computed
+        by forward-differences and on the real Jacobian */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#include <cminpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag);
+void fcnjac(int m, int n, const real *x, real *fjac, int ldfjac);
+
+int main()
+{
+  int i, m, n, ldfjac, mode;
+  real epsfcn;
+  real x[3], fvec[15], fjac[15*3], fdjac[15*3], xp[3], fvecp[15], 
+      err[15], errd[15], wa[15];
+  int one=1, iflag=1;
+
+  m = 15;
+  n = 3;
+
+  /*      the following values should be suitable for */
+  /*      checking the jacobian matrix. */
+
+  x[1-1] = 9.2e-1;
+  x[2-1] = 1.3e-1;
+  x[3-1] = 5.4e-1;
+
+  ldfjac = 15;
+
+  epsfcn = 0.;
+
+  mode = 1;
+  __minpack_func__(chkder)(&m, &n, x, NULL, NULL, &ldfjac, xp, NULL, &mode, NULL);
+  mode = 2;
+  fcn(&m, &n, x, fvec, &one);
+  __minpack_func__(fdjac2)(fcn, &m, &n, x, fvec, fdjac, &ldfjac, &iflag, &epsfcn, wa);
+  fcnjac(m, n, x, fjac, ldfjac);
+  fcn(&m, &n, xp, fvecp, &one);
+  __minpack_func__(chkder)(&m, &n, x, fvec, fdjac, &ldfjac, NULL, fvecp, &mode, errd);
+  __minpack_func__(chkder)(&m, &n, x, fvec, fjac, &ldfjac, NULL, fvecp, &mode, err);
+
+  for (i=1; i<=m; i++)
+    {
+      fvecp[i-1] = fvecp[i-1] - fvec[i-1];
+    }
+  printf("\n      fvec\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)fvec[i-1]);
+  printf("\n      fvecp - fvec\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)fvecp[i-1]);
+  printf("\n      errd\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)errd[i-1]);
+  printf("\n      err\n");  
+  for (i=1; i<=m; i++) printf("%s%15.7g",i%3==1?"\n     ":"", (double)err[i-1]);
+  printf("\n");
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag)
+{
+
+/*      subroutine fcn for fdjac2 example. */
+
+  int i;
+  real tmp1, tmp2, tmp3;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (*iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return;
+    }
+  for (i = 1; i <= 15; i++)
+    {
+      tmp1 = i;
+      tmp2 = 16 - i;
+      tmp3 = tmp1;
+      if (i > 8) tmp3 = tmp2;
+      fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+    }
+}
+
+void fcnjac(int m, int n, const real *x,
+            real *fjac, int ldfjac)
+{
+  /*      Jacobian of fcn (corrected version from tchkder). */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+
+  for (i = 1; i <= 15; i++)
+    {
+      tmp1 = i;
+      tmp2 = 16 - i;
+	  
+      tmp3 = tmp1;
+      if (i > 8) tmp3 = tmp2;
+      tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4=tmp4*tmp4;
+      fjac[i-1+ ldfjac*(1-1)] = -1.;
+      fjac[i-1+ ldfjac*(2-1)] = tmp1*tmp2/tmp4;
+      fjac[i-1+ ldfjac*(3-1)] = tmp1*tmp3/tmp4;
+    }
+}
diff --git a/examples/tfdjac2c.c b/examples/tfdjac2c.c
new file mode 100644
index 0000000..a9e28de
--- /dev/null
+++ b/examples/tfdjac2c.c
@@ -0,0 +1,127 @@
+/*      driver for fdjac2 example. */
+/*      The test works by running chkder both on the Jacobian computed
+        by forward-differences and on the real Jacobian */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag);
+void fcnjac(int m, int n, const real *x, real *fjac, int ldfjac);
+
+int main()
+{
+  int i, ldfjac;
+  real epsfcn;
+  real x[3], fvec[15], fjac[15*3], fdjac[15*3], xp[3], fvecp[15], 
+      err[15], errd[15], wa[15];
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+
+  /*      the following values should be suitable for */
+  /*      checking the jacobian matrix. */
+
+  x[1-1] = 9.2e-1;
+  x[2-1] = 1.3e-1;
+  x[3-1] = 5.4e-1;
+
+  ldfjac = 15;
+
+  epsfcn = 0.;
+
+  /* compute xp from x */
+  __cminpack_func__(chkder)(m, n, x, NULL, NULL, ldfjac, xp, NULL, 1, NULL);
+  /* compute fvec at x (all components of fvec should be != 0).*/
+  fcn(&data, m, n, x, fvec, 1);
+  /* compute fdjac (Jacobian using finite differences) at x */
+  __cminpack_func__(fdjac2)(fcn, &data, m, n, x, fvec, fdjac, ldfjac, epsfcn, wa);
+  /* compute fjac (real Jacobian) at x */
+  fcnjac(m, n, x, fjac, ldfjac);
+  /* compute fvecp at xp (all components of fvecp should be != 0)*/
+  fcn(&data, m, n, xp, fvecp, 1);
+  /* check Jacobian fdjac, put the result in errd */
+  __cminpack_func__(chkder)(m, n, x, fvec, fdjac, ldfjac, NULL, fvecp, 2, errd);
+  /* check Jacobian fjac, put the result in err */
+  __cminpack_func__(chkder)(m, n, x, fvec, fjac, ldfjac, NULL, fvecp, 2, err);
+  /* Output values:
+     err[i] = 1.: i-th gradient is correct
+     err[i] = 0.: i-th gradient is incorrect
+     err[I] > 0.5: i-th gradient is probably correct
+  */
+
+  for (i=0; i<m; ++i)
+    {
+      fvecp[i] = fvecp[i] - fvec[i];
+    }
+  printf("\n      fvec\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)fvec[i]);
+  printf("\n      fvecp - fvec\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)fvecp[i]);
+  printf("\n      errd\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)errd[i]);
+  printf("\n      err\n");  
+  for (i=0; i<m; ++i) printf("%s%15.7g",i%3==0?"\n     ":"", (double)err[i]);
+  printf("\n");
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag)
+{
+
+/*      subroutine fcn for fdjac2 example. */
+
+  int i;
+  real tmp1, tmp2, tmp3;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+  for (i = 1; i <= 15; i++)
+    {
+      tmp1 = i;
+      tmp2 = 16 - i;
+      tmp3 = tmp1;
+      if (i > 8) tmp3 = tmp2;
+      fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+    }
+  return 0;
+}
+
+void fcnjac(int m, int n, const real *x,
+            real *fjac, int ldfjac)
+{
+  /*      Jacobian of fcn (corrected version from tchkder). */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+
+  for (i = 1; i <= 15; i++)
+    {
+      tmp1 = i;
+      tmp2 = 16 - i;
+	  
+      tmp3 = tmp1;
+      if (i > 8) tmp3 = tmp2;
+      tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4=tmp4*tmp4;
+      fjac[i-1+ ldfjac*(1-1)] = -1.;
+      fjac[i-1+ ldfjac*(2-1)] = tmp1*tmp2/tmp4;
+      fjac[i-1+ ldfjac*(3-1)] = tmp1*tmp3/tmp4;
+    }
+}
diff --git a/examples/thybrd1_.c b/examples/thybrd1_.c
new file mode 100644
index 0000000..17832c2
--- /dev/null
+++ b/examples/thybrd1_.c
@@ -0,0 +1,63 @@
+/*      driver for hybrd1 example. */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *n, const real *x, real *fvec, int *iflag);
+
+int main()
+{
+  int j, n, info, lwa;
+  real tol, fnorm;
+  real x[9], fvec[9], wa[180];
+  int one=1;
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  lwa = 180;
+
+/*      set tol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  tol = sqrt(__minpack_func__(dpmpar)(&one));
+  __minpack_func__(hybrd1)(&fcn, &n, x, fvec, &tol, &info, wa, &lwa);
+  fnorm = __minpack_func__(enorm)(&n, fvec);
+
+  printf("     final L2 norm of the residuals %15.7g\n", (double)fnorm);
+  printf("     exit parameter                 %10i\n", info);
+  printf("     final approximates solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g",j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+
+  return 0;
+}
+
+void fcn(const int *n, const real *x, real *fvec, int *iflag)
+{
+/*      subroutine fcn for hybrd1 example. */
+
+  int k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0;
+
+  for (k=1; k <= *n; k++)
+    {
+      temp = (three - two*x[k-1])*x[k-1];
+      temp1 = zero;
+      if (k != 1) temp1 = x[k-1-1];
+      temp2 = zero;
+      if (k != *n) temp2 = x[k+1-1];
+      fvec[k-1] = temp - temp1 - two*temp2 + one;
+    }
+  return;
+}
diff --git a/examples/thybrd1c.c b/examples/thybrd1c.c
new file mode 100644
index 0000000..d7d2a5c
--- /dev/null
+++ b/examples/thybrd1c.c
@@ -0,0 +1,62 @@
+/*      driver for hybrd1 example. */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+int fcn(void *p, int n, const real *x, real *fvec, int iflag);
+
+int main()
+{
+  int j, n, info, lwa;
+  real tol, fnorm;
+  real x[9], fvec[9], wa[180];
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  lwa = 180;
+
+/*      set tol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  tol = sqrt(__cminpack_func__(dpmpar)(1));
+  info = __cminpack_func__(hybrd1)(fcn, 0, n, x, fvec, tol, wa, lwa);
+  fnorm = __cminpack_func__(enorm)(n, fvec);
+
+  printf("     final L2 norm of the residuals %15.7g\n", (double)fnorm);
+  printf("     exit parameter                 %10i\n", info);
+  printf("     final approximates solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g",j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+
+  return 0;
+}
+
+int fcn(void *p, int n, const real *x, real *fvec, int iflag)
+{
+/*      subroutine fcn for hybrd1 example. */
+
+  int k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0;
+
+  for (k=1; k <= n; k++)
+    {
+      temp = (three - two*x[k-1])*x[k-1];
+      temp1 = zero;
+      if (k != 1) temp1 = x[k-1-1];
+      temp2 = zero;
+      if (k != n) temp2 = x[k+1-1];
+      fvec[k-1] = temp - temp1 - two*temp2 + one;
+    }
+  return 0;
+}
diff --git a/examples/thybrd_.c b/examples/thybrd_.c
new file mode 100644
index 0000000..922dd6e
--- /dev/null
+++ b/examples/thybrd_.c
@@ -0,0 +1,87 @@
+/*      driver for hybrd example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *n, const real *x, real *fvec, int *iflag);
+
+int main()
+{
+  int j, n, maxfev, ml, mu, mode, nprint, info, nfev, ldfjac, lr;
+  real xtol, epsfcn, factor, fnorm;
+  real x[9], fvec[9], diag[9], fjac[9*9], r[45], qtf[9],
+    wa1[9], wa2[9], wa3[9], wa4[9];
+  int one=1;
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  ldfjac = 9;
+  lr = 45;
+
+/*      set xtol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  xtol = sqrt(__minpack_func__(dpmpar)(&one));
+
+  maxfev = 2000;
+  ml = 1;
+  mu = 1;
+  epsfcn = 0.;
+  mode = 2;
+  for (j=1; j<=9; j++)
+    {
+      diag[j-1] = 1.;
+    }
+
+  factor = 1.e2;
+  nprint = 0;
+
+  __minpack_func__(hybrd)(&fcn, &n, x, fvec, &xtol, &maxfev, &ml, &mu, &epsfcn,
+	 diag, &mode, &factor, &nprint, &info, &nfev,
+	 fjac, &ldfjac, r, &lr, qtf, wa1, wa2, wa3, wa4);
+  fnorm = __minpack_func__(enorm)(&n, fvec);
+  printf("     final l2 norm of the residuals %15.7g\n\n", (double)fnorm);
+  printf("     number of function evaluations  %10i\n\n", nfev);
+  printf("     exit parameter                  %10i\n\n", info);
+  printf("     final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+  return 0;
+}
+
+
+void fcn(const int *n, const real *x, real *fvec, int *iflag)
+{
+  /*      subroutine fcn for hybrd example. */
+
+  int k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0;
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return;
+    }
+  for (k=1; k<=*n; k++)
+    {
+      
+      temp = (three - two*x[k-1])*x[k-1];
+      temp1 = zero;
+      if (k != 1) temp1 = x[k-1-1];
+      temp2 = zero;
+      if (k != *n) temp2 = x[k+1-1];
+      fvec[k-1] = temp - temp1 - two*temp2 + one;
+    }
+  return;
+}
+
diff --git a/examples/thybrdc.c b/examples/thybrdc.c
new file mode 100644
index 0000000..24da2cf
--- /dev/null
+++ b/examples/thybrdc.c
@@ -0,0 +1,86 @@
+/*      driver for hybrd example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+int fcn(void *p, int n, const real *x, real *fvec, int iflag);
+
+int main()
+{
+  int j, n, maxfev, ml, mu, mode, nprint, info, nfev, ldfjac, lr;
+  real xtol, epsfcn, factor, fnorm;
+  real x[9], fvec[9], diag[9], fjac[9*9], r[45], qtf[9],
+    wa1[9], wa2[9], wa3[9], wa4[9];
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  ldfjac = 9;
+  lr = 45;
+
+/*      set xtol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  xtol = sqrt(__cminpack_func__(dpmpar)(1));
+
+  maxfev = 2000;
+  ml = 1;
+  mu = 1;
+  epsfcn = 0.;
+  mode = 2;
+  for (j=1; j<=9; j++)
+    {
+      diag[j-1] = 1.;
+    }
+
+  factor = 1.e2;
+  nprint = 0;
+
+  info = __cminpack_func__(hybrd)(fcn, 0, n, x, fvec, xtol, maxfev, ml, mu, epsfcn,
+	 diag, mode, factor, nprint, &nfev,
+	 fjac, ldfjac, r, lr, qtf, wa1, wa2, wa3, wa4);
+  fnorm = __cminpack_func__(enorm)(n, fvec);
+  printf("     final l2 norm of the residuals %15.7g\n\n", (double)fnorm);
+  printf("     number of function evaluations  %10i\n\n", nfev);
+  printf("     exit parameter                  %10i\n\n", info);
+  printf("     final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+  return 0;
+}
+
+
+int fcn(void *p, int n, const real *x, real *fvec, int iflag)
+{
+  /*      subroutine fcn for hybrd example. */
+
+  int k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0;
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+  for (k=1; k<=n; k++)
+    {
+      
+      temp = (three - two*x[k-1])*x[k-1];
+      temp1 = zero;
+      if (k != 1) temp1 = x[k-1-1];
+      temp2 = zero;
+      if (k != n) temp2 = x[k+1-1];
+      fvec[k-1] = temp - temp1 - two*temp2 + one;
+    }
+  return 0;
+}
+
diff --git a/examples/thybrj1_.c b/examples/thybrj1_.c
new file mode 100644
index 0000000..233aba9
--- /dev/null
+++ b/examples/thybrj1_.c
@@ -0,0 +1,83 @@
+/*      driver for hybrj1 example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, 
+	 int *iflag);
+
+int main()
+{
+  int j, n, ldfjac, info, lwa;
+  real tol, fnorm;
+  real x[9], fvec[9], fjac[9*9], wa[99];
+  int one=1;
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  ldfjac = 9;
+  lwa = 99;
+
+/*      set tol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  tol = sqrt(__minpack_func__(dpmpar)(&one));
+
+  __minpack_func__(hybrj1)(&fcn, &n, x, fvec, fjac, &ldfjac, &tol, &info, wa, &lwa);
+
+  fnorm = __minpack_func__(enorm)(&n, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+
+  return 0;
+}
+
+void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, 
+	 int *iflag)
+{
+  /*      subroutine fcn for hybrj1 example. */
+
+  int j, k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4;
+
+  if (*iflag != 2)
+    {
+      for (k = 1; k <= *n; k++)
+	{
+	  temp = (three - two*x[k-1])*x[k-1];
+	  temp1 = zero;
+	  if (k != 1) temp1 = x[k-1-1];
+	  temp2 = zero;
+	  if (k != *n) temp2 = x[k+1-1];
+	  fvec[k-1] = temp - temp1 - two*temp2 + one;
+	}
+    }
+  else
+    {
+     for (k = 1; k <= *n; k++)
+       {
+	 for (j = 1; j <= *n; j++)
+	   {
+	     fjac[k-1 + *ldfjac*(j-1)] = zero;
+	   }
+         fjac[k-1 + *ldfjac*(k-1)] = three - four*x[k-1];
+         if (k != 1) fjac[k-1 + *ldfjac*(k-1-1)] = -one;
+         if (k != *n) fjac[k-1 + *ldfjac*(k+1-1)] = -two;
+       }
+    }
+  return;
+}
diff --git a/examples/thybrj1c.c b/examples/thybrj1c.c
new file mode 100644
index 0000000..554d63b
--- /dev/null
+++ b/examples/thybrj1c.c
@@ -0,0 +1,82 @@
+/*      driver for hybrj1 example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, 
+	 int iflag);
+
+int main()
+{
+  int j, n, ldfjac, info, lwa;
+  real tol, fnorm;
+  real x[9], fvec[9], fjac[9*9], wa[99];
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  ldfjac = 9;
+  lwa = 99;
+
+/*      set tol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+  info = __cminpack_func__(hybrj1)(fcn, 0, n, x, fvec, fjac, ldfjac, tol, wa, lwa);
+
+  fnorm = __cminpack_func__(enorm)(n, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+
+  return 0;
+}
+
+int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, 
+	 int iflag)
+{
+  /*      subroutine fcn for hybrj1 example. */
+
+  int j, k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4;
+
+  if (iflag != 2)
+    {
+      for (k = 1; k <= n; k++)
+	{
+	  temp = (three - two*x[k-1])*x[k-1];
+	  temp1 = zero;
+	  if (k != 1) temp1 = x[k-1-1];
+	  temp2 = zero;
+	  if (k != n) temp2 = x[k+1-1];
+	  fvec[k-1] = temp - temp1 - two*temp2 + one;
+	}
+    }
+  else
+    {
+     for (k = 1; k <= n; k++)
+       {
+	 for (j = 1; j <= n; j++)
+	   {
+	     fjac[k-1 + ldfjac*(j-1)] = zero;
+	   }
+         fjac[k-1 + ldfjac*(k-1)] = three - four*x[k-1];
+         if (k != 1) fjac[k-1 + ldfjac*(k-1-1)] = -one;
+         if (k != n) fjac[k-1 + ldfjac*(k+1-1)] = -two;
+       }
+    }
+  return 0;
+}
diff --git a/examples/thybrj_.c b/examples/thybrj_.c
new file mode 100644
index 0000000..38ae812
--- /dev/null
+++ b/examples/thybrj_.c
@@ -0,0 +1,104 @@
+/*      driver for hybrj example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, 
+	 int *iflag);
+
+int main()
+{
+
+  int j, n, ldfjac, maxfev, mode, nprint, info, nfev, njev, lr;
+  real xtol, factor, fnorm;
+  real x[9], fvec[9], fjac[9*9], diag[9], r[45], qtf[9],
+    wa1[9], wa2[9], wa3[9], wa4[9];
+  int one=1;
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  ldfjac = 9;
+  lr = 45;
+
+/*      set xtol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  xtol = sqrt(__minpack_func__(dpmpar)(&one));
+
+  maxfev = 1000;
+  mode = 2;
+  for (j=1; j<=9; j++)
+    {
+      diag[j-1] = 1.;
+    }
+  factor = 1.e2;
+  nprint = 0;
+
+ __minpack_func__(hybrj)(&fcn, &n, x, fvec, fjac, &ldfjac, &xtol, &maxfev, diag, 
+	&mode, &factor, &nprint, &info, &nfev, &njev, r, &lr, qtf, 
+	wa1, wa2, wa3, wa4);
+ fnorm = __minpack_func__(enorm)(&n, fvec);
+
+ printf("     final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+ printf("     number of function evaluations%10i\n\n", nfev);
+ printf("     number of jacobian evaluations%10i\n\n", njev);
+ printf("     exit parameter                %10i\n\n", info);
+ printf("     final approximate solution\n\n");
+ for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+ printf("\n");
+ return 0;
+}
+
+void fcn(const int *n, const real *x, real *fvec, real *fjac, const int *ldfjac, 
+	 int *iflag)
+{
+  
+  /*      subroutine fcn for hybrj example. */
+
+  int j, k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4;
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return;
+    }
+
+  if (*iflag != 2) 
+    {
+      for (k=1; k <= *n; k++)
+	{
+	  temp = (three - two*x[k-1])*x[k-1];
+	  temp1 = zero;
+	  if (k != 1) temp1 = x[k-1-1];
+	  temp2 = zero;
+	  if (k != *n) temp2 = x[k+1-1];
+	  fvec[k-1] = temp - temp1 - two*temp2 + one;
+	}
+    }
+  else
+    {
+      for (k = 1; k <= *n; k++)
+	{
+	  for (j=1; j <= *n; j++)
+	    {
+	      fjac[k-1 + *ldfjac*(j-1)] = zero;
+	    }
+	  fjac[k-1 + *ldfjac*(k-1)] = three - four*x[k-1];
+	  if (k != 1) fjac[k-1 + *ldfjac*(k-1-1)] = -one;
+	  if (k != *n) fjac[k-1 + *ldfjac*(k+1-1)] = -two;
+	}      
+    }
+  return;
+}
+
diff --git a/examples/thybrjc.c b/examples/thybrjc.c
new file mode 100644
index 0000000..ed8fdc8
--- /dev/null
+++ b/examples/thybrjc.c
@@ -0,0 +1,152 @@
+/*      driver for hybrj example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+#ifdef BOX_CONSTRAINTS
+typedef struct  {
+    real *xmin;
+    real *xmax;
+} fcndata_t;
+#endif
+
+int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, 
+	 int iflag);
+
+int main()
+{
+
+  int j, n, ldfjac, maxfev, mode, nprint, info, nfev, njev, lr;
+  real xtol, factor, fnorm;
+  real x[9], fvec[9], fjac[9*9], diag[9], r[45], qtf[9],
+    wa1[9], wa2[9], wa3[9], wa4[9];
+  void *p = NULL;
+#ifdef BOX_CONSTRAINTS
+  real xmin[9] = {-2.,-0.5, -2., -2., -2., -2., -2., -2., -2.};
+  real xmax[9] = { 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.};
+  fcndata_t data;
+  data.xmin = xmin;
+  data.xmax = xmax;
+  p = &data;
+#endif
+
+  n = 9;
+
+/*      the following starting values provide a rough solution. */
+
+  for (j=1; j<=9; j++)
+    {
+      x[j-1] = -1.;
+    }
+
+  ldfjac = 9;
+  lr = 45;
+
+/*      set xtol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  xtol = sqrt(__cminpack_func__(dpmpar)(1));
+
+  maxfev = 1000;
+  mode = 2;
+  for (j=1; j<=9; j++)
+    {
+      diag[j-1] = 1.;
+    }
+  factor = 1.e2;
+  nprint = 0;
+
+  info = __cminpack_func__(hybrj)(fcn, p, n, x, fvec, fjac, ldfjac, xtol, maxfev, diag, 
+	mode, factor, nprint, &nfev, &njev, r, lr, qtf, 
+	wa1, wa2, wa3, wa4);
+#ifdef BOX_CONSTRAINTS
+  /* compute the real x, using the same change of variable as in fcn */
+  for (j = 0; j < 3; ++j) {
+    real xmiddle = (xmin[j]+xmax[j])/2.;
+    real xwidth = (xmax[j]-xmin[j])/2.;
+    real th =  tanh((x[j]-xmiddle)/xwidth);
+    x[j] = xmiddle + th * xwidth;
+  }
+#endif
+ fnorm = __cminpack_func__(enorm)(n, fvec);
+
+ printf("     final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+ printf("     number of function evaluations%10i\n\n", nfev);
+ printf("     number of jacobian evaluations%10i\n\n", njev);
+ printf("     exit parameter                %10i\n\n", info);
+ printf("     final approximate solution\n\n");
+ for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+ printf("\n");
+ return 0;
+}
+
+int fcn(void *p, int n, const real *x, real *fvec, real *fjac, int ldfjac, 
+	 int iflag)
+{
+  
+  /*      subroutine fcn for hybrj example. */
+
+  int j, k;
+  real one=1, temp, temp1, temp2, three=3, two=2, zero=0, four=4;
+#ifdef BOX_CONSTRAINTS
+  const real *xmin = ((fcndata_t*)p)->xmin;
+  const real *xmax = ((fcndata_t*)p)->xmax;
+  real xb[9];
+  real jacfac[9];
+
+  for (j = 0; j < 9; ++j) {
+    real xmiddle = (xmin[j]+xmax[j])/2.;
+    real xwidth = (xmax[j]-xmin[j])/2.;
+    real th =  tanh((x[j]-xmiddle)/xwidth);
+    xb[j] = xmiddle + th * xwidth;
+    jacfac[j] = 1. - th * th;
+  }
+  x = xb;
+#endif
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+
+  if (iflag != 2) 
+    {
+      for (k = 0; k < n; ++k)
+	{
+	  temp = (three - two*x[k])*x[k];
+	  temp1 = zero;
+	  if (k != 0) temp1 = x[k-1];
+	  temp2 = zero;
+	  if (k != n-1) temp2 = x[k+1];
+	  fvec[k] = temp - temp1 - two*temp2 + one;
+	}
+    }
+  else
+    {
+      for (k = 0; k < n; ++k)
+	{
+	  for (j = 0; j < n; ++j)
+	    {
+	      fjac[k + ldfjac*j] = zero;
+	    }
+	  fjac[k + ldfjac*k] = three - four*x[k];
+	  if (k != 0) {
+            fjac[k + ldfjac*(k-1)] = -one;
+          }
+	  if (k != n-1) {
+            fjac[k + ldfjac*(k+1)] = -two;
+          }
+#        ifdef BOX_CONSTRAINTS
+          for (j = 0; j < n; ++j) {
+	    fjac[k + ldfjac*j] *= jacfac[j];
+	  }
+#        endif
+	}      
+    }
+  return 0;
+}
+
diff --git a/examples/tlmder1_ b/examples/tlmder1_
new file mode 100755
index 0000000..1cb4d04
Binary files /dev/null and b/examples/tlmder1_ differ
diff --git a/examples/tlmder1_.c b/examples/tlmder1_.c
new file mode 100644
index 0000000..b7d62b3
--- /dev/null
+++ b/examples/tlmder1_.c
@@ -0,0 +1,86 @@
+/*      driver for lmder1 example. */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, 
+	 const int *ldfjac, int *iflag);
+
+int main()
+{
+  int j, m, n, ldfjac, info, lwa;
+  int ipvt[3];
+  real tol, fnorm;
+  real x[3], fvec[15], fjac[15*3], wa[30];
+  int one=1;
+
+  m = 15;
+  n = 3;
+
+/*      the following starting values provide a rough fit. */
+
+  x[1-1] = 1.;
+  x[2-1] = 1.;
+  x[3-1] = 1.;
+
+  ldfjac = 15;
+  lwa = 30;
+
+/*      set tol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  tol = sqrt(__minpack_func__(dpmpar)(&one));
+
+  __minpack_func__(lmder1)(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &tol, 
+	  &info, ipvt, wa, &lwa);
+  fnorm = __minpack_func__(enorm)(&m, fvec);
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, 
+	 const int *ldfjac, int *iflag)
+{
+
+/*      subroutine fcn for lmder1 example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (*iflag != 2)
+    {
+      for (i = 1; i <= 15; i++)
+	{
+	  tmp1 = i;
+	  tmp2 = 16 - i;
+	  tmp3 = tmp1;
+	  if (i > 8) tmp3 = tmp2;
+	  fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+	}
+    }
+  else
+    {
+      for ( i = 1; i <= 15; i++)
+	{
+	  tmp1 = i;
+	  tmp2 = 16 - i;
+	  tmp3 = tmp1;
+	  if (i > 8) tmp3 = tmp2;
+	  tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4;
+	  fjac[i-1 + *ldfjac*(1-1)] = -1.;
+	  fjac[i-1 + *ldfjac*(2-1)] = tmp1*tmp2/tmp4;
+	  fjac[i-1 + *ldfjac*(3-1)] = tmp1*tmp3/tmp4;
+	}
+    }
+}
diff --git a/examples/tlmder1c b/examples/tlmder1c
new file mode 100755
index 0000000..262fa56
Binary files /dev/null and b/examples/tlmder1c differ
diff --git a/examples/tlmder1c.c b/examples/tlmder1c.c
new file mode 100644
index 0000000..1f1aa8d
--- /dev/null
+++ b/examples/tlmder1c.c
@@ -0,0 +1,94 @@
+/*      driver for lmder1 example. */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, 
+	 int ldfjac, int iflag);
+
+int main()
+{
+  int j, ldfjac, info, lwa;
+  int ipvt[3];
+  real tol, fnorm;
+  real x[3], fvec[15], fjac[15*3], wa[30];
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+
+/*      the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  ldfjac = 15;
+  lwa = 30;
+
+/*      set tol to the square root of the machine precision. */
+/*      unless high solutions are required, */
+/*      this is the recommended setting. */
+
+  tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+  info = __cminpack_func__(lmder1)(fcn, &data, m, n, x, fvec, fjac, ldfjac, tol, 
+	  ipvt, wa, lwa);
+  fnorm = __cminpack_func__(enorm)(m, fvec);
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=0; j<n; ++j) printf("%s%15.7g", j%3==0?"\n     ":"", (double)x[j]);
+  printf("\n");
+
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, 
+	 int ldfjac, int iflag)
+{
+
+/*      subroutine fcn for lmder1 example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  const real *y = ((fcndata_t*)p)->y;
+
+  if (iflag != 2) 
+    {
+      for (i=0; i < 15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+	}
+    }
+  else
+    {
+      for (i=0; i<15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4;
+	  fjac[i + ldfjac*0] = -1.;
+	  fjac[i + ldfjac*1] = tmp1*tmp2/tmp4;
+	  fjac[i + ldfjac*2] = tmp1*tmp3/tmp4;
+	};
+    }
+  return 0;
+}
diff --git a/examples/tlmder_.c b/examples/tlmder_.c
new file mode 100644
index 0000000..2c86d1f
--- /dev/null
+++ b/examples/tlmder_.c
@@ -0,0 +1,112 @@
+/*      driver for lmder example. */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, 
+	 const int *ldfjac, int *iflag);
+
+int main()
+{
+  int i, j, m, n, ldfjac, maxfev, mode, nprint, info, nfev, njev;
+  int ipvt[3];
+  real ftol, xtol, gtol, factor, fnorm;
+  real x[3], fvec[15], fjac[15*3], diag[3], qtf[3], 
+    wa1[3], wa2[3], wa3[3], wa4[15];
+  int one=1;
+  real covfac;
+
+  m = 15;
+  n = 3;
+
+/*      the following starting values provide a rough fit. */
+
+  x[1-1] = 1.;
+  x[2-1] = 1.;
+  x[3-1] = 1.;
+
+  ldfjac = 15;
+
+  /*      set ftol and xtol to the square root of the machine */
+  /*      and gtol to zero. unless high solutions are */
+  /*      required, these are the recommended settings. */
+
+  ftol = sqrt(__minpack_func__(dpmpar)(&one));
+  xtol = sqrt(__minpack_func__(dpmpar)(&one));
+  gtol = 0.;
+    
+  maxfev = 400;
+  mode = 1;
+  factor = 1.e2;
+  nprint = 0;
+
+  __minpack_func__(lmder)(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &ftol, &xtol, &gtol, 
+	&maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, 
+	ipvt, qtf, wa1, wa2, wa3, wa4);
+  fnorm = __minpack_func__(enorm)(&m, fvec);
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      number of function evaluations%10i\n\n", nfev);
+  printf("      number of Jacobian evaluations%10i\n\n", njev);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+  ftol = __minpack_func__(dpmpar)(&one);
+  covfac = fnorm*fnorm/(m-n);
+  __minpack_func__(covar)(&n, fjac, &ldfjac, ipvt, &ftol, wa1);
+  printf("      covariance\n");
+  for (i=1; i<=n; i++) {
+    for (j=1; j<=n; j++)
+      printf("%s%15.7g", j%3==1?"\n     ":"", (double)fjac[(i-1)*ldfjac+j-1]*covfac);
+  }
+  printf("\n");
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjac, 
+	 const int *ldfjac, int *iflag)
+{      
+
+  /*      subroutine fcn for lmder example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (*iflag == 0) 
+    {
+      /*      insert print statements here when nprint is positive. */
+      return;
+    }
+
+  if (*iflag != 2) 
+    {
+      for (i=1; i <= 15; i++)
+	{
+	  tmp1 = i;
+	  tmp2 = 16 - i;
+	  tmp3 = tmp1;
+	  if (i > 8) tmp3 = tmp2;
+	  fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+	}
+    }
+  else
+    {
+      for (i=1; i<=15; i++)
+	{
+	  tmp1 = i;
+	  tmp2 = 16 - i;
+	  tmp3 = tmp1;
+	  if (i > 8) tmp3 = tmp2;
+	  tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4;
+	  fjac[i-1 + *ldfjac*(1-1)] = -1.;
+	  fjac[i-1 + *ldfjac*(2-1)] = tmp1*tmp2/tmp4;
+	  fjac[i-1 + *ldfjac*(3-1)] = tmp1*tmp3/tmp4;
+	};
+    }
+  return;
+}
diff --git a/examples/tlmderc.c b/examples/tlmderc.c
new file mode 100644
index 0000000..b2b2644
--- /dev/null
+++ b/examples/tlmderc.c
@@ -0,0 +1,197 @@
+/*      driver for lmder example. */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* define the preprocessor symbol BOX_CONSTRAINTS to enable the simulated box constraints
+   using a change of variables. */
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+#ifdef BOX_CONSTRAINTS
+    real *xmin;
+    real *xmax;
+#endif
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, 
+	 int ldfjac, int iflag);
+
+int main()
+{
+  int i, j, ldfjac, maxfev, mode, nprint, info, nfev, njev;
+  int ipvt[3];
+  real ftol, xtol, gtol, factor, fnorm;
+  real x[3], fvec[15], fjac[15*3], diag[3], qtf[3], 
+    wa1[3], wa2[3], wa3[3], wa4[15];
+  int k;
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+#ifdef BOX_CONSTRAINTS
+  /* the minimum and maximum bounds for each variable. */
+  real xmin[3] = {0., 0.1, 0.5};
+  real xmax[3] = {2., 1.5, 2.3};
+  /* the Jacobian factor for each line, used to compute the covariance matrix. */
+  real jacfac[3];
+#endif
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+#ifdef BOX_CONSTRAINTS
+  data.xmin = xmin;
+  data.xmax = xmax;
+#endif
+
+/*      the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  ldfjac = 15;
+
+  /*      set ftol and xtol to the square root of the machine */
+  /*      and gtol to zero. unless high solutions are */
+  /*      required, these are the recommended settings. */
+
+  ftol = sqrt(__cminpack_func__(dpmpar)(1));
+  xtol = sqrt(__cminpack_func__(dpmpar)(1));
+  gtol = 0.;
+    
+  maxfev = 400;
+  mode = 1;
+  factor = 1.e2;
+  nprint = 0;
+
+  info = __cminpack_func__(lmder)(fcn, &data, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, 
+	maxfev, diag, mode, factor, nprint, &nfev, &njev, 
+	ipvt, qtf, wa1, wa2, wa3, wa4);
+#ifdef BOX_CONSTRAINTS
+  /* compute the real x, using the same change of variable as in fcn */
+  for (j = 0; j < 3; ++j) {
+    real xmiddle = (xmin[j]+xmax[j])/2.;
+    real xwidth = (xmax[j]-xmin[j])/2.;
+    real th =  tanh((x[j]-xmiddle)/xwidth);
+    x[j] = xmiddle + th * xwidth;
+    jacfac[j] = 1. - th * th;
+  }
+#endif
+  fnorm = __cminpack_func__(enorm)(m, fvec);
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      number of function evaluations%10i\n\n", nfev);
+  printf("      number of Jacobian evaluations%10i\n\n", njev);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=0; j<n; ++j) printf("%s%15.7g", j%3==0?"\n     ":"", (double)x[j]);
+  printf("\n");
+  ftol = __cminpack_func__(dpmpar)(1);
+#ifdef TEST_COVAR
+  {
+      /* test the original covar from MINPACK */
+      real covfac = fnorm*fnorm/(m-n);
+      real fjac1[15*3];
+      memcpy(fjac1, fjac, sizeof(fjac));
+      covar(n, fjac1, ldfjac, ipvt, ftol, wa1);
+      printf("      covariance (using covar)\n");
+      for (i=0; i<n; ++i) {
+          for (j=0; j<n; ++j) {
+#           ifdef BOX_CONSTRAINTS
+              fjac1[i*ldfjac+j] *= jacfac[i] * jacfac[j];
+#           endif
+              printf("%s%15.7g", j%3==0?"\n     ":"", (double)fjac1[i*ldfjac+j]*covfac);
+          }
+      }
+      printf("\n");
+  }
+#endif
+  /* test covar1, which also estimates the rank of the Jacobian */
+  k = __cminpack_func__(covar1)(m, n, fnorm*fnorm, fjac, ldfjac, ipvt, ftol, wa1);
+  printf("      covariance\n");
+  for (i=0; i<n; ++i) {
+    for (j=0; j<n; ++j) {
+#    ifdef BOX_CONSTRAINTS
+      fjac[i*ldfjac+j] *= jacfac[i] * jacfac[j];
+#    endif
+      printf("%s%15.7g", j%3==0?"\n     ":"", (double)fjac[i*ldfjac+j]);
+    }
+  }
+  printf("\n");
+  /* printf("      rank(J) = %d\n", k != 0 ? k : n); */
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjac, 
+	 int ldfjac, int iflag)
+{      
+
+  /*      subroutine fcn for lmder example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  const real *y = ((fcndata_t*)p)->y;
+#ifdef BOX_CONSTRAINTS
+  const real *xmin = ((fcndata_t*)p)->xmin;
+  const real *xmax = ((fcndata_t*)p)->xmax;
+  int j;
+  real xb[3];
+  real jacfac[3];
+  real xmiddle, xwidth, th;
+
+  for (j = 0; j < 3; ++j) {
+    xmiddle = (xmin[j]+xmax[j])/2.;
+    xwidth = (xmax[j]-xmin[j])/2.;
+    th =  tanh((x[j]-xmiddle)/xwidth);
+    xb[j] = (xmin[j]+xmax[j])/2. + th * xwidth;
+    jacfac[j] = 1. - th * th;
+  }
+  x = xb;
+#endif
+
+  if (iflag == 0) 
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+
+  if (iflag != 2) 
+    {
+      for (i=0; i < 15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+	}
+    }
+  else
+    {
+      for (i=0; i<15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4;
+	  fjac[i + ldfjac*0] = -1.;
+	  fjac[i + ldfjac*1] = tmp1*tmp2/tmp4;
+	  fjac[i + ldfjac*2] = tmp1*tmp3/tmp4;
+	}
+#    ifdef BOX_CONSTRAINTS
+      for (j = 0; j < 3; ++j) {
+        for (i=0; i < 15; ++i)
+          {
+	    fjac[i + ldfjac*j] *= jacfac[j];
+	  }
+      }
+#    endif
+    }
+  return 0;
+}
diff --git a/examples/tlmdif1_.c b/examples/tlmdif1_.c
new file mode 100644
index 0000000..5cef088
--- /dev/null
+++ b/examples/tlmdif1_.c
@@ -0,0 +1,62 @@
+/*     driver for lmdif1 example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag);
+
+int main()
+{
+    int j, m, n, info, lwa, iwa[3], one=1;
+  real tol, fnorm, x[3], fvec[15], wa[75];
+
+  m = 15;
+  n = 3;
+
+  /* the following starting values provide a rough fit. */
+
+  x[0] = 1.e0;
+  x[1] = 1.e0;
+  x[2] = 1.e0;
+
+  lwa = 75;
+
+  /* set tol to the square root of the machine precision.  unless high
+     precision solutions are required, this is the recommended
+     setting. */
+
+  tol = sqrt(__minpack_func__(dpmpar)(&one));
+
+  __minpack_func__(lmdif1)(&fcn, &m, &n, x, fvec, &tol, &info, iwa, wa, &lwa);
+
+  fnorm = __minpack_func__(enorm)(&m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n ":"", (double)x[j-1]);
+  printf("\n");
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag)
+{
+  /* function fcn for lmdif1 example */
+
+  int i;
+  real tmp1,tmp2,tmp3;
+  real y[15]={1.4e-1,1.8e-1,2.2e-1,2.5e-1,2.9e-1,3.2e-1,3.5e-1,3.9e-1,
+		3.7e-1,5.8e-1,7.3e-1,9.6e-1,1.34e0,2.1e0,4.39e0};
+
+  for (i=0; i<15; i++)
+    {
+      tmp1 = i+1;
+      tmp2 = 15 - i;
+      tmp3 = tmp1;
+      
+      if (i >= 8) tmp3 = tmp2;
+      fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+    }
+}
diff --git a/examples/tlmdif1c.c b/examples/tlmdif1c.c
new file mode 100644
index 0000000..e390ef9
--- /dev/null
+++ b/examples/tlmdif1c.c
@@ -0,0 +1,72 @@
+
+
+/*     driver for lmdif1 example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag);
+
+int main()
+{
+  int info, lwa, iwa[3];
+  real tol, fnorm, x[3], fvec[15], wa[75];
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+
+  /* the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  lwa = 75;
+
+  /* set tol to the square root of the machine precision.  unless high
+     precision solutions are required, this is the recommended
+     setting. */
+
+  tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+  info = __cminpack_func__(lmdif1)(fcn, &data, m, n, x, fvec, tol, iwa, wa, lwa);
+
+  fnorm = __cminpack_func__(enorm)(m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n",(double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n\n %15.7g%15.7g%15.7g\n",
+	 (double)x[0], (double)x[1], (double)x[2]);
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag)
+{
+  /* function fcn for lmdif1 example */
+
+  int i;
+  real tmp1,tmp2,tmp3;
+  const real *y = ((fcndata_t*)p)->y;
+
+  for (i = 0; i < 15; ++i)
+    {
+      tmp1 = i + 1;
+      tmp2 = 15 - i;
+      tmp3 = (i > 7) ? tmp2 : tmp1;
+      fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+    }
+  return 0;
+}
diff --git a/examples/tlmdif_.c b/examples/tlmdif_.c
new file mode 100644
index 0000000..a0edbb8
--- /dev/null
+++ b/examples/tlmdif_.c
@@ -0,0 +1,93 @@
+/*      driver for lmdif example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag);
+
+int main()
+{
+  int i, j, m, n, maxfev, mode, nprint, info, nfev, ldfjac;
+  int ipvt[3];
+  real ftol, xtol, gtol, epsfcn, factor, fnorm;
+  real x[3], fvec[15], diag[3], fjac[15*3], qtf[3], 
+    wa1[3], wa2[3], wa3[3], wa4[15];
+  int one=1;
+  real covfac;
+
+  m = 15;
+  n = 3;
+
+/*      the following starting values provide a rough fit. */
+
+  x[1-1] = 1.;
+  x[2-1] = 1.;
+  x[3-1] = 1.;
+
+  ldfjac = 15;
+
+  /*      set ftol and xtol to the square root of the machine */
+  /*      and gtol to zero. unless high solutions are */
+  /*      required, these are the recommended settings. */
+
+  ftol = sqrt(__minpack_func__(dpmpar)(&one));
+  xtol = sqrt(__minpack_func__(dpmpar)(&one));
+  gtol = 0.;
+
+  maxfev = 800;
+  epsfcn = 0.;
+  mode = 1;
+  factor = 1.e2;
+  nprint = 0;
+
+  __minpack_func__(lmdif)(&fcn, &m, &n, x, fvec, &ftol, &xtol, &gtol, &maxfev, &epsfcn, 
+	 diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, 
+	 ipvt, qtf, wa1, wa2, wa3, wa4);
+
+  fnorm = __minpack_func__(enorm)(&m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      number of function evaluations%10i\n\n", nfev);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+  ftol = __minpack_func__(dpmpar)(&one);
+  covfac = fnorm*fnorm/(m-n);
+  __minpack_func__(covar)(&n, fjac, &ldfjac, ipvt, &ftol, wa1);
+  printf("      covariance\n");
+  for (i=1; i<=n; i++) {
+    for (j=1; j<=n; j++)
+      printf("%s%15.7g", j%3==1?"\n     ":"", (double)fjac[(i-1)*ldfjac+j-1]*covfac);
+  }
+  printf("\n");
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, int *iflag)
+{
+
+/*      subroutine fcn for lmdif example. */
+
+  int i;
+  real tmp1, tmp2, tmp3;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (*iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return;
+    }
+  for (i = 1; i <= 15; i++)
+    {
+      tmp1 = i;
+      tmp2 = 16 - i;
+      tmp3 = tmp1;
+      if (i > 8) tmp3 = tmp2;
+      fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+    }
+  return;
+}
diff --git a/examples/tlmdifc.c b/examples/tlmdifc.c
new file mode 100644
index 0000000..c3cd671
--- /dev/null
+++ b/examples/tlmdifc.c
@@ -0,0 +1,118 @@
+/*      driver for lmdif example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag);
+
+int main()
+{
+  int i, j, maxfev, mode, nprint, info, nfev, ldfjac;
+  int ipvt[3];
+  real ftol, xtol, gtol, epsfcn, factor, fnorm;
+  real x[3], fvec[15], diag[3], fjac[15*3], qtf[3], 
+    wa1[3], wa2[3], wa3[3], wa4[15];
+  int k;
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+
+/*      the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  ldfjac = 15;
+
+  /*      set ftol and xtol to the square root of the machine */
+  /*      and gtol to zero. unless high solutions are */
+  /*      required, these are the recommended settings. */
+
+  ftol = sqrt(__cminpack_func__(dpmpar)(1));
+  xtol = sqrt(__cminpack_func__(dpmpar)(1));
+  gtol = 0.;
+
+  maxfev = 800;
+  epsfcn = 0.;
+  mode = 1;
+  factor = 1.e2;
+  nprint = 0;
+
+  info = __cminpack_func__(lmdif)(fcn, &data, m, n, x, fvec, ftol, xtol, gtol, maxfev, epsfcn, 
+	 diag, mode, factor, nprint, &nfev, fjac, ldfjac, 
+	 ipvt, qtf, wa1, wa2, wa3, wa4);
+
+  fnorm = __cminpack_func__(enorm)(m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      number of function evaluations%10i\n\n", nfev);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=0; j<n; ++j) printf("%s%15.7g", j%3==0?"\n     ":"", (double)x[j]);
+  printf("\n");
+  ftol = __cminpack_func__(dpmpar)(1);
+#ifdef TEST_COVAR
+  {
+      /* test the original covar from MINPACK */
+      real covfac = fnorm*fnorm/(m-n);
+      real fjac1[15*3];
+      memcpy(fjac1, fjac, sizeof(fjac));
+      covar(n, fjac1, ldfjac, ipvt, ftol, wa1);
+      printf("      covariance (using covar)\n");
+      for (i=0; i<n; ++i) {
+          for (j=0; j<n; ++j)
+              printf("%s%15.7g", j%3==1?"\n     ":"", (double)fjac1[i*ldfjac+j]*covfac);
+      }
+      printf("\n");
+  }
+#endif
+  /* test covar1, which also estimates the rank of the Jacobian */
+  k = __cminpack_func__(covar1)(m, n, fnorm*fnorm, fjac, ldfjac, ipvt, ftol, wa1);
+  printf("      covariance\n");
+  for (i=0; i<n; ++i) {
+    for (j=0; j<n; ++j)
+      printf("%s%15.7g", j%3==0?"\n     ":"", (double)fjac[i*ldfjac+j]);
+  }
+  printf("\n");
+  /* printf("      rank(J) = %d\n", k != 0 ? k : n); */
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, int iflag)
+{
+
+/*      subroutine fcn for lmdif example. */
+
+  int i;
+  real tmp1, tmp2, tmp3;
+  const real *y = ((fcndata_t*)p)->y;
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+  for (i = 0; i < 15; ++i)
+    {
+      tmp1 = i + 1;
+      tmp2 = 15 - i;
+      tmp3 = (i > 7) ? tmp2 : tmp1;
+      fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+    }
+  return 0;
+}
diff --git a/examples/tlmstr1_.c b/examples/tlmstr1_.c
new file mode 100644
index 0000000..2b7cf4c
--- /dev/null
+++ b/examples/tlmstr1_.c
@@ -0,0 +1,80 @@
+/*    driver for lmstr1 example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void  fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag);
+
+int main()
+{
+  int j, m, n, ldfjac, info, lwa, ipvt[3], one=1;
+  real tol, fnorm;
+  real x[3], fvec[15], fjac[9], wa[30];
+
+  m = 15;
+  n = 3;
+
+  /*     the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  ldfjac = 3;
+  lwa = 30;
+
+  /*     set tol to the square root of the machine precision.
+     unless high precision solutions are required,
+     this is the recommended setting. */
+
+  tol = sqrt(__minpack_func__(dpmpar)(&one));
+
+  __minpack_func__(lmstr1)(&fcn, &m, &n, 
+	  x, fvec, fjac, &ldfjac, 
+	  &tol, &info, ipvt, wa, &lwa);
+
+  fnorm = __minpack_func__(enorm)(&m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=0; j<n; ++j) printf("%s%15.7g", j%3==0?"\n     ":"", (double)x[j]);
+  printf("\n");
+
+  return 0;
+}
+
+void  fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag)
+{
+  /*  subroutine fcn for lmstr1 example. */
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (*iflag < 2)
+    {
+      for (i=1; i<=15; i++)
+	{
+	  tmp1=i;
+	  tmp2 = 16-i;
+	  tmp3 = tmp1;
+	  if (i > 8) tmp3 = tmp2;
+	  fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+	}
+    }
+  else
+    {
+      i = *iflag - 1;
+      tmp1 = i;
+      tmp2 = 16 - i;
+      tmp3 = tmp1;
+      if (i > 8) tmp3 = tmp2;
+      tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4=tmp4*tmp4;
+      fjrow[1-1] = -1;
+      fjrow[2-1] = tmp1*tmp2/tmp4;
+      fjrow[3-1] = tmp1*tmp3/tmp4;
+    }
+}
diff --git a/examples/tlmstr1c.c b/examples/tlmstr1c.c
new file mode 100644
index 0000000..c8eb753
--- /dev/null
+++ b/examples/tlmstr1c.c
@@ -0,0 +1,89 @@
+/*    driver for lmstr1 example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+} fcndata_t;
+
+int  fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag);
+
+int main()
+{
+  int j, ldfjac, info, lwa, ipvt[3];
+  real tol, fnorm;
+  real x[3], fvec[15], fjac[9], wa[30];
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+
+  /*     the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  ldfjac = 3;
+  lwa = 30;
+
+  /*     set tol to the square root of the machine precision.
+     unless high precision solutions are required,
+     this is the recommended setting. */
+
+  tol = sqrt(__cminpack_func__(dpmpar)(1));
+
+  info = __cminpack_func__(lmstr1)(fcn, &data, m, n, 
+	  x, fvec, fjac, ldfjac, 
+	  tol, ipvt, wa, lwa);
+
+  fnorm = __cminpack_func__(enorm)(m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=0; j<n; ++j) printf("%s%15.7g", j%3==0?"\n     ":"", (double)x[j]);
+  printf("\n");
+
+  return 0;
+}
+
+int  fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag)
+{
+  /*  subroutine fcn for lmstr1 example. */
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  const real *y = ((fcndata_t*)p)->y;
+
+  if (iflag < 2)
+    {
+      for (i=0; i < 15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+	}
+    }
+  else
+    {
+      i = iflag - 2;
+      tmp1 = i + 1;
+      tmp2 = 15 - i;
+      tmp3 = (i > 7) ? tmp2 : tmp1;
+      tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4;
+      fjrow[0] = -1.;
+      fjrow[1] = tmp1*tmp2/tmp4;
+      fjrow[2] = tmp1*tmp3/tmp4;
+    }
+  return 0;
+}
diff --git a/examples/tlmstr_.c b/examples/tlmstr_.c
new file mode 100644
index 0000000..6891e22
--- /dev/null
+++ b/examples/tlmstr_.c
@@ -0,0 +1,110 @@
+/*      driver for lmstr example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <minpack.h>
+#define real __minpack_real__
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag);
+
+int main()
+{
+    int i, j, m, n, ldfjac, maxfev, mode, nprint, info, nfev, njev;
+  int ipvt[3];
+  real ftol, xtol, gtol, factor, fnorm;
+  real x[3], fvec[15], fjac[3*3], diag[3], qtf[3], 
+    wa1[3], wa2[3], wa3[3], wa4[15];
+  int one=1;
+
+  m = 15;
+  n = 3;
+
+  /*      the following starting values provide a rough fit. */
+
+  x[1-1] = 1.;
+  x[2-1] = 1.;
+  x[3-1] = 1.;
+
+  ldfjac = 3;
+
+  /*      set ftol and xtol to the square root of the machine */
+  /*      and gtol to zero. unless high solutions are */
+  /*      required, these are the recommended settings. */
+
+  ftol = sqrt(__minpack_func__(dpmpar)(&one));
+  xtol = sqrt(__minpack_func__(dpmpar)(&one));
+  gtol = 0.;
+
+  maxfev = 400;
+  mode = 1;
+  factor = 1.e2;
+  nprint = 0;
+
+  __minpack_func__(lmstr)(&fcn, &m, &n, x, fvec, fjac, &ldfjac, &ftol, &xtol, &gtol, 
+	&maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, 
+	ipvt, qtf, wa1, wa2, wa3, wa4);
+  fnorm = __minpack_func__(enorm)(&m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      number of function evaluations%10i\n\n", nfev);
+  printf("      number of Jacobian evaluations%10i\n\n", njev);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=1; j<=n; j++) printf("%s%15.7g", j%3==1?"\n     ":"", (double)x[j-1]);
+  printf("\n");
+  ftol = __minpack_func__(dpmpar)(&one);
+  {
+      /* test the original covar from MINPACK */
+      real covfac = fnorm*fnorm/(m-n);
+      __minpack_func__(covar)(&n, fjac, &ldfjac, ipvt, &ftol, wa1);
+      printf("      covariance\n");
+      for (i=0; i<n; ++i) {
+          for (j=0; j<n; ++j)
+              printf("%s%15.7g", j%3==0?"\n     ":"", (double)fjac[i*ldfjac+j]*covfac);
+      }
+      printf("\n");
+  }
+
+  return 0;
+}
+
+void fcn(const int *m, const int *n, const real *x, real *fvec, real *fjrow, int *iflag)
+{
+
+  /*      subroutine fcn for lmstr example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  real y[15]={1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+		3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+
+  if (*iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return;
+    }
+  if (*iflag < 2)
+    {
+      for (i = 1; i <= 15; i++)
+	{
+	  tmp1 = i;
+	  tmp2 = 16 - i;
+	  tmp3 = tmp1;
+	  if (i > 8) tmp3 = tmp2;
+	  fvec[i-1] = y[i-1] - (x[1-1] + tmp1/(x[2-1]*tmp2 + x[3-1]*tmp3));
+}
+			 }
+else
+  {
+    i = *iflag - 1;
+    tmp1 = i;
+    tmp2 = 16 - i;
+    tmp3 = tmp1;
+    if (i > 8) tmp3 = tmp2;
+    tmp4 = (x[2-1]*tmp2 + x[3-1]*tmp3); tmp4 = tmp4*tmp4;
+    fjrow[1-1] = -1.;
+    fjrow[2-1] = tmp1*tmp2/tmp4;
+    fjrow[3-1] = tmp1*tmp3/tmp4;
+  }
+  return;
+}
diff --git a/examples/tlmstrc.c b/examples/tlmstrc.c
new file mode 100644
index 0000000..2060cfb
--- /dev/null
+++ b/examples/tlmstrc.c
@@ -0,0 +1,131 @@
+/*      driver for lmstr example. */
+
+#include <stdio.h>
+#include <math.h>
+#include <cminpack.h>
+#define real __cminpack_real__
+
+/* the following struct defines the data points */
+typedef struct  {
+    int m;
+    real *y;
+} fcndata_t;
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag);
+
+int main()
+{
+  int i, j, ldfjac, maxfev, mode, nprint, info, nfev, njev;
+  int ipvt[3];
+  real ftol, xtol, gtol, factor, fnorm;
+  real x[3], fvec[15], fjac[3*3], diag[3], qtf[3], 
+    wa1[3], wa2[3], wa3[3], wa4[15];
+  int k;
+  const int m = 15;
+  const int n = 3;
+  /* auxiliary data (e.g. measurements) */
+  real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1,
+                  3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
+  fcndata_t data;
+  data.m = m;
+  data.y = y;
+
+  /*      the following starting values provide a rough fit. */
+
+  x[0] = 1.;
+  x[1] = 1.;
+  x[2] = 1.;
+
+  ldfjac = 3;
+
+  /*      set ftol and xtol to the square root of the machine */
+  /*      and gtol to zero. unless high solutions are */
+  /*      required, these are the recommended settings. */
+
+  ftol = sqrt(__cminpack_func__(dpmpar)(1));
+  xtol = sqrt(__cminpack_func__(dpmpar)(1));
+  gtol = 0.;
+
+  maxfev = 400;
+  mode = 1;
+  factor = 1.e2;
+  nprint = 0;
+
+  info = __cminpack_func__(lmstr)(fcn, &data, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, 
+	maxfev, diag, mode, factor, nprint, &nfev, &njev, 
+	ipvt, qtf, wa1, wa2, wa3, wa4);
+  fnorm = __cminpack_func__(enorm)(m, fvec);
+
+  printf("      final l2 norm of the residuals%15.7g\n\n", (double)fnorm);
+  printf("      number of function evaluations%10i\n\n", nfev);
+  printf("      number of Jacobian evaluations%10i\n\n", njev);
+  printf("      exit parameter                %10i\n\n", info);
+  printf("      final approximate solution\n");
+  for (j=0; j<n; ++j) printf("%s%15.7g", j%3==0?"\n     ":"", (double)x[j]);
+  printf("\n");
+  ftol = __cminpack_func__(dpmpar)(1);
+#ifdef TEST_COVAR
+  {
+      /* test the original covar from MINPACK */
+      real covfac = fnorm*fnorm/(m-n);
+      real fjac1[3*3];
+      memcpy(fjac1, fjac, sizeof(fjac));
+      covar(n, fjac1, ldfjac, ipvt, ftol, wa1);
+      printf("      covariance (using covar)\n");
+      for (i=0; i<n; ++i) {
+          for (j=0; j<n; ++j)
+              printf("%s%15.7g", j%3==0?"\n     ":"", (double)fjac1[i*ldfjac+j]*covfac);
+      }
+      printf("\n");
+  }
+#endif
+  /* test covar1, which also estimates the rank of the Jacobian */
+  k = __cminpack_func__(covar1)(m, n, fnorm*fnorm, fjac, ldfjac, ipvt, ftol, wa1);
+  printf("      covariance\n");
+  for (i=0; i<n; ++i) {
+    for (j=0; j<n; ++j)
+        printf("%s%15.7g", j%3==0?"\n     ":"", (double)fjac[i*ldfjac+j]);
+  }
+  printf("\n");
+  /* printf("      rank(J) = %d\n", k != 0 ? k : n); */
+
+  return 0;
+}
+
+int fcn(void *p, int m, int n, const real *x, real *fvec, real *fjrow, int iflag)
+{
+
+  /*      subroutine fcn for lmstr example. */
+
+  int i;
+  real tmp1, tmp2, tmp3, tmp4;
+  const real *y = ((fcndata_t*)p)->y;
+
+  if (iflag == 0)
+    {
+      /*      insert print statements here when nprint is positive. */
+      return 0;
+    }
+  if (iflag < 2)
+    {
+      for (i=0; i < 15; ++i)
+	{
+	  tmp1 = i + 1;
+	  tmp2 = 15 - i;
+	  tmp3 = (i > 7) ? tmp2 : tmp1;
+	  fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3));
+	}
+    }
+  else
+    {
+      i = iflag - 2;
+      tmp1 = i + 1;
+      tmp2 = 15 - i;
+      tmp3 = (i > 7) ? tmp2 : tmp1;
+      tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4;
+      fjrow[0] = -1.;
+      fjrow[1] = tmp1*tmp2/tmp4;
+      fjrow[2] = tmp1*tmp3/tmp4;
+    }
+  return 0;
+}
diff --git a/examples/ucodrv.f b/examples/ucodrv.f
new file mode 100644
index 0000000..3df3c44
--- /dev/null
+++ b/examples/ucodrv.f
@@ -0,0 +1,122 @@
+c     **********
+c
+c     this program tests codes for the unconstrained optimization of
+c     a nonlinear function of n variables. it consists of a driver
+c     and an interface subroutine fcn. the driver reads in data,
+c     calls the unconstrained optimizer, and finally prints out
+c     information on the performance of the optimizer. this is
+c     only a sample driver, many other drivers are possible. the
+c     interface subroutine fcn is necessary to take into account the
+c     forms of calling sequences used by the function subroutines
+c     in the various unconstrained optimizers.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,drvcr1,enorm,grdfcn,initpt,objfcn
+c
+c       fortran-supplied ... dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ic,info,k,lwa,n,nfev,nprob,nread,ntries,nwrite
+      integer na(120),nf(120),np(120),nx(120)
+      double precision factor,f1,f2,gnorm1,gnorm2,one,ten,tol
+      double precision fval(120),gvec(100),gnm(120),wa(6130),x(100)
+      double precision dpmpar,enorm
+      external fcn
+      common /refnum/ nprob,nfev
+c
+c     logical input unit is assumed to be number 5.
+c     logical output unit is assumed to be number 6.
+c
+      data nread,nwrite /5,6/
+c
+      data one,ten /1.0d0,1.0d1/
+      tol = dsqrt(dpmpar(1))
+      lwa = 6130
+      ic = 0
+   10 continue
+         read (nread,50) nprob,n,ntries
+         if (nprob .le. 0) go to 30
+         factor = one
+         do 20 k = 1, ntries
+            ic = ic + 1
+            call initpt(n,x,nprob,factor)
+            call objfcn(n,x,f1,nprob)
+            call grdfcn(n,x,gvec,nprob)
+            gnorm1 = enorm(n,gvec)
+            write (nwrite,60) nprob,n
+            nfev = 0
+            call drvcr1(fcn,n,x,f2,gvec,tol,info,wa,lwa)
+            call objfcn(n,x,f2,nprob)
+            call grdfcn(n,x,gvec,nprob)
+            gnorm2 = enorm(n,gvec)
+            np(ic) = nprob
+            na(ic) = n
+            nf(ic) = nfev
+            nx(ic) = info
+            fval(ic) = f2
+            gnm(ic) = gnorm2
+            write (nwrite,70)
+     *            f1,f2,gnorm1,gnorm2,nfev,info,(x(i), i = 1, n)
+            factor = ten*factor
+   20       continue
+         go to 10
+   30 continue
+      write (nwrite,80) ic
+      write (nwrite,90)
+      do 40 i = 1, ic
+         write (nwrite,100) np(i),na(i),nf(i),nx(i),fval(i),gnm(i)
+   40    continue
+      stop
+   50 format (3i5)
+   60 format ( //// 5x, 8h problem, i5, 5x, 10h dimension, i5, 5x //)
+   70 format (5x, 23h initial function value, d15.7 // 5x,
+     *        23h final function value  , d15.7 // 5x,
+     *        23h initial gradient norm , d15.7 // 5x,
+     *        23h final gradient norm   , d15.7 // 5x,
+     *        33h number of function evaluations  , i10 // 5x,
+     *        15h exit parameter, 18x, i10 // 5x,
+     *        27h final approximate solution // (5x, 5d15.7))
+   80 format (12h1summary of , i3, 16h calls to drvcr1 /)
+   90 format (25h nprob   n    nfev  info ,
+     *        42h final function value  final gradient norm /)
+  100 format (i4, i6, i7, i6, 5x, d15.7, 6x, d15.7)
+c
+c     last card of driver.
+c
+      end
+      subroutine fcn(n,x,f,gvec,iflag)
+      integer n,iflag
+      double precision f
+      double precision x(n),gvec(n)
+c     **********
+c
+c     the calling sequence of fcn should be identical to the
+c     calling sequence of the function subroutine in the
+c     unconstrained optimizer. fcn should only call the testing
+c     function and gradient subroutines objfcn and grdfcn with
+c     the appropriate value of problem number (nprob).
+c
+c     subprograms called
+c
+c       minpack-supplied ... grdfcn,objfcn
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer nprob,nfev
+      common /refnum/ nprob,nfev
+      call objfcn(n,x,f,nprob)
+      call grdfcn(n,x,gvec,nprob)
+      nfev = nfev + 1
+      return
+c
+c     last card of interface subroutine fcn.
+c
+      end
diff --git a/examples/vec.h b/examples/vec.h
new file mode 100644
index 0000000..65abb0f
--- /dev/null
+++ b/examples/vec.h
@@ -0,0 +1,21 @@
+#ifndef __CMINPACK_HYB_H__
+#define __CMINPACK_HYB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void hybipt(int n, __cminpack_real__ *x, int nprob, __cminpack_real__ factor);
+
+void vecfcn(int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int nprob);
+
+void vecjac(int n, const __cminpack_real__ *x, __cminpack_real__ *fjac, int ldfjac, int nprob);
+
+void errjac(int n, const __cminpack_real__ *x, __cminpack_real__ *fjac, int ldfjac, int nprob);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __CMINPACK_HYB_H__ */
diff --git a/examples/vecfcn.c b/examples/vecfcn.c
new file mode 100644
index 0000000..a2b3173
--- /dev/null
+++ b/examples/vecfcn.c
@@ -0,0 +1,389 @@
+#include <math.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+static inline real d_sign(real a, real b)
+{
+    real x;
+    x = (a >= 0 ? a : -a);
+    return( b >= 0 ? x : -x);
+}
+
+static inline int max(int a, int b)
+{
+    return (a > b) ? a : b;
+}
+
+static inline int min(int a, int b)
+{
+    return (a < b) ? a : b;
+}
+
+void vecfcn(int n, const real *x, real *fvec, int nprob)
+{
+    /* System generated locals */
+    real d__1, d__2;
+
+    /* Local variables */
+    static real h__;
+    static int i__, j, k, k1, k2, ml;
+    static real ti, tj, tk;
+    static int mu, kp1, iev;
+    static real tpi, sum, sum1, sum2, prod, temp, temp1, temp2;
+
+/*     ********** */
+
+/*     subroutine vecfcn */
+
+/*     this subroutine defines fourteen test functions. the first */
+/*     five test functions are of dimensions 2,4,2,4,3, respectively, */
+/*     while the remaining test functions are of variable dimension */
+/*     n for any n greater than or equal to 1 (problem 6 is an */
+/*     exception to this, since it does not allow n = 1). */
+
+/*     the subroutine statement is */
+
+/*       subroutine vecfcn(n,x,fvec,nprob) */
+
+/*     where */
+
+/*       n is a positive integer input variable. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an output array of length n which contains the nprob */
+/*         function vector evaluated at x. */
+
+/*       nprob is a positive integer input variable which defines the */
+/*         number of the problem. nprob must not exceed 14. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... datan,dcos,dexp,dsign,dsin,dsqrt, */
+/*                            max0,min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --x;
+
+    /* Function Body */
+
+/*     problem selector. */
+
+    switch (nprob) {
+	case 1:  goto L10;
+	case 2:  goto L20;
+	case 3:  goto L30;
+	case 4:  goto L40;
+	case 5:  goto L50;
+	case 6:  goto L60;
+	case 7:  goto L120;
+	case 8:  goto L170;
+	case 9:  goto L200;
+	case 10:  goto L220;
+	case 11:  goto L270;
+	case 12:  goto L300;
+	case 13:  goto L330;
+	case 14:  goto L350;
+    }
+
+/*     rosenbrock function. */
+
+L10:
+    fvec[1] = 1. - x[1];
+/* Computing 2nd power */
+    d__1 = x[1];
+    fvec[2] = 10. * (x[2] - d__1 * d__1);
+    goto L380;
+
+/*     powell singular function. */
+
+L20:
+    fvec[1] = x[1] + 10. * x[2];
+    fvec[2] = sqrt(5.) * (x[3] - x[4]);
+/* Computing 2nd power */
+    d__1 = x[2] - 2. * x[3];
+    fvec[3] = d__1 * d__1;
+/* Computing 2nd power */
+    d__1 = x[1] - x[4];
+    fvec[4] = sqrt(10.) * (d__1 * d__1);
+    goto L380;
+
+/*     powell badly scaled function. */
+
+L30:
+    fvec[1] = 1e4 * x[1] * x[2] - 1.;
+    fvec[2] = exp(-x[1]) + exp(-x[2]) - 1.0001;
+    goto L380;
+
+/*     wood function. */
+
+L40:
+/* Computing 2nd power */
+    d__1 = x[1];
+    temp1 = x[2] - d__1 * d__1;
+/* Computing 2nd power */
+    d__1 = x[3];
+    temp2 = x[4] - d__1 * d__1;
+    fvec[1] = -200. * x[1] * temp1 - (1. - x[1]);
+    fvec[2] = 200. * temp1 + 20.2 * (x[2] - 1.) + 19.8 * (x[4] - 1.);
+    fvec[3] = -180. * x[3] * temp2 - (1. - x[3]);
+    fvec[4] = 180. * temp2 + 20.2 * (x[4] - 1.) + 19.8 * (x[2] - 1.);
+    goto L380;
+
+/*     helical valley function. */
+
+L50:
+    tpi = 8. * atan(1.);
+    temp1 = d_sign(.25, x[2]);
+    if (x[1] > 0.) {
+	temp1 = atan(x[2] / x[1]) / tpi;
+    }
+    if (x[1] < 0.) {
+	temp1 = atan(x[2] / x[1]) / tpi + .5;
+    }
+/* Computing 2nd power */
+    d__1 = x[1];
+/* Computing 2nd power */
+    d__2 = x[2];
+    temp2 = sqrt(d__1 * d__1 + d__2 * d__2);
+    fvec[1] = 10. * (x[3] - 10. * temp1);
+    fvec[2] = 10. * (temp2 - 1.);
+    fvec[3] = x[3];
+    goto L380;
+
+/*     watson function. */
+
+L60:
+    for (k = 1; k <= n; ++k) {
+	fvec[k] = 0.;
+/* L70: */
+    }
+    for (i__ = 1; i__ <= 29; ++i__) {
+	ti = (real) i__ / 29.;
+	sum1 = 0.;
+	temp = 1.;
+	for (j = 2; j <= n; ++j) {
+	    sum1 += (real) (j - 1) * temp * x[j];
+	    temp = ti * temp;
+/* L80: */
+	}
+	sum2 = 0.;
+	temp = 1.;
+	for (j = 1; j <= n; ++j) {
+	    sum2 += temp * x[j];
+	    temp = ti * temp;
+/* L90: */
+	}
+/* Computing 2nd power */
+	d__1 = sum2;
+	temp1 = sum1 - d__1 * d__1 - 1.;
+	temp2 = 2. * ti * sum2;
+	temp = 1. / ti;
+	for (k = 1; k <= n; ++k) {
+	    fvec[k] += temp * ((real) (k - 1) - temp2) * temp1;
+	    temp = ti * temp;
+/* L100: */
+	}
+/* L110: */
+    }
+/* Computing 2nd power */
+    d__1 = x[1];
+    temp = x[2] - d__1 * d__1 - 1.;
+    fvec[1] += x[1] * (1. - 2. * temp);
+    fvec[2] += temp;
+    goto L380;
+
+/*     chebyquad function. */
+
+L120:
+    for (k = 1; k <= n; ++k) {
+	fvec[k] = 0.;
+/* L130: */
+    }
+    for (j = 1; j <= n; ++j) {
+	temp1 = 1.;
+	temp2 = 2. * x[j] - 1.;
+	temp = 2. * temp2;
+	for (i__ = 1; i__ <= n; ++i__) {
+	    fvec[i__] += temp2;
+	    ti = temp * temp2 - temp1;
+	    temp1 = temp2;
+	    temp2 = ti;
+/* L140: */
+	}
+/* L150: */
+    }
+    tk = 1. / (real) (n);
+    iev = -1;
+    for (k = 1; k <= n; ++k) {
+	fvec[k] = tk * fvec[k];
+	if (iev > 0) {
+/* Computing 2nd power */
+	    d__1 = (real) k;
+	    fvec[k] += 1. / (d__1 * d__1 - 1.);
+	}
+	iev = -iev;
+/* L160: */
+    }
+    goto L380;
+
+/*     brown almost-linear function. */
+
+L170:
+    sum = -((real) (n + 1));
+    prod = 1.;
+    for (j = 1; j <= n; ++j) {
+	sum += x[j];
+	prod = x[j] * prod;
+/* L180: */
+    }
+    for (k = 1; k <= n; ++k) {
+	fvec[k] = x[k] + sum;
+/* L190: */
+    }
+    fvec[n] = prod - 1.;
+    goto L380;
+
+/*     discrete boundary value function. */
+
+L200:
+    h__ = 1. / (real) (n + 1);
+    for (k = 1; k <= n; ++k) {
+/* Computing 3rd power */
+	d__1 = x[k] + (real) k * h__ + 1.;
+	temp = d__1 * (d__1 * d__1);
+	temp1 = 0.;
+	if (k != 1) {
+	    temp1 = x[k - 1];
+	}
+	temp2 = 0.;
+	if (k != n) {
+	    temp2 = x[k + 1];
+	}
+/* Computing 2nd power */
+	d__1 = h__;
+	fvec[k] = 2. * x[k] - temp1 - temp2 + temp * (d__1 * d__1) / 2.;
+/* L210: */
+    }
+    goto L380;
+
+/*     discrete integral equation function. */
+
+L220:
+    h__ = 1. / (real) (n + 1);
+    for (k = 1; k <= n; ++k) {
+	tk = (real) k * h__;
+	sum1 = 0.;
+	for (j = 1; j <= k; ++j) {
+	    tj = (real) j * h__;
+/* Computing 3rd power */
+	    d__1 = x[j] + tj + 1.;
+	    temp = d__1 * (d__1 * d__1);
+	    sum1 += tj * temp;
+/* L230: */
+	}
+	sum2 = 0.;
+	kp1 = k + 1;
+	if (n < kp1) {
+	    goto L250;
+	}
+	for (j = kp1; j <= n; ++j) {
+	    tj = (real) j * h__;
+/* Computing 3rd power */
+	    d__1 = x[j] + tj + 1.;
+	    temp = d__1 * (d__1 * d__1);
+	    sum2 += (1. - tj) * temp;
+/* L240: */
+	}
+L250:
+	fvec[k] = x[k] + h__ * ((1. - tk) * sum1 + tk * sum2) / 2.;
+/* L260: */
+    }
+    goto L380;
+
+/*     trigonometric function. */
+
+L270:
+    sum = 0.;
+    for (j = 1; j <= n; ++j) {
+	fvec[j] = cos(x[j]);
+	sum += fvec[j];
+/* L280: */
+    }
+    for (k = 1; k <= n; ++k) {
+	fvec[k] = (real) (n + k) - sin(x[k]) - sum - (real) k * fvec[
+		k];
+/* L290: */
+    }
+    goto L380;
+
+/*     variably dimensioned function. */
+
+L300:
+    sum = 0.;
+    for (j = 1; j <= n; ++j) {
+	sum += (real) j * (x[j] - 1.);
+/* L310: */
+    }
+/* Computing 2nd power */
+    d__1 = sum;
+    temp = sum * (1. + 2. * (d__1 * d__1));
+    for (k = 1; k <= n; ++k) {
+	fvec[k] = x[k] - 1. + (real) k * temp;
+/* L320: */
+    }
+    goto L380;
+
+/*     broyden tridiagonal function. */
+
+L330:
+    for (k = 1; k <= n; ++k) {
+	temp = (3. - 2. * x[k]) * x[k];
+	temp1 = 0.;
+	if (k != 1) {
+	    temp1 = x[k - 1];
+	}
+	temp2 = 0.;
+	if (k != n) {
+	    temp2 = x[k + 1];
+	}
+	fvec[k] = temp - temp1 - 2. * temp2 + 1.;
+/* L340: */
+    }
+    goto L380;
+
+/*     broyden banded function. */
+
+L350:
+    ml = 5;
+    mu = 1;
+    for (k = 1; k <= n; ++k) {
+/* Computing MAX */
+	k1 = max(1,k-ml);
+/* Computing MIN */
+	k2 = min(k+mu,n);
+	temp = 0.;
+	for (j = k1; j <= k2; ++j) {
+	    if (j != k) {
+		temp += x[j] * (1. + x[j]);
+	    }
+/* L360: */
+	}
+/* Computing 2nd power */
+	d__1 = x[k];
+	fvec[k] = x[k] * (2. + 5. * (d__1 * d__1)) + 1. - temp;
+/* L370: */
+    }
+L380:
+    return;
+
+/*     last card of subroutine vecfcn. */
+
+} /* vecfcn_ */
+
diff --git a/examples/vecfcn.f b/examples/vecfcn.f
new file mode 100644
index 0000000..aa7e16a
--- /dev/null
+++ b/examples/vecfcn.f
@@ -0,0 +1,273 @@
+      subroutine vecfcn(n,x,fvec,nprob)
+      integer n,nprob
+      double precision x(n),fvec(n)
+c     **********
+c
+c     subroutine vecfcn
+c
+c     this subroutine defines fourteen test functions. the first
+c     five test functions are of dimensions 2,4,2,4,3, respectively,
+c     while the remaining test functions are of variable dimension
+c     n for any n greater than or equal to 1 (problem 6 is an
+c     exception to this, since it does not allow n = 1).
+c
+c     the subroutine statement is
+c
+c       subroutine vecfcn(n,x,fvec,nprob)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an input array of length n.
+c
+c       fvec is an output array of length n which contains the nprob
+c         function vector evaluated at x.
+c
+c       nprob is a positive integer input variable which defines the
+c         number of the problem. nprob must not exceed 14.
+c
+c     subprograms called
+c
+c       fortran-supplied ... datan,dcos,dexp,dsign,dsin,dsqrt,
+c                            max0,min0
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iev,ivar,j,k,k1,k2,kp1,ml,mu
+      double precision c1,c2,c3,c4,c5,c6,c7,c8,c9,eight,five,h,one,
+     *                 prod,sum,sum1,sum2,temp,temp1,temp2,ten,three,
+     *                 ti,tj,tk,tpi,two,zero
+      double precision dfloat
+      data zero,one,two,three,five,eight,ten
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,5.0d0,8.0d0,1.0d1/
+      data c1,c2,c3,c4,c5,c6,c7,c8,c9
+     *     /1.0d4,1.0001d0,2.0d2,2.02d1,1.98d1,1.8d2,2.5d-1,5.0d-1,
+     *      2.9d1/
+      dfloat(ivar) = ivar
+c
+c     problem selector.
+c
+      go to (10,20,30,40,50,60,120,170,200,220,270,300,330,350), nprob
+c
+c     rosenbrock function.
+c
+   10 continue
+      fvec(1) = one - x(1)
+      fvec(2) = ten*(x(2) - x(1)**2)
+      go to 380
+c
+c     powell singular function.
+c
+   20 continue
+      fvec(1) = x(1) + ten*x(2)
+      fvec(2) = dsqrt(five)*(x(3) - x(4))
+      fvec(3) = (x(2) - two*x(3))**2
+      fvec(4) = dsqrt(ten)*(x(1) - x(4))**2
+      go to 380
+c
+c     powell badly scaled function.
+c
+   30 continue
+      fvec(1) = c1*x(1)*x(2) - one
+      fvec(2) = dexp(-x(1)) + dexp(-x(2)) - c2
+      go to 380
+c
+c     wood function.
+c
+   40 continue
+      temp1 = x(2) - x(1)**2
+      temp2 = x(4) - x(3)**2
+      fvec(1) = -c3*x(1)*temp1 - (one - x(1))
+      fvec(2) = c3*temp1 + c4*(x(2) - one) + c5*(x(4) - one)
+      fvec(3) = -c6*x(3)*temp2 - (one - x(3))
+      fvec(4) = c6*temp2 + c4*(x(4) - one) + c5*(x(2) - one)
+      go to 380
+c
+c     helical valley function.
+c
+   50 continue
+      tpi = eight*datan(one)
+      temp1 = dsign(c7,x(2))
+      if (x(1) .gt. zero) temp1 = datan(x(2)/x(1))/tpi
+      if (x(1) .lt. zero) temp1 = datan(x(2)/x(1))/tpi + c8
+      temp2 = dsqrt(x(1)**2+x(2)**2)
+      fvec(1) = ten*(x(3) - ten*temp1)
+      fvec(2) = ten*(temp2 - one)
+      fvec(3) = x(3)
+      go to 380
+c
+c     watson function.
+c
+   60 continue
+      do 70 k = 1, n
+         fvec(k) = zero
+   70    continue
+      do 110 i = 1, 29
+         ti = dfloat(i)/c9
+         sum1 = zero
+         temp = one
+         do 80 j = 2, n
+            sum1 = sum1 + dfloat(j-1)*temp*x(j)
+            temp = ti*temp
+   80       continue
+         sum2 = zero
+         temp = one
+         do 90 j = 1, n
+            sum2 = sum2 + temp*x(j)
+            temp = ti*temp
+   90       continue
+         temp1 = sum1 - sum2**2 - one
+         temp2 = two*ti*sum2
+         temp = one/ti
+         do 100 k = 1, n
+            fvec(k) = fvec(k) + temp*(dfloat(k-1) - temp2)*temp1
+            temp = ti*temp
+  100       continue
+  110    continue
+      temp = x(2) - x(1)**2 - one
+      fvec(1) = fvec(1) + x(1)*(one - two*temp)
+      fvec(2) = fvec(2) + temp
+      go to 380
+c
+c     chebyquad function.
+c
+  120 continue
+      do 130 k = 1, n
+         fvec(k) = zero
+  130    continue
+      do 150 j = 1, n
+         temp1 = one
+         temp2 = two*x(j) - one
+         temp = two*temp2
+         do 140 i = 1, n
+            fvec(i) = fvec(i) + temp2
+            ti = temp*temp2 - temp1
+            temp1 = temp2
+            temp2 = ti
+  140       continue
+  150    continue
+      tk = one/dfloat(n)
+      iev = -1
+      do 160 k = 1, n
+         fvec(k) = tk*fvec(k)
+         if (iev .gt. 0) fvec(k) = fvec(k) + one/(dfloat(k)**2 - one)
+         iev = -iev
+  160    continue
+      go to 380
+c
+c     brown almost-linear function.
+c
+  170 continue
+      sum = -dfloat(n+1)
+      prod = one
+      do 180 j = 1, n
+         sum = sum + x(j)
+         prod = x(j)*prod
+  180    continue
+      do 190 k = 1, n
+         fvec(k) = x(k) + sum
+  190    continue
+      fvec(n) = prod - one
+      go to 380
+c
+c     discrete boundary value function.
+c
+  200 continue
+      h = one/dfloat(n+1)
+      do 210 k = 1, n
+         temp = (x(k) + dfloat(k)*h + one)**3
+         temp1 = zero
+         if (k .ne. 1) temp1 = x(k-1)
+         temp2 = zero
+         if (k .ne. n) temp2 = x(k+1)
+         fvec(k) = two*x(k) - temp1 - temp2 + temp*h**2/two
+  210    continue
+      go to 380
+c
+c     discrete integral equation function.
+c
+  220 continue
+      h = one/dfloat(n+1)
+      do 260 k = 1, n
+         tk = dfloat(k)*h
+         sum1 = zero
+         do 230 j = 1, k
+            tj = dfloat(j)*h
+            temp = (x(j) + tj + one)**3
+            sum1 = sum1 + tj*temp
+  230       continue
+         sum2 = zero
+         kp1 = k + 1
+         if (n .lt. kp1) go to 250
+         do 240 j = kp1, n
+            tj = dfloat(j)*h
+            temp = (x(j) + tj + one)**3
+            sum2 = sum2 + (one - tj)*temp
+  240       continue
+  250    continue
+         fvec(k) = x(k) + h*((one - tk)*sum1 + tk*sum2)/two
+  260    continue
+      go to 380
+c
+c     trigonometric function.
+c
+  270 continue
+      sum = zero
+      do 280 j = 1, n
+         fvec(j) = dcos(x(j))
+         sum = sum + fvec(j)
+  280    continue
+      do 290 k = 1, n
+         fvec(k) = dfloat(n+k) - dsin(x(k)) - sum - dfloat(k)*fvec(k)
+  290    continue
+      go to 380
+c
+c     variably dimensioned function.
+c
+  300 continue
+      sum = zero
+      do 310 j = 1, n
+         sum = sum + dfloat(j)*(x(j) - one)
+  310    continue
+      temp = sum*(one + two*sum**2)
+      do 320 k = 1, n
+         fvec(k) = x(k) - one + dfloat(k)*temp
+  320    continue
+      go to 380
+c
+c     broyden tridiagonal function.
+c
+  330 continue
+      do 340 k = 1, n
+         temp = (three - two*x(k))*x(k)
+         temp1 = zero
+         if (k .ne. 1) temp1 = x(k-1)
+         temp2 = zero
+         if (k .ne. n) temp2 = x(k+1)
+         fvec(k) = temp - temp1 - two*temp2 + one
+  340    continue
+      go to 380
+c
+c     broyden banded function.
+c
+  350 continue
+      ml = 5
+      mu = 1
+      do 370 k = 1, n
+         k1 = max0(1,k-ml)
+         k2 = min0(k+mu,n)
+         temp = zero
+         do 360 j = k1, k2
+            if (j .ne. k) temp = temp + x(j)*(one + x(j))
+  360       continue
+         fvec(k) = x(k)*(two + five*x(k)**2) + one - temp
+  370    continue
+  380 continue
+      return
+c
+c     last card of subroutine vecfcn.
+c
+      end
diff --git a/examples/vecjac.c b/examples/vecjac.c
new file mode 100644
index 0000000..4f3ea08
--- /dev/null
+++ b/examples/vecjac.c
@@ -0,0 +1,430 @@
+#include <math.h>
+#include <assert.h>
+#include "cminpack.h"
+#include "vec.h"
+#define real __cminpack_real__
+
+static inline int max(int a, int b)
+{
+    return (a > b) ? a : b;
+}
+
+static inline int min(int a, int b)
+{
+    return (a < b) ? a : b;
+}
+
+void vecjac(int n, const real *x, real *fjac, int ldfjac, int nprob)
+{
+    /* System generated locals */
+    int fjac_offset;
+    real d__1, d__2;
+
+    /* Local variables */
+    static real h__;
+    static int i__, j, k, k1, k2, ml;
+    static real ti, tj, tk;
+    static int mu;
+    static real tpi, sum, sum1, sum2, prod, temp, temp1, temp2, temp3, 
+	    temp4;
+
+/*     ********** */
+
+/*     subroutine vecjac */
+
+/*     this subroutine defines the jacobian matrices of fourteen */
+/*     test functions. the problem dimensions are as described */
+/*     in the prologue comments of vecfcn. */
+
+/*     the subroutine statement is */
+
+/*       subroutine vecjac(n,x,fjac,ldfjac,nprob) */
+
+/*     where */
+
+/*       n is a positive integer variable. */
+
+/*       x is an array of length n. */
+
+/*       fjac is an n by n array. on output fjac contains the */
+/*         jacobian matrix of the nprob function evaluated at x. */
+
+/*       ldfjac is a positive integer variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       nprob is a positive integer variable which defines the */
+/*         number of the problem. nprob must not exceed 14. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt, */
+/*                            max0,min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+    fjac_offset = 1 + ldfjac;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     jacobian routine selector. */
+    assert(nprob >= 1 && nprob <=14);
+    switch (nprob) {
+	case 1:  goto L10;
+	case 2:  goto L20;
+	case 3:  goto L50;
+	case 4:  goto L60;
+	case 5:  goto L90;
+	case 6:  goto L100;
+	case 7:  goto L200;
+	case 8:  goto L230;
+	case 9:  goto L290;
+	case 10:  goto L320;
+	case 11:  goto L350;
+	case 12:  goto L380;
+	case 13:  goto L420;
+	case 14:  goto L450;
+    }
+
+/*     rosenbrock function. */
+
+L10:
+    fjac[1 * ldfjac + 1] = -1.;
+    fjac[2 * ldfjac + 1] = 0.;
+    fjac[1 * ldfjac + 2] = -20. * x[1];
+    fjac[2 * ldfjac + 2] = 10.;
+    goto L490;
+
+/*     powell singular function. */
+
+L20:
+    for (k = 1; k <= 4; ++k) {
+	for (j = 1; j <= 4; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L30: */
+	}
+/* L40: */
+    }
+    fjac[1 * ldfjac + 1] = 1.;
+    fjac[2 * ldfjac + 1] = 10.;
+    fjac[3 * ldfjac + 2] = sqrt(5.);
+    fjac[4 * ldfjac + 2] = -fjac[3 * ldfjac + 2];
+    fjac[2 * ldfjac + 3] = 2. * (x[2] - 2. * x[3]);
+    fjac[3 * ldfjac + 3] = -2. * fjac[2 * ldfjac + 3];
+    fjac[1 * ldfjac + 4] = 2. * sqrt(10.) * (x[1] - x[4]);
+    fjac[4 * ldfjac + 4] = -fjac[1 * ldfjac + 4];
+    goto L490;
+
+/*     powell badly scaled function. */
+
+L50:
+    fjac[1 * ldfjac + 1] = 1e4 * x[2];
+    fjac[2 * ldfjac + 1] = 1e4 * x[1];
+    fjac[1 * ldfjac + 2] = -exp(-x[1]);
+    fjac[2 * ldfjac + 2] = -exp(-x[2]);
+    goto L490;
+
+/*     wood function. */
+
+L60:
+    for (k = 1; k <= 4; ++k) {
+	for (j = 1; j <= 4; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L70: */
+	}
+/* L80: */
+    }
+/* Computing 2nd power */
+    d__1 = x[1];
+    temp1 = x[2] - 3. * (d__1 * d__1);
+/* Computing 2nd power */
+    d__1 = x[3];
+    temp2 = x[4] - 3. * (d__1 * d__1);
+    fjac[1 * ldfjac + 1] = -200. * temp1 + 1.;
+    fjac[2 * ldfjac + 1] = -200. * x[1];
+    fjac[1 * ldfjac + 2] = -2. * 200. * x[1];
+    fjac[2 * ldfjac + 2] = 200. + 20.2;
+    fjac[4 * ldfjac + 2] = 19.8;
+    fjac[3 * ldfjac + 3] = -180. * temp2 + 1.;
+    fjac[4 * ldfjac + 3] = -180. * x[3];
+    fjac[2 * ldfjac + 4] = 19.8;
+    fjac[3 * ldfjac + 4] = -2. * 180. * x[3];
+    fjac[4 * ldfjac + 4] = 180. + 20.2;
+    goto L490;
+
+/*     helical valley function. */
+
+L90:
+    tpi = 8. * atan(1.);
+/* Computing 2nd power */
+    d__1 = x[1];
+/* Computing 2nd power */
+    d__2 = x[2];
+    temp = d__1 * d__1 + d__2 * d__2;
+    temp1 = tpi * temp;
+    temp2 = sqrt(temp);
+    fjac[1 * ldfjac + 1] = 100. * x[2] / temp1;
+    fjac[2 * ldfjac + 1] = -100. * x[1] / temp1;
+    fjac[3 * ldfjac + 1] = 10.;
+    fjac[1 * ldfjac + 2] = 10. * x[1] / temp2;
+    fjac[2 * ldfjac + 2] = 10. * x[2] / temp2;
+    fjac[3 * ldfjac + 2] = 0.;
+    fjac[1 * ldfjac + 3] = 0.;
+    fjac[2 * ldfjac + 3] = 0.;
+    fjac[3 * ldfjac + 3] = 1.;
+    goto L490;
+
+/*     watson function. */
+
+L100:
+    for (k = 1; k <= n; ++k) {
+	for (j = k; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L110: */
+	}
+/* L120: */
+    }
+    for (i__ = 1; i__ <= 29; ++i__) {
+	ti = (real) i__ / 29.;
+	sum1 = 0.;
+	temp = 1.;
+	for (j = 2; j <= n; ++j) {
+	    sum1 += (real) (j-1) * temp * x[j];
+	    temp = ti * temp;
+/* L130: */
+	}
+	sum2 = 0.;
+	temp = 1.;
+	for (j = 1; j <= n; ++j) {
+	    sum2 += temp * x[j];
+	    temp = ti * temp;
+/* L140: */
+	}
+/* Computing 2nd power */
+	d__1 = sum2;
+	temp1 = 2. * (sum1 - d__1 * d__1 - 1.);
+	temp2 = 2. * sum2;
+/* Computing 2nd power */
+	d__1 = ti;
+	temp = d__1 * d__1;
+	tk = 1.;
+	for (k = 1; k <= n; ++k) {
+	    tj = tk;
+	    for (j = k; j <= n; ++j) {
+		fjac[k + j * ldfjac] += tj * (((real) (k-1) / ti - 
+			temp2) * ((real) (j-1) / ti - temp2) - temp1);
+		tj = ti * tj;
+/* L150: */
+	    }
+	    tk = temp * tk;
+/* L160: */
+	}
+/* L170: */
+    }
+/* Computing 2nd power */
+    d__1 = x[1];
+    fjac[1 * ldfjac + 1] = fjac[1 * ldfjac + 1] + 6. * (d__1 * d__1) - 2. * x[2] + 3.;
+    fjac[2 * ldfjac + 1] -= 2. * x[1];
+    fjac[2 * ldfjac + 2] += 1.;
+    for (k = 1; k <= n; ++k) {
+	for (j = k; j <= n; ++j) {
+	    fjac[j + k * ldfjac] = fjac[k + j * ldfjac];
+/* L180: */
+	}
+/* L190: */
+    }
+    goto L490;
+
+/*     chebyquad function. */
+
+L200:
+    tk = 1. / (real) (n);
+    for (j = 1; j <= n; ++j) {
+	temp1 = 1.;
+	temp2 = 2. * x[j] - 1.;
+	temp = 2. * temp2;
+	temp3 = 0.;
+	temp4 = 2.;
+	for (k = 1; k <= n; ++k) {
+	    fjac[k + j * ldfjac] = tk * temp4;
+	    ti = 4. * temp2 + temp * temp4 - temp3;
+	    temp3 = temp4;
+	    temp4 = ti;
+	    ti = temp * temp2 - temp1;
+	    temp1 = temp2;
+	    temp2 = ti;
+/* L210: */
+	}
+/* L220: */
+    }
+    goto L490;
+
+/*     brown almost-linear function. */
+
+L230:
+    prod = 1.;
+    for (j = 1; j <= n; ++j) {
+	prod = x[j] * prod;
+	for (k = 1; k <= n; ++k) {
+	    fjac[k + j * ldfjac] = 1.;
+/* L240: */
+	}
+	fjac[j + j * ldfjac] = 2.;
+/* L250: */
+    }
+    for (j = 1; j <= n; ++j) {
+	temp = x[j];
+	if (temp != 0.) {
+	    goto L270;
+	}
+	temp = 1.;
+	prod = 1.;
+	for (k = 1; k <= n; ++k) {
+	    if (k != j) {
+		prod = x[k] * prod;
+	    }
+/* L260: */
+	}
+L270:
+	fjac[n + j * ldfjac] = prod / temp;
+/* L280: */
+    }
+    goto L490;
+
+/*     discrete boundary value function. */
+
+L290:
+    h__ = 1. / (real) (n+1);
+    for (k = 1; k <= n; ++k) {
+/* Computing 2nd power */
+	d__1 = x[k] + (real) k * h__ + 1.;
+	temp = 3. * (d__1 * d__1);
+	for (j = 1; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L300: */
+	}
+/* Computing 2nd power */
+	d__1 = h__;
+	fjac[k + k * ldfjac] = 2. + temp * (d__1 * d__1) / 2.;
+	if (k != 1) {
+	    fjac[k + (k - 1) * ldfjac] = -1.;
+	}
+	if (k != n) {
+	    fjac[k + (k + 1) * ldfjac] = -1.;
+	}
+/* L310: */
+    }
+    goto L490;
+
+/*     discrete integral equation function. */
+
+L320:
+    h__ = 1. / (real) (n+1);
+    for (k = 1; k <= n; ++k) {
+	tk = (real) k * h__;
+	for (j = 1; j <= n; ++j) {
+	    tj = (real) j * h__;
+/* Computing 2nd power */
+	    d__1 = x[j] + tj + 1.;
+	    temp = 3. * (d__1 * d__1);
+/* Computing MIN */
+	    d__1 = tj * (1. - tk), d__2 = tk * (1. - tj);
+	    fjac[k + j * ldfjac] = h__ * min(d__1,d__2) * temp / 2.;
+/* L330: */
+	}
+	fjac[k + k * ldfjac] += 1.;
+/* L340: */
+    }
+    goto L490;
+
+/*     trigonometric function. */
+
+L350:
+    for (j = 1; j <= n; ++j) {
+	temp = sin(x[j]);
+	for (k = 1; k <= n; ++k) {
+	    fjac[k + j * ldfjac] = temp;
+/* L360: */
+	}
+	fjac[j + j * ldfjac] = (real) (j+1) * temp - cos(x[j]);
+/* L370: */
+    }
+    goto L490;
+
+/*     variably dimensioned function. */
+
+L380:
+    sum = 0.;
+    for (j = 1; j <= n; ++j) {
+	sum += (real) j * (x[j] - 1.);
+/* L390: */
+    }
+/* Computing 2nd power */
+    d__1 = sum;
+    temp = 1. + 6. * (d__1 * d__1);
+    for (k = 1; k <= n; ++k) {
+	for (j = k; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = (real) (k*j) * temp;
+	    fjac[j + k * ldfjac] = fjac[k + j * ldfjac];
+/* L400: */
+	}
+	fjac[k + k * ldfjac] += 1.;
+/* L410: */
+    }
+    goto L490;
+
+/*     broyden tridiagonal function. */
+
+L420:
+    for (k = 1; k <= n; ++k) {
+	for (j = 1; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L430: */
+	}
+	fjac[k + k * ldfjac] = 3. - 4. * x[k];
+	if (k != 1) {
+	    fjac[k + (k - 1) * ldfjac] = -1.;
+	}
+	if (k != n) {
+	    fjac[k + (k + 1) * ldfjac] = -2.;
+	}
+/* L440: */
+    }
+    goto L490;
+
+/*     broyden banded function. */
+
+L450:
+    ml = 5;
+    mu = 1;
+    for (k = 1; k <= n; ++k) {
+	for (j = 1; j <= n; ++j) {
+	    fjac[k + j * ldfjac] = 0.;
+/* L460: */
+	}
+/* Computing MAX */
+	k1 = max(1,k-ml);
+/* Computing MIN */
+	k2 = min(k+mu,n);
+	for (j = k1; j <= k2; ++j) {
+	    if (j != k) {
+		fjac[k + j * ldfjac] = -(1. + 2. * x[j]);
+	    }
+/* L470: */
+	}
+/* Computing 2nd power */
+	d__1 = x[k];
+	fjac[k + k * ldfjac] = 2. + 15. * (d__1 * d__1);
+/* L480: */
+    }
+L490:
+    return;
+
+/*     last card of subroutine vecjac. */
+
+} /* vecjac_ */
+
diff --git a/examples/vecjac.f b/examples/vecjac.f
new file mode 100644
index 0000000..7debfed
--- /dev/null
+++ b/examples/vecjac.f
@@ -0,0 +1,321 @@
+      subroutine vecjac(n,x,fjac,ldfjac,nprob)
+      integer n,ldfjac,nprob
+      double precision x(n),fjac(ldfjac,n)
+c     **********
+c
+c     subroutine vecjac
+c
+c     this subroutine defines the jacobian matrices of fourteen
+c     test functions. the problem dimensions are as described
+c     in the prologue comments of vecfcn.
+c
+c     the subroutine statement is
+c
+c       subroutine vecjac(n,x,fjac,ldfjac,nprob)
+c
+c     where
+c
+c       n is a positive integer variable.
+c
+c       x is an array of length n.
+c
+c       fjac is an n by n array. on output fjac contains the
+c         jacobian matrix of the nprob function evaluated at x.
+c
+c       ldfjac is a positive integer variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       nprob is a positive integer variable which defines the
+c         number of the problem. nprob must not exceed 14.
+c
+c     subprograms called
+c
+c       fortran-supplied ... datan,dcos,dexp,dmin1,dsin,dsqrt,
+c                            max0,min0
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ivar,j,k,k1,k2,ml,mu
+      double precision c1,c3,c4,c5,c6,c9,eight,fiftn,five,four,h,
+     *                 hundrd,one,prod,six,sum,sum1,sum2,temp,temp1,
+     *                 temp2,temp3,temp4,ten,three,ti,tj,tk,tpi,
+     *                 twenty,two,zero
+      double precision dfloat
+      data zero,one,two,three,four,five,six,eight,ten,fiftn,twenty,
+     *     hundrd
+     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,6.0d0,8.0d0,1.0d1,
+     *      1.5d1,2.0d1,1.0d2/
+      data c1,c3,c4,c5,c6,c9 /1.0d4,2.0d2,2.02d1,1.98d1,1.8d2,2.9d1/
+      dfloat(ivar) = ivar
+c
+c     jacobian routine selector.
+c
+      go to (10,20,50,60,90,100,200,230,290,320,350,380,420,450),
+     *      nprob
+c
+c     rosenbrock function.
+c
+   10 continue
+      fjac(1,1) = -one
+      fjac(1,2) = zero
+      fjac(2,1) = -twenty*x(1)
+      fjac(2,2) = ten
+      go to 490
+c
+c     powell singular function.
+c
+   20 continue
+      do 40 k = 1, 4
+         do 30 j = 1, 4
+            fjac(k,j) = zero
+   30       continue
+   40    continue
+      fjac(1,1) = one
+      fjac(1,2) = ten
+      fjac(2,3) = dsqrt(five)
+      fjac(2,4) = -fjac(2,3)
+      fjac(3,2) = two*(x(2) - two*x(3))
+      fjac(3,3) = -two*fjac(3,2)
+      fjac(4,1) = two*dsqrt(ten)*(x(1) - x(4))
+      fjac(4,4) = -fjac(4,1)
+      go to 490
+c
+c     powell badly scaled function.
+c
+   50 continue
+      fjac(1,1) = c1*x(2)
+      fjac(1,2) = c1*x(1)
+      fjac(2,1) = -dexp(-x(1))
+      fjac(2,2) = -dexp(-x(2))
+      go to 490
+c
+c     wood function.
+c
+   60 continue
+      do 80 k = 1, 4
+         do 70 j = 1, 4
+            fjac(k,j) = zero
+   70       continue
+   80    continue
+      temp1 = x(2) - three*x(1)**2
+      temp2 = x(4) - three*x(3)**2
+      fjac(1,1) = -c3*temp1 + one
+      fjac(1,2) = -c3*x(1)
+      fjac(2,1) = -two*c3*x(1)
+      fjac(2,2) = c3 + c4
+      fjac(2,4) = c5
+      fjac(3,3) = -c6*temp2 + one
+      fjac(3,4) = -c6*x(3)
+      fjac(4,2) = c5
+      fjac(4,3) = -two*c6*x(3)
+      fjac(4,4) = c6 + c4
+      go to 490
+c
+c     helical valley function.
+c
+   90 continue
+      tpi = eight*datan(one)
+      temp = x(1)**2 + x(2)**2
+      temp1 = tpi*temp
+      temp2 = dsqrt(temp)
+      fjac(1,1) = hundrd*x(2)/temp1
+      fjac(1,2) = -hundrd*x(1)/temp1
+      fjac(1,3) = ten
+      fjac(2,1) = ten*x(1)/temp2
+      fjac(2,2) = ten*x(2)/temp2
+      fjac(2,3) = zero
+      fjac(3,1) = zero
+      fjac(3,2) = zero
+      fjac(3,3) = one
+      go to 490
+c
+c     watson function.
+c
+  100 continue
+      do 120 k = 1, n
+         do 110 j = k, n
+            fjac(k,j) = zero
+  110       continue
+  120    continue
+      do 170 i = 1, 29
+         ti = dfloat(i)/c9
+         sum1 = zero
+         temp = one
+         do 130 j = 2, n
+            sum1 = sum1 + dfloat(j-1)*temp*x(j)
+            temp = ti*temp
+  130       continue
+         sum2 = zero
+         temp = one
+         do 140 j = 1, n
+            sum2 = sum2 + temp*x(j)
+            temp = ti*temp
+  140       continue
+         temp1 = two*(sum1 - sum2**2 - one)
+         temp2 = two*sum2
+         temp = ti**2
+         tk = one
+         do 160 k = 1, n
+            tj = tk
+            do 150 j = k, n
+               fjac(k,j) = fjac(k,j)
+     *                     + tj
+     *                       *((dfloat(k-1)/ti - temp2)
+     *                         *(dfloat(j-1)/ti - temp2) - temp1)
+               tj = ti*tj
+  150          continue
+            tk = temp*tk
+  160       continue
+  170    continue
+      fjac(1,1) = fjac(1,1) + six*x(1)**2 - two*x(2) + three
+      fjac(1,2) = fjac(1,2) - two*x(1)
+      fjac(2,2) = fjac(2,2) + one
+      do 190 k = 1, n
+         do 180 j = k, n
+            fjac(j,k) = fjac(k,j)
+  180       continue
+  190    continue
+      go to 490
+c
+c     chebyquad function.
+c
+  200 continue
+      tk = one/dfloat(n)
+      do 220 j = 1, n
+         temp1 = one
+         temp2 = two*x(j) - one
+         temp = two*temp2
+         temp3 = zero
+         temp4 = two
+         do 210 k = 1, n
+            fjac(k,j) = tk*temp4
+            ti = four*temp2 + temp*temp4 - temp3
+            temp3 = temp4
+            temp4 = ti
+            ti = temp*temp2 - temp1
+            temp1 = temp2
+            temp2 = ti
+  210       continue
+  220    continue
+      go to 490
+c
+c     brown almost-linear function.
+c
+  230 continue
+      prod = one
+      do 250 j = 1, n
+         prod = x(j)*prod
+         do 240 k = 1, n
+            fjac(k,j) = one
+  240       continue
+         fjac(j,j) = two
+  250    continue
+      do 280 j = 1, n
+         temp = x(j)
+         if (temp .ne. zero) go to 270
+         temp = one
+         prod = one
+         do 260 k = 1, n
+            if (k .ne. j) prod = x(k)*prod
+  260       continue
+  270    continue
+         fjac(n,j) = prod/temp
+  280    continue
+      go to 490
+c
+c     discrete boundary value function.
+c
+  290 continue
+      h = one/dfloat(n+1)
+      do 310 k = 1, n
+         temp = three*(x(k) + dfloat(k)*h + one)**2
+         do 300 j = 1, n
+            fjac(k,j) = zero
+  300       continue
+         fjac(k,k) = two + temp*h**2/two
+         if (k .ne. 1) fjac(k,k-1) = -one
+         if (k .ne. n) fjac(k,k+1) = -one
+  310    continue
+      go to 490
+c
+c     discrete integral equation function.
+c
+  320 continue
+      h = one/dfloat(n+1)
+      do 340 k = 1, n
+         tk = dfloat(k)*h
+         do 330 j = 1, n
+            tj = dfloat(j)*h
+            temp = three*(x(j) + tj + one)**2
+            fjac(k,j) = h*dmin1(tj*(one-tk),tk*(one-tj))*temp/two
+  330       continue
+         fjac(k,k) = fjac(k,k) + one
+  340    continue
+      go to 490
+c
+c     trigonometric function.
+c
+  350 continue
+      do 370 j = 1, n
+         temp = dsin(x(j))
+         do 360 k = 1, n
+            fjac(k,j) = temp
+  360       continue
+         fjac(j,j) = dfloat(j+1)*temp - dcos(x(j))
+  370    continue
+      go to 490
+c
+c     variably dimensioned function.
+c
+  380 continue
+      sum = zero
+      do 390 j = 1, n
+         sum = sum + dfloat(j)*(x(j) - one)
+  390    continue
+      temp = one + six*sum**2
+      do 410 k = 1, n
+         do 400 j = k, n
+            fjac(k,j) = dfloat(k*j)*temp
+            fjac(j,k) = fjac(k,j)
+  400       continue
+         fjac(k,k) = fjac(k,k) + one
+  410    continue
+      go to 490
+c
+c     broyden tridiagonal function.
+c
+  420 continue
+      do 440 k = 1, n
+         do 430 j = 1, n
+            fjac(k,j) = zero
+  430       continue
+         fjac(k,k) = three - four*x(k)
+         if (k .ne. 1) fjac(k,k-1) = -one
+         if (k .ne. n) fjac(k,k+1) = -two
+  440    continue
+      go to 490
+c
+c     broyden banded function.
+c
+  450 continue
+      ml = 5
+      mu = 1
+      do 480 k = 1, n
+         do 460 j = 1, n
+            fjac(k,j) = zero
+  460       continue
+         k1 = max0(1,k-ml)
+         k2 = min0(k+mu,n)
+         do 470 j = k1, k2
+            if (j .ne. k) fjac(k,j) = -(one + two*x(j))
+  470       continue
+         fjac(k,k) = two + fiftn*x(k)**2
+  480    continue
+  490 continue
+      return
+c
+c     last card of subroutine vecjac.
+c
+      end
diff --git a/fdjac1.c b/fdjac1.c
new file mode 100644
index 0000000..ec85e58
--- /dev/null
+++ b/fdjac1.c
@@ -0,0 +1,188 @@
+/* fdjac1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(fdjac1)(__cminpack_decl_fcn_nn__ void *p, int n, real *x, const real *
+	fvec, real *fjac, int ldfjac, int ml, 
+	int mu, real epsfcn, real *wa1, real *wa2)
+{
+    /* System generated locals */
+    int fjac_dim1, fjac_offset;
+
+    /* Local variables */
+    real h;
+    int i, j, k;
+    real eps, temp;
+    int msum;
+    real epsmch;
+    int iflag = 0;
+
+/*     ********** */
+
+/*     subroutine fdjac1 */
+
+/*     this subroutine computes a forward-difference approximation */
+/*     to the n by n jacobian matrix associated with a specified */
+/*     problem of n functions in n variables. if the jacobian has */
+/*     a banded form, then function evaluations are saved by only */
+/*     approximating the nonzero terms. */
+
+/*     the subroutine statement is */
+
+/*       subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, */
+/*                         wa1,wa2) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,iflag) */
+/*         integer n,iflag */
+/*         double precision x(n),fvec(n) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of fdjac1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an input array of length n which must contain the */
+/*         functions evaluated at x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         approximation to the jacobian matrix evaluated at x. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       iflag is an integer variable which can be used to terminate */
+/*         the execution of fdjac1. see description of fcn. */
+
+/*       ml is a nonnegative integer input variable which specifies */
+/*         the number of subdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         ml to at least n - 1. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       mu is a nonnegative integer input variable which specifies */
+/*         the number of superdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         mu to at least n - 1. */
+
+/*       wa1 and wa2 are work arrays of length n. if ml + mu + 1 is at */
+/*         least n, then the jacobian is considered dense, and wa2 is */
+/*         not referenced. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dmax1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa2;
+    --wa1;
+    --fvec;
+    --x;
+    fjac_dim1 = ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    eps = sqrt((max(epsfcn,epsmch)));
+    msum = ml + mu + 1;
+    if (msum >= n) {
+
+/*        computation of dense approximate jacobian. */
+
+        for (j = 1; j <= n; ++j) {
+            temp = x[j];
+            h = eps * fabs(temp);
+            if (h == 0.) {
+                h = eps;
+            }
+            x[j] = temp + h;
+            /* the last parameter of fcn_nn() is set to 2 to tell calls
+               made to compute the function from calls made to compute
+               the Jacobian (see fcn() in tlmfdrv.c) */
+            iflag = fcn_nn(p, n, &x[1], &wa1[1], 2);
+            if (iflag < 0) {
+                return iflag;
+            }
+            x[j] = temp;
+            for (i = 1; i <= n; ++i) {
+                fjac[i + j * fjac_dim1] = (wa1[i] - fvec[i]) / h;
+            }
+        }
+        return 0;
+    }
+
+/*        computation of banded approximate jacobian. */
+
+    for (k = 1; k <= msum; ++k) {
+	for (j = k; msum < 0 ? j >= n : j <= n; j += msum) {
+	    wa2[j] = x[j];
+	    h = eps * fabs(wa2[j]);
+	    if (h == 0.) {
+		h = eps;
+	    }
+	    x[j] = wa2[j] + h;
+	}
+	iflag = fcn_nn(p, n, &x[1], &wa1[1], 1);
+	if (iflag < 0) {
+            return iflag;
+	}
+	for (j = k; msum < 0 ? j >= n : j <= n; j += msum) {
+	    x[j] = wa2[j];
+	    h = eps * fabs(wa2[j]);
+	    if (h == 0.) {
+		h = eps;
+	    }
+	    for (i = 1; i <= n; ++i) {
+		fjac[i + j * fjac_dim1] = 0.;
+		if (i >= j - mu && i <= j + ml) {
+		    fjac[i + j * fjac_dim1] = (wa1[i] - fvec[i]) / h;
+		}
+	    }
+	}
+    }
+    return 0;
+
+/*     last card of subroutine fdjac1. */
+
+} /* fdjac1_ */
+
diff --git a/fdjac1_.c b/fdjac1_.c
new file mode 100644
index 0000000..7934994
--- /dev/null
+++ b/fdjac1_.c
@@ -0,0 +1,211 @@
+/* fdjac1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+__minpack_attr__
+void __minpack_func__(fdjac1)(__minpack_decl_fcn_nn__ const int *n, real *x, const real *
+	fvec, real *fjac, const int *ldfjac, int *iflag, const int *ml, 
+	const int *mu, const real *epsfcn, real *wa1, real *wa2)
+{
+    /* Table of constant values */
+
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2, i__3, i__4;
+
+    /* Local variables */
+    real h__;
+    int i__, j, k;
+    real eps, temp;
+    int msum;
+    real epsmch;
+
+/*     ********** */
+
+/*     subroutine fdjac1 */
+
+/*     this subroutine computes a forward-difference approximation */
+/*     to the n by n jacobian matrix associated with a specified */
+/*     problem of n functions in n variables. if the jacobian has */
+/*     a banded form, then function evaluations are saved by only */
+/*     approximating the nonzero terms. */
+
+/*     the subroutine statement is */
+
+/*       subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn, */
+/*                         wa1,wa2) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,iflag) */
+/*         integer n,iflag */
+/*         double precision x(n),fvec(n) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of fdjac1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an input array of length n which must contain the */
+/*         functions evaluated at x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         approximation to the jacobian matrix evaluated at x. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       iflag is an integer variable which can be used to terminate */
+/*         the execution of fdjac1. see description of fcn. */
+
+/*       ml is a nonnegative integer input variable which specifies */
+/*         the number of subdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         ml to at least n - 1. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       mu is a nonnegative integer input variable which specifies */
+/*         the number of superdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         mu to at least n - 1. */
+
+/*       wa1 and wa2 are work arrays of length n. if ml + mu + 1 is at */
+/*         least n, then the jacobian is considered dense, and wa2 is */
+/*         not referenced. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dmax1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa2;
+    --wa1;
+    --fvec;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    eps = sqrt((max(*epsfcn,epsmch)));
+    msum = *ml + *mu + 1;
+    if (msum < *n) {
+	goto L40;
+    }
+
+/*        computation of dense approximate jacobian. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	temp = x[j];
+	h__ = eps * fabs(temp);
+	if (h__ == 0.) {
+	    h__ = eps;
+	}
+	x[j] = temp + h__;
+	fcn_nn(n, &x[1], &wa1[1], iflag);
+	if (*iflag < 0) {
+	    goto L30;
+	}
+	x[j] = temp;
+	i__2 = *n;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    fjac[i__ + j * fjac_dim1] = (wa1[i__] - fvec[i__]) / h__;
+/* L10: */
+	}
+/* L20: */
+    }
+L30:
+    /* goto L110; */
+    return;
+L40:
+
+/*        computation of banded approximate jacobian. */
+
+    i__1 = msum;
+    for (k = 1; k <= i__1; ++k) {
+	i__2 = *n;
+	i__3 = msum;
+	for (j = k; i__3 < 0 ? j >= i__2 : j <= i__2; j += i__3) {
+	    wa2[j] = x[j];
+	    h__ = eps * fabs(wa2[j]);
+	    if (h__ == 0.) {
+		h__ = eps;
+	    }
+	    x[j] = wa2[j] + h__;
+/* L60: */
+	}
+	fcn_nn(n, &x[1], &wa1[1], iflag);
+	if (*iflag < 0) {
+	    /* goto L100; */
+            return;
+	}
+	i__3 = *n;
+	i__2 = msum;
+	for (j = k; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2) {
+	    x[j] = wa2[j];
+	    h__ = eps * fabs(wa2[j]);
+	    if (h__ == 0.) {
+		h__ = eps;
+	    }
+	    i__4 = *n;
+	    for (i__ = 1; i__ <= i__4; ++i__) {
+		fjac[i__ + j * fjac_dim1] = 0.;
+		if (i__ >= j - *mu && i__ <= j + *ml) {
+		    fjac[i__ + j * fjac_dim1] = (wa1[i__] - fvec[i__]) / h__;
+		}
+/* L70: */
+	    }
+/* L80: */
+	}
+/* L90: */
+    }
+/* L100: */
+/* L110: */
+    return;
+
+/*     last card of subroutine fdjac1. */
+
+} /* fdjac1_ */
+
diff --git a/fdjac2.c b/fdjac2.c
new file mode 100644
index 0000000..a67583b
--- /dev/null
+++ b/fdjac2.c
@@ -0,0 +1,121 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(fdjac2)(__cminpack_decl_fcn_mn__ void *p, int m, int n, real *x, 
+	const real *fvec, real *fjac, int ldfjac,
+	real epsfcn, real *wa)
+{
+    /* Local variables */
+    real h;
+    int i, j;
+    real eps, temp, epsmch;
+    int iflag;
+
+/*     ********** */
+
+/*     subroutine fdjac2 */
+
+/*     this subroutine computes a forward-difference approximation */
+/*     to the m by n jacobian matrix associated with a specified */
+/*     problem of m functions in n variables. */
+
+/*     the subroutine statement is */
+
+/*       subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of fdjac2. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an input array of length m which must contain the */
+/*         functions evaluated at x. */
+
+/*       fjac is an output m by n array which contains the */
+/*         approximation to the jacobian matrix evaluated at x. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       iflag is an integer variable which can be used to terminate */
+/*         the execution of fdjac2. see description of fcn. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       wa is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dmax1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    eps = sqrt((max(epsfcn,epsmch)));
+    for (j = 0; j < n; ++j) {
+	temp = x[j];
+	h = eps * fabs(temp);
+	if (h == 0.) {
+	    h = eps;
+	}
+	x[j] = temp + h;
+        /* the last parameter of fcn_mn() is set to 2 to tell calls
+           made to compute the function from calls made to compute
+           the Jacobian (see fcn() in tlmfdrv.c) */
+	iflag = fcn_mn(p, m, n, x, wa, 2);
+	if (iflag < 0) {
+            return iflag;
+	}
+	x[j] = temp;
+	for (i = 0; i < m; ++i) {
+	    fjac[i + j * ldfjac] = (wa[i] - fvec[i]) / h;
+	}
+    }
+    return 0;
+
+/*     last card of subroutine fdjac2. */
+
+} /* fdjac2_ */
+
diff --git a/fdjac2_.c b/fdjac2_.c
new file mode 100644
index 0000000..e90b3f4
--- /dev/null
+++ b/fdjac2_.c
@@ -0,0 +1,146 @@
+/* fdjac2.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+__minpack_attr__
+void __minpack_func__(fdjac2)(__minpack_decl_fcn_mn__ const int *m, const int *n, real *x, 
+	const real *fvec, real *fjac, const int *ldfjac, int *iflag, 
+	const real *epsfcn, real *wa)
+{
+    /* Table of constant values */
+
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+
+    /* Local variables */
+    real h__;
+    int i__, j;
+    real eps, temp, epsmch;
+
+/*     ********** */
+
+/*     subroutine fdjac2 */
+
+/*     this subroutine computes a forward-difference approximation */
+/*     to the m by n jacobian matrix associated with a specified */
+/*     problem of m functions in n variables. */
+
+/*     the subroutine statement is */
+
+/*       subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of fdjac2. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an input array of length n. */
+
+/*       fvec is an input array of length m which must contain the */
+/*         functions evaluated at x. */
+
+/*       fjac is an output m by n array which contains the */
+/*         approximation to the jacobian matrix evaluated at x. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       iflag is an integer variable which can be used to terminate */
+/*         the execution of fdjac2. see description of fcn. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       wa is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dmax1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    --fvec;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    eps = sqrt((max(*epsfcn,epsmch)));
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	temp = x[j];
+	h__ = eps * fabs(temp);
+	if (h__ == 0.) {
+	    h__ = eps;
+	}
+	x[j] = temp + h__;
+	fcn_mn(m, n, &x[1], &wa[1], iflag);
+	if (*iflag < 0) {
+	    /* goto L30; */
+            return;
+	}
+	x[j] = temp;
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    fjac[i__ + j * fjac_dim1] = (wa[i__] - fvec[i__]) / h__;
+/* L10: */
+	}
+/* L20: */
+    }
+/* L30: */
+    return;
+
+/*     last card of subroutine fdjac2. */
+
+} /* fdjac2_ */
+
diff --git a/fortran/Makefile b/fortran/Makefile
new file mode 100644
index 0000000..ec7b399
--- /dev/null
+++ b/fortran/Makefile
@@ -0,0 +1,37 @@
+#!/usr/bin/make 
+
+# pick up your FORTRAN compiler
+#F77=g77
+F77=gfortran
+FFLAGS=-O3
+# uncomment the following for FORTRAN MINPACK
+#MINPACK=-lminpack
+#F77C=$(F77)
+#F77CFLAGS=-g
+
+OBJS = \
+chkder.o  enorm.o   hybrd1.o  hybrj.o   lmdif1.o  lmstr1.o  qrfac.o   r1updt.o \
+dogleg.o  fdjac1.o  hybrd.o   lmder1.o  lmdif.o   lmstr.o   qrsolv.o  rwupdt.o \
+dpmpar.o  fdjac2.o  hybrj1.o  lmder.o   lmpar.o   qform.o   r1mpyq.o  covar.o
+
+# target dir for install
+DESTDIR=/usr/local
+#
+#  Static library target
+#
+
+all: libminpack.a
+
+libminpack.a:  $(OBJS)
+	ar r $@ $(OBJS); ranlib $@
+
+%.o: %.f
+	${F77} ${FFLAGS} -c -o $@ $<
+
+install: libminpack.a
+	cp libminpack.a ${DESTDIR}/lib
+	chmod 644 ${DESTDIR}/lib/libminpack.a
+	ranlib -t ${DESTDIR}/lib/libminpack.a # might be unnecessary
+
+clean:
+	rm -f *.o libminpack.a *~ #*#
diff --git a/fortran/README.txt b/fortran/README.txt
new file mode 100644
index 0000000..43fd277
--- /dev/null
+++ b/fortran/README.txt
@@ -0,0 +1,12 @@
+
+This is non-modified version of Minpack library.
+
+Downloaded from ftp://ftp.netlib.org/minpack/.
+
+For Copyright see CopyrightMINPACK.txt.
+
+
+Other resources:
+
+http://en.wikipedia.org/wiki/MINPACK
+http://www.netlib.org/minpack/
diff --git a/fortran/chkder.f b/fortran/chkder.f
new file mode 100644
index 0000000..29578fc
--- /dev/null
+++ b/fortran/chkder.f
@@ -0,0 +1,140 @@
+      subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)
+      integer m,n,ldfjac,mode
+      double precision x(n),fvec(m),fjac(ldfjac,n),xp(n),fvecp(m),
+     *                 err(m)
+c     **********
+c
+c     subroutine chkder
+c
+c     this subroutine checks the gradients of m nonlinear functions
+c     in n variables, evaluated at a point x, for consistency with
+c     the functions themselves. the user must call chkder twice,
+c     first with mode = 1 and then with mode = 2.
+c
+c     mode = 1. on input, x must contain the point of evaluation.
+c               on output, xp is set to a neighboring point.
+c
+c     mode = 2. on input, fvec must contain the functions and the
+c                         rows of fjac must contain the gradients
+c                         of the respective functions each evaluated
+c                         at x, and fvecp must contain the functions
+c                         evaluated at xp.
+c               on output, err contains measures of correctness of
+c                          the respective gradients.
+c
+c     the subroutine does not perform reliably if cancellation or
+c     rounding errors cause a severe loss of significance in the
+c     evaluation of a function. therefore, none of the components
+c     of x should be unusually small (in particular, zero) or any
+c     other value which may cause loss of significance.
+c
+c     the subroutine statement is
+c
+c       subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)
+c
+c     where
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables.
+c
+c       x is an input array of length n.
+c
+c       fvec is an array of length m. on input when mode = 2,
+c         fvec must contain the functions evaluated at x.
+c
+c       fjac is an m by n array. on input when mode = 2,
+c         the rows of fjac must contain the gradients of
+c         the respective functions evaluated at x.
+c
+c       ldfjac is a positive integer input parameter not less than m
+c         which specifies the leading dimension of the array fjac.
+c
+c       xp is an array of length n. on output when mode = 1,
+c         xp is set to a neighboring point of x.
+c
+c       fvecp is an array of length m. on input when mode = 2,
+c         fvecp must contain the functions evaluated at xp.
+c
+c       mode is an integer input variable set to 1 on the first call
+c         and 2 on the second. other values of mode are equivalent
+c         to mode = 1.
+c
+c       err is an array of length m. on output when mode = 2,
+c         err contains measures of correctness of the respective
+c         gradients. if there is no severe loss of significance,
+c         then if err(i) is 1.0 the i-th gradient is correct,
+c         while if err(i) is 0.0 the i-th gradient is incorrect.
+c         for values of err between 0.0 and 1.0, the categorization
+c         is less certain. in general, a value of err(i) greater
+c         than 0.5 indicates that the i-th gradient is probably
+c         correct, while a value of err(i) less than 0.5 indicates
+c         that the i-th gradient is probably incorrect.
+c
+c     subprograms called
+c
+c       minpack supplied ... dpmpar
+c
+c       fortran supplied ... dabs,dlog10,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j
+      double precision eps,epsf,epslog,epsmch,factor,one,temp,zero
+      double precision dpmpar
+      data factor,one,zero /1.0d2,1.0d0,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      eps = dsqrt(epsmch)
+c
+      if (mode .eq. 2) go to 20
+c
+c        mode = 1.
+c
+         do 10 j = 1, n
+            temp = eps*dabs(x(j))
+            if (temp .eq. zero) temp = eps
+            xp(j) = x(j) + temp
+   10       continue
+         go to 70
+   20 continue
+c
+c        mode = 2.
+c
+         epsf = factor*epsmch
+         epslog = dlog10(eps)
+         do 30 i = 1, m
+            err(i) = zero
+   30       continue
+         do 50 j = 1, n
+            temp = dabs(x(j))
+            if (temp .eq. zero) temp = one
+            do 40 i = 1, m
+               err(i) = err(i) + temp*fjac(i,j)
+   40          continue
+   50       continue
+         do 60 i = 1, m
+            temp = one
+            if (fvec(i) .ne. zero .and. fvecp(i) .ne. zero
+     *          .and. dabs(fvecp(i)-fvec(i)) .ge. epsf*dabs(fvec(i)))
+     *         temp = eps*dabs((fvecp(i)-fvec(i))/eps-err(i))
+     *                /(dabs(fvec(i)) + dabs(fvecp(i)))
+            err(i) = one
+            if (temp .gt. epsmch .and. temp .lt. eps)
+     *         err(i) = (dlog10(temp) - epslog)/epslog
+            if (temp .ge. eps) err(i) = zero
+   60       continue
+   70 continue
+c
+      return
+c
+c     last card of subroutine chkder.
+c
+      end
diff --git a/fortran/covar.f b/fortran/covar.f
new file mode 100644
index 0000000..c466758
--- /dev/null
+++ b/fortran/covar.f
@@ -0,0 +1,145 @@
+      subroutine covar(n,r,ldr,ipvt,tol,wa)
+      integer n,ldr
+      integer ipvt(n)
+      double precision tol
+      double precision r(ldr,n),wa(n)
+c     **********
+c
+c     subroutine covar
+c
+c     given an m by n matrix a, the problem is to determine
+c     the covariance matrix corresponding to a, defined as
+c
+c                    t
+c           inverse(a *a) .
+c
+c     this subroutine completes the solution of the problem
+c     if it is provided with the necessary information from the
+c     qr factorization, with column pivoting, of a. that is, if
+c     a*p = q*r, where p is a permutation matrix, q has orthogonal
+c     columns, and r is an upper triangular matrix with diagonal
+c     elements of nonincreasing magnitude, then covar expects
+c     the full upper triangle of r and the permutation matrix p.
+c     the covariance matrix is then computed as
+c
+c                      t     t
+c           p*inverse(r *r)*p  .
+c
+c     if a is nearly rank deficient, it may be desirable to compute
+c     the covariance matrix corresponding to the linearly independent
+c     columns of a. to define the numerical rank of a, covar uses
+c     the tolerance tol. if l is the largest integer such that
+c
+c           abs(r(l,l)) .gt. tol*abs(r(1,1)) ,
+c
+c     then covar computes the covariance matrix corresponding to
+c     the first l columns of r. for k greater than l, column
+c     and row ipvt(k) of the covariance matrix are set to zero.
+c
+c     the subroutine statement is
+c
+c       subroutine covar(n,r,ldr,ipvt,tol,wa)
+c
+c     where
+c
+c       n is a positive integer input variable set to the order of r.
+c
+c       r is an n by n array. on input the full upper triangle must
+c         contain the full upper triangle of the matrix r. on output
+c         r contains the square symmetric covariance matrix.
+c
+c       ldr is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array r.
+c
+c       ipvt is an integer input array of length n which defines the
+c         permutation matrix p such that a*p = q*r. column j of p
+c         is column ipvt(j) of the identity matrix.
+c
+c       tol is a nonnegative input variable used to define the
+c         numerical rank of a in the manner described above.
+c
+c       wa is a work array of length n.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs
+c
+c     argonne national laboratory. minpack project. august 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,ii,j,jj,k,km1,l
+      logical sing
+      double precision one,temp,tolr,zero
+      data one,zero /1.0d0,0.0d0/
+c
+c     form the inverse of r in the full upper triangle of r.
+c
+      tolr = tol*dabs(r(1,1))
+      l = 0
+      do 40 k = 1, n
+         if (dabs(r(k,k)) .le. tolr) go to 50
+         r(k,k) = one/r(k,k)
+         km1 = k - 1
+         if (km1 .lt. 1) go to 30
+         do 20 j = 1, km1
+            temp = r(k,k)*r(j,k)
+            r(j,k) = zero
+            do 10 i = 1, j
+               r(i,k) = r(i,k) - temp*r(i,j)
+   10          continue
+   20       continue
+   30    continue
+         l = k
+   40    continue
+   50 continue
+c
+c     form the full upper triangle of the inverse of (r transpose)*r
+c     in the full upper triangle of r.
+c
+      if (l .lt. 1) go to 110
+      do 100 k = 1, l
+         km1 = k - 1
+         if (km1 .lt. 1) go to 80
+         do 70 j = 1, km1
+            temp = r(j,k)
+            do 60 i = 1, j
+               r(i,j) = r(i,j) + temp*r(i,k)
+   60          continue
+   70       continue
+   80    continue
+         temp = r(k,k)
+         do 90 i = 1, k
+            r(i,k) = temp*r(i,k)
+   90       continue
+  100    continue
+  110 continue
+c
+c     form the full lower triangle of the covariance matrix
+c     in the strict lower triangle of r and in wa.
+c
+      do 130 j = 1, n
+         jj = ipvt(j)
+         sing = j .gt. l
+         do 120 i = 1, j
+            if (sing) r(i,j) = zero
+            ii = ipvt(i)
+            if (ii .gt. jj) r(ii,jj) = r(i,j)
+            if (ii .lt. jj) r(jj,ii) = r(i,j)
+  120       continue
+         wa(jj) = r(j,j)
+  130    continue
+c
+c     symmetrize the covariance matrix in r.
+c
+      do 150 j = 1, n
+         do 140 i = 1, j
+            r(i,j) = r(j,i)
+  140       continue
+         r(j,j) = wa(j)
+  150    continue
+      return
+c
+c     last card of subroutine covar.
+c
+      end
diff --git a/fortran/dogleg.f b/fortran/dogleg.f
new file mode 100644
index 0000000..b812f19
--- /dev/null
+++ b/fortran/dogleg.f
@@ -0,0 +1,177 @@
+      subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2)
+      integer n,lr
+      double precision delta
+      double precision r(lr),diag(n),qtb(n),x(n),wa1(n),wa2(n)
+c     **********
+c
+c     subroutine dogleg
+c
+c     given an m by n matrix a, an n by n nonsingular diagonal
+c     matrix d, an m-vector b, and a positive number delta, the
+c     problem is to determine the convex combination x of the
+c     gauss-newton and scaled gradient directions that minimizes
+c     (a*x - b) in the least squares sense, subject to the
+c     restriction that the euclidean norm of d*x be at most delta.
+c
+c     this subroutine completes the solution of the problem
+c     if it is provided with the necessary information from the
+c     qr factorization of a. that is, if a = q*r, where q has
+c     orthogonal columns and r is an upper triangular matrix,
+c     then dogleg expects the full upper triangle of r and
+c     the first n components of (q transpose)*b.
+c
+c     the subroutine statement is
+c
+c       subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2)
+c
+c     where
+c
+c       n is a positive integer input variable set to the order of r.
+c
+c       r is an input array of length lr which must contain the upper
+c         triangular matrix r stored by rows.
+c
+c       lr is a positive integer input variable not less than
+c         (n*(n+1))/2.
+c
+c       diag is an input array of length n which must contain the
+c         diagonal elements of the matrix d.
+c
+c       qtb is an input array of length n which must contain the first
+c         n elements of the vector (q transpose)*b.
+c
+c       delta is a positive input variable which specifies an upper
+c         bound on the euclidean norm of d*x.
+c
+c       x is an output array of length n which contains the desired
+c         convex combination of the gauss-newton direction and the
+c         scaled gradient direction.
+c
+c       wa1 and wa2 are work arrays of length n.
+c
+c     subprograms called
+c
+c       minpack-supplied ... dpmpar,enorm
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j,jj,jp1,k,l
+      double precision alpha,bnorm,epsmch,gnorm,one,qnorm,sgnorm,sum,
+     *                 temp,zero
+      double precision dpmpar,enorm
+      data one,zero /1.0d0,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+c     first, calculate the gauss-newton direction.
+c
+      jj = (n*(n + 1))/2 + 1
+      do 50 k = 1, n
+         j = n - k + 1
+         jp1 = j + 1
+         jj = jj - k
+         l = jj + 1
+         sum = zero
+         if (n .lt. jp1) go to 20
+         do 10 i = jp1, n
+            sum = sum + r(l)*x(i)
+            l = l + 1
+   10       continue
+   20    continue
+         temp = r(jj)
+         if (temp .ne. zero) go to 40
+         l = j
+         do 30 i = 1, j
+            temp = dmax1(temp,dabs(r(l)))
+            l = l + n - i
+   30       continue
+         temp = epsmch*temp
+         if (temp .eq. zero) temp = epsmch
+   40    continue
+         x(j) = (qtb(j) - sum)/temp
+   50    continue
+c
+c     test whether the gauss-newton direction is acceptable.
+c
+      do 60 j = 1, n
+         wa1(j) = zero
+         wa2(j) = diag(j)*x(j)
+   60    continue
+      qnorm = enorm(n,wa2)
+      if (qnorm .le. delta) go to 140
+c
+c     the gauss-newton direction is not acceptable.
+c     next, calculate the scaled gradient direction.
+c
+      l = 1
+      do 80 j = 1, n
+         temp = qtb(j)
+         do 70 i = j, n
+            wa1(i) = wa1(i) + r(l)*temp
+            l = l + 1
+   70       continue
+         wa1(j) = wa1(j)/diag(j)
+   80    continue
+c
+c     calculate the norm of the scaled gradient and test for
+c     the special case in which the scaled gradient is zero.
+c
+      gnorm = enorm(n,wa1)
+      sgnorm = zero
+      alpha = delta/qnorm
+      if (gnorm .eq. zero) go to 120
+c
+c     calculate the point along the scaled gradient
+c     at which the quadratic is minimized.
+c
+      do 90 j = 1, n
+         wa1(j) = (wa1(j)/gnorm)/diag(j)
+   90    continue
+      l = 1
+      do 110 j = 1, n
+         sum = zero
+         do 100 i = j, n
+            sum = sum + r(l)*wa1(i)
+            l = l + 1
+  100       continue
+         wa2(j) = sum
+  110    continue
+      temp = enorm(n,wa2)
+      sgnorm = (gnorm/temp)/temp
+c
+c     test whether the scaled gradient direction is acceptable.
+c
+      alpha = zero
+      if (sgnorm .ge. delta) go to 120
+c
+c     the scaled gradient direction is not acceptable.
+c     finally, calculate the point along the dogleg
+c     at which the quadratic is minimized.
+c
+      bnorm = enorm(n,qtb)
+      temp = (bnorm/gnorm)*(bnorm/qnorm)*(sgnorm/delta)
+      temp = temp - (delta/qnorm)*(sgnorm/delta)**2
+     *       + dsqrt((temp-(delta/qnorm))**2
+     *               +(one-(delta/qnorm)**2)*(one-(sgnorm/delta)**2))
+      alpha = ((delta/qnorm)*(one - (sgnorm/delta)**2))/temp
+  120 continue
+c
+c     form appropriate convex combination of the gauss-newton
+c     direction and the scaled gradient direction.
+c
+      temp = (one - alpha)*dmin1(sgnorm,delta)
+      do 130 j = 1, n
+         x(j) = temp*wa1(j) + alpha*x(j)
+  130    continue
+  140 continue
+      return
+c
+c     last card of subroutine dogleg.
+c
+      end
diff --git a/fortran/dpmpar.f b/fortran/dpmpar.f
new file mode 100644
index 0000000..8597027
--- /dev/null
+++ b/fortran/dpmpar.f
@@ -0,0 +1,181 @@
+      double precision function dpmpar(i)
+      integer i
+c     **********
+c
+c     Function dpmpar
+c
+c     This function provides double precision machine parameters
+c     when the appropriate set of data statements is activated (by
+c     removing the c from column 1) and all other data statements are
+c     rendered inactive. Most of the parameter values were obtained
+c     from the corresponding Bell Laboratories Port Library function.
+c
+c     The function statement is
+c
+c       double precision function dpmpar(i)
+c
+c     where
+c
+c       i is an integer input variable set to 1, 2, or 3 which
+c         selects the desired machine parameter. If the machine has
+c         t base b digits and its smallest and largest exponents are
+c         emin and emax, respectively, then these parameters are
+c
+c         dpmpar(1) = b**(1 - t), the machine precision,
+c
+c         dpmpar(2) = b**(emin - 1), the smallest magnitude,
+c
+c         dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude.
+c
+c     Argonne National Laboratory. MINPACK Project. November 1996.
+c     Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More'
+c
+c     **********
+      integer mcheps(4)
+      integer minmag(4)
+      integer maxmag(4)
+      double precision dmach(3)
+      equivalence (dmach(1),mcheps(1))
+      equivalence (dmach(2),minmag(1))
+      equivalence (dmach(3),maxmag(1))
+c
+c     Machine constants for the IBM 360/370 series,
+c     the Amdahl 470/V6, the ICL 2900, the Itel AS/6,
+c     the Xerox Sigma 5/7/9 and the Sel systems 85/86.
+c
+c     data mcheps(1),mcheps(2) / z34100000, z00000000 /
+c     data minmag(1),minmag(2) / z00100000, z00000000 /
+c     data maxmag(1),maxmag(2) / z7fffffff, zffffffff /
+c
+c     Machine constants for the Honeywell 600/6000 series.
+c
+c     data mcheps(1),mcheps(2) / o606400000000, o000000000000 /
+c     data minmag(1),minmag(2) / o402400000000, o000000000000 /
+c     data maxmag(1),maxmag(2) / o376777777777, o777777777777 /
+c
+c     Machine constants for the CDC 6000/7000 series.
+c
+c     data mcheps(1) / 15614000000000000000b /
+c     data mcheps(2) / 15010000000000000000b /
+c
+c     data minmag(1) / 00604000000000000000b /
+c     data minmag(2) / 00000000000000000000b /
+c
+c     data maxmag(1) / 37767777777777777777b /
+c     data maxmag(2) / 37167777777777777777b /
+c
+c     Machine constants for the PDP-10 (KA processor).
+c
+c     data mcheps(1),mcheps(2) / "114400000000, "000000000000 /
+c     data minmag(1),minmag(2) / "033400000000, "000000000000 /
+c     data maxmag(1),maxmag(2) / "377777777777, "344777777777 /
+c
+c     Machine constants for the PDP-10 (KI processor).
+c
+c     data mcheps(1),mcheps(2) / "104400000000, "000000000000 /
+c     data minmag(1),minmag(2) / "000400000000, "000000000000 /
+c     data maxmag(1),maxmag(2) / "377777777777, "377777777777 /
+c
+c     Machine constants for the PDP-11. 
+c
+c     data mcheps(1),mcheps(2) /   9472,      0 /
+c     data mcheps(3),mcheps(4) /      0,      0 /
+c
+c     data minmag(1),minmag(2) /    128,      0 /
+c     data minmag(3),minmag(4) /      0,      0 /
+c
+c     data maxmag(1),maxmag(2) /  32767,     -1 /
+c     data maxmag(3),maxmag(4) /     -1,     -1 /
+c
+c     Machine constants for the Burroughs 6700/7700 systems.
+c
+c     data mcheps(1) / o1451000000000000 /
+c     data mcheps(2) / o0000000000000000 /
+c
+c     data minmag(1) / o1771000000000000 /
+c     data minmag(2) / o7770000000000000 /
+c
+c     data maxmag(1) / o0777777777777777 /
+c     data maxmag(2) / o7777777777777777 /
+c
+c     Machine constants for the Burroughs 5700 system.
+c
+c     data mcheps(1) / o1451000000000000 /
+c     data mcheps(2) / o0000000000000000 /
+c
+c     data minmag(1) / o1771000000000000 /
+c     data minmag(2) / o0000000000000000 /
+c
+c     data maxmag(1) / o0777777777777777 /
+c     data maxmag(2) / o0007777777777777 /
+c
+c     Machine constants for the Burroughs 1700 system.
+c
+c     data mcheps(1) / zcc6800000 /
+c     data mcheps(2) / z000000000 /
+c
+c     data minmag(1) / zc00800000 /
+c     data minmag(2) / z000000000 /
+c
+c     data maxmag(1) / zdffffffff /
+c     data maxmag(2) / zfffffffff /
+c
+c     Machine constants for the Univac 1100 series.
+c
+c     data mcheps(1),mcheps(2) / o170640000000, o000000000000 /
+c     data minmag(1),minmag(2) / o000040000000, o000000000000 /
+c     data maxmag(1),maxmag(2) / o377777777777, o777777777777 /
+c
+c     Machine constants for the Data General Eclipse S/200.
+c
+c     Note - it may be appropriate to include the following card -
+c     static dmach(3)
+c
+c     data minmag/20k,3*0/,maxmag/77777k,3*177777k/
+c     data mcheps/32020k,3*0/
+c
+c     Machine constants for the Harris 220.
+c
+c     data mcheps(1),mcheps(2) / '20000000, '00000334 /
+c     data minmag(1),minmag(2) / '20000000, '00000201 /
+c     data maxmag(1),maxmag(2) / '37777777, '37777577 /
+c
+c     Machine constants for the Cray-1.
+c
+c     data mcheps(1) / 0376424000000000000000b /
+c     data mcheps(2) / 0000000000000000000000b /
+c
+c     data minmag(1) / 0200034000000000000000b /
+c     data minmag(2) / 0000000000000000000000b /
+c
+c     data maxmag(1) / 0577777777777777777777b /
+c     data maxmag(2) / 0000007777777777777776b /
+c
+c     Machine constants for the Prime 400.
+c
+c     data mcheps(1),mcheps(2) / :10000000000, :00000000123 /
+c     data minmag(1),minmag(2) / :10000000000, :00000100000 /
+c     data maxmag(1),maxmag(2) / :17777777777, :37777677776 /
+c
+c     Machine constants for the VAX-11.
+c
+c     data mcheps(1),mcheps(2) /   9472,  0 /
+c     data minmag(1),minmag(2) /    128,  0 /
+c     data maxmag(1),maxmag(2) / -32769, -1 /
+c
+c     Machine constants for IEEE machines.
+c
+c     These values were not accurate enough, according to MACHAR
+c     data dmach(1) /2.22044604926d-16/
+c     data dmach(2) /2.22507385852d-308/
+c     data dmach(3) /1.79769313485d+308/
+      data dmach(1) /2.2204460492503131d-16/
+      data dmach(2) /2.2250738585072014d-308/
+      data dmach(3) /1.7976931348623158d+308/
+c
+      dpmpar = dmach(i)
+      return
+c
+c     Last card of function dpmpar.
+c
+      end
diff --git a/fortran/enorm.f b/fortran/enorm.f
new file mode 100644
index 0000000..2cb5b60
--- /dev/null
+++ b/fortran/enorm.f
@@ -0,0 +1,108 @@
+      double precision function enorm(n,x)
+      integer n
+      double precision x(n)
+c     **********
+c
+c     function enorm
+c
+c     given an n-vector x, this function calculates the
+c     euclidean norm of x.
+c
+c     the euclidean norm is computed by accumulating the sum of
+c     squares in three different sums. the sums of squares for the
+c     small and large components are scaled so that no overflows
+c     occur. non-destructive underflows are permitted. underflows
+c     and overflows do not occur in the computation of the unscaled
+c     sum of squares for the intermediate components.
+c     the definitions of small, intermediate and large components
+c     depend on two constants, rdwarf and rgiant. the main
+c     restrictions on these constants are that rdwarf**2 not
+c     underflow and rgiant**2 not overflow. the constants
+c     given here are suitable for every known computer.
+c
+c     the function statement is
+c
+c       double precision function enorm(n,x)
+c
+c     where
+c
+c       n is a positive integer input variable.
+c
+c       x is an input array of length n.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i
+      double precision agiant,floatn,one,rdwarf,rgiant,s1,s2,s3,xabs,
+     *                 x1max,x3max,zero
+      data one,zero,rdwarf,rgiant /1.0d0,0.0d0,3.834d-20,1.304d19/
+      s1 = zero
+      s2 = zero
+      s3 = zero
+      x1max = zero
+      x3max = zero
+      floatn = n
+      agiant = rgiant/floatn
+      do 90 i = 1, n
+         xabs = dabs(x(i))
+         if (xabs .gt. rdwarf .and. xabs .lt. agiant) go to 70
+            if (xabs .le. rdwarf) go to 30
+c
+c              sum for large components.
+c
+               if (xabs .le. x1max) go to 10
+                  s1 = one + s1*(x1max/xabs)**2
+                  x1max = xabs
+                  go to 20
+   10          continue
+                  s1 = s1 + (xabs/x1max)**2
+   20          continue
+               go to 60
+   30       continue
+c
+c              sum for small components.
+c
+               if (xabs .le. x3max) go to 40
+                  s3 = one + s3*(x3max/xabs)**2
+                  x3max = xabs
+                  go to 50
+   40          continue
+                  if (xabs .ne. zero) s3 = s3 + (xabs/x3max)**2
+   50          continue
+   60       continue
+            go to 80
+   70    continue
+c
+c           sum for intermediate components.
+c
+            s2 = s2 + xabs**2
+   80    continue
+   90    continue
+c
+c     calculation of norm.
+c
+      if (s1 .eq. zero) go to 100
+         enorm = x1max*dsqrt(s1+(s2/x1max)/x1max)
+         go to 130
+  100 continue
+         if (s2 .eq. zero) go to 110
+            if (s2 .ge. x3max)
+     *         enorm = dsqrt(s2*(one+(x3max/s2)*(x3max*s3)))
+            if (s2 .lt. x3max)
+     *         enorm = dsqrt(x3max*((s2/x3max)+(x3max*s3)))
+            go to 120
+  110    continue
+            enorm = x3max*dsqrt(s3)
+  120    continue
+  130 continue
+      return
+c
+c     last card of function enorm.
+c
+      end
diff --git a/fortran/fdjac1.f b/fortran/fdjac1.f
new file mode 100644
index 0000000..031ed46
--- /dev/null
+++ b/fortran/fdjac1.f
@@ -0,0 +1,151 @@
+      subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,
+     *                  wa1,wa2)
+      integer n,ldfjac,iflag,ml,mu
+      double precision epsfcn
+      double precision x(n),fvec(n),fjac(ldfjac,n),wa1(n),wa2(n)
+c     **********
+c
+c     subroutine fdjac1
+c
+c     this subroutine computes a forward-difference approximation
+c     to the n by n jacobian matrix associated with a specified
+c     problem of n functions in n variables. if the jacobian has
+c     a banded form, then function evaluations are saved by only
+c     approximating the nonzero terms.
+c
+c     the subroutine statement is
+c
+c       subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,
+c                         wa1,wa2)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions. fcn must be declared
+c         in an external statement in the user calling
+c         program, and should be written as follows.
+c
+c         subroutine fcn(n,x,fvec,iflag)
+c         integer n,iflag
+c         double precision x(n),fvec(n)
+c         ----------
+c         calculate the functions at x and
+c         return this vector in fvec.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of fdjac1.
+c         in this case set iflag to a negative integer.
+c
+c       n is a positive integer input variable set to the number
+c         of functions and variables.
+c
+c       x is an input array of length n.
+c
+c       fvec is an input array of length n which must contain the
+c         functions evaluated at x.
+c
+c       fjac is an output n by n array which contains the
+c         approximation to the jacobian matrix evaluated at x.
+c
+c       ldfjac is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       iflag is an integer variable which can be used to terminate
+c         the execution of fdjac1. see description of fcn.
+c
+c       ml is a nonnegative integer input variable which specifies
+c         the number of subdiagonals within the band of the
+c         jacobian matrix. if the jacobian is not banded, set
+c         ml to at least n - 1.
+c
+c       epsfcn is an input variable used in determining a suitable
+c         step length for the forward-difference approximation. this
+c         approximation assumes that the relative errors in the
+c         functions are of the order of epsfcn. if epsfcn is less
+c         than the machine precision, it is assumed that the relative
+c         errors in the functions are of the order of the machine
+c         precision.
+c
+c       mu is a nonnegative integer input variable which specifies
+c         the number of superdiagonals within the band of the
+c         jacobian matrix. if the jacobian is not banded, set
+c         mu to at least n - 1.
+c
+c       wa1 and wa2 are work arrays of length n. if ml + mu + 1 is at
+c         least n, then the jacobian is considered dense, and wa2 is
+c         not referenced.
+c
+c     subprograms called
+c
+c       minpack-supplied ... dpmpar
+c
+c       fortran-supplied ... dabs,dmax1,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j,k,msum
+      double precision eps,epsmch,h,temp,zero
+      double precision dpmpar
+      data zero /0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      eps = dsqrt(dmax1(epsfcn,epsmch))
+      msum = ml + mu + 1
+      if (msum .lt. n) go to 40
+c
+c        computation of dense approximate jacobian.
+c
+         do 20 j = 1, n
+            temp = x(j)
+            h = eps*dabs(temp)
+            if (h .eq. zero) h = eps
+            x(j) = temp + h
+            call fcn(n,x,wa1,iflag)
+            if (iflag .lt. 0) go to 30
+            x(j) = temp
+            do 10 i = 1, n
+               fjac(i,j) = (wa1(i) - fvec(i))/h
+   10          continue
+   20       continue
+   30    continue
+         go to 110
+   40 continue
+c
+c        computation of banded approximate jacobian.
+c
+         do 90 k = 1, msum
+            do 60 j = k, n, msum
+               wa2(j) = x(j)
+               h = eps*dabs(wa2(j))
+               if (h .eq. zero) h = eps
+               x(j) = wa2(j) + h
+   60          continue
+            call fcn(n,x,wa1,iflag)
+            if (iflag .lt. 0) go to 100
+            do 80 j = k, n, msum
+               x(j) = wa2(j)
+               h = eps*dabs(wa2(j))
+               if (h .eq. zero) h = eps
+               do 70 i = 1, n
+                  fjac(i,j) = zero
+                  if (i .ge. j - mu .and. i .le. j + ml)
+     *               fjac(i,j) = (wa1(i) - fvec(i))/h
+   70             continue
+   80          continue
+   90       continue
+  100    continue
+  110 continue
+      return
+c
+c     last card of subroutine fdjac1.
+c
+      end
+
diff --git a/fortran/fdjac2.f b/fortran/fdjac2.f
new file mode 100644
index 0000000..218ab94
--- /dev/null
+++ b/fortran/fdjac2.f
@@ -0,0 +1,107 @@
+      subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)
+      integer m,n,ldfjac,iflag
+      double precision epsfcn
+      double precision x(n),fvec(m),fjac(ldfjac,n),wa(m)
+c     **********
+c
+c     subroutine fdjac2
+c
+c     this subroutine computes a forward-difference approximation
+c     to the m by n jacobian matrix associated with a specified
+c     problem of m functions in n variables.
+c
+c     the subroutine statement is
+c
+c       subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions. fcn must be declared
+c         in an external statement in the user calling
+c         program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,iflag)
+c         integer m,n,iflag
+c         double precision x(n),fvec(m)
+c         ----------
+c         calculate the functions at x and
+c         return this vector in fvec.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of fdjac2.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an input array of length n.
+c
+c       fvec is an input array of length m which must contain the
+c         functions evaluated at x.
+c
+c       fjac is an output m by n array which contains the
+c         approximation to the jacobian matrix evaluated at x.
+c
+c       ldfjac is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array fjac.
+c
+c       iflag is an integer variable which can be used to terminate
+c         the execution of fdjac2. see description of fcn.
+c
+c       epsfcn is an input variable used in determining a suitable
+c         step length for the forward-difference approximation. this
+c         approximation assumes that the relative errors in the
+c         functions are of the order of epsfcn. if epsfcn is less
+c         than the machine precision, it is assumed that the relative
+c         errors in the functions are of the order of the machine
+c         precision.
+c
+c       wa is a work array of length m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar
+c
+c       fortran-supplied ... dabs,dmax1,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j
+      double precision eps,epsmch,h,temp,zero
+      double precision dpmpar
+      data zero /0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      eps = dsqrt(dmax1(epsfcn,epsmch))
+      do 20 j = 1, n
+         temp = x(j)
+         h = eps*dabs(temp)
+         if (h .eq. zero) h = eps
+         x(j) = temp + h
+         call fcn(m,n,x,wa,iflag)
+         if (iflag .lt. 0) go to 30
+         x(j) = temp
+         do 10 i = 1, m
+            fjac(i,j) = (wa(i) - fvec(i))/h
+   10       continue
+   20    continue
+   30 continue
+      return
+c
+c     last card of subroutine fdjac2.
+c
+      end
diff --git a/fortran/hybrd.f b/fortran/hybrd.f
new file mode 100644
index 0000000..fc0b4c2
--- /dev/null
+++ b/fortran/hybrd.f
@@ -0,0 +1,459 @@
+      subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag,
+     *                 mode,factor,nprint,info,nfev,fjac,ldfjac,r,lr,
+     *                 qtf,wa1,wa2,wa3,wa4)
+      integer n,maxfev,ml,mu,mode,nprint,info,nfev,ldfjac,lr
+      double precision xtol,epsfcn,factor
+      double precision x(n),fvec(n),diag(n),fjac(ldfjac,n),r(lr),
+     *                 qtf(n),wa1(n),wa2(n),wa3(n),wa4(n)
+      external fcn
+c     **********
+c
+c     subroutine hybrd
+c
+c     the purpose of hybrd is to find a zero of a system of
+c     n nonlinear functions in n variables by a modification
+c     of the powell hybrid method. the user must provide a
+c     subroutine which calculates the functions. the jacobian is
+c     then calculated by a forward-difference approximation.
+c
+c     the subroutine statement is
+c
+c       subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,
+c                        diag,mode,factor,nprint,info,nfev,fjac,
+c                        ldfjac,r,lr,qtf,wa1,wa2,wa3,wa4)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions. fcn must be declared
+c         in an external statement in the user calling
+c         program, and should be written as follows.
+c
+c         subroutine fcn(n,x,fvec,iflag)
+c         integer n,iflag
+c         double precision x(n),fvec(n)
+c         ----------
+c         calculate the functions at x and
+c         return this vector in fvec.
+c         ---------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of hybrd.
+c         in this case set iflag to a negative integer.
+c
+c       n is a positive integer input variable set to the number
+c         of functions and variables.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length n which contains
+c         the functions evaluated at the output x.
+c
+c       xtol is a nonnegative input variable. termination
+c         occurs when the relative error between two consecutive
+c         iterates is at most xtol.
+c
+c       maxfev is a positive integer input variable. termination
+c         occurs when the number of calls to fcn is at least maxfev
+c         by the end of an iteration.
+c
+c       ml is a nonnegative integer input variable which specifies
+c         the number of subdiagonals within the band of the
+c         jacobian matrix. if the jacobian is not banded, set
+c         ml to at least n - 1.
+c
+c       mu is a nonnegative integer input variable which specifies
+c         the number of superdiagonals within the band of the
+c         jacobian matrix. if the jacobian is not banded, set
+c         mu to at least n - 1.
+c
+c       epsfcn is an input variable used in determining a suitable
+c         step length for the forward-difference approximation. this
+c         approximation assumes that the relative errors in the
+c         functions are of the order of epsfcn. if epsfcn is less
+c         than the machine precision, it is assumed that the relative
+c         errors in the functions are of the order of the machine
+c         precision.
+c
+c       diag is an array of length n. if mode = 1 (see
+c         below), diag is internally set. if mode = 2, diag
+c         must contain positive entries that serve as
+c         multiplicative scale factors for the variables.
+c
+c       mode is an integer input variable. if mode = 1, the
+c         variables will be scaled internally. if mode = 2,
+c         the scaling is specified by the input diag. other
+c         values of mode are equivalent to mode = 1.
+c
+c       factor is a positive input variable used in determining the
+c         initial step bound. this bound is set to the product of
+c         factor and the euclidean norm of diag*x if nonzero, or else
+c         to factor itself. in most cases factor should lie in the
+c         interval (.1,100.). 100. is a generally recommended value.
+c
+c       nprint is an integer input variable that enables controlled
+c         printing of iterates if it is positive. in this case,
+c         fcn is called with iflag = 0 at the beginning of the first
+c         iteration and every nprint iterations thereafter and
+c         immediately prior to return, with x and fvec available
+c         for printing. if nprint is not positive, no special calls
+c         of fcn with iflag = 0 are made.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0   improper input parameters.
+c
+c         info = 1   relative error between two consecutive iterates
+c                    is at most xtol.
+c
+c         info = 2   number of calls to fcn has reached or exceeded
+c                    maxfev.
+c
+c         info = 3   xtol is too small. no further improvement in
+c                    the approximate solution x is possible.
+c
+c         info = 4   iteration is not making good progress, as
+c                    measured by the improvement from the last
+c                    five jacobian evaluations.
+c
+c         info = 5   iteration is not making good progress, as
+c                    measured by the improvement from the last
+c                    ten iterations.
+c
+c       nfev is an integer output variable set to the number of
+c         calls to fcn.
+c
+c       fjac is an output n by n array which contains the
+c         orthogonal matrix q produced by the qr factorization
+c         of the final approximate jacobian.
+c
+c       ldfjac is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       r is an output array of length lr which contains the
+c         upper triangular matrix produced by the qr factorization
+c         of the final approximate jacobian, stored rowwise.
+c
+c       lr is a positive integer input variable not less than
+c         (n*(n+1))/2.
+c
+c       qtf is an output array of length n which contains
+c         the vector (q transpose)*fvec.
+c
+c       wa1, wa2, wa3, and wa4 are work arrays of length n.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dogleg,dpmpar,enorm,fdjac1,
+c                            qform,qrfac,r1mpyq,r1updt
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,min0,mod
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iflag,iter,j,jm1,l,msum,ncfail,ncsuc,nslow1,nslow2
+      integer iwa(1)
+      logical jeval,sing
+      double precision actred,delta,epsmch,fnorm,fnorm1,one,pnorm,
+     *                 prered,p1,p5,p001,p0001,ratio,sum,temp,xnorm,
+     *                 zero
+      double precision dpmpar,enorm
+      data one,p1,p5,p001,p0001,zero
+     *     /1.0d0,1.0d-1,5.0d-1,1.0d-3,1.0d-4,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      info = 0
+      iflag = 0
+      nfev = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. xtol .lt. zero .or. maxfev .le. 0
+     *    .or. ml .lt. 0 .or. mu .lt. 0 .or. factor .le. zero
+     *    .or. ldfjac .lt. n .or. lr .lt. (n*(n + 1))/2) go to 300
+      if (mode .ne. 2) go to 20
+      do 10 j = 1, n
+         if (diag(j) .le. zero) go to 300
+   10    continue
+   20 continue
+c
+c     evaluate the function at the starting point
+c     and calculate its norm.
+c
+      iflag = 1
+      call fcn(n,x,fvec,iflag)
+      nfev = 1
+      if (iflag .lt. 0) go to 300
+      fnorm = enorm(n,fvec)
+c
+c     determine the number of calls to fcn needed to compute
+c     the jacobian matrix.
+c
+      msum = min0(ml+mu+1,n)
+c
+c     initialize iteration counter and monitors.
+c
+      iter = 1
+      ncsuc = 0
+      ncfail = 0
+      nslow1 = 0
+      nslow2 = 0
+c
+c     beginning of the outer loop.
+c
+   30 continue
+         jeval = .true.
+c
+c        calculate the jacobian matrix.
+c
+         iflag = 2
+         call fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,wa1,
+     *               wa2)
+         nfev = nfev + msum
+         if (iflag .lt. 0) go to 300
+c
+c        compute the qr factorization of the jacobian.
+c
+         call qrfac(n,n,fjac,ldfjac,.false.,iwa,1,wa1,wa2,wa3)
+c
+c        on the first iteration and if mode is 1, scale according
+c        to the norms of the columns of the initial jacobian.
+c
+         if (iter .ne. 1) go to 70
+         if (mode .eq. 2) go to 50
+         do 40 j = 1, n
+            diag(j) = wa2(j)
+            if (wa2(j) .eq. zero) diag(j) = one
+   40       continue
+   50    continue
+c
+c        on the first iteration, calculate the norm of the scaled x
+c        and initialize the step bound delta.
+c
+         do 60 j = 1, n
+            wa3(j) = diag(j)*x(j)
+   60       continue
+         xnorm = enorm(n,wa3)
+         delta = factor*xnorm
+         if (delta .eq. zero) delta = factor
+   70    continue
+c
+c        form (q transpose)*fvec and store in qtf.
+c
+         do 80 i = 1, n
+            qtf(i) = fvec(i)
+   80       continue
+         do 120 j = 1, n
+            if (fjac(j,j) .eq. zero) go to 110
+            sum = zero
+            do 90 i = j, n
+               sum = sum + fjac(i,j)*qtf(i)
+   90          continue
+            temp = -sum/fjac(j,j)
+            do 100 i = j, n
+               qtf(i) = qtf(i) + fjac(i,j)*temp
+  100          continue
+  110       continue
+  120       continue
+c
+c        copy the triangular factor of the qr factorization into r.
+c
+         sing = .false.
+         do 150 j = 1, n
+            l = j
+            jm1 = j - 1
+            if (jm1 .lt. 1) go to 140
+            do 130 i = 1, jm1
+               r(l) = fjac(i,j)
+               l = l + n - i
+  130          continue
+  140       continue
+            r(l) = wa1(j)
+            if (wa1(j) .eq. zero) sing = .true.
+  150       continue
+c
+c        accumulate the orthogonal factor in fjac.
+c
+         call qform(n,n,fjac,ldfjac,wa1)
+c
+c        rescale if necessary.
+c
+         if (mode .eq. 2) go to 170
+         do 160 j = 1, n
+            diag(j) = dmax1(diag(j),wa2(j))
+  160       continue
+  170    continue
+c
+c        beginning of the inner loop.
+c
+  180    continue
+c
+c           if requested, call fcn to enable printing of iterates.
+c
+            if (nprint .le. 0) go to 190
+            iflag = 0
+            if (mod(iter-1,nprint) .eq. 0) call fcn(n,x,fvec,iflag)
+            if (iflag .lt. 0) go to 300
+  190       continue
+c
+c           determine the direction p.
+c
+            call dogleg(n,r,lr,diag,qtf,delta,wa1,wa2,wa3)
+c
+c           store the direction p and x + p. calculate the norm of p.
+c
+            do 200 j = 1, n
+               wa1(j) = -wa1(j)
+               wa2(j) = x(j) + wa1(j)
+               wa3(j) = diag(j)*wa1(j)
+  200          continue
+            pnorm = enorm(n,wa3)
+c
+c           on the first iteration, adjust the initial step bound.
+c
+            if (iter .eq. 1) delta = dmin1(delta,pnorm)
+c
+c           evaluate the function at x + p and calculate its norm.
+c
+            iflag = 1
+            call fcn(n,wa2,wa4,iflag)
+            nfev = nfev + 1
+            if (iflag .lt. 0) go to 300
+            fnorm1 = enorm(n,wa4)
+c
+c           compute the scaled actual reduction.
+c
+            actred = -one
+            if (fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2
+c
+c           compute the scaled predicted reduction.
+c
+            l = 1
+            do 220 i = 1, n
+               sum = zero
+               do 210 j = i, n
+                  sum = sum + r(l)*wa1(j)
+                  l = l + 1
+  210             continue
+               wa3(i) = qtf(i) + sum
+  220          continue
+            temp = enorm(n,wa3)
+            prered = zero
+            if (temp .lt. fnorm) prered = one - (temp/fnorm)**2
+c
+c           compute the ratio of the actual to the predicted
+c           reduction.
+c
+            ratio = zero
+            if (prered .gt. zero) ratio = actred/prered
+c
+c           update the step bound.
+c
+            if (ratio .ge. p1) go to 230
+               ncsuc = 0
+               ncfail = ncfail + 1
+               delta = p5*delta
+               go to 240
+  230       continue
+               ncfail = 0
+               ncsuc = ncsuc + 1
+               if (ratio .ge. p5 .or. ncsuc .gt. 1)
+     *            delta = dmax1(delta,pnorm/p5)
+               if (dabs(ratio-one) .le. p1) delta = pnorm/p5
+  240       continue
+c
+c           test for successful iteration.
+c
+            if (ratio .lt. p0001) go to 260
+c
+c           successful iteration. update x, fvec, and their norms.
+c
+            do 250 j = 1, n
+               x(j) = wa2(j)
+               wa2(j) = diag(j)*x(j)
+               fvec(j) = wa4(j)
+  250          continue
+            xnorm = enorm(n,wa2)
+            fnorm = fnorm1
+            iter = iter + 1
+  260       continue
+c
+c           determine the progress of the iteration.
+c
+            nslow1 = nslow1 + 1
+            if (actred .ge. p001) nslow1 = 0
+            if (jeval) nslow2 = nslow2 + 1
+            if (actred .ge. p1) nslow2 = 0
+c
+c           test for convergence.
+c
+            if (delta .le. xtol*xnorm .or. fnorm .eq. zero) info = 1
+            if (info .ne. 0) go to 300
+c
+c           tests for termination and stringent tolerances.
+c
+            if (nfev .ge. maxfev) info = 2
+            if (p1*dmax1(p1*delta,pnorm) .le. epsmch*xnorm) info = 3
+            if (nslow2 .eq. 5) info = 4
+            if (nslow1 .eq. 10) info = 5
+            if (info .ne. 0) go to 300
+c
+c           criterion for recalculating jacobian approximation
+c           by forward differences.
+c
+            if (ncfail .eq. 2) go to 290
+c
+c           calculate the rank one modification to the jacobian
+c           and update qtf if necessary.
+c
+            do 280 j = 1, n
+               sum = zero
+               do 270 i = 1, n
+                  sum = sum + fjac(i,j)*wa4(i)
+  270             continue
+               wa2(j) = (sum - wa3(j))/pnorm
+               wa1(j) = diag(j)*((diag(j)*wa1(j))/pnorm)
+               if (ratio .ge. p0001) qtf(j) = sum
+  280          continue
+c
+c           compute the qr factorization of the updated jacobian.
+c
+            call r1updt(n,n,r,lr,wa1,wa2,wa3,sing)
+            call r1mpyq(n,n,fjac,ldfjac,wa2,wa3)
+            call r1mpyq(1,n,qtf,1,wa2,wa3)
+c
+c           end of the inner loop.
+c
+            jeval = .false.
+            go to 180
+  290    continue
+c
+c        end of the outer loop.
+c
+         go to 30
+  300 continue
+c
+c     termination, either normal or user imposed.
+c
+      if (iflag .lt. 0) info = iflag
+      iflag = 0
+      if (nprint .gt. 0) call fcn(n,x,fvec,iflag)
+      return
+c
+c     last card of subroutine hybrd.
+c
+      end
diff --git a/fortran/hybrd1.f b/fortran/hybrd1.f
new file mode 100644
index 0000000..c0a8592
--- /dev/null
+++ b/fortran/hybrd1.f
@@ -0,0 +1,123 @@
+      subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
+      integer n,info,lwa
+      double precision tol
+      double precision x(n),fvec(n),wa(lwa)
+      external fcn
+c     **********
+c
+c     subroutine hybrd1
+c
+c     the purpose of hybrd1 is to find a zero of a system of
+c     n nonlinear functions in n variables by a modification
+c     of the powell hybrid method. this is done by using the
+c     more general nonlinear equation solver hybrd. the user
+c     must provide a subroutine which calculates the functions.
+c     the jacobian is then calculated by a forward-difference
+c     approximation.
+c
+c     the subroutine statement is
+c
+c       subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions. fcn must be declared
+c         in an external statement in the user calling
+c         program, and should be written as follows.
+c
+c         subroutine fcn(n,x,fvec,iflag)
+c         integer n,iflag
+c         double precision x(n),fvec(n)
+c         ----------
+c         calculate the functions at x and
+c         return this vector in fvec.
+c         ---------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of hybrd1.
+c         in this case set iflag to a negative integer.
+c
+c       n is a positive integer input variable set to the number
+c         of functions and variables.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length n which contains
+c         the functions evaluated at the output x.
+c
+c       tol is a nonnegative input variable. termination occurs
+c         when the algorithm estimates that the relative error
+c         between x and the solution is at most tol.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0   improper input parameters.
+c
+c         info = 1   algorithm estimates that the relative error
+c                    between x and the solution is at most tol.
+c
+c         info = 2   number of calls to fcn has reached or exceeded
+c                    200*(n+1).
+c
+c         info = 3   tol is too small. no further improvement in
+c                    the approximate solution x is possible.
+c
+c         info = 4   iteration is not making good progress.
+c
+c       wa is a work array of length lwa.
+c
+c       lwa is a positive integer input variable not less than
+c         (n*(3*n+13))/2.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... hybrd
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer index,j,lr,maxfev,ml,mode,mu,nfev,nprint
+      double precision epsfcn,factor,one,xtol,zero
+      data factor,one,zero /1.0d2,1.0d0,0.0d0/
+      info = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. tol .lt. zero .or. lwa .lt. (n*(3*n + 13))/2)
+     *   go to 20
+c
+c     call hybrd.
+c
+      maxfev = 200*(n + 1)
+      xtol = tol
+      ml = n - 1
+      mu = n - 1
+      epsfcn = zero
+      mode = 2
+      do 10 j = 1, n
+         wa(j) = one
+   10    continue
+      nprint = 0
+      lr = (n*(n + 1))/2
+      index = 6*n + lr
+      call hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,wa(1),mode,
+     *           factor,nprint,info,nfev,wa(index+1),n,wa(6*n+1),lr,
+     *           wa(n+1),wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1))
+      if (info .eq. 5) info = 4
+   20 continue
+      return
+c
+c     last card of subroutine hybrd1.
+c
+      end
diff --git a/fortran/hybrj.f b/fortran/hybrj.f
new file mode 100644
index 0000000..3070dad
--- /dev/null
+++ b/fortran/hybrj.f
@@ -0,0 +1,440 @@
+      subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode,
+     *                 factor,nprint,info,nfev,njev,r,lr,qtf,wa1,wa2,
+     *                 wa3,wa4)
+      integer n,ldfjac,maxfev,mode,nprint,info,nfev,njev,lr
+      double precision xtol,factor
+      double precision x(n),fvec(n),fjac(ldfjac,n),diag(n),r(lr),
+     *                 qtf(n),wa1(n),wa2(n),wa3(n),wa4(n)
+c     **********
+c
+c     subroutine hybrj
+c
+c     the purpose of hybrj is to find a zero of a system of
+c     n nonlinear functions in n variables by a modification
+c     of the powell hybrid method. the user must provide a
+c     subroutine which calculates the functions and the jacobian.
+c
+c     the subroutine statement is
+c
+c       subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,
+c                        mode,factor,nprint,info,nfev,njev,r,lr,qtf,
+c                        wa1,wa2,wa3,wa4)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions and the jacobian. fcn must
+c         be declared in an external statement in the user
+c         calling program, and should be written as follows.
+c
+c         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+c         integer n,ldfjac,iflag
+c         double precision x(n),fvec(n),fjac(ldfjac,n)
+c         ----------
+c         if iflag = 1 calculate the functions at x and
+c         return this vector in fvec. do not alter fjac.
+c         if iflag = 2 calculate the jacobian at x and
+c         return this matrix in fjac. do not alter fvec.
+c         ---------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of hybrj.
+c         in this case set iflag to a negative integer.
+c
+c       n is a positive integer input variable set to the number
+c         of functions and variables.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length n which contains
+c         the functions evaluated at the output x.
+c
+c       fjac is an output n by n array which contains the
+c         orthogonal matrix q produced by the qr factorization
+c         of the final approximate jacobian.
+c
+c       ldfjac is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       xtol is a nonnegative input variable. termination
+c         occurs when the relative error between two consecutive
+c         iterates is at most xtol.
+c
+c       maxfev is a positive integer input variable. termination
+c         occurs when the number of calls to fcn with iflag = 1
+c         has reached maxfev.
+c
+c       diag is an array of length n. if mode = 1 (see
+c         below), diag is internally set. if mode = 2, diag
+c         must contain positive entries that serve as
+c         multiplicative scale factors for the variables.
+c
+c       mode is an integer input variable. if mode = 1, the
+c         variables will be scaled internally. if mode = 2,
+c         the scaling is specified by the input diag. other
+c         values of mode are equivalent to mode = 1.
+c
+c       factor is a positive input variable used in determining the
+c         initial step bound. this bound is set to the product of
+c         factor and the euclidean norm of diag*x if nonzero, or else
+c         to factor itself. in most cases factor should lie in the
+c         interval (.1,100.). 100. is a generally recommended value.
+c
+c       nprint is an integer input variable that enables controlled
+c         printing of iterates if it is positive. in this case,
+c         fcn is called with iflag = 0 at the beginning of the first
+c         iteration and every nprint iterations thereafter and
+c         immediately prior to return, with x and fvec available
+c         for printing. fvec and fjac should not be altered.
+c         if nprint is not positive, no special calls of fcn
+c         with iflag = 0 are made.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0   improper input parameters.
+c
+c         info = 1   relative error between two consecutive iterates
+c                    is at most xtol.
+c
+c         info = 2   number of calls to fcn with iflag = 1 has
+c                    reached maxfev.
+c
+c         info = 3   xtol is too small. no further improvement in
+c                    the approximate solution x is possible.
+c
+c         info = 4   iteration is not making good progress, as
+c                    measured by the improvement from the last
+c                    five jacobian evaluations.
+c
+c         info = 5   iteration is not making good progress, as
+c                    measured by the improvement from the last
+c                    ten iterations.
+c
+c       nfev is an integer output variable set to the number of
+c         calls to fcn with iflag = 1.
+c
+c       njev is an integer output variable set to the number of
+c         calls to fcn with iflag = 2.
+c
+c       r is an output array of length lr which contains the
+c         upper triangular matrix produced by the qr factorization
+c         of the final approximate jacobian, stored rowwise.
+c
+c       lr is a positive integer input variable not less than
+c         (n*(n+1))/2.
+c
+c       qtf is an output array of length n which contains
+c         the vector (q transpose)*fvec.
+c
+c       wa1, wa2, wa3, and wa4 are work arrays of length n.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dogleg,dpmpar,enorm,
+c                            qform,qrfac,r1mpyq,r1updt
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,mod
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iflag,iter,j,jm1,l,ncfail,ncsuc,nslow1,nslow2
+      integer iwa(1)
+      logical jeval,sing
+      double precision actred,delta,epsmch,fnorm,fnorm1,one,pnorm,
+     *                 prered,p1,p5,p001,p0001,ratio,sum,temp,xnorm,
+     *                 zero
+      double precision dpmpar,enorm
+      data one,p1,p5,p001,p0001,zero
+     *     /1.0d0,1.0d-1,5.0d-1,1.0d-3,1.0d-4,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      info = 0
+      iflag = 0
+      nfev = 0
+      njev = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. ldfjac .lt. n .or. xtol .lt. zero
+     *    .or. maxfev .le. 0 .or. factor .le. zero
+     *    .or. lr .lt. (n*(n + 1))/2) go to 300
+      if (mode .ne. 2) go to 20
+      do 10 j = 1, n
+         if (diag(j) .le. zero) go to 300
+   10    continue
+   20 continue
+c
+c     evaluate the function at the starting point
+c     and calculate its norm.
+c
+      iflag = 1
+      call fcn(n,x,fvec,fjac,ldfjac,iflag)
+      nfev = 1
+      if (iflag .lt. 0) go to 300
+      fnorm = enorm(n,fvec)
+c
+c     initialize iteration counter and monitors.
+c
+      iter = 1
+      ncsuc = 0
+      ncfail = 0
+      nslow1 = 0
+      nslow2 = 0
+c
+c     beginning of the outer loop.
+c
+   30 continue
+         jeval = .true.
+c
+c        calculate the jacobian matrix.
+c
+         iflag = 2
+         call fcn(n,x,fvec,fjac,ldfjac,iflag)
+         njev = njev + 1
+         if (iflag .lt. 0) go to 300
+c
+c        compute the qr factorization of the jacobian.
+c
+         call qrfac(n,n,fjac,ldfjac,.false.,iwa,1,wa1,wa2,wa3)
+c
+c        on the first iteration and if mode is 1, scale according
+c        to the norms of the columns of the initial jacobian.
+c
+         if (iter .ne. 1) go to 70
+         if (mode .eq. 2) go to 50
+         do 40 j = 1, n
+            diag(j) = wa2(j)
+            if (wa2(j) .eq. zero) diag(j) = one
+   40       continue
+   50    continue
+c
+c        on the first iteration, calculate the norm of the scaled x
+c        and initialize the step bound delta.
+c
+         do 60 j = 1, n
+            wa3(j) = diag(j)*x(j)
+   60       continue
+         xnorm = enorm(n,wa3)
+         delta = factor*xnorm
+         if (delta .eq. zero) delta = factor
+   70    continue
+c
+c        form (q transpose)*fvec and store in qtf.
+c
+         do 80 i = 1, n
+            qtf(i) = fvec(i)
+   80       continue
+         do 120 j = 1, n
+            if (fjac(j,j) .eq. zero) go to 110
+            sum = zero
+            do 90 i = j, n
+               sum = sum + fjac(i,j)*qtf(i)
+   90          continue
+            temp = -sum/fjac(j,j)
+            do 100 i = j, n
+               qtf(i) = qtf(i) + fjac(i,j)*temp
+  100          continue
+  110       continue
+  120       continue
+c
+c        copy the triangular factor of the qr factorization into r.
+c
+         sing = .false.
+         do 150 j = 1, n
+            l = j
+            jm1 = j - 1
+            if (jm1 .lt. 1) go to 140
+            do 130 i = 1, jm1
+               r(l) = fjac(i,j)
+               l = l + n - i
+  130          continue
+  140       continue
+            r(l) = wa1(j)
+            if (wa1(j) .eq. zero) sing = .true.
+  150       continue
+c
+c        accumulate the orthogonal factor in fjac.
+c
+         call qform(n,n,fjac,ldfjac,wa1)
+c
+c        rescale if necessary.
+c
+         if (mode .eq. 2) go to 170
+         do 160 j = 1, n
+            diag(j) = dmax1(diag(j),wa2(j))
+  160       continue
+  170    continue
+c
+c        beginning of the inner loop.
+c
+  180    continue
+c
+c           if requested, call fcn to enable printing of iterates.
+c
+            if (nprint .le. 0) go to 190
+            iflag = 0
+            if (mod(iter-1,nprint) .eq. 0)
+     *         call fcn(n,x,fvec,fjac,ldfjac,iflag)
+            if (iflag .lt. 0) go to 300
+  190       continue
+c
+c           determine the direction p.
+c
+            call dogleg(n,r,lr,diag,qtf,delta,wa1,wa2,wa3)
+c
+c           store the direction p and x + p. calculate the norm of p.
+c
+            do 200 j = 1, n
+               wa1(j) = -wa1(j)
+               wa2(j) = x(j) + wa1(j)
+               wa3(j) = diag(j)*wa1(j)
+  200          continue
+            pnorm = enorm(n,wa3)
+c
+c           on the first iteration, adjust the initial step bound.
+c
+            if (iter .eq. 1) delta = dmin1(delta,pnorm)
+c
+c           evaluate the function at x + p and calculate its norm.
+c
+            iflag = 1
+            call fcn(n,wa2,wa4,fjac,ldfjac,iflag)
+            nfev = nfev + 1
+            if (iflag .lt. 0) go to 300
+            fnorm1 = enorm(n,wa4)
+c
+c           compute the scaled actual reduction.
+c
+            actred = -one
+            if (fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2
+c
+c           compute the scaled predicted reduction.
+c
+            l = 1
+            do 220 i = 1, n
+               sum = zero
+               do 210 j = i, n
+                  sum = sum + r(l)*wa1(j)
+                  l = l + 1
+  210             continue
+               wa3(i) = qtf(i) + sum
+  220          continue
+            temp = enorm(n,wa3)
+            prered = zero
+            if (temp .lt. fnorm) prered = one - (temp/fnorm)**2
+c
+c           compute the ratio of the actual to the predicted
+c           reduction.
+c
+            ratio = zero
+            if (prered .gt. zero) ratio = actred/prered
+c
+c           update the step bound.
+c
+            if (ratio .ge. p1) go to 230
+               ncsuc = 0
+               ncfail = ncfail + 1
+               delta = p5*delta
+               go to 240
+  230       continue
+               ncfail = 0
+               ncsuc = ncsuc + 1
+               if (ratio .ge. p5 .or. ncsuc .gt. 1)
+     *            delta = dmax1(delta,pnorm/p5)
+               if (dabs(ratio-one) .le. p1) delta = pnorm/p5
+  240       continue
+c
+c           test for successful iteration.
+c
+            if (ratio .lt. p0001) go to 260
+c
+c           successful iteration. update x, fvec, and their norms.
+c
+            do 250 j = 1, n
+               x(j) = wa2(j)
+               wa2(j) = diag(j)*x(j)
+               fvec(j) = wa4(j)
+  250          continue
+            xnorm = enorm(n,wa2)
+            fnorm = fnorm1
+            iter = iter + 1
+  260       continue
+c
+c           determine the progress of the iteration.
+c
+            nslow1 = nslow1 + 1
+            if (actred .ge. p001) nslow1 = 0
+            if (jeval) nslow2 = nslow2 + 1
+            if (actred .ge. p1) nslow2 = 0
+c
+c           test for convergence.
+c
+            if (delta .le. xtol*xnorm .or. fnorm .eq. zero) info = 1
+            if (info .ne. 0) go to 300
+c
+c           tests for termination and stringent tolerances.
+c
+            if (nfev .ge. maxfev) info = 2
+            if (p1*dmax1(p1*delta,pnorm) .le. epsmch*xnorm) info = 3
+            if (nslow2 .eq. 5) info = 4
+            if (nslow1 .eq. 10) info = 5
+            if (info .ne. 0) go to 300
+c
+c           criterion for recalculating jacobian.
+c
+            if (ncfail .eq. 2) go to 290
+c
+c           calculate the rank one modification to the jacobian
+c           and update qtf if necessary.
+c
+            do 280 j = 1, n
+               sum = zero
+               do 270 i = 1, n
+                  sum = sum + fjac(i,j)*wa4(i)
+  270             continue
+               wa2(j) = (sum - wa3(j))/pnorm
+               wa1(j) = diag(j)*((diag(j)*wa1(j))/pnorm)
+               if (ratio .ge. p0001) qtf(j) = sum
+  280          continue
+c
+c           compute the qr factorization of the updated jacobian.
+c
+            call r1updt(n,n,r,lr,wa1,wa2,wa3,sing)
+            call r1mpyq(n,n,fjac,ldfjac,wa2,wa3)
+            call r1mpyq(1,n,qtf,1,wa2,wa3)
+c
+c           end of the inner loop.
+c
+            jeval = .false.
+            go to 180
+  290    continue
+c
+c        end of the outer loop.
+c
+         go to 30
+  300 continue
+c
+c     termination, either normal or user imposed.
+c
+      if (iflag .lt. 0) info = iflag
+      iflag = 0
+      if (nprint .gt. 0) call fcn(n,x,fvec,fjac,ldfjac,iflag)
+      return
+c
+c     last card of subroutine hybrj.
+c
+      end
diff --git a/fortran/hybrj1.f b/fortran/hybrj1.f
new file mode 100644
index 0000000..9f51c49
--- /dev/null
+++ b/fortran/hybrj1.f
@@ -0,0 +1,127 @@
+      subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)
+      integer n,ldfjac,info,lwa
+      double precision tol
+      double precision x(n),fvec(n),fjac(ldfjac,n),wa(lwa)
+      external fcn
+c     **********
+c
+c     subroutine hybrj1
+c
+c     the purpose of hybrj1 is to find a zero of a system of
+c     n nonlinear functions in n variables by a modification
+c     of the powell hybrid method. this is done by using the
+c     more general nonlinear equation solver hybrj. the user
+c     must provide a subroutine which calculates the functions
+c     and the jacobian.
+c
+c     the subroutine statement is
+c
+c       subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions and the jacobian. fcn must
+c         be declared in an external statement in the user
+c         calling program, and should be written as follows.
+c
+c         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+c         integer n,ldfjac,iflag
+c         double precision x(n),fvec(n),fjac(ldfjac,n)
+c         ----------
+c         if iflag = 1 calculate the functions at x and
+c         return this vector in fvec. do not alter fjac.
+c         if iflag = 2 calculate the jacobian at x and
+c         return this matrix in fjac. do not alter fvec.
+c         ---------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of hybrj1.
+c         in this case set iflag to a negative integer.
+c
+c       n is a positive integer input variable set to the number
+c         of functions and variables.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length n which contains
+c         the functions evaluated at the output x.
+c
+c       fjac is an output n by n array which contains the
+c         orthogonal matrix q produced by the qr factorization
+c         of the final approximate jacobian.
+c
+c       ldfjac is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       tol is a nonnegative input variable. termination occurs
+c         when the algorithm estimates that the relative error
+c         between x and the solution is at most tol.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0   improper input parameters.
+c
+c         info = 1   algorithm estimates that the relative error
+c                    between x and the solution is at most tol.
+c
+c         info = 2   number of calls to fcn with iflag = 1 has
+c                    reached 100*(n+1).
+c
+c         info = 3   tol is too small. no further improvement in
+c                    the approximate solution x is possible.
+c
+c         info = 4   iteration is not making good progress.
+c
+c       wa is a work array of length lwa.
+c
+c       lwa is a positive integer input variable not less than
+c         (n*(n+13))/2.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... hybrj
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer j,lr,maxfev,mode,nfev,njev,nprint
+      double precision factor,one,xtol,zero
+      data factor,one,zero /1.0d2,1.0d0,0.0d0/
+      info = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. ldfjac .lt. n .or. tol .lt. zero
+     *    .or. lwa .lt. (n*(n + 13))/2) go to 20
+c
+c     call hybrj.
+c
+      maxfev = 100*(n + 1)
+      xtol = tol
+      mode = 2
+      do 10 j = 1, n
+         wa(j) = one
+   10    continue
+      nprint = 0
+      lr = (n*(n + 1))/2
+      call hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,wa(1),mode,
+     *           factor,nprint,info,nfev,njev,wa(6*n+1),lr,wa(n+1),
+     *           wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1))
+      if (info .eq. 5) info = 4
+   20 continue
+      return
+c
+c     last card of subroutine hybrj1.
+c
+      end
diff --git a/fortran/lmder.f b/fortran/lmder.f
new file mode 100644
index 0000000..8797d8b
--- /dev/null
+++ b/fortran/lmder.f
@@ -0,0 +1,452 @@
+      subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
+     *                 maxfev,diag,mode,factor,nprint,info,nfev,njev,
+     *                 ipvt,qtf,wa1,wa2,wa3,wa4)
+      integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev
+      integer ipvt(n)
+      double precision ftol,xtol,gtol,factor
+      double precision x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n),
+     *                 wa1(n),wa2(n),wa3(n),wa4(m)
+c     **********
+c
+c     subroutine lmder
+c
+c     the purpose of lmder is to minimize the sum of the squares of
+c     m nonlinear functions in n variables by a modification of
+c     the levenberg-marquardt algorithm. the user must provide a
+c     subroutine which calculates the functions and the jacobian.
+c
+c     the subroutine statement is
+c
+c       subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
+c                        maxfev,diag,mode,factor,nprint,info,nfev,
+c                        njev,ipvt,qtf,wa1,wa2,wa3,wa4)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions and the jacobian. fcn must
+c         be declared in an external statement in the user
+c         calling program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+c         integer m,n,ldfjac,iflag
+c         double precision x(n),fvec(m),fjac(ldfjac,n)
+c         ----------
+c         if iflag = 1 calculate the functions at x and
+c         return this vector in fvec. do not alter fjac.
+c         if iflag = 2 calculate the jacobian at x and
+c         return this matrix in fjac. do not alter fvec.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of lmder.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length m which contains
+c         the functions evaluated at the output x.
+c
+c       fjac is an output m by n array. the upper n by n submatrix
+c         of fjac contains an upper triangular matrix r with
+c         diagonal elements of nonincreasing magnitude such that
+c
+c                t     t           t
+c               p *(jac *jac)*p = r *r,
+c
+c         where p is a permutation matrix and jac is the final
+c         calculated jacobian. column j of p is column ipvt(j)
+c         (see below) of the identity matrix. the lower trapezoidal
+c         part of fjac contains information generated during
+c         the computation of r.
+c
+c       ldfjac is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array fjac.
+c
+c       ftol is a nonnegative input variable. termination
+c         occurs when both the actual and predicted relative
+c         reductions in the sum of squares are at most ftol.
+c         therefore, ftol measures the relative error desired
+c         in the sum of squares.
+c
+c       xtol is a nonnegative input variable. termination
+c         occurs when the relative error between two consecutive
+c         iterates is at most xtol. therefore, xtol measures the
+c         relative error desired in the approximate solution.
+c
+c       gtol is a nonnegative input variable. termination
+c         occurs when the cosine of the angle between fvec and
+c         any column of the jacobian is at most gtol in absolute
+c         value. therefore, gtol measures the orthogonality
+c         desired between the function vector and the columns
+c         of the jacobian.
+c
+c       maxfev is a positive integer input variable. termination
+c         occurs when the number of calls to fcn with iflag = 1
+c         has reached maxfev.
+c
+c       diag is an array of length n. if mode = 1 (see
+c         below), diag is internally set. if mode = 2, diag
+c         must contain positive entries that serve as
+c         multiplicative scale factors for the variables.
+c
+c       mode is an integer input variable. if mode = 1, the
+c         variables will be scaled internally. if mode = 2,
+c         the scaling is specified by the input diag. other
+c         values of mode are equivalent to mode = 1.
+c
+c       factor is a positive input variable used in determining the
+c         initial step bound. this bound is set to the product of
+c         factor and the euclidean norm of diag*x if nonzero, or else
+c         to factor itself. in most cases factor should lie in the
+c         interval (.1,100.).100. is a generally recommended value.
+c
+c       nprint is an integer input variable that enables controlled
+c         printing of iterates if it is positive. in this case,
+c         fcn is called with iflag = 0 at the beginning of the first
+c         iteration and every nprint iterations thereafter and
+c         immediately prior to return, with x, fvec, and fjac
+c         available for printing. fvec and fjac should not be
+c         altered. if nprint is not positive, no special calls
+c         of fcn with iflag = 0 are made.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0  improper input parameters.
+c
+c         info = 1  both actual and predicted relative reductions
+c                   in the sum of squares are at most ftol.
+c
+c         info = 2  relative error between two consecutive iterates
+c                   is at most xtol.
+c
+c         info = 3  conditions for info = 1 and info = 2 both hold.
+c
+c         info = 4  the cosine of the angle between fvec and any
+c                   column of the jacobian is at most gtol in
+c                   absolute value.
+c
+c         info = 5  number of calls to fcn with iflag = 1 has
+c                   reached maxfev.
+c
+c         info = 6  ftol is too small. no further reduction in
+c                   the sum of squares is possible.
+c
+c         info = 7  xtol is too small. no further improvement in
+c                   the approximate solution x is possible.
+c
+c         info = 8  gtol is too small. fvec is orthogonal to the
+c                   columns of the jacobian to machine precision.
+c
+c       nfev is an integer output variable set to the number of
+c         calls to fcn with iflag = 1.
+c
+c       njev is an integer output variable set to the number of
+c         calls to fcn with iflag = 2.
+c
+c       ipvt is an integer output array of length n. ipvt
+c         defines a permutation matrix p such that jac*p = q*r,
+c         where jac is the final calculated jacobian, q is
+c         orthogonal (not stored), and r is upper triangular
+c         with diagonal elements of nonincreasing magnitude.
+c         column j of p is column ipvt(j) of the identity matrix.
+c
+c       qtf is an output array of length n which contains
+c         the first n elements of the vector (q transpose)*fvec.
+c
+c       wa1, wa2, and wa3 are work arrays of length n.
+c
+c       wa4 is a work array of length m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,lmpar,qrfac
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iflag,iter,j,l
+      double precision actred,delta,dirder,epsmch,fnorm,fnorm1,gnorm,
+     *                 one,par,pnorm,prered,p1,p5,p25,p75,p0001,ratio,
+     *                 sum,temp,temp1,temp2,xnorm,zero
+      double precision dpmpar,enorm
+      data one,p1,p5,p25,p75,p0001,zero
+     *     /1.0d0,1.0d-1,5.0d-1,2.5d-1,7.5d-1,1.0d-4,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      info = 0
+      iflag = 0
+      nfev = 0
+      njev = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. m
+     *    .or. ftol .lt. zero .or. xtol .lt. zero .or. gtol .lt. zero
+     *    .or. maxfev .le. 0 .or. factor .le. zero) go to 300
+      if (mode .ne. 2) go to 20
+      do 10 j = 1, n
+         if (diag(j) .le. zero) go to 300
+   10    continue
+   20 continue
+c
+c     evaluate the function at the starting point
+c     and calculate its norm.
+c
+      iflag = 1
+      call fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+      nfev = 1
+      if (iflag .lt. 0) go to 300
+      fnorm = enorm(m,fvec)
+c
+c     initialize levenberg-marquardt parameter and iteration counter.
+c
+      par = zero
+      iter = 1
+c
+c     beginning of the outer loop.
+c
+   30 continue
+c
+c        calculate the jacobian matrix.
+c
+         iflag = 2
+         call fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+         njev = njev + 1
+         if (iflag .lt. 0) go to 300
+c
+c        if requested, call fcn to enable printing of iterates.
+c
+         if (nprint .le. 0) go to 40
+         iflag = 0
+         if (mod(iter-1,nprint) .eq. 0)
+     *      call fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+         if (iflag .lt. 0) go to 300
+   40    continue
+c
+c        compute the qr factorization of the jacobian.
+c
+         call qrfac(m,n,fjac,ldfjac,.true.,ipvt,n,wa1,wa2,wa3)
+c
+c        on the first iteration and if mode is 1, scale according
+c        to the norms of the columns of the initial jacobian.
+c
+         if (iter .ne. 1) go to 80
+         if (mode .eq. 2) go to 60
+         do 50 j = 1, n
+            diag(j) = wa2(j)
+            if (wa2(j) .eq. zero) diag(j) = one
+   50       continue
+   60    continue
+c
+c        on the first iteration, calculate the norm of the scaled x
+c        and initialize the step bound delta.
+c
+         do 70 j = 1, n
+            wa3(j) = diag(j)*x(j)
+   70       continue
+         xnorm = enorm(n,wa3)
+         delta = factor*xnorm
+         if (delta .eq. zero) delta = factor
+   80    continue
+c
+c        form (q transpose)*fvec and store the first n components in
+c        qtf.
+c
+         do 90 i = 1, m
+            wa4(i) = fvec(i)
+   90       continue
+         do 130 j = 1, n
+            if (fjac(j,j) .eq. zero) go to 120
+            sum = zero
+            do 100 i = j, m
+               sum = sum + fjac(i,j)*wa4(i)
+  100          continue
+            temp = -sum/fjac(j,j)
+            do 110 i = j, m
+               wa4(i) = wa4(i) + fjac(i,j)*temp
+  110          continue
+  120       continue
+            fjac(j,j) = wa1(j)
+            qtf(j) = wa4(j)
+  130       continue
+c
+c        compute the norm of the scaled gradient.
+c
+         gnorm = zero
+         if (fnorm .eq. zero) go to 170
+         do 160 j = 1, n
+            l = ipvt(j)
+            if (wa2(l) .eq. zero) go to 150
+            sum = zero
+            do 140 i = 1, j
+               sum = sum + fjac(i,j)*(qtf(i)/fnorm)
+  140          continue
+            gnorm = dmax1(gnorm,dabs(sum/wa2(l)))
+  150       continue
+  160       continue
+  170    continue
+c
+c        test for convergence of the gradient norm.
+c
+         if (gnorm .le. gtol) info = 4
+         if (info .ne. 0) go to 300
+c
+c        rescale if necessary.
+c
+         if (mode .eq. 2) go to 190
+         do 180 j = 1, n
+            diag(j) = dmax1(diag(j),wa2(j))
+  180       continue
+  190    continue
+c
+c        beginning of the inner loop.
+c
+  200    continue
+c
+c           determine the levenberg-marquardt parameter.
+c
+            call lmpar(n,fjac,ldfjac,ipvt,diag,qtf,delta,par,wa1,wa2,
+     *                 wa3,wa4)
+c
+c           store the direction p and x + p. calculate the norm of p.
+c
+            do 210 j = 1, n
+               wa1(j) = -wa1(j)
+               wa2(j) = x(j) + wa1(j)
+               wa3(j) = diag(j)*wa1(j)
+  210          continue
+            pnorm = enorm(n,wa3)
+c
+c           on the first iteration, adjust the initial step bound.
+c
+            if (iter .eq. 1) delta = dmin1(delta,pnorm)
+c
+c           evaluate the function at x + p and calculate its norm.
+c
+            iflag = 1
+            call fcn(m,n,wa2,wa4,fjac,ldfjac,iflag)
+            nfev = nfev + 1
+            if (iflag .lt. 0) go to 300
+            fnorm1 = enorm(m,wa4)
+c
+c           compute the scaled actual reduction.
+c
+            actred = -one
+            if (p1*fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2
+c
+c           compute the scaled predicted reduction and
+c           the scaled directional derivative.
+c
+            do 230 j = 1, n
+               wa3(j) = zero
+               l = ipvt(j)
+               temp = wa1(l)
+               do 220 i = 1, j
+                  wa3(i) = wa3(i) + fjac(i,j)*temp
+  220             continue
+  230          continue
+            temp1 = enorm(n,wa3)/fnorm
+            temp2 = (dsqrt(par)*pnorm)/fnorm
+            prered = temp1**2 + temp2**2/p5
+            dirder = -(temp1**2 + temp2**2)
+c
+c           compute the ratio of the actual to the predicted
+c           reduction.
+c
+            ratio = zero
+            if (prered .ne. zero) ratio = actred/prered
+c
+c           update the step bound.
+c
+            if (ratio .gt. p25) go to 240
+               if (actred .ge. zero) temp = p5
+               if (actred .lt. zero)
+     *            temp = p5*dirder/(dirder + p5*actred)
+               if (p1*fnorm1 .ge. fnorm .or. temp .lt. p1) temp = p1
+               delta = temp*dmin1(delta,pnorm/p1)
+               par = par/temp
+               go to 260
+  240       continue
+               if (par .ne. zero .and. ratio .lt. p75) go to 250
+               delta = pnorm/p5
+               par = p5*par
+  250          continue
+  260       continue
+c
+c           test for successful iteration.
+c
+            if (ratio .lt. p0001) go to 290
+c
+c           successful iteration. update x, fvec, and their norms.
+c
+            do 270 j = 1, n
+               x(j) = wa2(j)
+               wa2(j) = diag(j)*x(j)
+  270          continue
+            do 280 i = 1, m
+               fvec(i) = wa4(i)
+  280          continue
+            xnorm = enorm(n,wa2)
+            fnorm = fnorm1
+            iter = iter + 1
+  290       continue
+c
+c           tests for convergence.
+c
+            if (dabs(actred) .le. ftol .and. prered .le. ftol
+     *          .and. p5*ratio .le. one) info = 1
+            if (delta .le. xtol*xnorm) info = 2
+            if (dabs(actred) .le. ftol .and. prered .le. ftol
+     *          .and. p5*ratio .le. one .and. info .eq. 2) info = 3
+            if (info .ne. 0) go to 300
+c
+c           tests for termination and stringent tolerances.
+c
+            if (nfev .ge. maxfev) info = 5
+            if (dabs(actred) .le. epsmch .and. prered .le. epsmch
+     *          .and. p5*ratio .le. one) info = 6
+            if (delta .le. epsmch*xnorm) info = 7
+            if (gnorm .le. epsmch) info = 8
+            if (info .ne. 0) go to 300
+c
+c           end of the inner loop. repeat if iteration unsuccessful.
+c
+            if (ratio .lt. p0001) go to 200
+c
+c        end of the outer loop.
+c
+         go to 30
+  300 continue
+c
+c     termination, either normal or user imposed.
+c
+      if (iflag .lt. 0) info = iflag
+      iflag = 0
+      if (nprint .gt. 0) call fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+      return
+c
+c     last card of subroutine lmder.
+c
+      end
diff --git a/fortran/lmder1.f b/fortran/lmder1.f
new file mode 100644
index 0000000..d691940
--- /dev/null
+++ b/fortran/lmder1.f
@@ -0,0 +1,156 @@
+      subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,
+     *                  lwa)
+      integer m,n,ldfjac,info,lwa
+      integer ipvt(n)
+      double precision tol
+      double precision x(n),fvec(m),fjac(ldfjac,n),wa(lwa)
+      external fcn
+c     **********
+c
+c     subroutine lmder1
+c
+c     the purpose of lmder1 is to minimize the sum of the squares of
+c     m nonlinear functions in n variables by a modification of the
+c     levenberg-marquardt algorithm. this is done by using the more
+c     general least-squares solver lmder. the user must provide a
+c     subroutine which calculates the functions and the jacobian.
+c
+c     the subroutine statement is
+c
+c       subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,
+c                         ipvt,wa,lwa)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions and the jacobian. fcn must
+c         be declared in an external statement in the user
+c         calling program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+c         integer m,n,ldfjac,iflag
+c         double precision x(n),fvec(m),fjac(ldfjac,n)
+c         ----------
+c         if iflag = 1 calculate the functions at x and
+c         return this vector in fvec. do not alter fjac.
+c         if iflag = 2 calculate the jacobian at x and
+c         return this matrix in fjac. do not alter fvec.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of lmder1.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length m which contains
+c         the functions evaluated at the output x.
+c
+c       fjac is an output m by n array. the upper n by n submatrix
+c         of fjac contains an upper triangular matrix r with
+c         diagonal elements of nonincreasing magnitude such that
+c
+c                t     t           t
+c               p *(jac *jac)*p = r *r,
+c
+c         where p is a permutation matrix and jac is the final
+c         calculated jacobian. column j of p is column ipvt(j)
+c         (see below) of the identity matrix. the lower trapezoidal
+c         part of fjac contains information generated during
+c         the computation of r.
+c
+c       ldfjac is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array fjac.
+c
+c       tol is a nonnegative input variable. termination occurs
+c         when the algorithm estimates either that the relative
+c         error in the sum of squares is at most tol or that
+c         the relative error between x and the solution is at
+c         most tol.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0  improper input parameters.
+c
+c         info = 1  algorithm estimates that the relative error
+c                   in the sum of squares is at most tol.
+c
+c         info = 2  algorithm estimates that the relative error
+c                   between x and the solution is at most tol.
+c
+c         info = 3  conditions for info = 1 and info = 2 both hold.
+c
+c         info = 4  fvec is orthogonal to the columns of the
+c                   jacobian to machine precision.
+c
+c         info = 5  number of calls to fcn with iflag = 1 has
+c                   reached 100*(n+1).
+c
+c         info = 6  tol is too small. no further reduction in
+c                   the sum of squares is possible.
+c
+c         info = 7  tol is too small. no further improvement in
+c                   the approximate solution x is possible.
+c
+c       ipvt is an integer output array of length n. ipvt
+c         defines a permutation matrix p such that jac*p = q*r,
+c         where jac is the final calculated jacobian, q is
+c         orthogonal (not stored), and r is upper triangular
+c         with diagonal elements of nonincreasing magnitude.
+c         column j of p is column ipvt(j) of the identity matrix.
+c
+c       wa is a work array of length lwa.
+c
+c       lwa is a positive integer input variable not less than 5*n+m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... lmder
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer maxfev,mode,nfev,njev,nprint
+      double precision factor,ftol,gtol,xtol,zero
+      data factor,zero /1.0d2,0.0d0/
+      info = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. m .or. tol .lt. zero
+     *    .or. lwa .lt. 5*n + m) go to 10
+c
+c     call lmder.
+c
+      maxfev = 100*(n + 1)
+      ftol = tol
+      xtol = tol
+      gtol = zero
+      mode = 1
+      nprint = 0
+      call lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,maxfev,
+     *           wa(1),mode,factor,nprint,info,nfev,njev,ipvt,wa(n+1),
+     *           wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1))
+      if (info .eq. 8) info = 4
+   10 continue
+      return
+c
+c     last card of subroutine lmder1.
+c
+      end
diff --git a/fortran/lmdif.f b/fortran/lmdif.f
new file mode 100644
index 0000000..dd3d4ee
--- /dev/null
+++ b/fortran/lmdif.f
@@ -0,0 +1,454 @@
+      subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,
+     *                 diag,mode,factor,nprint,info,nfev,fjac,ldfjac,
+     *                 ipvt,qtf,wa1,wa2,wa3,wa4)
+      integer m,n,maxfev,mode,nprint,info,nfev,ldfjac
+      integer ipvt(n)
+      double precision ftol,xtol,gtol,epsfcn,factor
+      double precision x(n),fvec(m),diag(n),fjac(ldfjac,n),qtf(n),
+     *                 wa1(n),wa2(n),wa3(n),wa4(m)
+      external fcn
+c     **********
+c
+c     subroutine lmdif
+c
+c     the purpose of lmdif is to minimize the sum of the squares of
+c     m nonlinear functions in n variables by a modification of
+c     the levenberg-marquardt algorithm. the user must provide a
+c     subroutine which calculates the functions. the jacobian is
+c     then calculated by a forward-difference approximation.
+c
+c     the subroutine statement is
+c
+c       subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,
+c                        diag,mode,factor,nprint,info,nfev,fjac,
+c                        ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions. fcn must be declared
+c         in an external statement in the user calling
+c         program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,iflag)
+c         integer m,n,iflag
+c         double precision x(n),fvec(m)
+c         ----------
+c         calculate the functions at x and
+c         return this vector in fvec.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of lmdif.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length m which contains
+c         the functions evaluated at the output x.
+c
+c       ftol is a nonnegative input variable. termination
+c         occurs when both the actual and predicted relative
+c         reductions in the sum of squares are at most ftol.
+c         therefore, ftol measures the relative error desired
+c         in the sum of squares.
+c
+c       xtol is a nonnegative input variable. termination
+c         occurs when the relative error between two consecutive
+c         iterates is at most xtol. therefore, xtol measures the
+c         relative error desired in the approximate solution.
+c
+c       gtol is a nonnegative input variable. termination
+c         occurs when the cosine of the angle between fvec and
+c         any column of the jacobian is at most gtol in absolute
+c         value. therefore, gtol measures the orthogonality
+c         desired between the function vector and the columns
+c         of the jacobian.
+c
+c       maxfev is a positive integer input variable. termination
+c         occurs when the number of calls to fcn is at least
+c         maxfev by the end of an iteration.
+c
+c       epsfcn is an input variable used in determining a suitable
+c         step length for the forward-difference approximation. this
+c         approximation assumes that the relative errors in the
+c         functions are of the order of epsfcn. if epsfcn is less
+c         than the machine precision, it is assumed that the relative
+c         errors in the functions are of the order of the machine
+c         precision.
+c
+c       diag is an array of length n. if mode = 1 (see
+c         below), diag is internally set. if mode = 2, diag
+c         must contain positive entries that serve as
+c         multiplicative scale factors for the variables.
+c
+c       mode is an integer input variable. if mode = 1, the
+c         variables will be scaled internally. if mode = 2,
+c         the scaling is specified by the input diag. other
+c         values of mode are equivalent to mode = 1.
+c
+c       factor is a positive input variable used in determining the
+c         initial step bound. this bound is set to the product of
+c         factor and the euclidean norm of diag*x if nonzero, or else
+c         to factor itself. in most cases factor should lie in the
+c         interval (.1,100.). 100. is a generally recommended value.
+c
+c       nprint is an integer input variable that enables controlled
+c         printing of iterates if it is positive. in this case,
+c         fcn is called with iflag = 0 at the beginning of the first
+c         iteration and every nprint iterations thereafter and
+c         immediately prior to return, with x and fvec available
+c         for printing. if nprint is not positive, no special calls
+c         of fcn with iflag = 0 are made.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0  improper input parameters.
+c
+c         info = 1  both actual and predicted relative reductions
+c                   in the sum of squares are at most ftol.
+c
+c         info = 2  relative error between two consecutive iterates
+c                   is at most xtol.
+c
+c         info = 3  conditions for info = 1 and info = 2 both hold.
+c
+c         info = 4  the cosine of the angle between fvec and any
+c                   column of the jacobian is at most gtol in
+c                   absolute value.
+c
+c         info = 5  number of calls to fcn has reached or
+c                   exceeded maxfev.
+c
+c         info = 6  ftol is too small. no further reduction in
+c                   the sum of squares is possible.
+c
+c         info = 7  xtol is too small. no further improvement in
+c                   the approximate solution x is possible.
+c
+c         info = 8  gtol is too small. fvec is orthogonal to the
+c                   columns of the jacobian to machine precision.
+c
+c       nfev is an integer output variable set to the number of
+c         calls to fcn.
+c
+c       fjac is an output m by n array. the upper n by n submatrix
+c         of fjac contains an upper triangular matrix r with
+c         diagonal elements of nonincreasing magnitude such that
+c
+c                t     t           t
+c               p *(jac *jac)*p = r *r,
+c
+c         where p is a permutation matrix and jac is the final
+c         calculated jacobian. column j of p is column ipvt(j)
+c         (see below) of the identity matrix. the lower trapezoidal
+c         part of fjac contains information generated during
+c         the computation of r.
+c
+c       ldfjac is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array fjac.
+c
+c       ipvt is an integer output array of length n. ipvt
+c         defines a permutation matrix p such that jac*p = q*r,
+c         where jac is the final calculated jacobian, q is
+c         orthogonal (not stored), and r is upper triangular
+c         with diagonal elements of nonincreasing magnitude.
+c         column j of p is column ipvt(j) of the identity matrix.
+c
+c       qtf is an output array of length n which contains
+c         the first n elements of the vector (q transpose)*fvec.
+c
+c       wa1, wa2, and wa3 are work arrays of length n.
+c
+c       wa4 is a work array of length m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,fdjac2,lmpar,qrfac
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iflag,iter,j,l
+      double precision actred,delta,dirder,epsmch,fnorm,fnorm1,gnorm,
+     *                 one,par,pnorm,prered,p1,p5,p25,p75,p0001,ratio,
+     *                 sum,temp,temp1,temp2,xnorm,zero
+      double precision dpmpar,enorm
+      data one,p1,p5,p25,p75,p0001,zero
+     *     /1.0d0,1.0d-1,5.0d-1,2.5d-1,7.5d-1,1.0d-4,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      info = 0
+      iflag = 0
+      nfev = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. m
+     *    .or. ftol .lt. zero .or. xtol .lt. zero .or. gtol .lt. zero
+     *    .or. maxfev .le. 0 .or. factor .le. zero) go to 300
+      if (mode .ne. 2) go to 20
+      do 10 j = 1, n
+         if (diag(j) .le. zero) go to 300
+   10    continue
+   20 continue
+c
+c     evaluate the function at the starting point
+c     and calculate its norm.
+c
+      iflag = 1
+      call fcn(m,n,x,fvec,iflag)
+      nfev = 1
+      if (iflag .lt. 0) go to 300
+      fnorm = enorm(m,fvec)
+c
+c     initialize levenberg-marquardt parameter and iteration counter.
+c
+      par = zero
+      iter = 1
+c
+c     beginning of the outer loop.
+c
+   30 continue
+c
+c        calculate the jacobian matrix.
+c
+         iflag = 2
+         call fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa4)
+         nfev = nfev + n
+         if (iflag .lt. 0) go to 300
+c
+c        if requested, call fcn to enable printing of iterates.
+c
+         if (nprint .le. 0) go to 40
+         iflag = 0
+         if (mod(iter-1,nprint) .eq. 0) call fcn(m,n,x,fvec,iflag)
+         if (iflag .lt. 0) go to 300
+   40    continue
+c
+c        compute the qr factorization of the jacobian.
+c
+         call qrfac(m,n,fjac,ldfjac,.true.,ipvt,n,wa1,wa2,wa3)
+c
+c        on the first iteration and if mode is 1, scale according
+c        to the norms of the columns of the initial jacobian.
+c
+         if (iter .ne. 1) go to 80
+         if (mode .eq. 2) go to 60
+         do 50 j = 1, n
+            diag(j) = wa2(j)
+            if (wa2(j) .eq. zero) diag(j) = one
+   50       continue
+   60    continue
+c
+c        on the first iteration, calculate the norm of the scaled x
+c        and initialize the step bound delta.
+c
+         do 70 j = 1, n
+            wa3(j) = diag(j)*x(j)
+   70       continue
+         xnorm = enorm(n,wa3)
+         delta = factor*xnorm
+         if (delta .eq. zero) delta = factor
+   80    continue
+c
+c        form (q transpose)*fvec and store the first n components in
+c        qtf.
+c
+         do 90 i = 1, m
+            wa4(i) = fvec(i)
+   90       continue
+         do 130 j = 1, n
+            if (fjac(j,j) .eq. zero) go to 120
+            sum = zero
+            do 100 i = j, m
+               sum = sum + fjac(i,j)*wa4(i)
+  100          continue
+            temp = -sum/fjac(j,j)
+            do 110 i = j, m
+               wa4(i) = wa4(i) + fjac(i,j)*temp
+  110          continue
+  120       continue
+            fjac(j,j) = wa1(j)
+            qtf(j) = wa4(j)
+  130       continue
+c
+c        compute the norm of the scaled gradient.
+c
+         gnorm = zero
+         if (fnorm .eq. zero) go to 170
+         do 160 j = 1, n
+            l = ipvt(j)
+            if (wa2(l) .eq. zero) go to 150
+            sum = zero
+            do 140 i = 1, j
+               sum = sum + fjac(i,j)*(qtf(i)/fnorm)
+  140          continue
+            gnorm = dmax1(gnorm,dabs(sum/wa2(l)))
+  150       continue
+  160       continue
+  170    continue
+c
+c        test for convergence of the gradient norm.
+c
+         if (gnorm .le. gtol) info = 4
+         if (info .ne. 0) go to 300
+c
+c        rescale if necessary.
+c
+         if (mode .eq. 2) go to 190
+         do 180 j = 1, n
+            diag(j) = dmax1(diag(j),wa2(j))
+  180       continue
+  190    continue
+c
+c        beginning of the inner loop.
+c
+  200    continue
+c
+c           determine the levenberg-marquardt parameter.
+c
+            call lmpar(n,fjac,ldfjac,ipvt,diag,qtf,delta,par,wa1,wa2,
+     *                 wa3,wa4)
+c
+c           store the direction p and x + p. calculate the norm of p.
+c
+            do 210 j = 1, n
+               wa1(j) = -wa1(j)
+               wa2(j) = x(j) + wa1(j)
+               wa3(j) = diag(j)*wa1(j)
+  210          continue
+            pnorm = enorm(n,wa3)
+c
+c           on the first iteration, adjust the initial step bound.
+c
+            if (iter .eq. 1) delta = dmin1(delta,pnorm)
+c
+c           evaluate the function at x + p and calculate its norm.
+c
+            iflag = 1
+            call fcn(m,n,wa2,wa4,iflag)
+            nfev = nfev + 1
+            if (iflag .lt. 0) go to 300
+            fnorm1 = enorm(m,wa4)
+c
+c           compute the scaled actual reduction.
+c
+            actred = -one
+            if (p1*fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2
+c
+c           compute the scaled predicted reduction and
+c           the scaled directional derivative.
+c
+            do 230 j = 1, n
+               wa3(j) = zero
+               l = ipvt(j)
+               temp = wa1(l)
+               do 220 i = 1, j
+                  wa3(i) = wa3(i) + fjac(i,j)*temp
+  220             continue
+  230          continue
+            temp1 = enorm(n,wa3)/fnorm
+            temp2 = (dsqrt(par)*pnorm)/fnorm
+            prered = temp1**2 + temp2**2/p5
+            dirder = -(temp1**2 + temp2**2)
+c
+c           compute the ratio of the actual to the predicted
+c           reduction.
+c
+            ratio = zero
+            if (prered .ne. zero) ratio = actred/prered
+c
+c           update the step bound.
+c
+            if (ratio .gt. p25) go to 240
+               if (actred .ge. zero) temp = p5
+               if (actred .lt. zero)
+     *            temp = p5*dirder/(dirder + p5*actred)
+               if (p1*fnorm1 .ge. fnorm .or. temp .lt. p1) temp = p1
+               delta = temp*dmin1(delta,pnorm/p1)
+               par = par/temp
+               go to 260
+  240       continue
+               if (par .ne. zero .and. ratio .lt. p75) go to 250
+               delta = pnorm/p5
+               par = p5*par
+  250          continue
+  260       continue
+c
+c           test for successful iteration.
+c
+            if (ratio .lt. p0001) go to 290
+c
+c           successful iteration. update x, fvec, and their norms.
+c
+            do 270 j = 1, n
+               x(j) = wa2(j)
+               wa2(j) = diag(j)*x(j)
+  270          continue
+            do 280 i = 1, m
+               fvec(i) = wa4(i)
+  280          continue
+            xnorm = enorm(n,wa2)
+            fnorm = fnorm1
+            iter = iter + 1
+  290       continue
+c
+c           tests for convergence.
+c
+            if (dabs(actred) .le. ftol .and. prered .le. ftol
+     *          .and. p5*ratio .le. one) info = 1
+            if (delta .le. xtol*xnorm) info = 2
+            if (dabs(actred) .le. ftol .and. prered .le. ftol
+     *          .and. p5*ratio .le. one .and. info .eq. 2) info = 3
+            if (info .ne. 0) go to 300
+c
+c           tests for termination and stringent tolerances.
+c
+            if (nfev .ge. maxfev) info = 5
+            if (dabs(actred) .le. epsmch .and. prered .le. epsmch
+     *          .and. p5*ratio .le. one) info = 6
+            if (delta .le. epsmch*xnorm) info = 7
+            if (gnorm .le. epsmch) info = 8
+            if (info .ne. 0) go to 300
+c
+c           end of the inner loop. repeat if iteration unsuccessful.
+c
+            if (ratio .lt. p0001) go to 200
+c
+c        end of the outer loop.
+c
+         go to 30
+  300 continue
+c
+c     termination, either normal or user imposed.
+c
+      if (iflag .lt. 0) info = iflag
+      iflag = 0
+      if (nprint .gt. 0) call fcn(m,n,x,fvec,iflag)
+      return
+c
+c     last card of subroutine lmdif.
+c
+      end
diff --git a/fortran/lmdif1.f b/fortran/lmdif1.f
new file mode 100644
index 0000000..70f8aae
--- /dev/null
+++ b/fortran/lmdif1.f
@@ -0,0 +1,135 @@
+      subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa)
+      integer m,n,info,lwa
+      integer iwa(n)
+      double precision tol
+      double precision x(n),fvec(m),wa(lwa)
+      external fcn
+c     **********
+c
+c     subroutine lmdif1
+c
+c     the purpose of lmdif1 is to minimize the sum of the squares of
+c     m nonlinear functions in n variables by a modification of the
+c     levenberg-marquardt algorithm. this is done by using the more
+c     general least-squares solver lmdif. the user must provide a
+c     subroutine which calculates the functions. the jacobian is
+c     then calculated by a forward-difference approximation.
+c
+c     the subroutine statement is
+c
+c       subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions. fcn must be declared
+c         in an external statement in the user calling
+c         program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,iflag)
+c         integer m,n,iflag
+c         double precision x(n),fvec(m)
+c         ----------
+c         calculate the functions at x and
+c         return this vector in fvec.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of lmdif1.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length m which contains
+c         the functions evaluated at the output x.
+c
+c       tol is a nonnegative input variable. termination occurs
+c         when the algorithm estimates either that the relative
+c         error in the sum of squares is at most tol or that
+c         the relative error between x and the solution is at
+c         most tol.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0  improper input parameters.
+c
+c         info = 1  algorithm estimates that the relative error
+c                   in the sum of squares is at most tol.
+c
+c         info = 2  algorithm estimates that the relative error
+c                   between x and the solution is at most tol.
+c
+c         info = 3  conditions for info = 1 and info = 2 both hold.
+c
+c         info = 4  fvec is orthogonal to the columns of the
+c                   jacobian to machine precision.
+c
+c         info = 5  number of calls to fcn has reached or
+c                   exceeded 200*(n+1).
+c
+c         info = 6  tol is too small. no further reduction in
+c                   the sum of squares is possible.
+c
+c         info = 7  tol is too small. no further improvement in
+c                   the approximate solution x is possible.
+c
+c       iwa is an integer work array of length n.
+c
+c       wa is a work array of length lwa.
+c
+c       lwa is a positive integer input variable not less than
+c         m*n+5*n+m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... lmdif
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer maxfev,mode,mp5n,nfev,nprint
+      double precision epsfcn,factor,ftol,gtol,xtol,zero
+      data factor,zero /1.0d2,0.0d0/
+      info = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. m .lt. n .or. tol .lt. zero
+     *    .or. lwa .lt. m*n + 5*n + m) go to 10
+c
+c     call lmdif.
+c
+      maxfev = 200*(n + 1)
+      ftol = tol
+      xtol = tol
+      gtol = zero
+      epsfcn = zero
+      mode = 1
+      nprint = 0
+      mp5n = m + 5*n
+      call lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,wa(1),
+     *           mode,factor,nprint,info,nfev,wa(mp5n+1),m,iwa,
+     *           wa(n+1),wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1))
+      if (info .eq. 8) info = 4
+   10 continue
+      return
+c
+c     last card of subroutine lmdif1.
+c
+      end
diff --git a/fortran/lmpar.f b/fortran/lmpar.f
new file mode 100644
index 0000000..26c422a
--- /dev/null
+++ b/fortran/lmpar.f
@@ -0,0 +1,264 @@
+      subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1,
+     *                 wa2)
+      integer n,ldr
+      integer ipvt(n)
+      double precision delta,par
+      double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa1(n),
+     *                 wa2(n)
+c     **********
+c
+c     subroutine lmpar
+c
+c     given an m by n matrix a, an n by n nonsingular diagonal
+c     matrix d, an m-vector b, and a positive number delta,
+c     the problem is to determine a value for the parameter
+c     par such that if x solves the system
+c
+c           a*x = b ,     sqrt(par)*d*x = 0 ,
+c
+c     in the least squares sense, and dxnorm is the euclidean
+c     norm of d*x, then either par is zero and
+c
+c           (dxnorm-delta) .le. 0.1*delta ,
+c
+c     or par is positive and
+c
+c           abs(dxnorm-delta) .le. 0.1*delta .
+c
+c     this subroutine completes the solution of the problem
+c     if it is provided with the necessary information from the
+c     qr factorization, with column pivoting, of a. that is, if
+c     a*p = q*r, where p is a permutation matrix, q has orthogonal
+c     columns, and r is an upper triangular matrix with diagonal
+c     elements of nonincreasing magnitude, then lmpar expects
+c     the full upper triangle of r, the permutation matrix p,
+c     and the first n components of (q transpose)*b. on output
+c     lmpar also provides an upper triangular matrix s such that
+c
+c            t   t                   t
+c           p *(a *a + par*d*d)*p = s *s .
+c
+c     s is employed within lmpar and may be of separate interest.
+c
+c     only a few iterations are generally needed for convergence
+c     of the algorithm. if, however, the limit of 10 iterations
+c     is reached, then the output par will contain the best
+c     value obtained so far.
+c
+c     the subroutine statement is
+c
+c       subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,
+c                        wa1,wa2)
+c
+c     where
+c
+c       n is a positive integer input variable set to the order of r.
+c
+c       r is an n by n array. on input the full upper triangle
+c         must contain the full upper triangle of the matrix r.
+c         on output the full upper triangle is unaltered, and the
+c         strict lower triangle contains the strict upper triangle
+c         (transposed) of the upper triangular matrix s.
+c
+c       ldr is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array r.
+c
+c       ipvt is an integer input array of length n which defines the
+c         permutation matrix p such that a*p = q*r. column j of p
+c         is column ipvt(j) of the identity matrix.
+c
+c       diag is an input array of length n which must contain the
+c         diagonal elements of the matrix d.
+c
+c       qtb is an input array of length n which must contain the first
+c         n elements of the vector (q transpose)*b.
+c
+c       delta is a positive input variable which specifies an upper
+c         bound on the euclidean norm of d*x.
+c
+c       par is a nonnegative variable. on input par contains an
+c         initial estimate of the levenberg-marquardt parameter.
+c         on output par contains the final estimate.
+c
+c       x is an output array of length n which contains the least
+c         squares solution of the system a*x = b, sqrt(par)*d*x = 0,
+c         for the output par.
+c
+c       sdiag is an output array of length n which contains the
+c         diagonal elements of the upper triangular matrix s.
+c
+c       wa1 and wa2 are work arrays of length n.
+c
+c     subprograms called
+c
+c       minpack-supplied ... dpmpar,enorm,qrsolv
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,iter,j,jm1,jp1,k,l,nsing
+      double precision dxnorm,dwarf,fp,gnorm,parc,parl,paru,p1,p001,
+     *                 sum,temp,zero
+      double precision dpmpar,enorm
+      data p1,p001,zero /1.0d-1,1.0d-3,0.0d0/
+c
+c     dwarf is the smallest positive magnitude.
+c
+      dwarf = dpmpar(2)
+c
+c     compute and store in x the gauss-newton direction. if the
+c     jacobian is rank-deficient, obtain a least squares solution.
+c
+      nsing = n
+      do 10 j = 1, n
+         wa1(j) = qtb(j)
+         if (r(j,j) .eq. zero .and. nsing .eq. n) nsing = j - 1
+         if (nsing .lt. n) wa1(j) = zero
+   10    continue
+      if (nsing .lt. 1) go to 50
+      do 40 k = 1, nsing
+         j = nsing - k + 1
+         wa1(j) = wa1(j)/r(j,j)
+         temp = wa1(j)
+         jm1 = j - 1
+         if (jm1 .lt. 1) go to 30
+         do 20 i = 1, jm1
+            wa1(i) = wa1(i) - r(i,j)*temp
+   20       continue
+   30    continue
+   40    continue
+   50 continue
+      do 60 j = 1, n
+         l = ipvt(j)
+         x(l) = wa1(j)
+   60    continue
+c
+c     initialize the iteration counter.
+c     evaluate the function at the origin, and test
+c     for acceptance of the gauss-newton direction.
+c
+      iter = 0
+      do 70 j = 1, n
+         wa2(j) = diag(j)*x(j)
+   70    continue
+      dxnorm = enorm(n,wa2)
+      fp = dxnorm - delta
+      if (fp .le. p1*delta) go to 220
+c
+c     if the jacobian is not rank deficient, the newton
+c     step provides a lower bound, parl, for the zero of
+c     the function. otherwise set this bound to zero.
+c
+      parl = zero
+      if (nsing .lt. n) go to 120
+      do 80 j = 1, n
+         l = ipvt(j)
+         wa1(j) = diag(l)*(wa2(l)/dxnorm)
+   80    continue
+      do 110 j = 1, n
+         sum = zero
+         jm1 = j - 1
+         if (jm1 .lt. 1) go to 100
+         do 90 i = 1, jm1
+            sum = sum + r(i,j)*wa1(i)
+   90       continue
+  100    continue
+         wa1(j) = (wa1(j) - sum)/r(j,j)
+  110    continue
+      temp = enorm(n,wa1)
+      parl = ((fp/delta)/temp)/temp
+  120 continue
+c
+c     calculate an upper bound, paru, for the zero of the function.
+c
+      do 140 j = 1, n
+         sum = zero
+         do 130 i = 1, j
+            sum = sum + r(i,j)*qtb(i)
+  130       continue
+         l = ipvt(j)
+         wa1(j) = sum/diag(l)
+  140    continue
+      gnorm = enorm(n,wa1)
+      paru = gnorm/delta
+      if (paru .eq. zero) paru = dwarf/dmin1(delta,p1)
+c
+c     if the input par lies outside of the interval (parl,paru),
+c     set par to the closer endpoint.
+c
+      par = dmax1(par,parl)
+      par = dmin1(par,paru)
+      if (par .eq. zero) par = gnorm/dxnorm
+c
+c     beginning of an iteration.
+c
+  150 continue
+         iter = iter + 1
+c
+c        evaluate the function at the current value of par.
+c
+         if (par .eq. zero) par = dmax1(dwarf,p001*paru)
+         temp = dsqrt(par)
+         do 160 j = 1, n
+            wa1(j) = temp*diag(j)
+  160       continue
+         call qrsolv(n,r,ldr,ipvt,wa1,qtb,x,sdiag,wa2)
+         do 170 j = 1, n
+            wa2(j) = diag(j)*x(j)
+  170       continue
+         dxnorm = enorm(n,wa2)
+         temp = fp
+         fp = dxnorm - delta
+c
+c        if the function is small enough, accept the current value
+c        of par. also test for the exceptional cases where parl
+c        is zero or the number of iterations has reached 10.
+c
+         if (dabs(fp) .le. p1*delta
+     *       .or. parl .eq. zero .and. fp .le. temp
+     *            .and. temp .lt. zero .or. iter .eq. 10) go to 220
+c
+c        compute the newton correction.
+c
+         do 180 j = 1, n
+            l = ipvt(j)
+            wa1(j) = diag(l)*(wa2(l)/dxnorm)
+  180       continue
+         do 210 j = 1, n
+            wa1(j) = wa1(j)/sdiag(j)
+            temp = wa1(j)
+            jp1 = j + 1
+            if (n .lt. jp1) go to 200
+            do 190 i = jp1, n
+               wa1(i) = wa1(i) - r(i,j)*temp
+  190          continue
+  200       continue
+  210       continue
+         temp = enorm(n,wa1)
+         parc = ((fp/delta)/temp)/temp
+c
+c        depending on the sign of the function, update parl or paru.
+c
+         if (fp .gt. zero) parl = dmax1(parl,par)
+         if (fp .lt. zero) paru = dmin1(paru,par)
+c
+c        compute an improved estimate for par.
+c
+         par = dmax1(parl,par+parc)
+c
+c        end of an iteration.
+c
+         go to 150
+  220 continue
+c
+c     termination.
+c
+      if (iter .eq. 0) par = zero
+      return
+c
+c     last card of subroutine lmpar.
+c
+      end
diff --git a/fortran/lmstr.f b/fortran/lmstr.f
new file mode 100644
index 0000000..d9a7893
--- /dev/null
+++ b/fortran/lmstr.f
@@ -0,0 +1,466 @@
+      subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
+     *                 maxfev,diag,mode,factor,nprint,info,nfev,njev,
+     *                 ipvt,qtf,wa1,wa2,wa3,wa4)
+      integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev
+      integer ipvt(n)
+      logical sing
+      double precision ftol,xtol,gtol,factor
+      double precision x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n),
+     *                 wa1(n),wa2(n),wa3(n),wa4(m)
+c     **********
+c
+c     subroutine lmstr
+c
+c     the purpose of lmstr is to minimize the sum of the squares of
+c     m nonlinear functions in n variables by a modification of
+c     the levenberg-marquardt algorithm which uses minimal storage.
+c     the user must provide a subroutine which calculates the
+c     functions and the rows of the jacobian.
+c
+c     the subroutine statement is
+c
+c       subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
+c                        maxfev,diag,mode,factor,nprint,info,nfev,
+c                        njev,ipvt,qtf,wa1,wa2,wa3,wa4)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions and the rows of the jacobian.
+c         fcn must be declared in an external statement in the
+c         user calling program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,fjrow,iflag)
+c         integer m,n,iflag
+c         double precision x(n),fvec(m),fjrow(n)
+c         ----------
+c         if iflag = 1 calculate the functions at x and
+c         return this vector in fvec.
+c         if iflag = i calculate the (i-1)-st row of the
+c         jacobian at x and return this vector in fjrow.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of lmstr.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length m which contains
+c         the functions evaluated at the output x.
+c
+c       fjac is an output n by n array. the upper triangle of fjac
+c         contains an upper triangular matrix r such that
+c
+c                t     t           t
+c               p *(jac *jac)*p = r *r,
+c
+c         where p is a permutation matrix and jac is the final
+c         calculated jacobian. column j of p is column ipvt(j)
+c         (see below) of the identity matrix. the lower triangular
+c         part of fjac contains information generated during
+c         the computation of r.
+c
+c       ldfjac is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       ftol is a nonnegative input variable. termination
+c         occurs when both the actual and predicted relative
+c         reductions in the sum of squares are at most ftol.
+c         therefore, ftol measures the relative error desired
+c         in the sum of squares.
+c
+c       xtol is a nonnegative input variable. termination
+c         occurs when the relative error between two consecutive
+c         iterates is at most xtol. therefore, xtol measures the
+c         relative error desired in the approximate solution.
+c
+c       gtol is a nonnegative input variable. termination
+c         occurs when the cosine of the angle between fvec and
+c         any column of the jacobian is at most gtol in absolute
+c         value. therefore, gtol measures the orthogonality
+c         desired between the function vector and the columns
+c         of the jacobian.
+c
+c       maxfev is a positive integer input variable. termination
+c         occurs when the number of calls to fcn with iflag = 1
+c         has reached maxfev.
+c
+c       diag is an array of length n. if mode = 1 (see
+c         below), diag is internally set. if mode = 2, diag
+c         must contain positive entries that serve as
+c         multiplicative scale factors for the variables.
+c
+c       mode is an integer input variable. if mode = 1, the
+c         variables will be scaled internally. if mode = 2,
+c         the scaling is specified by the input diag. other
+c         values of mode are equivalent to mode = 1.
+c
+c       factor is a positive input variable used in determining the
+c         initial step bound. this bound is set to the product of
+c         factor and the euclidean norm of diag*x if nonzero, or else
+c         to factor itself. in most cases factor should lie in the
+c         interval (.1,100.). 100. is a generally recommended value.
+c
+c       nprint is an integer input variable that enables controlled
+c         printing of iterates if it is positive. in this case,
+c         fcn is called with iflag = 0 at the beginning of the first
+c         iteration and every nprint iterations thereafter and
+c         immediately prior to return, with x and fvec available
+c         for printing. if nprint is not positive, no special calls
+c         of fcn with iflag = 0 are made.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0  improper input parameters.
+c
+c         info = 1  both actual and predicted relative reductions
+c                   in the sum of squares are at most ftol.
+c
+c         info = 2  relative error between two consecutive iterates
+c                   is at most xtol.
+c
+c         info = 3  conditions for info = 1 and info = 2 both hold.
+c
+c         info = 4  the cosine of the angle between fvec and any
+c                   column of the jacobian is at most gtol in
+c                   absolute value.
+c
+c         info = 5  number of calls to fcn with iflag = 1 has
+c                   reached maxfev.
+c
+c         info = 6  ftol is too small. no further reduction in
+c                   the sum of squares is possible.
+c
+c         info = 7  xtol is too small. no further improvement in
+c                   the approximate solution x is possible.
+c
+c         info = 8  gtol is too small. fvec is orthogonal to the
+c                   columns of the jacobian to machine precision.
+c
+c       nfev is an integer output variable set to the number of
+c         calls to fcn with iflag = 1.
+c
+c       njev is an integer output variable set to the number of
+c         calls to fcn with iflag = 2.
+c
+c       ipvt is an integer output array of length n. ipvt
+c         defines a permutation matrix p such that jac*p = q*r,
+c         where jac is the final calculated jacobian, q is
+c         orthogonal (not stored), and r is upper triangular.
+c         column j of p is column ipvt(j) of the identity matrix.
+c
+c       qtf is an output array of length n which contains
+c         the first n elements of the vector (q transpose)*fvec.
+c
+c       wa1, wa2, and wa3 are work arrays of length n.
+c
+c       wa4 is a work array of length m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... dpmpar,enorm,lmpar,qrfac,rwupdt
+c
+c       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom,
+c     jorge j. more
+c
+c     **********
+      integer i,iflag,iter,j,l
+      double precision actred,delta,dirder,epsmch,fnorm,fnorm1,gnorm,
+     *                 one,par,pnorm,prered,p1,p5,p25,p75,p0001,ratio,
+     *                 sum,temp,temp1,temp2,xnorm,zero
+      double precision dpmpar,enorm
+      data one,p1,p5,p25,p75,p0001,zero
+     *     /1.0d0,1.0d-1,5.0d-1,2.5d-1,7.5d-1,1.0d-4,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+      info = 0
+      iflag = 0
+      nfev = 0
+      njev = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. n
+     *    .or. ftol .lt. zero .or. xtol .lt. zero .or. gtol .lt. zero
+     *    .or. maxfev .le. 0 .or. factor .le. zero) go to 340
+      if (mode .ne. 2) go to 20
+      do 10 j = 1, n
+         if (diag(j) .le. zero) go to 340
+   10    continue
+   20 continue
+c
+c     evaluate the function at the starting point
+c     and calculate its norm.
+c
+      iflag = 1
+      call fcn(m,n,x,fvec,wa3,iflag)
+      nfev = 1
+      if (iflag .lt. 0) go to 340
+      fnorm = enorm(m,fvec)
+c
+c     initialize levenberg-marquardt parameter and iteration counter.
+c
+      par = zero
+      iter = 1
+c
+c     beginning of the outer loop.
+c
+   30 continue
+c
+c        if requested, call fcn to enable printing of iterates.
+c
+         if (nprint .le. 0) go to 40
+         iflag = 0
+         if (mod(iter-1,nprint) .eq. 0) call fcn(m,n,x,fvec,wa3,iflag)
+         if (iflag .lt. 0) go to 340
+   40    continue
+c
+c        compute the qr factorization of the jacobian matrix
+c        calculated one row at a time, while simultaneously
+c        forming (q transpose)*fvec and storing the first
+c        n components in qtf.
+c
+         do 60 j = 1, n
+            qtf(j) = zero
+            do 50 i = 1, n
+               fjac(i,j) = zero
+   50          continue
+   60       continue
+         iflag = 2
+         do 70 i = 1, m
+            call fcn(m,n,x,fvec,wa3,iflag)
+            if (iflag .lt. 0) go to 340
+            temp = fvec(i)
+            call rwupdt(n,fjac,ldfjac,wa3,qtf,temp,wa1,wa2)
+            iflag = iflag + 1
+   70       continue
+         njev = njev + 1
+c
+c        if the jacobian is rank deficient, call qrfac to
+c        reorder its columns and update the components of qtf.
+c
+         sing = .false.
+         do 80 j = 1, n
+            if (fjac(j,j) .eq. zero) sing = .true.
+            ipvt(j) = j
+            wa2(j) = enorm(j,fjac(1,j))
+   80       continue
+         if (.not.sing) go to 130
+         call qrfac(n,n,fjac,ldfjac,.true.,ipvt,n,wa1,wa2,wa3)
+         do 120 j = 1, n
+            if (fjac(j,j) .eq. zero) go to 110
+            sum = zero
+            do 90 i = j, n
+               sum = sum + fjac(i,j)*qtf(i)
+   90          continue
+            temp = -sum/fjac(j,j)
+            do 100 i = j, n
+               qtf(i) = qtf(i) + fjac(i,j)*temp
+  100          continue
+  110       continue
+            fjac(j,j) = wa1(j)
+  120       continue
+  130    continue
+c
+c        on the first iteration and if mode is 1, scale according
+c        to the norms of the columns of the initial jacobian.
+c
+         if (iter .ne. 1) go to 170
+         if (mode .eq. 2) go to 150
+         do 140 j = 1, n
+            diag(j) = wa2(j)
+            if (wa2(j) .eq. zero) diag(j) = one
+  140       continue
+  150    continue
+c
+c        on the first iteration, calculate the norm of the scaled x
+c        and initialize the step bound delta.
+c
+         do 160 j = 1, n
+            wa3(j) = diag(j)*x(j)
+  160       continue
+         xnorm = enorm(n,wa3)
+         delta = factor*xnorm
+         if (delta .eq. zero) delta = factor
+  170    continue
+c
+c        compute the norm of the scaled gradient.
+c
+         gnorm = zero
+         if (fnorm .eq. zero) go to 210
+         do 200 j = 1, n
+            l = ipvt(j)
+            if (wa2(l) .eq. zero) go to 190
+            sum = zero
+            do 180 i = 1, j
+               sum = sum + fjac(i,j)*(qtf(i)/fnorm)
+  180          continue
+            gnorm = dmax1(gnorm,dabs(sum/wa2(l)))
+  190       continue
+  200       continue
+  210    continue
+c
+c        test for convergence of the gradient norm.
+c
+         if (gnorm .le. gtol) info = 4
+         if (info .ne. 0) go to 340
+c
+c        rescale if necessary.
+c
+         if (mode .eq. 2) go to 230
+         do 220 j = 1, n
+            diag(j) = dmax1(diag(j),wa2(j))
+  220       continue
+  230    continue
+c
+c        beginning of the inner loop.
+c
+  240    continue
+c
+c           determine the levenberg-marquardt parameter.
+c
+            call lmpar(n,fjac,ldfjac,ipvt,diag,qtf,delta,par,wa1,wa2,
+     *                 wa3,wa4)
+c
+c           store the direction p and x + p. calculate the norm of p.
+c
+            do 250 j = 1, n
+               wa1(j) = -wa1(j)
+               wa2(j) = x(j) + wa1(j)
+               wa3(j) = diag(j)*wa1(j)
+  250          continue
+            pnorm = enorm(n,wa3)
+c
+c           on the first iteration, adjust the initial step bound.
+c
+            if (iter .eq. 1) delta = dmin1(delta,pnorm)
+c
+c           evaluate the function at x + p and calculate its norm.
+c
+            iflag = 1
+            call fcn(m,n,wa2,wa4,wa3,iflag)
+            nfev = nfev + 1
+            if (iflag .lt. 0) go to 340
+            fnorm1 = enorm(m,wa4)
+c
+c           compute the scaled actual reduction.
+c
+            actred = -one
+            if (p1*fnorm1 .lt. fnorm) actred = one - (fnorm1/fnorm)**2
+c
+c           compute the scaled predicted reduction and
+c           the scaled directional derivative.
+c
+            do 270 j = 1, n
+               wa3(j) = zero
+               l = ipvt(j)
+               temp = wa1(l)
+               do 260 i = 1, j
+                  wa3(i) = wa3(i) + fjac(i,j)*temp
+  260             continue
+  270          continue
+            temp1 = enorm(n,wa3)/fnorm
+            temp2 = (dsqrt(par)*pnorm)/fnorm
+            prered = temp1**2 + temp2**2/p5
+            dirder = -(temp1**2 + temp2**2)
+c
+c           compute the ratio of the actual to the predicted
+c           reduction.
+c
+            ratio = zero
+            if (prered .ne. zero) ratio = actred/prered
+c
+c           update the step bound.
+c
+            if (ratio .gt. p25) go to 280
+               if (actred .ge. zero) temp = p5
+               if (actred .lt. zero)
+     *            temp = p5*dirder/(dirder + p5*actred)
+               if (p1*fnorm1 .ge. fnorm .or. temp .lt. p1) temp = p1
+               delta = temp*dmin1(delta,pnorm/p1)
+               par = par/temp
+               go to 300
+  280       continue
+               if (par .ne. zero .and. ratio .lt. p75) go to 290
+               delta = pnorm/p5
+               par = p5*par
+  290          continue
+  300       continue
+c
+c           test for successful iteration.
+c
+            if (ratio .lt. p0001) go to 330
+c
+c           successful iteration. update x, fvec, and their norms.
+c
+            do 310 j = 1, n
+               x(j) = wa2(j)
+               wa2(j) = diag(j)*x(j)
+  310          continue
+            do 320 i = 1, m
+               fvec(i) = wa4(i)
+  320          continue
+            xnorm = enorm(n,wa2)
+            fnorm = fnorm1
+            iter = iter + 1
+  330       continue
+c
+c           tests for convergence.
+c
+            if (dabs(actred) .le. ftol .and. prered .le. ftol
+     *          .and. p5*ratio .le. one) info = 1
+            if (delta .le. xtol*xnorm) info = 2
+            if (dabs(actred) .le. ftol .and. prered .le. ftol
+     *          .and. p5*ratio .le. one .and. info .eq. 2) info = 3
+            if (info .ne. 0) go to 340
+c
+c           tests for termination and stringent tolerances.
+c
+            if (nfev .ge. maxfev) info = 5
+            if (dabs(actred) .le. epsmch .and. prered .le. epsmch
+     *          .and. p5*ratio .le. one) info = 6
+            if (delta .le. epsmch*xnorm) info = 7
+            if (gnorm .le. epsmch) info = 8
+            if (info .ne. 0) go to 340
+c
+c           end of the inner loop. repeat if iteration unsuccessful.
+c
+            if (ratio .lt. p0001) go to 240
+c
+c        end of the outer loop.
+c
+         go to 30
+  340 continue
+c
+c     termination, either normal or user imposed.
+c
+      if (iflag .lt. 0) info = iflag
+      iflag = 0
+      if (nprint .gt. 0) call fcn(m,n,x,fvec,wa3,iflag)
+      return
+c
+c     last card of subroutine lmstr.
+c
+      end
diff --git a/fortran/lmstr1.f b/fortran/lmstr1.f
new file mode 100644
index 0000000..2fa8ee1
--- /dev/null
+++ b/fortran/lmstr1.f
@@ -0,0 +1,156 @@
+      subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,
+     *                  lwa)
+      integer m,n,ldfjac,info,lwa
+      integer ipvt(n)
+      double precision tol
+      double precision x(n),fvec(m),fjac(ldfjac,n),wa(lwa)
+      external fcn
+c     **********
+c
+c     subroutine lmstr1
+c
+c     the purpose of lmstr1 is to minimize the sum of the squares of
+c     m nonlinear functions in n variables by a modification of
+c     the levenberg-marquardt algorithm which uses minimal storage.
+c     this is done by using the more general least-squares solver
+c     lmstr. the user must provide a subroutine which calculates
+c     the functions and the rows of the jacobian.
+c
+c     the subroutine statement is
+c
+c       subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,
+c                         ipvt,wa,lwa)
+c
+c     where
+c
+c       fcn is the name of the user-supplied subroutine which
+c         calculates the functions and the rows of the jacobian.
+c         fcn must be declared in an external statement in the
+c         user calling program, and should be written as follows.
+c
+c         subroutine fcn(m,n,x,fvec,fjrow,iflag)
+c         integer m,n,iflag
+c         double precision x(n),fvec(m),fjrow(n)
+c         ----------
+c         if iflag = 1 calculate the functions at x and
+c         return this vector in fvec.
+c         if iflag = i calculate the (i-1)-st row of the
+c         jacobian at x and return this vector in fjrow.
+c         ----------
+c         return
+c         end
+c
+c         the value of iflag should not be changed by fcn unless
+c         the user wants to terminate execution of lmstr1.
+c         in this case set iflag to a negative integer.
+c
+c       m is a positive integer input variable set to the number
+c         of functions.
+c
+c       n is a positive integer input variable set to the number
+c         of variables. n must not exceed m.
+c
+c       x is an array of length n. on input x must contain
+c         an initial estimate of the solution vector. on output x
+c         contains the final estimate of the solution vector.
+c
+c       fvec is an output array of length m which contains
+c         the functions evaluated at the output x.
+c
+c       fjac is an output n by n array. the upper triangle of fjac
+c         contains an upper triangular matrix r such that
+c
+c                t     t           t
+c               p *(jac *jac)*p = r *r,
+c
+c         where p is a permutation matrix and jac is the final
+c         calculated jacobian. column j of p is column ipvt(j)
+c         (see below) of the identity matrix. the lower triangular
+c         part of fjac contains information generated during
+c         the computation of r.
+c
+c       ldfjac is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array fjac.
+c
+c       tol is a nonnegative input variable. termination occurs
+c         when the algorithm estimates either that the relative
+c         error in the sum of squares is at most tol or that
+c         the relative error between x and the solution is at
+c         most tol.
+c
+c       info is an integer output variable. if the user has
+c         terminated execution, info is set to the (negative)
+c         value of iflag. see description of fcn. otherwise,
+c         info is set as follows.
+c
+c         info = 0  improper input parameters.
+c
+c         info = 1  algorithm estimates that the relative error
+c                   in the sum of squares is at most tol.
+c
+c         info = 2  algorithm estimates that the relative error
+c                   between x and the solution is at most tol.
+c
+c         info = 3  conditions for info = 1 and info = 2 both hold.
+c
+c         info = 4  fvec is orthogonal to the columns of the
+c                   jacobian to machine precision.
+c
+c         info = 5  number of calls to fcn with iflag = 1 has
+c                   reached 100*(n+1).
+c
+c         info = 6  tol is too small. no further reduction in
+c                   the sum of squares is possible.
+c
+c         info = 7  tol is too small. no further improvement in
+c                   the approximate solution x is possible.
+c
+c       ipvt is an integer output array of length n. ipvt
+c         defines a permutation matrix p such that jac*p = q*r,
+c         where jac is the final calculated jacobian, q is
+c         orthogonal (not stored), and r is upper triangular.
+c         column j of p is column ipvt(j) of the identity matrix.
+c
+c       wa is a work array of length lwa.
+c
+c       lwa is a positive integer input variable not less than 5*n+m.
+c
+c     subprograms called
+c
+c       user-supplied ...... fcn
+c
+c       minpack-supplied ... lmstr
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom,
+c     jorge j. more
+c
+c     **********
+      integer maxfev,mode,nfev,njev,nprint
+      double precision factor,ftol,gtol,xtol,zero
+      data factor,zero /1.0d2,0.0d0/
+      info = 0
+c
+c     check the input parameters for errors.
+c
+      if (n .le. 0 .or. m .lt. n .or. ldfjac .lt. n .or. tol .lt. zero
+     *    .or. lwa .lt. 5*n + m) go to 10
+c
+c     call lmstr.
+c
+      maxfev = 100*(n + 1)
+      ftol = tol
+      xtol = tol
+      gtol = zero
+      mode = 1
+      nprint = 0
+      call lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,maxfev,
+     *           wa(1),mode,factor,nprint,info,nfev,njev,ipvt,wa(n+1),
+     *           wa(2*n+1),wa(3*n+1),wa(4*n+1),wa(5*n+1))
+      if (info .eq. 8) info = 4
+   10 continue
+      return
+c
+c     last card of subroutine lmstr1.
+c
+      end
diff --git a/fortran/minpack.f90 b/fortran/minpack.f90
new file mode 100644
index 0000000..59907d8
--- /dev/null
+++ b/fortran/minpack.f90
@@ -0,0 +1,450 @@
+
+module minpack
+
+! F90 interface to minpack
+
+  implicit none
+
+  ! set to .true. for debug prints
+  logical, parameter, private :: dbg = .true.
+
+  ! precision for double real
+  integer, parameter, private :: r8 = selected_real_kind(15)
+
+  interface
+
+     subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer, intent(in) :: m,n,ldfjac,mode
+       real(r8) :: x(n),fvec(m),fjac(ldfjac,n),xp(n),fvecp(m),err(m)
+     end subroutine chkder
+
+     subroutine covar(n,r,ldr,ipvt,tol,wa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer, intent(in) ::  n,ldr
+       integer::  ipvt(n)
+       real(r8) :: tol
+       real(r8) :: r(ldr,n),wa(n)
+     end subroutine covar
+
+     subroutine dmchar(ibeta,it,irnd,ngrd,machep,negep,iexp,minexp, &
+          maxexp,eps,epsneg,xmin,xmax)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: i,ibeta,iexp,irnd,it,iz,j,k,machep,maxexp,minexp, &
+            mx,negep,ngrd
+       real(r8) :: a,b,beta,betain,betam1,eps,epsneg,one,xmax, &
+            xmin,y,z,zero
+     end subroutine dmchar
+
+     subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,lr
+       real(r8) :: delta
+       real(r8) :: r(lr),diag(n),qtb(n),x(n),wa1(n),wa2(n)
+     end subroutine dogleg
+
+     function dpmpar(i)
+       integer, parameter :: r8 = selected_real_kind(15)
+       real(r8) :: dpmpar
+       integer, intent(in) :: i
+     end function dpmpar
+     
+     function enorm(n,x)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer, intent(in) :: n
+       real(r8) :: enorm,x(n)
+     end function enorm
+
+     subroutine errjac(n,x,fjac,ldfjac,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldfjac,nprob
+       real(r8) :: x(n),fjac(ldfjac,n)
+     end subroutine errjac
+
+     subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,wa1,wa2)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldfjac,iflag,ml,mu
+       real(r8) :: epsfcn
+       real(r8) :: x(n),fvec(n),fjac(ldfjac,n),wa1(n),wa2(n)
+       interface
+          subroutine fcn(n,x,fvec,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: n,iflag
+            real(r8) :: x(n),fvec(n)
+          end subroutine fcn
+       end interface
+     end subroutine fdjac1
+
+     subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldfjac,iflag
+       real(r8) :: epsfcn
+       real(r8) :: x(n),fvec(m),fjac(ldfjac,n),wa(m)
+       interface
+          subroutine fcn(m,n,x,fvec,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: m,n,iflag
+            real(r8) :: x(n),fvec(m)
+          end subroutine fcn
+       end interface
+     end subroutine fdjac2
+
+     subroutine grdfcn(n,x,g,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,nprob
+       real(r8) :: x(n),g(n)
+     end subroutine grdfcn
+
+     subroutine hesfcn(n,x,h,ldh,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldh,nprob
+       real(r8) :: x(n),h(ldh,n)
+     end subroutine hesfcn
+
+     subroutine initpt(n,x,nprob,factor)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,nprob
+       real(r8) :: factor
+       real(r8) :: x(n)
+     end subroutine initpt
+
+     subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag, &
+          mode,factor,nprint,info,nfev,fjac,ldfjac,r,lr, &
+          qtf,wa1,wa2,wa3,wa4)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,maxfev,ml,mu,mode,nprint,info,nfev,ldfjac,lr
+       real(r8) :: xtol,epsfcn,factor
+       real(r8) :: x(n),fvec(n),diag(n),fjac(ldfjac,n),r(lr), &
+            qtf(n),wa1(n),wa2(n),wa3(n),wa4(n)
+       interface
+          subroutine fcn(n,x,fvec,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: n,iflag
+            real(r8) :: x(n),fvec(n)
+          end subroutine fcn
+       end interface
+     end subroutine hybrd
+
+     subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,info,lwa
+       real(r8) :: tol
+       real(r8) :: x(n),fvec(n),wa(lwa)
+       interface
+          subroutine fcn(n,x,fvec,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: n,iflag
+            real(r8) :: x(n),fvec(n)
+          end subroutine fcn
+       end interface
+     end subroutine hybrd1
+
+     subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode, &
+          factor,nprint,info,nfev,njev,r,lr,qtf,wa1,wa2, &
+          wa3,wa4)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldfjac,maxfev,mode,nprint,info,nfev,njev,lr
+       real(r8) :: xtol,factor
+       real(r8) :: x(n),fvec(n),fjac(ldfjac,n),diag(n),r(lr), &
+            qtf(n),wa1(n),wa2(n),wa3(n),wa4(n)
+       interface
+          subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: n,ldfjac,iflag
+            real(r8) :: x(n),fvec(n),fjac(ldfjac,n)
+          end subroutine fcn
+       end interface
+     end subroutine hybrj
+
+     subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldfjac,info,lwa
+       real(r8) :: tol
+       real(r8) :: x(n),fvec(n),fjac(ldfjac,n),wa(lwa)
+       interface
+          subroutine fcn(n,x,fvec,fjac,ldfjac,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: n,ldfjac,iflag
+            real(r8) :: x(n),fvec(n),fjac(ldfjac,n)
+          end subroutine fcn
+       end interface
+     end subroutine hybrj1
+     
+     subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, &
+          maxfev,diag,mode,factor,nprint,info,nfev,njev, &
+          ipvt,qtf,wa1,wa2,wa3,wa4)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev
+       integer :: ipvt(n)
+       real(r8) :: ftol,xtol,gtol,factor
+       real(r8) :: x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n), &
+            wa1(n),wa2(n),wa3(n),wa4(m)
+       interface
+          subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: m,n,ldfjac,iflag
+            real(r8) :: x(n),fvec(m),fjac(ldfjac,n)
+          end subroutine fcn
+       end interface
+     end subroutine lmder
+
+     subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,lwa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldfjac,info,lwa
+       integer :: ipvt(n)
+       real(r8) :: tol
+       real(r8) :: x(n),fvec(m),fjac(ldfjac,n),wa(lwa)
+       interface
+          subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: m,n,ldfjac,iflag
+            real(r8) :: x(n),fvec(m),fjac(ldfjac,n)
+          end subroutine fcn
+       end interface
+     end subroutine lmder1
+ 
+     subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, &
+          diag,mode,factor,nprint,info,nfev,fjac,ldfjac, &
+          ipvt,qtf,wa1,wa2,wa3,wa4)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,maxfev,mode,nprint,info,nfev,ldfjac
+       integer :: ipvt(n)
+       real(r8) :: ftol,xtol,gtol,epsfcn,factor
+       real(r8) :: x(n),fvec(m),diag(n),fjac(ldfjac,n),qtf(n), &
+            wa1(n),wa2(n),wa3(n),wa4(m)
+       interface
+          subroutine fcn(m,n,x,fvec,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: m,n,iflag
+            real(r8) :: x(n),fvec(m)
+          end subroutine fcn
+       end interface
+     end subroutine lmdif
+
+     subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,info,lwa
+       integer :: iwa(n)
+       real(r8) :: tol
+       real(r8) :: x(n),fvec(m),wa(lwa)
+       interface
+          subroutine fcn(m,n,x,fvec,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: m,n,iflag
+            real(r8) :: x(n),fvec(m)
+          end subroutine fcn
+       end interface
+     end subroutine lmdif1
+     
+     subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1,wa2)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldr
+       integer :: ipvt(n)
+       real(r8) :: delta,par
+       real(r8) :: r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa1(n),wa2(n)
+     end subroutine lmpar
+
+     subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, &
+          maxfev,diag,mode,factor,nprint,info,nfev,njev, &
+          ipvt,qtf,wa1,wa2,wa3,wa4)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev
+       integer :: ipvt(n)
+       logical :: sing
+       real(r8) :: ftol,xtol,gtol,factor
+       real(r8) :: x(n),fvec(m),fjac(ldfjac,n),diag(n),qtf(n), &
+            wa1(n),wa2(n),wa3(n),wa4(m)
+       interface
+          subroutine fcn(m,n,x,fvec,fjrow,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer :: m,n,iflag
+            real(r8) :: x(n),fvec(m),fjrow(n)
+          end subroutine fcn
+       end interface
+     end subroutine lmstr
+
+     subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,lwa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldfjac,info,lwa
+       integer :: ipvt(n)
+       real(r8) :: tol
+       real(r8) :: x(n),fvec(m),fjac(ldfjac,n),wa(lwa)
+       interface
+          subroutine fcn(m,n,x,fvec,fjrow,iflag)
+            integer, parameter :: r8 = selected_real_kind(15)
+            integer m,n,iflag
+            real(r8) x(n),fvec(m),fjrow(n)
+          end subroutine fcn
+       end interface
+     end subroutine lmstr1
+
+     subroutine objfcn(n,x,f,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,nprob
+       real(r8) :: f
+       real(r8) :: x(n)
+     end subroutine objfcn
+
+     subroutine qform(m,n,q,ldq,wa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldq
+       real(r8) :: q(ldq,m),wa(m)
+     end subroutine qform
+
+     subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,lda,lipvt
+       integer :: ipvt(lipvt)
+       logical :: pivot
+       real(r8) :: a(lda,n),rdiag(n),acnorm(n),wa(n)
+     end subroutine qrfac
+
+     subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldr
+       integer :: ipvt(n)
+       real(r8) :: r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n)
+     end subroutine qrsolv
+
+     subroutine r1mpyq(m,n,a,lda,v,w)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,lda
+       real(r8) :: a(lda,n),v(n),w(n)
+     end subroutine r1mpyq
+
+     subroutine r1updt(m,n,s,ls,u,v,w,sing)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ls
+       logical :: sing
+       real(r8) :: s(ls),u(m),v(n),w(m)
+     end subroutine r1updt
+
+     subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldr
+       real(r8) :: alpha
+       real(r8) :: r(ldr,n),w(n),b(n),cos(n),sin(n)
+     end subroutine rwupdt
+
+     subroutine ssqfcn(m,n,x,fvec,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,nprob
+       real(r8) :: x(n),fvec(m)
+     end subroutine ssqfcn
+
+     subroutine ssqjac(m,n,x,fjac,ldfjac,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: m,n,ldfjac,nprob
+       real(r8) :: x(n),fjac(ldfjac,n)
+     end subroutine ssqjac
+
+     subroutine vecfcn(n,x,fvec,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,nprob
+       real(r8) :: x(n),fvec(n)
+     end subroutine vecfcn
+
+     subroutine vecjac(n,x,fjac,ldfjac,nprob)
+       integer, parameter :: r8 = selected_real_kind(15)
+       integer :: n,ldfjac,nprob
+       real(r8) :: x(n),fjac(ldfjac,n)
+     end subroutine vecjac
+
+  end interface
+
+
+contains
+
+  !----------------------------------------------------------------------
+  !
+  ! add-ons 
+  !
+  !----------------------------------------------------------------------
+
+    subroutine qrinv(m,n,a,a1,lda,diag)
+
+      ! compute inverse matrix in least-quare sense by the use
+      ! of the QR factorisation
+
+      ! implementation is reference, no effective, test for different
+      ! m and n are sparse
+      
+      implicit none
+
+      integer :: m,n,lda
+      real(r8) :: a(lda,n),a1(lda,n), diag(n)
+      real(r8) :: r(m,n), q(m,n), qtb(m,n)
+      integer :: i,ipvt(n)
+      real(r8) :: rdiag(n),acnorm(n),wa(n),x(n),b(n),sdiag(n)
+      character(len=10) :: fmt = '(xxf17.7)'
+
+      if(dbg) then
+         write(*,*) 'qrinv:'
+         write(fmt(2:3),'(i2.2)') n
+         write(*,fmt) a
+      endif
+
+      ! form the r matrix, r is upper trinagle (without diagonal)
+      ! of the factorized a, diagonal is presented in rdiag 
+
+      call qrfac(m,n,a,lda,.true.,ipvt,n,rdiag,acnorm,wa)
+      if(dbg) then
+         write(*,*) 'qrfac:'
+         write(*,fmt) a,rdiag,acnorm
+      end if
+
+      r = a
+      do i = 1, n
+         r(i,i) = rdiag(i)
+      end do
+
+      if(dbg) then
+         write(*,*) 'r:'
+         write(*,fmt) r
+      endif
+
+    ! form the q matrix 
+
+      call qform(m,n,a,lda,wa)
+
+      if(dbg) then 
+         write(*,*) 'qform:'
+         write(*,fmt) a,rdiag,acnorm
+         write(*,*) 'ipvt:'
+         write(*,*) ipvt
+      end if
+    
+      q = a
+      qtb = transpose(q)
+      do i = 1, n
+         b = 0
+         b(i) = 1.0
+         b = matmul(qtb,b)
+         call qrsolv(n,r,m,ipvt,diag,b,x,sdiag,wa)
+         a1(i,:) = x
+      enddo
+
+    end subroutine qrinv
+
+
+  !---------------------------------------------------------------------
+  !
+  ! Fortran 90 interfaces
+  !
+  !---------------------------------------------------------------------
+
+!    subroutine chkder_8(x,fvec,fjac,xp,fvecp,mode,err)
+!      integer, intent(in) :: mode
+!      real(r8) :: x(:),fvec(:),fjac(:,:),xp(:),fvecp(:),err(:)
+!      integer :: m,n,ldfjac
+!      
+!      m = size(fvec)
+!      n = size(x)
+!      ldfjac = size(fjac,1)
+!      
+!      call chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)
+!    end subroutine chkder_8
+
+  
+
+end module minpack
diff --git a/fortran/qform.f b/fortran/qform.f
new file mode 100644
index 0000000..087b247
--- /dev/null
+++ b/fortran/qform.f
@@ -0,0 +1,95 @@
+      subroutine qform(m,n,q,ldq,wa)
+      integer m,n,ldq
+      double precision q(ldq,m),wa(m)
+c     **********
+c
+c     subroutine qform
+c
+c     this subroutine proceeds from the computed qr factorization of
+c     an m by n matrix a to accumulate the m by m orthogonal matrix
+c     q from its factored form.
+c
+c     the subroutine statement is
+c
+c       subroutine qform(m,n,q,ldq,wa)
+c
+c     where
+c
+c       m is a positive integer input variable set to the number
+c         of rows of a and the order of q.
+c
+c       n is a positive integer input variable set to the number
+c         of columns of a.
+c
+c       q is an m by m array. on input the full lower trapezoid in
+c         the first min(m,n) columns of q contains the factored form.
+c         on output q has been accumulated into a square matrix.
+c
+c       ldq is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array q.
+c
+c       wa is a work array of length m.
+c
+c     subprograms called
+c
+c       fortran-supplied ... min0
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j,jm1,k,l,minmn,np1
+      double precision one,sum,temp,zero
+      data one,zero /1.0d0,0.0d0/
+c
+c     zero out upper triangle of q in the first min(m,n) columns.
+c
+      minmn = min0(m,n)
+      if (minmn .lt. 2) go to 30
+      do 20 j = 2, minmn
+         jm1 = j - 1
+         do 10 i = 1, jm1
+            q(i,j) = zero
+   10       continue
+   20    continue
+   30 continue
+c
+c     initialize remaining columns to those of the identity matrix.
+c
+      np1 = n + 1
+      if (m .lt. np1) go to 60
+      do 50 j = np1, m
+         do 40 i = 1, m
+            q(i,j) = zero
+   40       continue
+         q(j,j) = one
+   50    continue
+   60 continue
+c
+c     accumulate q from its factored form.
+c
+      do 120 l = 1, minmn
+         k = minmn - l + 1
+         do 70 i = k, m
+            wa(i) = q(i,k)
+            q(i,k) = zero
+   70       continue
+         q(k,k) = one
+         if (wa(k) .eq. zero) go to 110
+         do 100 j = k, m
+            sum = zero
+            do 80 i = k, m
+               sum = sum + q(i,j)*wa(i)
+   80          continue
+            temp = sum/wa(k)
+            do 90 i = k, m
+               q(i,j) = q(i,j) - temp*wa(i)
+   90          continue
+  100       continue
+  110    continue
+  120    continue
+      return
+c
+c     last card of subroutine qform.
+c
+      end
diff --git a/fortran/qrfac.f b/fortran/qrfac.f
new file mode 100644
index 0000000..cb68608
--- /dev/null
+++ b/fortran/qrfac.f
@@ -0,0 +1,164 @@
+      subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa)
+      integer m,n,lda,lipvt
+      integer ipvt(lipvt)
+      logical pivot
+      double precision a(lda,n),rdiag(n),acnorm(n),wa(n)
+c     **********
+c
+c     subroutine qrfac
+c
+c     this subroutine uses householder transformations with column
+c     pivoting (optional) to compute a qr factorization of the
+c     m by n matrix a. that is, qrfac determines an orthogonal
+c     matrix q, a permutation matrix p, and an upper trapezoidal
+c     matrix r with diagonal elements of nonincreasing magnitude,
+c     such that a*p = q*r. the householder transformation for
+c     column k, k = 1,2,...,min(m,n), is of the form
+c
+c                           t
+c           i - (1/u(k))*u*u
+c
+c     where u has zeros in the first k-1 positions. the form of
+c     this transformation and the method of pivoting first
+c     appeared in the corresponding linpack subroutine.
+c
+c     the subroutine statement is
+c
+c       subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa)
+c
+c     where
+c
+c       m is a positive integer input variable set to the number
+c         of rows of a.
+c
+c       n is a positive integer input variable set to the number
+c         of columns of a.
+c
+c       a is an m by n array. on input a contains the matrix for
+c         which the qr factorization is to be computed. on output
+c         the strict upper trapezoidal part of a contains the strict
+c         upper trapezoidal part of r, and the lower trapezoidal
+c         part of a contains a factored form of q (the non-trivial
+c         elements of the u vectors described above).
+c
+c       lda is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array a.
+c
+c       pivot is a logical input variable. if pivot is set true,
+c         then column pivoting is enforced. if pivot is set false,
+c         then no column pivoting is done.
+c
+c       ipvt is an integer output array of length lipvt. ipvt
+c         defines the permutation matrix p such that a*p = q*r.
+c         column j of p is column ipvt(j) of the identity matrix.
+c         if pivot is false, ipvt is not referenced.
+c
+c       lipvt is a positive integer input variable. if pivot is false,
+c         then lipvt may be as small as 1. if pivot is true, then
+c         lipvt must be at least n.
+c
+c       rdiag is an output array of length n which contains the
+c         diagonal elements of r.
+c
+c       acnorm is an output array of length n which contains the
+c         norms of the corresponding columns of the input matrix a.
+c         if this information is not needed, then acnorm can coincide
+c         with rdiag.
+c
+c       wa is a work array of length n. if pivot is false, then wa
+c         can coincide with rdiag.
+c
+c     subprograms called
+c
+c       minpack-supplied ... dpmpar,enorm
+c
+c       fortran-supplied ... dmax1,dsqrt,min0
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j,jp1,k,kmax,minmn
+      double precision ajnorm,epsmch,one,p05,sum,temp,zero
+      double precision dpmpar,enorm
+      data one,p05,zero /1.0d0,5.0d-2,0.0d0/
+c
+c     epsmch is the machine precision.
+c
+      epsmch = dpmpar(1)
+c
+c     compute the initial column norms and initialize several arrays.
+c
+      do 10 j = 1, n
+         acnorm(j) = enorm(m,a(1,j))
+         rdiag(j) = acnorm(j)
+         wa(j) = rdiag(j)
+         if (pivot) ipvt(j) = j
+   10    continue
+c
+c     reduce a to r with householder transformations.
+c
+      minmn = min0(m,n)
+      do 110 j = 1, minmn
+         if (.not.pivot) go to 40
+c
+c        bring the column of largest norm into the pivot position.
+c
+         kmax = j
+         do 20 k = j, n
+            if (rdiag(k) .gt. rdiag(kmax)) kmax = k
+   20       continue
+         if (kmax .eq. j) go to 40
+         do 30 i = 1, m
+            temp = a(i,j)
+            a(i,j) = a(i,kmax)
+            a(i,kmax) = temp
+   30       continue
+         rdiag(kmax) = rdiag(j)
+         wa(kmax) = wa(j)
+         k = ipvt(j)
+         ipvt(j) = ipvt(kmax)
+         ipvt(kmax) = k
+   40    continue
+c
+c        compute the householder transformation to reduce the
+c        j-th column of a to a multiple of the j-th unit vector.
+c
+         ajnorm = enorm(m-j+1,a(j,j))
+         if (ajnorm .eq. zero) go to 100
+         if (a(j,j) .lt. zero) ajnorm = -ajnorm
+         do 50 i = j, m
+            a(i,j) = a(i,j)/ajnorm
+   50       continue
+         a(j,j) = a(j,j) + one
+c
+c        apply the transformation to the remaining columns
+c        and update the norms.
+c
+         jp1 = j + 1
+         if (n .lt. jp1) go to 100
+         do 90 k = jp1, n
+            sum = zero
+            do 60 i = j, m
+               sum = sum + a(i,j)*a(i,k)
+   60          continue
+            temp = sum/a(j,j)
+            do 70 i = j, m
+               a(i,k) = a(i,k) - temp*a(i,j)
+   70          continue
+            if (.not.pivot .or. rdiag(k) .eq. zero) go to 80
+            temp = a(j,k)/rdiag(k)
+            rdiag(k) = rdiag(k)*dsqrt(dmax1(zero,one-temp**2))
+            if (p05*(rdiag(k)/wa(k))**2 .gt. epsmch) go to 80
+            rdiag(k) = enorm(m-j,a(jp1,k))
+            wa(k) = rdiag(k)
+   80       continue
+   90       continue
+  100    continue
+         rdiag(j) = -ajnorm
+  110    continue
+      return
+c
+c     last card of subroutine qrfac.
+c
+      end
diff --git a/fortran/qrsolv.f b/fortran/qrsolv.f
new file mode 100644
index 0000000..f48954b
--- /dev/null
+++ b/fortran/qrsolv.f
@@ -0,0 +1,193 @@
+      subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa)
+      integer n,ldr
+      integer ipvt(n)
+      double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n)
+c     **********
+c
+c     subroutine qrsolv
+c
+c     given an m by n matrix a, an n by n diagonal matrix d,
+c     and an m-vector b, the problem is to determine an x which
+c     solves the system
+c
+c           a*x = b ,     d*x = 0 ,
+c
+c     in the least squares sense.
+c
+c     this subroutine completes the solution of the problem
+c     if it is provided with the necessary information from the
+c     qr factorization, with column pivoting, of a. that is, if
+c     a*p = q*r, where p is a permutation matrix, q has orthogonal
+c     columns, and r is an upper triangular matrix with diagonal
+c     elements of nonincreasing magnitude, then qrsolv expects
+c     the full upper triangle of r, the permutation matrix p,
+c     and the first n components of (q transpose)*b. the system
+c     a*x = b, d*x = 0, is then equivalent to
+c
+c                  t       t
+c           r*z = q *b ,  p *d*p*z = 0 ,
+c
+c     where x = p*z. if this system does not have full rank,
+c     then a least squares solution is obtained. on output qrsolv
+c     also provides an upper triangular matrix s such that
+c
+c            t   t               t
+c           p *(a *a + d*d)*p = s *s .
+c
+c     s is computed within qrsolv and may be of separate interest.
+c
+c     the subroutine statement is
+c
+c       subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa)
+c
+c     where
+c
+c       n is a positive integer input variable set to the order of r.
+c
+c       r is an n by n array. on input the full upper triangle
+c         must contain the full upper triangle of the matrix r.
+c         on output the full upper triangle is unaltered, and the
+c         strict lower triangle contains the strict upper triangle
+c         (transposed) of the upper triangular matrix s.
+c
+c       ldr is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array r.
+c
+c       ipvt is an integer input array of length n which defines the
+c         permutation matrix p such that a*p = q*r. column j of p
+c         is column ipvt(j) of the identity matrix.
+c
+c       diag is an input array of length n which must contain the
+c         diagonal elements of the matrix d.
+c
+c       qtb is an input array of length n which must contain the first
+c         n elements of the vector (q transpose)*b.
+c
+c       x is an output array of length n which contains the least
+c         squares solution of the system a*x = b, d*x = 0.
+c
+c       sdiag is an output array of length n which contains the
+c         diagonal elements of the upper triangular matrix s.
+c
+c       wa is a work array of length n.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j,jp1,k,kp1,l,nsing
+      double precision cos,cotan,p5,p25,qtbpj,sin,sum,tan,temp,zero
+      data p5,p25,zero /5.0d-1,2.5d-1,0.0d0/
+c
+c     copy r and (q transpose)*b to preserve input and initialize s.
+c     in particular, save the diagonal elements of r in x.
+c
+      do 20 j = 1, n
+         do 10 i = j, n
+            r(i,j) = r(j,i)
+   10       continue
+         x(j) = r(j,j)
+         wa(j) = qtb(j)
+   20    continue
+c
+c     eliminate the diagonal matrix d using a givens rotation.
+c
+      do 100 j = 1, n
+c
+c        prepare the row of d to be eliminated, locating the
+c        diagonal element using p from the qr factorization.
+c
+         l = ipvt(j)
+         if (diag(l) .eq. zero) go to 90
+         do 30 k = j, n
+            sdiag(k) = zero
+   30       continue
+         sdiag(j) = diag(l)
+c
+c        the transformations to eliminate the row of d
+c        modify only a single element of (q transpose)*b
+c        beyond the first n, which is initially zero.
+c
+         qtbpj = zero
+         do 80 k = j, n
+c
+c           determine a givens rotation which eliminates the
+c           appropriate element in the current row of d.
+c
+            if (sdiag(k) .eq. zero) go to 70
+            if (dabs(r(k,k)) .ge. dabs(sdiag(k))) go to 40
+               cotan = r(k,k)/sdiag(k)
+               sin = p5/dsqrt(p25+p25*cotan**2)
+               cos = sin*cotan
+               go to 50
+   40       continue
+               tan = sdiag(k)/r(k,k)
+               cos = p5/dsqrt(p25+p25*tan**2)
+               sin = cos*tan
+   50       continue
+c
+c           compute the modified diagonal element of r and
+c           the modified element of ((q transpose)*b,0).
+c
+            r(k,k) = cos*r(k,k) + sin*sdiag(k)
+            temp = cos*wa(k) + sin*qtbpj
+            qtbpj = -sin*wa(k) + cos*qtbpj
+            wa(k) = temp
+c
+c           accumulate the tranformation in the row of s.
+c
+            kp1 = k + 1
+            if (n .lt. kp1) go to 70
+            do 60 i = kp1, n
+               temp = cos*r(i,k) + sin*sdiag(i)
+               sdiag(i) = -sin*r(i,k) + cos*sdiag(i)
+               r(i,k) = temp
+   60          continue
+   70       continue
+   80       continue
+   90    continue
+c
+c        store the diagonal element of s and restore
+c        the corresponding diagonal element of r.
+c
+         sdiag(j) = r(j,j)
+         r(j,j) = x(j)
+  100    continue
+c
+c     solve the triangular system for z. if the system is
+c     singular, then obtain a least squares solution.
+c
+      nsing = n
+      do 110 j = 1, n
+         if (sdiag(j) .eq. zero .and. nsing .eq. n) nsing = j - 1
+         if (nsing .lt. n) wa(j) = zero
+  110    continue
+      if (nsing .lt. 1) go to 150
+      do 140 k = 1, nsing
+         j = nsing - k + 1
+         sum = zero
+         jp1 = j + 1
+         if (nsing .lt. jp1) go to 130
+         do 120 i = jp1, nsing
+            sum = sum + r(i,j)*wa(i)
+  120       continue
+  130    continue
+         wa(j) = (wa(j) - sum)/sdiag(j)
+  140    continue
+  150 continue
+c
+c     permute the components of z back to components of x.
+c
+      do 160 j = 1, n
+         l = ipvt(j)
+         x(l) = wa(j)
+  160    continue
+      return
+c
+c     last card of subroutine qrsolv.
+c
+      end
diff --git a/fortran/r1mpyq.f b/fortran/r1mpyq.f
new file mode 100644
index 0000000..ec99b96
--- /dev/null
+++ b/fortran/r1mpyq.f
@@ -0,0 +1,92 @@
+      subroutine r1mpyq(m,n,a,lda,v,w)
+      integer m,n,lda
+      double precision a(lda,n),v(n),w(n)
+c     **********
+c
+c     subroutine r1mpyq
+c
+c     given an m by n matrix a, this subroutine computes a*q where
+c     q is the product of 2*(n - 1) transformations
+c
+c           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1)
+c
+c     and gv(i), gw(i) are givens rotations in the (i,n) plane which
+c     eliminate elements in the i-th and n-th planes, respectively.
+c     q itself is not given, rather the information to recover the
+c     gv, gw rotations is supplied.
+c
+c     the subroutine statement is
+c
+c       subroutine r1mpyq(m,n,a,lda,v,w)
+c
+c     where
+c
+c       m is a positive integer input variable set to the number
+c         of rows of a.
+c
+c       n is a positive integer input variable set to the number
+c         of columns of a.
+c
+c       a is an m by n array. on input a must contain the matrix
+c         to be postmultiplied by the orthogonal matrix q
+c         described above. on output a*q has replaced a.
+c
+c       lda is a positive integer input variable not less than m
+c         which specifies the leading dimension of the array a.
+c
+c       v is an input array of length n. v(i) must contain the
+c         information necessary to recover the givens rotation gv(i)
+c         described above.
+c
+c       w is an input array of length n. w(i) must contain the
+c         information necessary to recover the givens rotation gw(i)
+c         described above.
+c
+c     subroutines called
+c
+c       fortran-supplied ... dabs,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more
+c
+c     **********
+      integer i,j,nmj,nm1
+      double precision cos,one,sin,temp
+      data one /1.0d0/
+c
+c     apply the first set of givens rotations to a.
+c
+      nm1 = n - 1
+      if (nm1 .lt. 1) go to 50
+      do 20 nmj = 1, nm1
+         j = n - nmj
+         if (dabs(v(j)) .gt. one) cos = one/v(j)
+         if (dabs(v(j)) .gt. one) sin = dsqrt(one-cos**2)
+         if (dabs(v(j)) .le. one) sin = v(j)
+         if (dabs(v(j)) .le. one) cos = dsqrt(one-sin**2)
+         do 10 i = 1, m
+            temp = cos*a(i,j) - sin*a(i,n)
+            a(i,n) = sin*a(i,j) + cos*a(i,n)
+            a(i,j) = temp
+   10       continue
+   20    continue
+c
+c     apply the second set of givens rotations to a.
+c
+      do 40 j = 1, nm1
+         if (dabs(w(j)) .gt. one) cos = one/w(j)
+         if (dabs(w(j)) .gt. one) sin = dsqrt(one-cos**2)
+         if (dabs(w(j)) .le. one) sin = w(j)
+         if (dabs(w(j)) .le. one) cos = dsqrt(one-sin**2)
+         do 30 i = 1, m
+            temp = cos*a(i,j) + sin*a(i,n)
+            a(i,n) = -sin*a(i,j) + cos*a(i,n)
+            a(i,j) = temp
+   30       continue
+   40    continue
+   50 continue
+      return
+c
+c     last card of subroutine r1mpyq.
+c
+      end
diff --git a/fortran/r1updt.f b/fortran/r1updt.f
new file mode 100644
index 0000000..e034973
--- /dev/null
+++ b/fortran/r1updt.f
@@ -0,0 +1,207 @@
+      subroutine r1updt(m,n,s,ls,u,v,w,sing)
+      integer m,n,ls
+      logical sing
+      double precision s(ls),u(m),v(n),w(m)
+c     **********
+c
+c     subroutine r1updt
+c
+c     given an m by n lower trapezoidal matrix s, an m-vector u,
+c     and an n-vector v, the problem is to determine an
+c     orthogonal matrix q such that
+c
+c                   t
+c           (s + u*v )*q
+c
+c     is again lower trapezoidal.
+c
+c     this subroutine determines q as the product of 2*(n - 1)
+c     transformations
+c
+c           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1)
+c
+c     where gv(i), gw(i) are givens rotations in the (i,n) plane
+c     which eliminate elements in the i-th and n-th planes,
+c     respectively. q itself is not accumulated, rather the
+c     information to recover the gv, gw rotations is returned.
+c
+c     the subroutine statement is
+c
+c       subroutine r1updt(m,n,s,ls,u,v,w,sing)
+c
+c     where
+c
+c       m is a positive integer input variable set to the number
+c         of rows of s.
+c
+c       n is a positive integer input variable set to the number
+c         of columns of s. n must not exceed m.
+c
+c       s is an array of length ls. on input s must contain the lower
+c         trapezoidal matrix s stored by columns. on output s contains
+c         the lower trapezoidal matrix produced as described above.
+c
+c       ls is a positive integer input variable not less than
+c         (n*(2*m-n+1))/2.
+c
+c       u is an input array of length m which must contain the
+c         vector u.
+c
+c       v is an array of length n. on input v must contain the vector
+c         v. on output v(i) contains the information necessary to
+c         recover the givens rotation gv(i) described above.
+c
+c       w is an output array of length m. w(i) contains information
+c         necessary to recover the givens rotation gw(i) described
+c         above.
+c
+c       sing is a logical output variable. sing is set true if any
+c         of the diagonal elements of the output s are zero. otherwise
+c         sing is set false.
+c
+c     subprograms called
+c
+c       minpack-supplied ... dpmpar
+c
+c       fortran-supplied ... dabs,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, kenneth e. hillstrom, jorge j. more,
+c     john l. nazareth
+c
+c     **********
+      integer i,j,jj,l,nmj,nm1
+      double precision cos,cotan,giant,one,p5,p25,sin,tan,tau,temp,
+     *                 zero
+      double precision dpmpar
+      data one,p5,p25,zero /1.0d0,5.0d-1,2.5d-1,0.0d0/
+c
+c     giant is the largest magnitude.
+c
+      giant = dpmpar(3)
+c
+c     initialize the diagonal element pointer.
+c
+      jj = (n*(2*m - n + 1))/2 - (m - n)
+c
+c     move the nontrivial part of the last column of s into w.
+c
+      l = jj
+      do 10 i = n, m
+         w(i) = s(l)
+         l = l + 1
+   10    continue
+c
+c     rotate the vector v into a multiple of the n-th unit vector
+c     in such a way that a spike is introduced into w.
+c
+      nm1 = n - 1
+      if (nm1 .lt. 1) go to 70
+      do 60 nmj = 1, nm1
+         j = n - nmj
+         jj = jj - (m - j + 1)
+         w(j) = zero
+         if (v(j) .eq. zero) go to 50
+c
+c        determine a givens rotation which eliminates the
+c        j-th element of v.
+c
+         if (dabs(v(n)) .ge. dabs(v(j))) go to 20
+            cotan = v(n)/v(j)
+            sin = p5/dsqrt(p25+p25*cotan**2)
+            cos = sin*cotan
+            tau = one
+            if (dabs(cos)*giant .gt. one) tau = one/cos
+            go to 30
+   20    continue
+            tan = v(j)/v(n)
+            cos = p5/dsqrt(p25+p25*tan**2)
+            sin = cos*tan
+            tau = sin
+   30    continue
+c
+c        apply the transformation to v and store the information
+c        necessary to recover the givens rotation.
+c
+         v(n) = sin*v(j) + cos*v(n)
+         v(j) = tau
+c
+c        apply the transformation to s and extend the spike in w.
+c
+         l = jj
+         do 40 i = j, m
+            temp = cos*s(l) - sin*w(i)
+            w(i) = sin*s(l) + cos*w(i)
+            s(l) = temp
+            l = l + 1
+   40       continue
+   50    continue
+   60    continue
+   70 continue
+c
+c     add the spike from the rank 1 update to w.
+c
+      do 80 i = 1, m
+         w(i) = w(i) + v(n)*u(i)
+   80    continue
+c
+c     eliminate the spike.
+c
+      sing = .false.
+      if (nm1 .lt. 1) go to 140
+      do 130 j = 1, nm1
+         if (w(j) .eq. zero) go to 120
+c
+c        determine a givens rotation which eliminates the
+c        j-th element of the spike.
+c
+         if (dabs(s(jj)) .ge. dabs(w(j))) go to 90
+            cotan = s(jj)/w(j)
+            sin = p5/dsqrt(p25+p25*cotan**2)
+            cos = sin*cotan
+            tau = one
+            if (dabs(cos)*giant .gt. one) tau = one/cos
+            go to 100
+   90    continue
+            tan = w(j)/s(jj)
+            cos = p5/dsqrt(p25+p25*tan**2)
+            sin = cos*tan
+            tau = sin
+  100    continue
+c
+c        apply the transformation to s and reduce the spike in w.
+c
+         l = jj
+         do 110 i = j, m
+            temp = cos*s(l) + sin*w(i)
+            w(i) = -sin*s(l) + cos*w(i)
+            s(l) = temp
+            l = l + 1
+  110       continue
+c
+c        store the information necessary to recover the
+c        givens rotation.
+c
+         w(j) = tau
+  120    continue
+c
+c        test for zero diagonal elements in the output s.
+c
+         if (s(jj) .eq. zero) sing = .true.
+         jj = jj + (m - j + 1)
+  130    continue
+  140 continue
+c
+c     move w back into the last column of the output s.
+c
+      l = jj
+      do 150 i = n, m
+         s(l) = w(i)
+         l = l + 1
+  150    continue
+      if (s(jj) .eq. zero) sing = .true.
+      return
+c
+c     last card of subroutine r1updt.
+c
+      end
diff --git a/fortran/rwupdt.f b/fortran/rwupdt.f
new file mode 100644
index 0000000..05282b5
--- /dev/null
+++ b/fortran/rwupdt.f
@@ -0,0 +1,113 @@
+      subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin)
+      integer n,ldr
+      double precision alpha
+      double precision r(ldr,n),w(n),b(n),cos(n),sin(n)
+c     **********
+c
+c     subroutine rwupdt
+c
+c     given an n by n upper triangular matrix r, this subroutine
+c     computes the qr decomposition of the matrix formed when a row
+c     is added to r. if the row is specified by the vector w, then
+c     rwupdt determines an orthogonal matrix q such that when the
+c     n+1 by n matrix composed of r augmented by w is premultiplied
+c     by (q transpose), the resulting matrix is upper trapezoidal.
+c     the matrix (q transpose) is the product of n transformations
+c
+c           g(n)*g(n-1)* ... *g(1)
+c
+c     where g(i) is a givens rotation in the (i,n+1) plane which
+c     eliminates elements in the (n+1)-st plane. rwupdt also
+c     computes the product (q transpose)*c where c is the
+c     (n+1)-vector (b,alpha). q itself is not accumulated, rather
+c     the information to recover the g rotations is supplied.
+c
+c     the subroutine statement is
+c
+c       subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin)
+c
+c     where
+c
+c       n is a positive integer input variable set to the order of r.
+c
+c       r is an n by n array. on input the upper triangular part of
+c         r must contain the matrix to be updated. on output r
+c         contains the updated triangular matrix.
+c
+c       ldr is a positive integer input variable not less than n
+c         which specifies the leading dimension of the array r.
+c
+c       w is an input array of length n which must contain the row
+c         vector to be added to r.
+c
+c       b is an array of length n. on input b must contain the
+c         first n elements of the vector c. on output b contains
+c         the first n elements of the vector (q transpose)*c.
+c
+c       alpha is a variable. on input alpha must contain the
+c         (n+1)-st element of the vector c. on output alpha contains
+c         the (n+1)-st element of the vector (q transpose)*c.
+c
+c       cos is an output array of length n which contains the
+c         cosines of the transforming givens rotations.
+c
+c       sin is an output array of length n which contains the
+c         sines of the transforming givens rotations.
+c
+c     subprograms called
+c
+c       fortran-supplied ... dabs,dsqrt
+c
+c     argonne national laboratory. minpack project. march 1980.
+c     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom,
+c     jorge j. more
+c
+c     **********
+      integer i,j,jm1
+      double precision cotan,one,p5,p25,rowj,tan,temp,zero
+      data one,p5,p25,zero /1.0d0,5.0d-1,2.5d-1,0.0d0/
+c
+      do 60 j = 1, n
+         rowj = w(j)
+         jm1 = j - 1
+c
+c        apply the previous transformations to
+c        r(i,j), i=1,2,...,j-1, and to w(j).
+c
+         if (jm1 .lt. 1) go to 20
+         do 10 i = 1, jm1
+            temp = cos(i)*r(i,j) + sin(i)*rowj
+            rowj = -sin(i)*r(i,j) + cos(i)*rowj
+            r(i,j) = temp
+   10       continue
+   20    continue
+c
+c        determine a givens rotation which eliminates w(j).
+c
+         cos(j) = one
+         sin(j) = zero
+         if (rowj .eq. zero) go to 50
+         if (dabs(r(j,j)) .ge. dabs(rowj)) go to 30
+            cotan = r(j,j)/rowj
+            sin(j) = p5/dsqrt(p25+p25*cotan**2)
+            cos(j) = sin(j)*cotan
+            go to 40
+   30    continue
+            tan = rowj/r(j,j)
+            cos(j) = p5/dsqrt(p25+p25*tan**2)
+            sin(j) = cos(j)*tan
+   40    continue
+c
+c        apply the current transformation to r(j,j), b(j), and alpha.
+c
+         r(j,j) = cos(j)*r(j,j) + sin(j)*rowj
+         temp = cos(j)*b(j) + sin(j)*alpha
+         alpha = -sin(j)*b(j) + cos(j)*alpha
+         b(j) = temp
+   50    continue
+   60    continue
+      return
+c
+c     last card of subroutine rwupdt.
+c
+      end
diff --git a/hybrd.c b/hybrd.c
new file mode 100644
index 0000000..e8efa69
--- /dev/null
+++ b/hybrd.c
@@ -0,0 +1,570 @@
+/* hybrd.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(hybrd)(__cminpack_decl_fcn_nn__ void *p, int n, real *x, real *
+	fvec, real xtol, int maxfev, int ml, int mu, 
+	real epsfcn, real *diag, int mode, real
+	factor, int nprint, int *nfev, real *
+	fjac, int ldfjac, real *r, int lr, real *qtf, 
+	real *wa1, real *wa2, real *wa3, real *wa4)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p001 .001
+#define p0001 1e-4
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i1;
+    real d1, d2;
+
+    /* Local variables */
+    int i, j, l, jm1, iwa[1];
+    real sum;
+    int sing;
+    int iter;
+    real temp;
+    int msum, iflag;
+    real delta = 0.;
+    int jeval;
+    int ncsuc;
+    real ratio;
+    real fnorm;
+    real pnorm, xnorm = 0., fnorm1;
+    int nslow1, nslow2;
+    int ncfail;
+    real actred, epsmch, prered;
+    int info;
+
+/*     ********** */
+
+/*     subroutine hybrd */
+
+/*     the purpose of hybrd is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. the user must provide a */
+/*     subroutine which calculates the functions. the jacobian is */
+/*     then calculated by a forward-difference approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn, */
+/*                        diag,mode,factor,nprint,info,nfev,fjac, */
+/*                        ldfjac,r,lr,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,iflag) */
+/*         integer n,iflag */
+/*         double precision x(n),fvec(n) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrd. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn is at least maxfev */
+/*         by the end of an iteration. */
+
+/*       ml is a nonnegative integer input variable which specifies */
+/*         the number of subdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         ml to at least n - 1. */
+
+/*       mu is a nonnegative integer input variable which specifies */
+/*         the number of superdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         mu to at least n - 1. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   relative error between two consecutive iterates */
+/*                    is at most xtol. */
+
+/*         info = 2   number of calls to fcn has reached or exceeded */
+/*                    maxfev. */
+
+/*         info = 3   xtol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    five jacobian evaluations. */
+
+/*         info = 5   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    ten iterations. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       r is an output array of length lr which contains the */
+/*         upper triangular matrix produced by the qr factorization */
+/*         of the final approximate jacobian, stored rowwise. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       qtf is an output array of length n which contains */
+/*         the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, wa3, and wa4 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dogleg,dpmpar,enorm,fdjac1, */
+/*                            qform,qrfac,r1mpyq,r1updt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,min0,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --diag;
+    --fvec;
+    --x;
+    fjac_dim1 = ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --r;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    info = 0;
+    iflag = 0;
+    *nfev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || xtol < 0. || maxfev <= 0 || ml < 0 || mu < 0 ||
+	    factor <= 0. || ldfjac < n || lr < n * (n + 1) / 2) {
+	goto TERMINATE;
+    }
+    if (mode == 2) {
+        for (j = 1; j <= n; ++j) {
+            if (diag[j] <= 0.) {
+                goto TERMINATE;
+            }
+        }
+    }
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = fcn_nn(p, n, &x[1], &fvec[1], 1);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto TERMINATE;
+    }
+    fnorm = __cminpack_enorm__(n, &fvec[1]);
+
+/*     determine the number of calls to fcn needed to compute */
+/*     the jacobian matrix. */
+
+/* Computing MIN */
+    i1 = ml + mu + 1;
+    msum = min(i1,n);
+
+/*     initialize iteration counter and monitors. */
+
+    iter = 1;
+    ncsuc = 0;
+    ncfail = 0;
+    nslow1 = 0;
+    nslow2 = 0;
+
+/*     beginning of the outer loop. */
+
+    for (;;) {
+        jeval = TRUE_;
+
+/*        calculate the jacobian matrix. */
+
+        iflag = __cminpack_func__(fdjac1)(__cminpack_param_fcn_nn__ p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac,
+                       ml, mu, epsfcn, &wa1[1], &wa2[1]);
+        *nfev += msum;
+        if (iflag < 0) {
+            goto TERMINATE;
+        }
+
+/*        compute the qr factorization of the jacobian. */
+
+        __cminpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, FALSE_, iwa, 1,
+              &wa1[1], &wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+        if (iter == 1) {
+            if (mode != 2) {
+                for (j = 1; j <= n; ++j) {
+                    diag[j] = wa2[j];
+                    if (wa2[j] == 0.) {
+                        diag[j] = 1.;
+                    }
+                }
+            }
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+            for (j = 1; j <= n; ++j) {
+                wa3[j] = diag[j] * x[j];
+            }
+            xnorm = __cminpack_enorm__(n, &wa3[1]);
+            delta = factor * xnorm;
+            if (delta == 0.) {
+                delta = factor;
+            }
+        }
+
+/*        form (q transpose)*fvec and store in qtf. */
+
+        for (i = 1; i <= n; ++i) {
+            qtf[i] = fvec[i];
+        }
+        for (j = 1; j <= n; ++j) {
+            if (fjac[j + j * fjac_dim1] != 0.) {
+                sum = 0.;
+                for (i = j; i <= n; ++i) {
+                    sum += fjac[i + j * fjac_dim1] * qtf[i];
+                }
+                temp = -sum / fjac[j + j * fjac_dim1];
+                for (i = j; i <= n; ++i) {
+                    qtf[i] += fjac[i + j * fjac_dim1] * temp;
+                }
+            }
+        }
+
+/*        copy the triangular factor of the qr factorization into r. */
+
+        sing = FALSE_;
+        for (j = 1; j <= n; ++j) {
+            l = j;
+            jm1 = j - 1;
+            if (jm1 >= 1) {
+                for (i = 1; i <= jm1; ++i) {
+                    r[l] = fjac[i + j * fjac_dim1];
+                    l = l + n - i;
+                }
+            }
+            r[l] = wa1[j];
+            if (wa1[j] == 0.) {
+                sing = TRUE_;
+            }
+        }
+
+/*        accumulate the orthogonal factor in fjac. */
+
+        __cminpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]);
+
+/*        rescale if necessary. */
+
+        if (mode != 2) {
+            for (j = 1; j <= n; ++j) {
+                /* Computing MAX */
+                d1 = diag[j], d2 = wa2[j];
+                diag[j] = max(d1,d2);
+            }
+        }
+
+/*        beginning of the inner loop. */
+
+        for (;;) {
+
+/*           if requested, call fcn to enable printing of iterates. */
+
+            if (nprint > 0) {
+                iflag = 0;
+                if ((iter - 1) % nprint == 0) {
+                    iflag = fcn_nn(p, n, &x[1], &fvec[1], 0);
+                }
+                if (iflag < 0) {
+                    goto TERMINATE;
+                }
+            }
+
+/*           determine the direction p. */
+
+            __cminpack_func__(dogleg)(n, &r[1], lr, &diag[1], &qtf[1], delta, &wa1[1], &wa2[1], &wa3[1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+            for (j = 1; j <= n; ++j) {
+                wa1[j] = -wa1[j];
+                wa2[j] = x[j] + wa1[j];
+                wa3[j] = diag[j] * wa1[j];
+            }
+            pnorm = __cminpack_enorm__(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+            if (iter == 1) {
+                delta = min(delta,pnorm);
+            }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+            iflag = fcn_nn(p, n, &wa2[1], &wa4[1], 1);
+            ++(*nfev);
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+            fnorm1 = __cminpack_enorm__(n, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+            actred = -1.;
+            if (fnorm1 < fnorm) {
+                /* Computing 2nd power */
+                d1 = fnorm1 / fnorm;
+                actred = 1. - d1 * d1;
+            }
+
+/*           compute the scaled predicted reduction. */
+
+            l = 1;
+            for (i = 1; i <= n; ++i) {
+                sum = 0.;
+                for (j = i; j <= n; ++j) {
+                    sum += r[l] * wa1[j];
+                    ++l;
+                }
+                wa3[i] = qtf[i] + sum;
+            }
+            temp = __cminpack_enorm__(n, &wa3[1]);
+            prered = 0.;
+            if (temp < fnorm) {
+                /* Computing 2nd power */
+                d1 = temp / fnorm;
+                prered = 1. - d1 * d1;
+            }
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+            ratio = 0.;
+            if (prered > 0.) {
+                ratio = actred / prered;
+            }
+
+/*           update the step bound. */
+
+            if (ratio < p1) {
+                ncsuc = 0;
+                ++ncfail;
+                delta = p5 * delta;
+            } else {
+                ncfail = 0;
+                ++ncsuc;
+                if (ratio >= p5 || ncsuc > 1) {
+                    /* Computing MAX */
+                    d1 = pnorm / p5;
+                    delta = max(delta,d1);
+                }
+                if (fabs(ratio - 1.) <= p1) {
+                    delta = pnorm / p5;
+                }
+            }
+
+/*           test for successful iteration. */
+
+            if (ratio >= p0001) {
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+                for (j = 1; j <= n; ++j) {
+                    x[j] = wa2[j];
+                    wa2[j] = diag[j] * x[j];
+                    fvec[j] = wa4[j];
+                }
+                xnorm = __cminpack_enorm__(n, &wa2[1]);
+                fnorm = fnorm1;
+                ++iter;
+            }
+
+/*           determine the progress of the iteration. */
+
+            ++nslow1;
+            if (actred >= p001) {
+                nslow1 = 0;
+            }
+            if (jeval) {
+                ++nslow2;
+            }
+            if (actred >= p1) {
+                nslow2 = 0;
+            }
+
+/*           test for convergence. */
+
+            if (delta <= xtol * xnorm || fnorm == 0.) {
+                info = 1;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           tests for termination and stringent tolerances. */
+
+            if (*nfev >= maxfev) {
+                info = 2;
+            }
+            /* Computing MAX */
+            d1 = p1 * delta;
+            if (p1 * max(d1,pnorm) <= epsmch * xnorm) {
+                info = 3;
+            }
+            if (nslow2 == 5) {
+                info = 4;
+            }
+            if (nslow1 == 10) {
+                info = 5;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           criterion for recalculating jacobian approximation */
+/*           by forward differences. */
+
+            if (ncfail == 2) {
+                goto TERMINATE_INNER_LOOP;
+            }
+
+/*           calculate the rank one modification to the jacobian */
+/*           and update qtf if necessary. */
+
+            for (j = 1; j <= n; ++j) {
+                sum = 0.;
+                for (i = 1; i <= n; ++i) {
+                    sum += fjac[i + j * fjac_dim1] * wa4[i];
+                }
+                wa2[j] = (sum - wa3[j]) / pnorm;
+                wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm);
+                if (ratio >= p0001) {
+                    qtf[j] = sum;
+                }
+            }
+
+/*           compute the qr factorization of the updated jacobian. */
+
+            __cminpack_func__(r1updt)(n, n, &r[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing);
+            __cminpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]);
+            __cminpack_func__(r1mpyq)(1, n, &qtf[1], 1, &wa2[1], &wa3[1]);
+
+/*           end of the inner loop. */
+
+            jeval = FALSE_;
+        }
+TERMINATE_INNER_LOOP:
+        ;
+/*        end of the outer loop. */
+
+    }
+TERMINATE:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	info = iflag;
+    }
+    if (nprint > 0) {
+	fcn_nn(p, n, &x[1], &fvec[1], 0);
+    }
+    return info;
+
+/*     last card of subroutine hybrd. */
+
+} /* hybrd_ */
+
diff --git a/hybrd1.c b/hybrd1.c
new file mode 100644
index 0000000..8a41a8b
--- /dev/null
+++ b/hybrd1.c
@@ -0,0 +1,148 @@
+/* hybrd1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(hybrd1)(__cminpack_decl_fcn_nn__ void *p, int n, real *x, real *
+	fvec, real tol, real *wa, int lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* Local variables */
+    int j, ml, lr, mu, mode, nfev;
+    real xtol;
+    int index;
+    real epsfcn;
+    int maxfev, nprint;
+    int info;
+
+/*     ********** */
+
+/*     subroutine hybrd1 */
+
+/*     the purpose of hybrd1 is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. this is done by using the */
+/*     more general nonlinear equation solver hybrd. the user */
+/*     must provide a subroutine which calculates the functions. */
+/*     the jacobian is then calculated by a forward-difference */
+/*     approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,iflag) */
+/*         integer n,iflag */
+/*         double precision x(n),fvec(n) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrd1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates that the relative error */
+/*         between x and the solution is at most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   algorithm estimates that the relative error */
+/*                    between x and the solution is at most tol. */
+
+/*         info = 2   number of calls to fcn has reached or exceeded */
+/*                    200*(n+1). */
+
+/*         info = 3   tol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than */
+/*         (n*(3*n+13))/2. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... hybrd */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --x;
+    --wa;
+
+    /* Function Body */
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || tol < 0. || lwa < n * (n * 3 + 13) / 2) {
+        return 0;
+    }
+
+/*     call hybrd. */
+
+    maxfev = (n + 1) * 200;
+    xtol = tol;
+    ml = n - 1;
+    mu = n - 1;
+    epsfcn = 0.;
+    mode = 2;
+    for (j = 1; j <= n; ++j) {
+	wa[j] = 1.;
+    }
+    nprint = 0;
+    lr = n * (n + 1) / 2;
+    index = n * 6 + lr;
+    info = __cminpack_func__(hybrd)(__cminpack_param_fcn_nn__ p, n, &x[1], &fvec[1], xtol, maxfev, ml, mu, epsfcn, &
+	    wa[1], mode, factor, nprint, &nfev, &wa[index + 1], n, &
+	    wa[n * 6 + 1], lr, &wa[n + 1], &wa[(n << 1) + 1], &wa[n * 3 
+	    + 1], &wa[(n << 2) + 1], &wa[n * 5 + 1]);
+    if (info == 5) {
+	info = 4;
+    }
+    return info;
+
+/*     last card of subroutine hybrd1. */
+
+} /* hybrd1_ */
+
diff --git a/hybrd1_.c b/hybrd1_.c
new file mode 100644
index 0000000..5f2081a
--- /dev/null
+++ b/hybrd1_.c
@@ -0,0 +1,156 @@
+/* hybrd1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+__minpack_attr__
+void __minpack_func__(hybrd1)(__minpack_decl_fcn_nn__  const int *n, real *x, real *
+	fvec, const real *tol, int *info, real *wa, const int *lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* System generated locals */
+    int i__1;
+
+    /* Local variables */
+    int j, ml, lr, mu, mode, nfev;
+    real xtol;
+    int index;
+    real epsfcn;
+    int maxfev, nprint;
+
+/*     ********** */
+
+/*     subroutine hybrd1 */
+
+/*     the purpose of hybrd1 is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. this is done by using the */
+/*     more general nonlinear equation solver hybrd. the user */
+/*     must provide a subroutine which calculates the functions. */
+/*     the jacobian is then calculated by a forward-difference */
+/*     approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,iflag) */
+/*         integer n,iflag */
+/*         double precision x(n),fvec(n) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrd1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates that the relative error */
+/*         between x and the solution is at most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   algorithm estimates that the relative error */
+/*                    between x and the solution is at most tol. */
+
+/*         info = 2   number of calls to fcn has reached or exceeded */
+/*                    200*(n+1). */
+
+/*         info = 3   tol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than */
+/*         (n*(3*n+13))/2. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... hybrd */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --x;
+    --wa;
+
+    /* Function Body */
+    *info = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *tol < 0. || *lwa < *n * (*n * 3 + 13) / 2) {
+	/* goto L20; */
+        return;
+    }
+
+/*     call hybrd. */
+
+    maxfev = (*n + 1) * 200;
+    xtol = *tol;
+    ml = *n - 1;
+    mu = *n - 1;
+    epsfcn = 0.;
+    mode = 2;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa[j] = 1.;
+/* L10: */
+    }
+    nprint = 0;
+    lr = *n * (*n + 1) / 2;
+    index = *n * 6 + lr;
+    __minpack_func__(hybrd)(__minpack_param_fcn_nn__ n, &x[1], &fvec[1], &xtol, &maxfev, &ml, &mu, &epsfcn, &
+	    wa[1], &mode, &factor, &nprint, info, &nfev, &wa[index + 1], n, &
+	    wa[*n * 6 + 1], &lr, &wa[*n + 1], &wa[(*n << 1) + 1], &wa[*n * 3 
+	    + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]);
+    if (*info == 5) {
+	*info = 4;
+    }
+/* L20: */
+    return;
+
+/*     last card of subroutine hybrd1. */
+
+} /* hybrd1_ */
+
diff --git a/hybrd_.c b/hybrd_.c
new file mode 100644
index 0000000..7c3f696
--- /dev/null
+++ b/hybrd_.c
@@ -0,0 +1,636 @@
+/* hybrd.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(hybrd)(__minpack_decl_fcn_nn__ const int *n, real *x, real *
+	fvec, const real *xtol, const int *maxfev, const int *ml, const int *mu, 
+	const real *epsfcn, real *diag, const int *mode, const real *
+	factor, const int *nprint, int *info, int *nfev, real *
+	fjac, const int *ldfjac, real *r__, const int *lr, real *qtf, 
+	real *wa1, real *wa2, real *wa3, real *wa4)
+{
+    /* Table of constant values */
+
+    const int c__1 = 1;
+    const int c_false = FALSE_;
+
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p001 .001
+#define p0001 1e-4
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, l, jm1, iwa[1];
+    real sum;
+    int sing;
+    int iter;
+    real temp;
+    int msum, iflag;
+    real delta;
+    int jeval;
+    int ncsuc;
+    real ratio;
+    real fnorm;
+    real pnorm, xnorm, fnorm1;
+    int nslow1, nslow2;
+    int ncfail;
+    real actred, epsmch, prered;
+
+/*     ********** */
+
+/*     subroutine hybrd */
+
+/*     the purpose of hybrd is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. the user must provide a */
+/*     subroutine which calculates the functions. the jacobian is */
+/*     then calculated by a forward-difference approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn, */
+/*                        diag,mode,factor,nprint,info,nfev,fjac, */
+/*                        ldfjac,r,lr,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,iflag) */
+/*         integer n,iflag */
+/*         double precision x(n),fvec(n) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrd. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn is at least maxfev */
+/*         by the end of an iteration. */
+
+/*       ml is a nonnegative integer input variable which specifies */
+/*         the number of subdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         ml to at least n - 1. */
+
+/*       mu is a nonnegative integer input variable which specifies */
+/*         the number of superdiagonals within the band of the */
+/*         jacobian matrix. if the jacobian is not banded, set */
+/*         mu to at least n - 1. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   relative error between two consecutive iterates */
+/*                    is at most xtol. */
+
+/*         info = 2   number of calls to fcn has reached or exceeded */
+/*                    maxfev. */
+
+/*         info = 3   xtol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    five jacobian evaluations. */
+
+/*         info = 5   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    ten iterations. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       r is an output array of length lr which contains the */
+/*         upper triangular matrix produced by the qr factorization */
+/*         of the final approximate jacobian, stored rowwise. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       qtf is an output array of length n which contains */
+/*         the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, wa3, and wa4 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dogleg,dpmpar,enorm,fdjac1, */
+/*                            qform,qrfac,r1mpyq,r1updt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,min0,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --diag;
+    --fvec;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --r__;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    *info = 0;
+    iflag = 0;
+    *nfev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *xtol < 0. || *maxfev <= 0 || *ml < 0 || *mu < 0 || *
+	    factor <= 0. || *ldfjac < *n || *lr < *n * (*n + 1) / 2) {
+	goto L300;
+    }
+    if (*mode != 2) {
+	goto L20;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (diag[j] <= 0.) {
+	    goto L300;
+	}
+/* L10: */
+    }
+L20:
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = 1;
+    fcn_nn(n, &x[1], &fvec[1], &iflag);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm = __minpack_func__(enorm)(n, &fvec[1]);
+
+/*     determine the number of calls to fcn needed to compute */
+/*     the jacobian matrix. */
+
+/* Computing MIN */
+    i__1 = *ml + *mu + 1;
+    msum = min(i__1,*n);
+
+/*     initialize iteration counter and monitors. */
+
+    iter = 1;
+    ncsuc = 0;
+    ncfail = 0;
+    nslow1 = 0;
+    nslow2 = 0;
+
+/*     beginning of the outer loop. */
+
+L30:
+    jeval = TRUE_;
+
+/*        calculate the jacobian matrix. */
+
+    iflag = 2;
+    __minpack_func__(fdjac1)(__minpack_param_fcn_nn__ n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag,
+	     ml, mu, epsfcn, &wa1[1], &wa2[1]);
+    *nfev += msum;
+    if (iflag < 0) {
+	goto L300;
+    }
+
+/*        compute the qr factorization of the jacobian. */
+
+    __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_false, iwa, &c__1, &wa1[1], &
+	    wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+    if (iter != 1) {
+	goto L70;
+    }
+    if (*mode == 2) {
+	goto L50;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	diag[j] = wa2[j];
+	if (wa2[j] == 0.) {
+	    diag[j] = 1.;
+	}
+/* L40: */
+    }
+L50:
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = diag[j] * x[j];
+/* L60: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa3[1]);
+    delta = *factor * xnorm;
+    if (delta == 0.) {
+	delta = *factor;
+    }
+L70:
+
+/*        form (q transpose)*fvec and store in qtf. */
+
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	qtf[i__] = fvec[i__];
+/* L80: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    goto L110;
+	}
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * qtf[i__];
+/* L90: */
+	}
+	temp = -sum / fjac[j + j * fjac_dim1];
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    qtf[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L100: */
+	}
+L110:
+/* L120: */
+	;
+    }
+
+/*        copy the triangular factor of the qr factorization into r. */
+
+    sing = FALSE_;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = j;
+	jm1 = j - 1;
+	if (jm1 < 1) {
+	    goto L140;
+	}
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    r__[l] = fjac[i__ + j * fjac_dim1];
+	    l = l + *n - i__;
+/* L130: */
+	}
+L140:
+	r__[l] = wa1[j];
+	if (wa1[j] == 0.) {
+	    sing = TRUE_;
+	}
+/* L150: */
+    }
+
+/*        accumulate the orthogonal factor in fjac. */
+
+    __minpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]);
+
+/*        rescale if necessary. */
+
+    if (*mode == 2) {
+	goto L170;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MAX */
+	d__1 = diag[j], d__2 = wa2[j];
+	diag[j] = max(d__1,d__2);
+/* L160: */
+    }
+L170:
+
+/*        beginning of the inner loop. */
+
+L180:
+
+/*           if requested, call fcn to enable printing of iterates. */
+
+    if (*nprint <= 0) {
+	goto L190;
+    }
+    iflag = 0;
+    if ((iter - 1) % *nprint == 0) {
+	fcn_nn(n, &x[1], &fvec[1], &iflag);
+    }
+    if (iflag < 0) {
+	goto L300;
+    }
+L190:
+
+/*           determine the direction p. */
+
+    __minpack_func__(dogleg)(n, &r__[1], lr, &diag[1], &qtf[1], &delta, &wa1[1], &wa2[1], &wa3[
+	    1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = -wa1[j];
+	wa2[j] = x[j] + wa1[j];
+	wa3[j] = diag[j] * wa1[j];
+/* L200: */
+    }
+    pnorm = __minpack_func__(enorm)(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+    if (iter == 1) {
+	delta = min(delta,pnorm);
+    }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+    iflag = 1;
+    fcn_nn(n, &wa2[1], &wa4[1], &iflag);
+    ++(*nfev);
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm1 = __minpack_func__(enorm)(n, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+    actred = -1.;
+    if (fnorm1 < fnorm) {
+/* Computing 2nd power */
+	d__1 = fnorm1 / fnorm;
+	actred = 1. - d__1 * d__1;
+    }
+
+/*           compute the scaled predicted reduction. */
+
+    l = 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	sum = 0.;
+	i__2 = *n;
+	for (j = i__; j <= i__2; ++j) {
+	    sum += r__[l] * wa1[j];
+	    ++l;
+/* L210: */
+	}
+	wa3[i__] = qtf[i__] + sum;
+/* L220: */
+    }
+    temp = __minpack_func__(enorm)(n, &wa3[1]);
+    prered = 0.;
+    if (temp < fnorm) {
+/* Computing 2nd power */
+	d__1 = temp / fnorm;
+	prered = 1. - d__1 * d__1;
+    }
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+    ratio = 0.;
+    if (prered > 0.) {
+	ratio = actred / prered;
+    }
+
+/*           update the step bound. */
+
+    if (ratio >= p1) {
+	goto L230;
+    }
+    ncsuc = 0;
+    ++ncfail;
+    delta = p5 * delta;
+    goto L240;
+L230:
+    ncfail = 0;
+    ++ncsuc;
+    if (ratio >= p5 || ncsuc > 1) {
+/* Computing MAX */
+	d__1 = delta, d__2 = pnorm / p5;
+	delta = max(d__1,d__2);
+    }
+    if (fabs(ratio - 1.) <= p1) {
+	delta = pnorm / p5;
+    }
+L240:
+
+/*           test for successful iteration. */
+
+    if (ratio < p0001) {
+	goto L260;
+    }
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = wa2[j];
+	wa2[j] = diag[j] * x[j];
+	fvec[j] = wa4[j];
+/* L250: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fnorm = fnorm1;
+    ++iter;
+L260:
+
+/*           determine the progress of the iteration. */
+
+    ++nslow1;
+    if (actred >= p001) {
+	nslow1 = 0;
+    }
+    if (jeval) {
+	++nslow2;
+    }
+    if (actred >= p1) {
+	nslow2 = 0;
+    }
+
+/*           test for convergence. */
+
+    if (delta <= *xtol * xnorm || fnorm == 0.) {
+	*info = 1;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           tests for termination and stringent tolerances. */
+
+    if (*nfev >= *maxfev) {
+	*info = 2;
+    }
+/* Computing MAX */
+    d__1 = p1 * delta;
+    if (p1 * max(d__1,pnorm) <= epsmch * xnorm) {
+	*info = 3;
+    }
+    if (nslow2 == 5) {
+	*info = 4;
+    }
+    if (nslow1 == 10) {
+	*info = 5;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           criterion for recalculating jacobian approximation */
+/*           by forward differences. */
+
+    if (ncfail == 2) {
+	goto L290;
+    }
+
+/*           calculate the rank one modification to the jacobian */
+/*           and update qtf if necessary. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * wa4[i__];
+/* L270: */
+	}
+	wa2[j] = (sum - wa3[j]) / pnorm;
+	wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm);
+	if (ratio >= p0001) {
+	    qtf[j] = sum;
+	}
+/* L280: */
+    }
+
+/*           compute the qr factorization of the updated jacobian. */
+
+    __minpack_func__(r1updt)(n, n, &r__[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing);
+    __minpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]);
+    __minpack_func__(r1mpyq)(&c__1, n, &qtf[1], &c__1, &wa2[1], &wa3[1]);
+
+/*           end of the inner loop. */
+
+    jeval = FALSE_;
+    goto L180;
+L290:
+
+/*        end of the outer loop. */
+
+    goto L30;
+L300:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	*info = iflag;
+    }
+    iflag = 0;
+    if (*nprint > 0) {
+	fcn_nn(n, &x[1], &fvec[1], &iflag);
+    }
+    return;
+
+/*     last card of subroutine hybrd. */
+
+} /* hybrd_ */
+
diff --git a/hybrj.c b/hybrj.c
new file mode 100644
index 0000000..df00257
--- /dev/null
+++ b/hybrj.c
@@ -0,0 +1,549 @@
+/* hybrj.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(hybrj)(__cminpack_decl_fcnder_nn__ void *p, int n, real *x, real *
+	fvec, real *fjac, int ldfjac, real xtol, int
+	maxfev, real *diag, int mode, real factor, int
+	nprint, int *nfev, int *njev, real *r, 
+	int lr, real *qtf, real *wa1, real *wa2, 
+	real *wa3, real *wa4)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p001 .001
+#define p0001 1e-4
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset;
+    real d1, d2;
+
+    /* Local variables */
+    int i, j, l, jm1, iwa[1];
+    real sum;
+    int sing;
+    int iter;
+    real temp;
+    int iflag;
+    real delta = 0.;
+    int jeval;
+    int ncsuc;
+    real ratio;
+    real fnorm;
+    real pnorm, xnorm = 0., fnorm1;
+    int nslow1, nslow2;
+    int ncfail;
+    real actred, epsmch, prered;
+    int info;
+
+/*     ********** */
+
+/*     subroutine hybrj */
+
+/*     the purpose of hybrj is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag, */
+/*                        mode,factor,nprint,info,nfev,njev,r,lr,qtf, */
+/*                        wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer n,ldfjac,iflag */
+/*         double precision x(n),fvec(n),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrj. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. fvec and fjac should not be altered. */
+/*         if nprint is not positive, no special calls of fcn */
+/*         with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   relative error between two consecutive iterates */
+/*                    is at most xtol. */
+
+/*         info = 2   number of calls to fcn with iflag = 1 has */
+/*                    reached maxfev. */
+
+/*         info = 3   xtol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    five jacobian evaluations. */
+
+/*         info = 5   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    ten iterations. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       r is an output array of length lr which contains the */
+/*         upper triangular matrix produced by the qr factorization */
+/*         of the final approximate jacobian, stored rowwise. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       qtf is an output array of length n which contains */
+/*         the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, wa3, and wa4 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dogleg,dpmpar,enorm, */
+/*                            qform,qrfac,r1mpyq,r1updt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --diag;
+    --fvec;
+    --x;
+    fjac_dim1 = ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --r;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || ldfjac < n || xtol < 0. || maxfev <= 0 || factor <= 
+	    0. || lr < n * (n + 1) / 2) {
+	goto TERMINATE;
+    }
+    if (mode == 2) {
+        for (j = 1; j <= n; ++j) {
+            if (diag[j] <= 0.) {
+                goto TERMINATE;
+            }
+        }
+    }
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 1);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto TERMINATE;
+    }
+    fnorm = __cminpack_enorm__(n, &fvec[1]);
+
+/*     initialize iteration counter and monitors. */
+
+    iter = 1;
+    ncsuc = 0;
+    ncfail = 0;
+    nslow1 = 0;
+    nslow2 = 0;
+
+/*     beginning of the outer loop. */
+
+    for (;;) {
+        jeval = TRUE_;
+
+/*        calculate the jacobian matrix. */
+
+        iflag = fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 2);
+        ++(*njev);
+        if (iflag < 0) {
+            goto TERMINATE;
+        }
+
+/*        compute the qr factorization of the jacobian. */
+
+        __cminpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, FALSE_, iwa, 1,
+              &wa1[1], &wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+        if (iter == 1) {
+            if (mode != 2) {
+                for (j = 1; j <= n; ++j) {
+                    diag[j] = wa2[j];
+                    if (wa2[j] == 0.) {
+                        diag[j] = 1.;
+                    }
+                }
+            }
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+            for (j = 1; j <= n; ++j) {
+                wa3[j] = diag[j] * x[j];
+            }
+            xnorm = __cminpack_enorm__(n, &wa3[1]);
+            delta = factor * xnorm;
+            if (delta == 0.) {
+                delta = factor;
+            }
+        }
+
+/*        form (q transpose)*fvec and store in qtf. */
+
+        for (i = 1; i <= n; ++i) {
+            qtf[i] = fvec[i];
+        }
+        for (j = 1; j <= n; ++j) {
+            if (fjac[j + j * fjac_dim1] != 0.) {
+                sum = 0.;
+                for (i = j; i <= n; ++i) {
+                    sum += fjac[i + j * fjac_dim1] * qtf[i];
+                }
+                temp = -sum / fjac[j + j * fjac_dim1];
+                for (i = j; i <= n; ++i) {
+                    qtf[i] += fjac[i + j * fjac_dim1] * temp;
+                }
+            }
+        }
+
+/*        copy the triangular factor of the qr factorization into r. */
+
+        sing = FALSE_;
+        for (j = 1; j <= n; ++j) {
+            l = j;
+            jm1 = j - 1;
+            if (jm1 >= 1) {
+                for (i = 1; i <= jm1; ++i) {
+                    r[l] = fjac[i + j * fjac_dim1];
+                    l = l + n - i;
+                }
+            }
+            r[l] = wa1[j];
+            if (wa1[j] == 0.) {
+                sing = TRUE_;
+            }
+        }
+
+/*        accumulate the orthogonal factor in fjac. */
+
+        __cminpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]);
+
+/*        rescale if necessary. */
+
+        if (mode != 2) {
+            for (j = 1; j <= n; ++j) {
+                /* Computing MAX */
+                d1 = diag[j], d2 = wa2[j];
+                diag[j] = max(d1,d2);
+            }
+        }
+
+/*        beginning of the inner loop. */
+
+        for (;;) {
+
+/*           if requested, call fcn to enable printing of iterates. */
+
+            if (nprint > 0) {
+                iflag = 0;
+                if ((iter - 1) % nprint == 0) {
+                    iflag = fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 0);
+                }
+                if (iflag < 0) {
+                    goto TERMINATE;
+                }
+            }
+
+/*           determine the direction p. */
+
+            __cminpack_func__(dogleg)(n, &r[1], lr, &diag[1], &qtf[1], delta, &wa1[1], &wa2[1], &wa3[1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+            for (j = 1; j <= n; ++j) {
+                wa1[j] = -wa1[j];
+                wa2[j] = x[j] + wa1[j];
+                wa3[j] = diag[j] * wa1[j];
+            }
+            pnorm = __cminpack_enorm__(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+            if (iter == 1) {
+                delta = min(delta,pnorm);
+            }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+            iflag = fcnder_nn(p, n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, 1);
+            ++(*nfev);
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+            fnorm1 = __cminpack_enorm__(n, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+            actred = -1.;
+            if (fnorm1 < fnorm) {
+                /* Computing 2nd power */
+                d1 = fnorm1 / fnorm;
+                actred = 1. - d1 * d1;
+            }
+
+/*           compute the scaled predicted reduction. */
+
+            l = 1;
+            for (i = 1; i <= n; ++i) {
+                sum = 0.;
+                for (j = i; j <= n; ++j) {
+                    sum += r[l] * wa1[j];
+                    ++l;
+                }
+                wa3[i] = qtf[i] + sum;
+            }
+            temp = __cminpack_enorm__(n, &wa3[1]);
+            prered = 0.;
+            if (temp < fnorm) {
+                /* Computing 2nd power */
+                d1 = temp / fnorm;
+                prered = 1. - d1 * d1;
+            }
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+            ratio = 0.;
+            if (prered > 0.) {
+                ratio = actred / prered;
+            }
+
+/*           update the step bound. */
+
+            if (ratio < p1) {
+                ncsuc = 0;
+                ++ncfail;
+                delta = p5 * delta;
+            } else {
+                ncfail = 0;
+                ++ncsuc;
+                if (ratio >= p5 || ncsuc > 1) {
+                    /* Computing MAX */
+                    d1 = pnorm / p5;
+                    delta = max(delta,d1);
+                }
+                if (fabs(ratio - 1.) <= p1) {
+                    delta = pnorm / p5;
+                }
+            }
+
+/*           test for successful iteration. */
+
+            if (ratio >= p0001) {
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+                for (j = 1; j <= n; ++j) {
+                    x[j] = wa2[j];
+                    wa2[j] = diag[j] * x[j];
+                    fvec[j] = wa4[j];
+                }
+                xnorm = __cminpack_enorm__(n, &wa2[1]);
+                fnorm = fnorm1;
+                ++iter;
+            }
+
+/*           determine the progress of the iteration. */
+
+            ++nslow1;
+            if (actred >= p001) {
+                nslow1 = 0;
+            }
+            if (jeval) {
+                ++nslow2;
+            }
+            if (actred >= p1) {
+                nslow2 = 0;
+            }
+
+/*           test for convergence. */
+
+            if (delta <= xtol * xnorm || fnorm == 0.) {
+                info = 1;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           tests for termination and stringent tolerances. */
+
+            if (*nfev >= maxfev) {
+                info = 2;
+            }
+            /* Computing MAX */
+            d1 = p1 * delta;
+            if (p1 * max(d1,pnorm) <= epsmch * xnorm) {
+                info = 3;
+            }
+            if (nslow2 == 5) {
+                info = 4;
+            }
+            if (nslow1 == 10) {
+                info = 5;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           criterion for recalculating jacobian. */
+
+            if (ncfail == 2) {
+                goto TERMINATE_INNER_LOOP;
+            }
+
+/*           calculate the rank one modification to the jacobian */
+/*           and update qtf if necessary. */
+
+            for (j = 1; j <= n; ++j) {
+                sum = 0.;
+                for (i = 1; i <= n; ++i) {
+                    sum += fjac[i + j * fjac_dim1] * wa4[i];
+                }
+                wa2[j] = (sum - wa3[j]) / pnorm;
+                wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm);
+                if (ratio >= p0001) {
+                    qtf[j] = sum;
+                }
+            }
+
+/*           compute the qr factorization of the updated jacobian. */
+
+            __cminpack_func__(r1updt)(n, n, &r[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing);
+            __cminpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]);
+            __cminpack_func__(r1mpyq)(1, n, &qtf[1], 1, &wa2[1], &wa3[1]);
+
+/*           end of the inner loop. */
+
+            jeval = FALSE_;
+        }
+TERMINATE_INNER_LOOP:
+        ;
+/*        end of the outer loop. */
+
+    }
+TERMINATE:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	info = iflag;
+    }
+    if (nprint > 0) {
+	fcnder_nn(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 0);
+    }
+    return info;
+
+/*     last card of subroutine hybrj. */
+
+} /* hybrj_ */
+
diff --git a/hybrj1.c b/hybrj1.c
new file mode 100644
index 0000000..041c06d
--- /dev/null
+++ b/hybrj1.c
@@ -0,0 +1,158 @@
+/* hybrj1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(hybrj1)(__cminpack_decl_fcnder_nn__ void *p, int n, real *x, real *
+	fvec, real *fjac, int ldfjac, real tol,
+	real *wa, int lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset;
+
+    /* Local variables */
+    int j, lr, mode, nfev, njev;
+    real xtol;
+    int maxfev, nprint;
+    int info;
+
+/*     ********** */
+
+/*     subroutine hybrj1 */
+
+/*     the purpose of hybrj1 is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. this is done by using the */
+/*     more general nonlinear equation solver hybrj. the user */
+/*     must provide a subroutine which calculates the functions */
+/*     and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer n,ldfjac,iflag */
+/*         double precision x(n),fvec(n),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrj1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates that the relative error */
+/*         between x and the solution is at most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   algorithm estimates that the relative error */
+/*                    between x and the solution is at most tol. */
+
+/*         info = 2   number of calls to fcn with iflag = 1 has */
+/*                    reached 100*(n+1). */
+
+/*         info = 3   tol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than */
+/*         (n*(n+13))/2. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... hybrj */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --x;
+    fjac_dim1 = ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --wa;
+
+    /* Function Body */
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || ldfjac < n || tol < 0. || lwa < n * (n + 13) / 2) {
+        return 0;
+    }
+
+/*     call hybrj. */
+
+    maxfev = (n + 1) * 100;
+    xtol = tol;
+    mode = 2;
+    for (j = 1; j <= n; ++j) {
+	wa[j] = 1.;
+/* L10: */
+    }
+    nprint = 0;
+    lr = n * (n + 1) / 2;
+    info = __cminpack_func__(hybrj)(__cminpack_param_fcnder_nn__ p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, xtol,
+	    maxfev, &wa[1], mode, factor, nprint, &nfev, &njev, &wa[
+	    n * 6 + 1], lr, &wa[n + 1], &wa[(n << 1) + 1], &wa[n * 3 + 1],
+	     &wa[(n << 2) + 1], &wa[n * 5 + 1]);
+    if (info == 5) {
+	info = 4;
+    }
+    return info;
+
+/*     last card of subroutine hybrj1. */
+
+} /* hybrj1_ */
+
diff --git a/hybrj1_.c b/hybrj1_.c
new file mode 100644
index 0000000..430bdc1
--- /dev/null
+++ b/hybrj1_.c
@@ -0,0 +1,162 @@
+/* hybrj1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+__minpack_attr__
+void __minpack_func__(hybrj1)(__minpack_decl_fcnder_nn__ const int *n, real *x, real *
+	fvec, real *fjac, const int *ldfjac, const real *tol, int *
+	info, real *wa, const int *lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1;
+
+    /* Local variables */
+    int j, lr, mode, nfev, njev;
+    real xtol;
+    int maxfev, nprint;
+
+/*     ********** */
+
+/*     subroutine hybrj1 */
+
+/*     the purpose of hybrj1 is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. this is done by using the */
+/*     more general nonlinear equation solver hybrj. the user */
+/*     must provide a subroutine which calculates the functions */
+/*     and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer n,ldfjac,iflag */
+/*         double precision x(n),fvec(n),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrj1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates that the relative error */
+/*         between x and the solution is at most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   algorithm estimates that the relative error */
+/*                    between x and the solution is at most tol. */
+
+/*         info = 2   number of calls to fcn with iflag = 1 has */
+/*                    reached 100*(n+1). */
+
+/*         info = 3   tol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than */
+/*         (n*(n+13))/2. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... hybrj */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --wa;
+
+    /* Function Body */
+    *info = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *ldfjac < *n || *tol < 0. || *lwa < *n * (*n + 13) / 2) {
+	/* goto L20; */
+        return;
+    }
+
+/*     call hybrj. */
+
+    maxfev = (*n + 1) * 100;
+    xtol = *tol;
+    mode = 2;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa[j] = 1.;
+/* L10: */
+    }
+    nprint = 0;
+    lr = *n * (*n + 1) / 2;
+    __minpack_func__(hybrj)(__minpack_param_fcnder_nn__ n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &xtol, &
+	    maxfev, &wa[1], &mode, &factor, &nprint, info, &nfev, &njev, &wa[*
+	    n * 6 + 1], &lr, &wa[*n + 1], &wa[(*n << 1) + 1], &wa[*n * 3 + 1],
+	     &wa[(*n << 2) + 1], &wa[*n * 5 + 1]);
+    if (*info == 5) {
+	*info = 4;
+    }
+/* L20: */
+    return;
+
+/*     last card of subroutine hybrj1. */
+
+} /* hybrj1_ */
+
diff --git a/hybrj_.c b/hybrj_.c
new file mode 100644
index 0000000..9840404
--- /dev/null
+++ b/hybrj_.c
@@ -0,0 +1,612 @@
+/* hybrj.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(hybrj)(__minpack_decl_fcnder_nn__  const int *n, real *x, real *
+	fvec, real *fjac, const int *ldfjac, const real *xtol, const int *
+	maxfev, real *diag, const int *mode, const real *factor, const int *
+	nprint, int *info, int *nfev, int *njev, real *r__, 
+	const int *lr, real *qtf, real *wa1, real *wa2, 
+	real *wa3, real *wa4)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p001 .001
+#define p0001 1e-4
+    const int c_false = FALSE_;
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, l, jm1, iwa[1];
+    real sum;
+    int sing;
+    int iter;
+    real temp;
+    int iflag;
+    real delta;
+    int jeval;
+    int ncsuc;
+    real ratio;
+    real fnorm;
+    real pnorm, xnorm, fnorm1;
+    int nslow1, nslow2;
+    int ncfail;
+    real actred, epsmch, prered;
+
+/*     ********** */
+
+/*     subroutine hybrj */
+
+/*     the purpose of hybrj is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag, */
+/*                        mode,factor,nprint,info,nfev,njev,r,lr,qtf, */
+/*                        wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer n,ldfjac,iflag */
+/*         double precision x(n),fvec(n),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrj. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. fvec and fjac should not be altered. */
+/*         if nprint is not positive, no special calls of fcn */
+/*         with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   relative error between two consecutive iterates */
+/*                    is at most xtol. */
+
+/*         info = 2   number of calls to fcn with iflag = 1 has */
+/*                    reached maxfev. */
+
+/*         info = 3   xtol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    five jacobian evaluations. */
+
+/*         info = 5   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    ten iterations. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       r is an output array of length lr which contains the */
+/*         upper triangular matrix produced by the qr factorization */
+/*         of the final approximate jacobian, stored rowwise. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       qtf is an output array of length n which contains */
+/*         the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, wa3, and wa4 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dogleg,dpmpar,enorm, */
+/*                            qform,qrfac,r1mpyq,r1updt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --diag;
+    --fvec;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --r__;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    *info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *ldfjac < *n || *xtol < 0. || *maxfev <= 0 || *factor <= 
+	    0. || *lr < *n * (*n + 1) / 2) {
+	goto L300;
+    }
+    if (*mode != 2) {
+	goto L20;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (diag[j] <= 0.) {
+	    goto L300;
+	}
+/* L10: */
+    }
+L20:
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = 1;
+    fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm = __minpack_func__(enorm)(n, &fvec[1]);
+
+/*     initialize iteration counter and monitors. */
+
+    iter = 1;
+    ncsuc = 0;
+    ncfail = 0;
+    nslow1 = 0;
+    nslow2 = 0;
+
+/*     beginning of the outer loop. */
+
+L30:
+    jeval = TRUE_;
+
+/*        calculate the jacobian matrix. */
+
+    iflag = 2;
+    fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    ++(*njev);
+    if (iflag < 0) {
+	goto L300;
+    }
+
+/*        compute the qr factorization of the jacobian. */
+
+    __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_false, iwa, &c__1, &wa1[1], &
+	    wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+    if (iter != 1) {
+	goto L70;
+    }
+    if (*mode == 2) {
+	goto L50;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	diag[j] = wa2[j];
+	if (wa2[j] == 0.) {
+	    diag[j] = 1.;
+	}
+/* L40: */
+    }
+L50:
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = diag[j] * x[j];
+/* L60: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa3[1]);
+    delta = *factor * xnorm;
+    if (delta == 0.) {
+	delta = *factor;
+    }
+L70:
+
+/*        form (q transpose)*fvec and store in qtf. */
+
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	qtf[i__] = fvec[i__];
+/* L80: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    goto L110;
+	}
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * qtf[i__];
+/* L90: */
+	}
+	temp = -sum / fjac[j + j * fjac_dim1];
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    qtf[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L100: */
+	}
+L110:
+/* L120: */
+	;
+    }
+
+/*        copy the triangular factor of the qr factorization into r. */
+
+    sing = FALSE_;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = j;
+	jm1 = j - 1;
+	if (jm1 < 1) {
+	    goto L140;
+	}
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    r__[l] = fjac[i__ + j * fjac_dim1];
+	    l = l + *n - i__;
+/* L130: */
+	}
+L140:
+	r__[l] = wa1[j];
+	if (wa1[j] == 0.) {
+	    sing = TRUE_;
+	}
+/* L150: */
+    }
+
+/*        accumulate the orthogonal factor in fjac. */
+
+    __minpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]);
+
+/*        rescale if necessary. */
+
+    if (*mode == 2) {
+	goto L170;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MAX */
+	d__1 = diag[j], d__2 = wa2[j];
+	diag[j] = max(d__1,d__2);
+/* L160: */
+    }
+L170:
+
+/*        beginning of the inner loop. */
+
+L180:
+
+/*           if requested, call fcn to enable printing of iterates. */
+
+    if (*nprint <= 0) {
+	goto L190;
+    }
+    iflag = 0;
+    if ((iter - 1) % *nprint == 0) {
+	fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    }
+    if (iflag < 0) {
+	goto L300;
+    }
+L190:
+
+/*           determine the direction p. */
+
+    __minpack_func__(dogleg)(n, &r__[1], lr, &diag[1], &qtf[1], &delta, &wa1[1], &wa2[1], &wa3[
+	    1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = -wa1[j];
+	wa2[j] = x[j] + wa1[j];
+	wa3[j] = diag[j] * wa1[j];
+/* L200: */
+    }
+    pnorm = __minpack_func__(enorm)(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+    if (iter == 1) {
+	delta = min(delta,pnorm);
+    }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+    iflag = 1;
+    fcnder_nn(n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, &iflag);
+    ++(*nfev);
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm1 = __minpack_func__(enorm)(n, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+    actred = -1.;
+    if (fnorm1 < fnorm) {
+/* Computing 2nd power */
+	d__1 = fnorm1 / fnorm;
+	actred = 1. - d__1 * d__1;
+    }
+
+/*           compute the scaled predicted reduction. */
+
+    l = 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	sum = 0.;
+	i__2 = *n;
+	for (j = i__; j <= i__2; ++j) {
+	    sum += r__[l] * wa1[j];
+	    ++l;
+/* L210: */
+	}
+	wa3[i__] = qtf[i__] + sum;
+/* L220: */
+    }
+    temp = __minpack_func__(enorm)(n, &wa3[1]);
+    prered = 0.;
+    if (temp < fnorm) {
+/* Computing 2nd power */
+	d__1 = temp / fnorm;
+	prered = 1. - d__1 * d__1;
+    }
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+    ratio = 0.;
+    if (prered > 0.) {
+	ratio = actred / prered;
+    }
+
+/*           update the step bound. */
+
+    if (ratio >= p1) {
+	goto L230;
+    }
+    ncsuc = 0;
+    ++ncfail;
+    delta = p5 * delta;
+    goto L240;
+L230:
+    ncfail = 0;
+    ++ncsuc;
+    if (ratio >= p5 || ncsuc > 1) {
+/* Computing MAX */
+	d__1 = delta, d__2 = pnorm / p5;
+	delta = max(d__1,d__2);
+    }
+    if (fabs(ratio - 1.) <= p1) {
+	delta = pnorm / p5;
+    }
+L240:
+
+/*           test for successful iteration. */
+
+    if (ratio < p0001) {
+	goto L260;
+    }
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = wa2[j];
+	wa2[j] = diag[j] * x[j];
+	fvec[j] = wa4[j];
+/* L250: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fnorm = fnorm1;
+    ++iter;
+L260:
+
+/*           determine the progress of the iteration. */
+
+    ++nslow1;
+    if (actred >= p001) {
+	nslow1 = 0;
+    }
+    if (jeval) {
+	++nslow2;
+    }
+    if (actred >= p1) {
+	nslow2 = 0;
+    }
+
+/*           test for convergence. */
+
+    if (delta <= *xtol * xnorm || fnorm == 0.) {
+	*info = 1;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           tests for termination and stringent tolerances. */
+
+    if (*nfev >= *maxfev) {
+	*info = 2;
+    }
+/* Computing MAX */
+    d__1 = p1 * delta;
+    if (p1 * max(d__1,pnorm) <= epsmch * xnorm) {
+	*info = 3;
+    }
+    if (nslow2 == 5) {
+	*info = 4;
+    }
+    if (nslow1 == 10) {
+	*info = 5;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           criterion for recalculating jacobian. */
+
+    if (ncfail == 2) {
+	goto L290;
+    }
+
+/*           calculate the rank one modification to the jacobian */
+/*           and update qtf if necessary. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * wa4[i__];
+/* L270: */
+	}
+	wa2[j] = (sum - wa3[j]) / pnorm;
+	wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm);
+	if (ratio >= p0001) {
+	    qtf[j] = sum;
+	}
+/* L280: */
+    }
+
+/*           compute the qr factorization of the updated jacobian. */
+
+    __minpack_func__(r1updt)(n, n, &r__[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing);
+    __minpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]);
+    __minpack_func__(r1mpyq)(&c__1, n, &qtf[1], &c__1, &wa2[1], &wa3[1]);
+
+/*           end of the inner loop. */
+
+    jeval = FALSE_;
+    goto L180;
+L290:
+
+/*        end of the outer loop. */
+
+    goto L30;
+L300:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	*info = iflag;
+    }
+    iflag = 0;
+    if (*nprint > 0) {
+	fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    }
+    return;
+
+/*     last card of subroutine hybrj. */
+
+} /* hybrj_ */
+
diff --git a/lmder.c b/lmder.c
new file mode 100644
index 0000000..7f57428
--- /dev/null
+++ b/lmder.c
@@ -0,0 +1,526 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(lmder)(__cminpack_decl_fcnder_mn__ void *p, int m, int n, real *x, 
+	real *fvec, real *fjac, int ldfjac, real ftol,
+	real xtol, real gtol, int maxfev, real *
+	diag, int mode, real factor, int nprint,
+	int *nfev, int *njev, int *ipvt, real *qtf, 
+	real *wa1, real *wa2, real *wa3, real *wa4)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p25 .25
+#define p75 .75
+#define p0001 1e-4
+
+    /* System generated locals */
+    real d1, d2;
+
+    /* Local variables */
+    int i, j, l;
+    real par, sum;
+    int iter;
+    real temp, temp1, temp2;
+    int iflag;
+    real delta = 0.;
+    real ratio;
+    real fnorm, gnorm, pnorm, xnorm = 0., fnorm1, actred, dirder, 
+	    epsmch, prered;
+    int info;
+
+/*     ********** */
+
+/*     subroutine lmder */
+
+/*     the purpose of lmder is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */
+/*                        maxfev,diag,mode,factor,nprint,info,nfev, */
+/*                        njev,ipvt,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer m,n,ldfjac,iflag */
+/*         double precision x(n),fvec(m),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmder. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output m by n array. the upper n by n submatrix */
+/*         of fjac contains an upper triangular matrix r with */
+/*         diagonal elements of nonincreasing magnitude such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower trapezoidal */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       ftol is a nonnegative input variable. termination */
+/*         occurs when both the actual and predicted relative */
+/*         reductions in the sum of squares are at most ftol. */
+/*         therefore, ftol measures the relative error desired */
+/*         in the sum of squares. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. therefore, xtol measures the */
+/*         relative error desired in the approximate solution. */
+
+/*       gtol is a nonnegative input variable. termination */
+/*         occurs when the cosine of the angle between fvec and */
+/*         any column of the jacobian is at most gtol in absolute */
+/*         value. therefore, gtol measures the orthogonality */
+/*         desired between the function vector and the columns */
+/*         of the jacobian. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.).100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x, fvec, and fjac */
+/*         available for printing. fvec and fjac should not be */
+/*         altered. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  both actual and predicted relative reductions */
+/*                   in the sum of squares are at most ftol. */
+
+/*         info = 2  relative error between two consecutive iterates */
+/*                   is at most xtol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  the cosine of the angle between fvec and any */
+/*                   column of the jacobian is at most gtol in */
+/*                   absolute value. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached maxfev. */
+
+/*         info = 6  ftol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  xtol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*         info = 8  gtol is too small. fvec is orthogonal to the */
+/*                   columns of the jacobian to machine precision. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular */
+/*         with diagonal elements of nonincreasing magnitude. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       qtf is an output array of length n which contains */
+/*         the first n elements of the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, and wa3 are work arrays of length n. */
+
+/*       wa4 is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,lmpar,qrfac */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || m < n || ldfjac < m || ftol < 0. || xtol < 0. || 
+	    gtol < 0. || maxfev <= 0 || factor <= 0.) {
+	goto TERMINATE;
+    }
+    if (mode == 2) {
+        for (j = 0; j < n; ++j) {
+            if (diag[j] <= 0.) {
+                goto TERMINATE;
+            }
+        }
+    }
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 1);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto TERMINATE;
+    }
+    fnorm = __cminpack_enorm__(m, fvec);
+
+/*     initialize levenberg-marquardt parameter and iteration counter. */
+
+    par = 0.;
+    iter = 1;
+
+/*     beginning of the outer loop. */
+
+    for (;;) {
+
+/*        calculate the jacobian matrix. */
+
+        iflag = fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 2);
+        ++(*njev);
+        if (iflag < 0) {
+            goto TERMINATE;
+        }
+
+/*        if requested, call fcn to enable printing of iterates. */
+
+        if (nprint > 0) {
+            iflag = 0;
+            if ((iter - 1) % nprint == 0) {
+                iflag = fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 0);
+            }
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+        }
+
+/*        compute the qr factorization of the jacobian. */
+
+        __cminpack_func__(qrfac)(m, n, fjac, ldfjac, TRUE_, ipvt, n,
+              wa1, wa2, wa3);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+        if (iter == 1) {
+            if (mode != 2) {
+                for (j = 0; j < n; ++j) {
+                    diag[j] = wa2[j];
+                    if (wa2[j] == 0.) {
+                        diag[j] = 1.;
+                    }
+                }
+            }
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+            for (j = 0; j < n; ++j) {
+                wa3[j] = diag[j] * x[j];
+            }
+            xnorm = __cminpack_enorm__(n, wa3);
+            delta = factor * xnorm;
+            if (delta == 0.) {
+                delta = factor;
+            }
+        }
+
+/*        form (q transpose)*fvec and store the first n components in */
+/*        qtf. */
+
+        for (i = 0; i < m; ++i) {
+            wa4[i] = fvec[i];
+        }
+        for (j = 0; j < n; ++j) {
+            if (fjac[j + j * ldfjac] != 0.) {
+                sum = 0.;
+                for (i = j; i < m; ++i) {
+                    sum += fjac[i + j * ldfjac] * wa4[i];
+                }
+                temp = -sum / fjac[j + j * ldfjac];
+                for (i = j; i < m; ++i) {
+                    wa4[i] += fjac[i + j * ldfjac] * temp;
+                }
+            }
+            fjac[j + j * ldfjac] = wa1[j];
+            qtf[j] = wa4[j];
+        }
+
+/*        compute the norm of the scaled gradient. */
+
+        gnorm = 0.;
+        if (fnorm != 0.) {
+            for (j = 0; j < n; ++j) {
+                l = ipvt[j]-1;
+                if (wa2[l] != 0.) {
+                    sum = 0.;
+                    for (i = 0; i <= j; ++i) {
+                        sum += fjac[i + j * ldfjac] * (qtf[i] / fnorm);
+                    }
+                    /* Computing MAX */
+                    d1 = fabs(sum / wa2[l]);
+                    gnorm = max(gnorm,d1);
+                }
+            }
+        }
+
+/*        test for convergence of the gradient norm. */
+
+        if (gnorm <= gtol) {
+            info = 4;
+        }
+        if (info != 0) {
+            goto TERMINATE;
+        }
+
+/*        rescale if necessary. */
+
+        if (mode != 2) {
+            for (j = 0; j < n; ++j) {
+                /* Computing MAX */
+                d1 = diag[j], d2 = wa2[j];
+                diag[j] = max(d1,d2);
+            }
+        }
+
+/*        beginning of the inner loop. */
+
+        do {
+
+/*           determine the levenberg-marquardt parameter. */
+
+            __cminpack_func__(lmpar)(n, fjac, ldfjac, ipvt, diag, qtf, delta,
+                  &par, wa1, wa2, wa3, wa4);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+            for (j = 0; j < n; ++j) {
+                wa1[j] = -wa1[j];
+                wa2[j] = x[j] + wa1[j];
+                wa3[j] = diag[j] * wa1[j];
+            }
+            pnorm = __cminpack_enorm__(n, wa3);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+            if (iter == 1) {
+                delta = min(delta,pnorm);
+            }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+            iflag = fcnder_mn(p, m, n, wa2, wa4, fjac, ldfjac, 1);
+            ++(*nfev);
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+            fnorm1 = __cminpack_enorm__(m, wa4);
+
+/*           compute the scaled actual reduction. */
+
+            actred = -1.;
+            if (p1 * fnorm1 < fnorm) {
+                /* Computing 2nd power */
+                d1 = fnorm1 / fnorm;
+                actred = 1. - d1 * d1;
+            }
+
+/*           compute the scaled predicted reduction and */
+/*           the scaled directional derivative. */
+
+            for (j = 0; j < n; ++j) {
+                wa3[j] = 0.;
+                l = ipvt[j]-1;
+                temp = wa1[l];
+                for (i = 0; i <= j; ++i) {
+                    wa3[i] += fjac[i + j * ldfjac] * temp;
+                }
+            }
+            temp1 = __cminpack_enorm__(n, wa3) / fnorm;
+            temp2 = (sqrt(par) * pnorm) / fnorm;
+            prered = temp1 * temp1 + temp2 * temp2 / p5;
+            dirder = -(temp1 * temp1 + temp2 * temp2);
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+            ratio = 0.;
+            if (prered != 0.) {
+                ratio = actred / prered;
+            }
+
+/*           update the step bound. */
+
+            if (ratio <= p25) {
+                if (actred >= 0.) {
+                    temp = p5;
+                } else {
+                    temp = p5 * dirder / (dirder + p5 * actred);
+                }
+                if (p1 * fnorm1 >= fnorm || temp < p1) {
+                    temp = p1;
+                }
+                /* Computing MIN */
+                d1 = pnorm / p1;
+                delta = temp * min(delta,d1);
+                par /= temp;
+            } else {
+                if (par == 0. || ratio >= p75) {
+                    delta = pnorm / p5;
+                    par = p5 * par;
+                }
+            }
+
+/*           test for successful iteration. */
+
+            if (ratio >= p0001) {
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+                for (j = 0; j < n; ++j) {
+                    x[j] = wa2[j];
+                    wa2[j] = diag[j] * x[j];
+                }
+                for (i = 0; i < m; ++i) {
+                    fvec[i] = wa4[i];
+                }
+                xnorm = __cminpack_enorm__(n, wa2);
+                fnorm = fnorm1;
+                ++iter;
+            }
+
+/*           tests for convergence. */
+
+            if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) {
+                info = 1;
+            }
+            if (delta <= xtol * xnorm) {
+                info = 2;
+            }
+            if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) {
+                info = 3;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           tests for termination and stringent tolerances. */
+
+            if (*nfev >= maxfev) {
+                info = 5;
+            }
+            if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+                info = 6;
+            }
+            if (delta <= epsmch * xnorm) {
+                info = 7;
+            }
+            if (gnorm <= epsmch) {
+                info = 8;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           end of the inner loop. repeat if iteration unsuccessful. */
+
+        } while (ratio < p0001);
+
+/*        end of the outer loop. */
+
+    }
+TERMINATE:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	info = iflag;
+    }
+    if (nprint > 0) {
+	fcnder_mn(p, m, n, x, fvec, fjac, ldfjac, 0);
+    }
+    return info;
+
+/*     last card of subroutine lmder. */
+
+} /* lmder_ */
+
diff --git a/lmder1.c b/lmder1.c
new file mode 100644
index 0000000..581462e
--- /dev/null
+++ b/lmder1.c
@@ -0,0 +1,167 @@
+#include "cminpack.h"
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(lmder1)(__cminpack_decl_fcnder_mn__ void *p, int m, int n, real *x, 
+	real *fvec, real *fjac, int ldfjac, real tol, 
+	int *ipvt, real *wa, int lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* Local variables */
+    int mode, nfev, njev;
+    real ftol, gtol, xtol;
+    int maxfev, nprint;
+    int info;
+
+/*     ********** */
+
+/*     subroutine lmder1 */
+
+/*     the purpose of lmder1 is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of the */
+/*     levenberg-marquardt algorithm. this is done by using the more */
+/*     general least-squares solver lmder. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */
+/*                         ipvt,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer m,n,ldfjac,iflag */
+/*         double precision x(n),fvec(m),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmder1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output m by n array. the upper n by n submatrix */
+/*         of fjac contains an upper triangular matrix r with */
+/*         diagonal elements of nonincreasing magnitude such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower trapezoidal */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates either that the relative */
+/*         error in the sum of squares is at most tol or that */
+/*         the relative error between x and the solution is at */
+/*         most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  algorithm estimates that the relative error */
+/*                   in the sum of squares is at most tol. */
+
+/*         info = 2  algorithm estimates that the relative error */
+/*                   between x and the solution is at most tol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  fvec is orthogonal to the columns of the */
+/*                   jacobian to machine precision. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached 100*(n+1). */
+
+/*         info = 6  tol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  tol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular */
+/*         with diagonal elements of nonincreasing magnitude. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than 5*n+m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... lmder */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || m < n || ldfjac < m || tol < 0. || lwa < n * 5 + m) {
+        return 0;
+    }
+
+/*     call lmder. */
+
+    maxfev = (n + 1) * 100;
+    ftol = tol;
+    xtol = tol;
+    gtol = 0.;
+    mode = 1;
+    nprint = 0;
+    info = __cminpack_func__(lmder)(__cminpack_param_fcnder_mn__ p, m, n, x, fvec, fjac, ldfjac,
+	    ftol, xtol, gtol, maxfev, wa, mode, factor, nprint, 
+	    &nfev, &njev, ipvt, &wa[n], &wa[(n << 1)], &
+	    wa[n * 3], &wa[(n << 2)], &wa[n * 5]);
+    if (info == 8) {
+	info = 4;
+    }
+    return info;
+
+/*     last card of subroutine lmder1. */
+
+} /* lmder1_ */
+
diff --git a/lmder1_.c b/lmder1_.c
new file mode 100644
index 0000000..bc6ca45
--- /dev/null
+++ b/lmder1_.c
@@ -0,0 +1,189 @@
+/* lmder1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+__minpack_attr__
+void __minpack_func__(lmder1)(__minpack_decl_fcnder_mn__ const int *m, const int *n, real *x, 
+	real *fvec, real *fjac, const int *ldfjac, const real *tol, 
+	int *info, int *ipvt, real *wa, const int *lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset;
+
+    /* Local variables */
+    int mode, nfev, njev;
+    real ftol, gtol, xtol;
+    int maxfev, nprint;
+
+/*     ********** */
+
+/*     subroutine lmder1 */
+
+/*     the purpose of lmder1 is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of the */
+/*     levenberg-marquardt algorithm. this is done by using the more */
+/*     general least-squares solver lmder. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */
+/*                         ipvt,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer m,n,ldfjac,iflag */
+/*         double precision x(n),fvec(m),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmder1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output m by n array. the upper n by n submatrix */
+/*         of fjac contains an upper triangular matrix r with */
+/*         diagonal elements of nonincreasing magnitude such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower trapezoidal */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates either that the relative */
+/*         error in the sum of squares is at most tol or that */
+/*         the relative error between x and the solution is at */
+/*         most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  algorithm estimates that the relative error */
+/*                   in the sum of squares is at most tol. */
+
+/*         info = 2  algorithm estimates that the relative error */
+/*                   between x and the solution is at most tol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  fvec is orthogonal to the columns of the */
+/*                   jacobian to machine precision. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached 100*(n+1). */
+
+/*         info = 6  tol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  tol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular */
+/*         with diagonal elements of nonincreasing magnitude. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than 5*n+m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... lmder */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --ipvt;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --wa;
+
+    /* Function Body */
+    *info = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *m < *n || *ldfjac < *m || *tol < 0. || *lwa < *n * 5 + *
+	    m) {
+	/* goto L10; */
+        return;
+    }
+
+/*     call lmder. */
+
+    maxfev = (*n + 1) * 100;
+    ftol = *tol;
+    xtol = *tol;
+    gtol = 0.;
+    mode = 1;
+    nprint = 0;
+    __minpack_func__(lmder)(__minpack_param_fcnder_mn__ m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &
+	    ftol, &xtol, &gtol, &maxfev, &wa[1], &mode, &factor, &nprint, 
+	    info, &nfev, &njev, &ipvt[1], &wa[*n + 1], &wa[(*n << 1) + 1], &
+	    wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]);
+    if (*info == 8) {
+	*info = 4;
+    }
+/* L10: */
+    return;
+
+/*     last card of subroutine lmder1. */
+
+} /* lmder1_ */
+
diff --git a/lmder_.c b/lmder_.c
new file mode 100644
index 0000000..28ebe8c
--- /dev/null
+++ b/lmder_.c
@@ -0,0 +1,626 @@
+/* lmder.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(lmder)(__minpack_decl_fcnder_mn__ const int *m, const int *n, real *x, 
+	real *fvec, real *fjac, const int *ldfjac, const real *ftol,
+	const real *xtol, const real *gtol, const int *maxfev, real *
+	diag, const int *mode, const real *factor, const int *nprint, int *
+	info, int *nfev, int *njev, int *ipvt, real *qtf, 
+	real *wa1, real *wa2, real *wa3, real *wa4)
+{
+    /* Table of constant values */
+
+    const int c__1 = 1;
+    const int c_true = TRUE_;
+
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p25 .25
+#define p75 .75
+#define p0001 1e-4
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+    real d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__, j, l;
+    real par, sum;
+    int iter;
+    real temp, temp1, temp2;
+    int iflag;
+    real delta;
+    real ratio;
+    real fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, 
+	    epsmch, prered;
+
+/*     ********** */
+
+/*     subroutine lmder */
+
+/*     the purpose of lmder is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */
+/*                        maxfev,diag,mode,factor,nprint,info,nfev, */
+/*                        njev,ipvt,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer m,n,ldfjac,iflag */
+/*         double precision x(n),fvec(m),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmder. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output m by n array. the upper n by n submatrix */
+/*         of fjac contains an upper triangular matrix r with */
+/*         diagonal elements of nonincreasing magnitude such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower trapezoidal */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       ftol is a nonnegative input variable. termination */
+/*         occurs when both the actual and predicted relative */
+/*         reductions in the sum of squares are at most ftol. */
+/*         therefore, ftol measures the relative error desired */
+/*         in the sum of squares. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. therefore, xtol measures the */
+/*         relative error desired in the approximate solution. */
+
+/*       gtol is a nonnegative input variable. termination */
+/*         occurs when the cosine of the angle between fvec and */
+/*         any column of the jacobian is at most gtol in absolute */
+/*         value. therefore, gtol measures the orthogonality */
+/*         desired between the function vector and the columns */
+/*         of the jacobian. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.).100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x, fvec, and fjac */
+/*         available for printing. fvec and fjac should not be */
+/*         altered. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  both actual and predicted relative reductions */
+/*                   in the sum of squares are at most ftol. */
+
+/*         info = 2  relative error between two consecutive iterates */
+/*                   is at most xtol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  the cosine of the angle between fvec and any */
+/*                   column of the jacobian is at most gtol in */
+/*                   absolute value. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached maxfev. */
+
+/*         info = 6  ftol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  xtol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*         info = 8  gtol is too small. fvec is orthogonal to the */
+/*                   columns of the jacobian to machine precision. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular */
+/*         with diagonal elements of nonincreasing magnitude. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       qtf is an output array of length n which contains */
+/*         the first n elements of the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, and wa3 are work arrays of length n. */
+
+/*       wa4 is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,lmpar,qrfac */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --fvec;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --ipvt;
+    --diag;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    *info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *m < *n || *ldfjac < *m || *ftol < 0. || *xtol < 0. || 
+	    *gtol < 0. || *maxfev <= 0 || *factor <= 0.) {
+	goto L300;
+    }
+    if (*mode != 2) {
+	goto L20;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (diag[j] <= 0.) {
+	    goto L300;
+	}
+/* L10: */
+    }
+L20:
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = 1;
+    fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm = __minpack_func__(enorm)(m, &fvec[1]);
+
+/*     initialize levenberg-marquardt parameter and iteration counter. */
+
+    par = 0.;
+    iter = 1;
+
+/*     beginning of the outer loop. */
+
+L30:
+
+/*        calculate the jacobian matrix. */
+
+    iflag = 2;
+    fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    ++(*njev);
+    if (iflag < 0) {
+	goto L300;
+    }
+
+/*        if requested, call fcn to enable printing of iterates. */
+
+    if (*nprint <= 0) {
+	goto L40;
+    }
+    iflag = 0;
+    if ((iter - 1) % *nprint == 0) {
+	fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    }
+    if (iflag < 0) {
+	goto L300;
+    }
+L40:
+
+/*        compute the qr factorization of the jacobian. */
+
+    __minpack_func__(qrfac)(m, n, &fjac[fjac_offset], ldfjac, &c_true, &ipvt[1], n, &wa1[1], &
+	    wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+    if (iter != 1) {
+	goto L80;
+    }
+    if (*mode == 2) {
+	goto L60;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	diag[j] = wa2[j];
+	if (wa2[j] == 0.) {
+	    diag[j] = 1.;
+	}
+/* L50: */
+    }
+L60:
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = diag[j] * x[j];
+/* L70: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa3[1]);
+    delta = *factor * xnorm;
+    if (delta == 0.) {
+	delta = *factor;
+    }
+L80:
+
+/*        form (q transpose)*fvec and store the first n components in */
+/*        qtf. */
+
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	wa4[i__] = fvec[i__];
+/* L90: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    goto L120;
+	}
+	sum = 0.;
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * wa4[i__];
+/* L100: */
+	}
+	temp = -sum / fjac[j + j * fjac_dim1];
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    wa4[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L110: */
+	}
+L120:
+	fjac[j + j * fjac_dim1] = wa1[j];
+	qtf[j] = wa4[j];
+/* L130: */
+    }
+
+/*        compute the norm of the scaled gradient. */
+
+    gnorm = 0.;
+    if (fnorm == 0.) {
+	goto L170;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	if (wa2[l] == 0.) {
+	    goto L150;
+	}
+	sum = 0.;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * (qtf[i__] / fnorm);
+/* L140: */
+	}
+/* Computing MAX */
+	d__2 = gnorm, d__3 = fabs(sum / wa2[l]);
+	gnorm = max(d__2,d__3);
+L150:
+/* L160: */
+	;
+    }
+L170:
+
+/*        test for convergence of the gradient norm. */
+
+    if (gnorm <= *gtol) {
+	*info = 4;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*        rescale if necessary. */
+
+    if (*mode == 2) {
+	goto L190;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MAX */
+	d__1 = diag[j], d__2 = wa2[j];
+	diag[j] = max(d__1,d__2);
+/* L180: */
+    }
+L190:
+
+/*        beginning of the inner loop. */
+
+L200:
+
+/*           determine the levenberg-marquardt parameter. */
+
+    __minpack_func__(lmpar)(n, &fjac[fjac_offset], ldfjac, &ipvt[1], &diag[1], &qtf[1], &delta,
+	     &par, &wa1[1], &wa2[1], &wa3[1], &wa4[1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = -wa1[j];
+	wa2[j] = x[j] + wa1[j];
+	wa3[j] = diag[j] * wa1[j];
+/* L210: */
+    }
+    pnorm = __minpack_func__(enorm)(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+    if (iter == 1) {
+	delta = min(delta,pnorm);
+    }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+    iflag = 1;
+    fcnder_mn(m, n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, &iflag);
+    ++(*nfev);
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm1 = __minpack_func__(enorm)(m, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+    actred = -1.;
+    if (p1 * fnorm1 < fnorm) {
+/* Computing 2nd power */
+	d__1 = fnorm1 / fnorm;
+	actred = 1. - d__1 * d__1;
+    }
+
+/*           compute the scaled predicted reduction and */
+/*           the scaled directional derivative. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = 0.;
+	l = ipvt[j];
+	temp = wa1[l];
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    wa3[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L220: */
+	}
+/* L230: */
+    }
+    temp1 = __minpack_func__(enorm)(n, &wa3[1]) / fnorm;
+    temp2 = sqrt(par) * pnorm / fnorm;
+/* Computing 2nd power */
+    d__1 = temp1;
+/* Computing 2nd power */
+    d__2 = temp2;
+    prered = d__1 * d__1 + d__2 * d__2 / p5;
+/* Computing 2nd power */
+    d__1 = temp1;
+/* Computing 2nd power */
+    d__2 = temp2;
+    dirder = -(d__1 * d__1 + d__2 * d__2);
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+    ratio = 0.;
+    if (prered != 0.) {
+	ratio = actred / prered;
+    }
+
+/*           update the step bound. */
+
+    if (ratio > p25) {
+	goto L240;
+    }
+    if (actred >= 0.) {
+	temp = p5;
+    }
+    if (actred < 0.) {
+	temp = p5 * dirder / (dirder + p5 * actred);
+    }
+    if (p1 * fnorm1 >= fnorm || temp < p1) {
+	temp = p1;
+    }
+/* Computing MIN */
+    d__1 = delta, d__2 = pnorm / p1;
+    delta = temp * min(d__1,d__2);
+    par /= temp;
+    goto L260;
+L240:
+    if (par != 0. && ratio < p75) {
+	goto L250;
+    }
+    delta = pnorm / p5;
+    par = p5 * par;
+L250:
+L260:
+
+/*           test for successful iteration. */
+
+    if (ratio < p0001) {
+	goto L290;
+    }
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = wa2[j];
+	wa2[j] = diag[j] * x[j];
+/* L270: */
+    }
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	fvec[i__] = wa4[i__];
+/* L280: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fnorm = fnorm1;
+    ++iter;
+L290:
+
+/*           tests for convergence. */
+
+    if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1.) {
+	*info = 1;
+    }
+    if (delta <= *xtol * xnorm) {
+	*info = 2;
+    }
+    if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1. && *info 
+	    == 2) {
+	*info = 3;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           tests for termination and stringent tolerances. */
+
+    if (*nfev >= *maxfev) {
+	*info = 5;
+    }
+    if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+	*info = 6;
+    }
+    if (delta <= epsmch * xnorm) {
+	*info = 7;
+    }
+    if (gnorm <= epsmch) {
+	*info = 8;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           end of the inner loop. repeat if iteration unsuccessful. */
+
+    if (ratio < p0001) {
+	goto L200;
+    }
+
+/*        end of the outer loop. */
+
+    goto L30;
+L300:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	*info = iflag;
+    }
+    iflag = 0;
+    if (*nprint > 0) {
+	fcnder_mn(m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag);
+    }
+    return;
+
+/*     last card of subroutine lmder. */
+
+} /* lmder_ */
+
diff --git a/lmdif.c b/lmdif.c
new file mode 100644
index 0000000..fede3b6
--- /dev/null
+++ b/lmdif.c
@@ -0,0 +1,530 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(lmdif)(__cminpack_decl_fcn_mn__ void *p, int m, int n, real *x, 
+	real *fvec, real ftol, real xtol, real
+	gtol, int maxfev, real epsfcn, real *diag, int
+	mode, real factor, int nprint, int *
+	nfev, real *fjac, int ldfjac, int *ipvt, real *
+	qtf, real *wa1, real *wa2, real *wa3, real *
+	wa4)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p25 .25
+#define p75 .75
+#define p0001 1e-4
+
+    /* System generated locals */
+    real d1, d2;
+
+    /* Local variables */
+    int i, j, l;
+    real par, sum;
+    int iter;
+    real temp, temp1, temp2;
+    int iflag;
+    real delta = 0.;
+    real ratio;
+    real fnorm, gnorm;
+    real pnorm, xnorm = 0., fnorm1, actred, dirder, epsmch, prered;
+    int info;
+
+/*     ********** */
+
+/*     subroutine lmdif */
+
+/*     the purpose of lmdif is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm. the user must provide a */
+/*     subroutine which calculates the functions. the jacobian is */
+/*     then calculated by a forward-difference approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, */
+/*                        diag,mode,factor,nprint,info,nfev,fjac, */
+/*                        ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmdif. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       ftol is a nonnegative input variable. termination */
+/*         occurs when both the actual and predicted relative */
+/*         reductions in the sum of squares are at most ftol. */
+/*         therefore, ftol measures the relative error desired */
+/*         in the sum of squares. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. therefore, xtol measures the */
+/*         relative error desired in the approximate solution. */
+
+/*       gtol is a nonnegative input variable. termination */
+/*         occurs when the cosine of the angle between fvec and */
+/*         any column of the jacobian is at most gtol in absolute */
+/*         value. therefore, gtol measures the orthogonality */
+/*         desired between the function vector and the columns */
+/*         of the jacobian. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn is at least */
+/*         maxfev by the end of an iteration. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  both actual and predicted relative reductions */
+/*                   in the sum of squares are at most ftol. */
+
+/*         info = 2  relative error between two consecutive iterates */
+/*                   is at most xtol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  the cosine of the angle between fvec and any */
+/*                   column of the jacobian is at most gtol in */
+/*                   absolute value. */
+
+/*         info = 5  number of calls to fcn has reached or */
+/*                   exceeded maxfev. */
+
+/*         info = 6  ftol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  xtol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*         info = 8  gtol is too small. fvec is orthogonal to the */
+/*                   columns of the jacobian to machine precision. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn. */
+
+/*       fjac is an output m by n array. the upper n by n submatrix */
+/*         of fjac contains an upper triangular matrix r with */
+/*         diagonal elements of nonincreasing magnitude such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower trapezoidal */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular */
+/*         with diagonal elements of nonincreasing magnitude. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       qtf is an output array of length n which contains */
+/*         the first n elements of the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, and wa3 are work arrays of length n. */
+
+/*       wa4 is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,fdjac2,lmpar,qrfac */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    info = 0;
+    iflag = 0;
+    *nfev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || m < n || ldfjac < m || ftol < 0. || xtol < 0. || 
+	    gtol < 0. || maxfev <= 0 || factor <= 0.) {
+	goto TERMINATE;
+    }
+    if (mode == 2) {
+        for (j = 0; j < n; ++j) {
+            if (diag[j] <= 0.) {
+                goto TERMINATE;
+            }
+        }
+    }
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = fcn_mn(p, m, n, x, fvec, 1);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto TERMINATE;
+    }
+    fnorm = __cminpack_enorm__(m, fvec);
+
+/*     initialize levenberg-marquardt parameter and iteration counter. */
+
+    par = 0.;
+    iter = 1;
+
+/*     beginning of the outer loop. */
+
+    for (;;) {
+
+/*        calculate the jacobian matrix. */
+
+        iflag = __cminpack_func__(fdjac2)(__cminpack_param_fcn_mn__ p, m, n, x, fvec, fjac, ldfjac,
+                       epsfcn, wa4);
+        *nfev += n;
+        if (iflag < 0) {
+            goto TERMINATE;
+        }
+
+/*        if requested, call fcn to enable printing of iterates. */
+
+        if (nprint > 0) {
+            iflag = 0;
+            if ((iter - 1) % nprint == 0) {
+                iflag = fcn_mn(p, m, n, x, fvec, 0);
+            }
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+        }
+
+/*        compute the qr factorization of the jacobian. */
+
+        __cminpack_func__(qrfac)(m, n, fjac, ldfjac, TRUE_, ipvt, n,
+              wa1, wa2, wa3);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+        if (iter == 1) {
+            if (mode != 2) {
+                for (j = 0; j < n; ++j) {
+                    diag[j] = wa2[j];
+                    if (wa2[j] == 0.) {
+                        diag[j] = 1.;
+                    }
+                }
+            }
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+            for (j = 0; j < n; ++j) {
+                wa3[j] = diag[j] * x[j];
+            }
+            xnorm = __cminpack_enorm__(n, wa3);
+            delta = factor * xnorm;
+            if (delta == 0.) {
+                delta = factor;
+            }
+        }
+
+/*        form (q transpose)*fvec and store the first n components in */
+/*        qtf. */
+
+        for (i = 0; i < m; ++i) {
+            wa4[i] = fvec[i];
+        }
+        for (j = 0; j < n; ++j) {
+            if (fjac[j + j * ldfjac] != 0.) {
+                sum = 0.;
+                for (i = j; i < m; ++i) {
+                    sum += fjac[i + j * ldfjac] * wa4[i];
+                }
+                temp = -sum / fjac[j + j * ldfjac];
+                for (i = j; i < m; ++i) {
+                    wa4[i] += fjac[i + j * ldfjac] * temp;
+                }
+            }
+            fjac[j + j * ldfjac] = wa1[j];
+            qtf[j] = wa4[j];
+        }
+
+/*        compute the norm of the scaled gradient. */
+
+        gnorm = 0.;
+        if (fnorm != 0.) {
+            for (j = 0; j < n; ++j) {
+                l = ipvt[j]-1;
+                if (wa2[l] != 0.) {
+                    sum = 0.;
+                    for (i = 0; i <= j; ++i) {
+                        sum += fjac[i + j * ldfjac] * (qtf[i] / fnorm);
+                    }
+                    /* Computing MAX */
+                    d1 = fabs(sum / wa2[l]);
+                    gnorm = max(gnorm,d1);
+                }
+            }
+        }
+
+/*        test for convergence of the gradient norm. */
+
+        if (gnorm <= gtol) {
+            info = 4;
+        }
+        if (info != 0) {
+            goto TERMINATE;
+        }
+
+/*        rescale if necessary. */
+
+        if (mode != 2) {
+            for (j = 0; j < n; ++j) {
+                /* Computing MAX */
+                d1 = diag[j], d2 = wa2[j];
+                diag[j] = max(d1,d2);
+            }
+        }
+
+/*        beginning of the inner loop. */
+
+        do {
+
+/*           determine the levenberg-marquardt parameter. */
+
+            __cminpack_func__(lmpar)(n, fjac, ldfjac, ipvt, diag, qtf, delta,
+                  &par, wa1, wa2, wa3, wa4);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+            for (j = 0; j < n; ++j) {
+                wa1[j] = -wa1[j];
+                wa2[j] = x[j] + wa1[j];
+                wa3[j] = diag[j] * wa1[j];
+            }
+            pnorm = __cminpack_enorm__(n, wa3);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+            if (iter == 1) {
+                delta = min(delta,pnorm);
+            }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+            iflag = fcn_mn(p, m, n, wa2, wa4, 1);
+            ++(*nfev);
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+            fnorm1 = __cminpack_enorm__(m, wa4);
+
+/*           compute the scaled actual reduction. */
+
+            actred = -1.;
+            if (p1 * fnorm1 < fnorm) {
+                /* Computing 2nd power */
+                d1 = fnorm1 / fnorm;
+                actred = 1. - d1 * d1;
+            }
+
+/*           compute the scaled predicted reduction and */
+/*           the scaled directional derivative. */
+
+            for (j = 0; j < n; ++j) {
+                wa3[j] = 0.;
+                l = ipvt[j]-1;
+                temp = wa1[l];
+                for (i = 0; i <= j; ++i) {
+                    wa3[i] += fjac[i + j * ldfjac] * temp;
+                }
+            }
+            temp1 = __cminpack_enorm__(n, wa3) / fnorm;
+            temp2 = (sqrt(par) * pnorm) / fnorm;
+            prered = temp1 * temp1 + temp2 * temp2 / p5;
+            dirder = -(temp1 * temp1 + temp2 * temp2);
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+            ratio = 0.;
+            if (prered != 0.) {
+                ratio = actred / prered;
+            }
+
+/*           update the step bound. */
+
+            if (ratio <= p25) {
+                if (actred >= 0.) {
+                    temp = p5;
+                } else {
+                    temp = p5 * dirder / (dirder + p5 * actred);
+                }
+                if (p1 * fnorm1 >= fnorm || temp < p1) {
+                    temp = p1;
+                }
+                /* Computing MIN */
+                d1 = pnorm / p1;
+                delta = temp * min(delta,d1);
+                par /= temp;
+            } else {
+                if (par == 0. || ratio >= p75) {
+                    delta = pnorm / p5;
+                    par = p5 * par;
+                }
+            }
+
+/*           test for successful iteration. */
+
+            if (ratio >= p0001) {
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+                for (j = 0; j < n; ++j) {
+                    x[j] = wa2[j];
+                    wa2[j] = diag[j] * x[j];
+                }
+                for (i = 0; i < m; ++i) {
+                    fvec[i] = wa4[i];
+                }
+                xnorm = __cminpack_enorm__(n, wa2);
+                fnorm = fnorm1;
+                ++iter;
+            }
+
+/*           tests for convergence. */
+
+            if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) {
+                info = 1;
+            }
+            if (delta <= xtol * xnorm) {
+                info = 2;
+            }
+            if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) {
+                info = 3;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           tests for termination and stringent tolerances. */
+
+            if (*nfev >= maxfev) {
+                info = 5;
+            }
+            if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+                info = 6;
+            }
+            if (delta <= epsmch * xnorm) {
+                info = 7;
+            }
+            if (gnorm <= epsmch) {
+                info = 8;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           end of the inner loop. repeat if iteration unsuccessful. */
+
+        } while (ratio < p0001);
+
+/*        end of the outer loop. */
+
+    }
+TERMINATE:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	info = iflag;
+    }
+    if (nprint > 0) {
+	fcn_mn(p, m, n, x, fvec, 0);
+    }
+    return info;
+
+/*     last card of subroutine lmdif. */
+
+} /* lmdif_ */
+
diff --git a/lmdif1.c b/lmdif1.c
new file mode 100644
index 0000000..6a3dd05
--- /dev/null
+++ b/lmdif1.c
@@ -0,0 +1,147 @@
+#include "cminpack.h"
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(lmdif1)(__cminpack_decl_fcn_mn__ void *p, int m, int n, real *x, 
+	real *fvec, real tol, int *iwa, 
+	real *wa, int lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    int mp5n, mode, nfev;
+    real ftol, gtol, xtol;
+    real epsfcn;
+    int maxfev, nprint;
+    int info;
+
+/*     ********** */
+
+/*     subroutine lmdif1 */
+
+/*     the purpose of lmdif1 is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of the */
+/*     levenberg-marquardt algorithm. this is done by using the more */
+/*     general least-squares solver lmdif. the user must provide a */
+/*     subroutine which calculates the functions. the jacobian is */
+/*     then calculated by a forward-difference approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmdif1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates either that the relative */
+/*         error in the sum of squares is at most tol or that */
+/*         the relative error between x and the solution is at */
+/*         most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  algorithm estimates that the relative error */
+/*                   in the sum of squares is at most tol. */
+
+/*         info = 2  algorithm estimates that the relative error */
+/*                   between x and the solution is at most tol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  fvec is orthogonal to the columns of the */
+/*                   jacobian to machine precision. */
+
+/*         info = 5  number of calls to fcn has reached or */
+/*                   exceeded 200*(n+1). */
+
+/*         info = 6  tol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  tol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*       iwa is an integer work array of length n. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than */
+/*         m*n+5*n+m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... lmdif */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || m < n || tol < 0. || lwa < m * n + n * 5 + m) {
+        return 0;
+    }
+
+/*     call lmdif. */
+
+    maxfev = (n + 1) * 200;
+    ftol = tol;
+    xtol = tol;
+    gtol = 0.;
+    epsfcn = 0.;
+    mode = 1;
+    nprint = 0;
+    mp5n = m + n * 5;
+    info = __cminpack_func__(lmdif)(__cminpack_param_fcn_mn__ p, m, n, x, fvec, ftol, xtol, gtol, maxfev,
+	    epsfcn, wa, mode, factor, nprint, &nfev, &wa[mp5n],
+            m, iwa, &wa[n], &wa[(n << 1)], &wa[n * 3], 
+	    &wa[(n << 2)], &wa[n * 5]);
+    if (info == 8) {
+	info = 4;
+    }
+    return info;
+
+/*     last card of subroutine lmdif1. */
+
+} /* lmdif1_ */
+
diff --git a/lmdif1_.c b/lmdif1_.c
new file mode 100644
index 0000000..d6270fc
--- /dev/null
+++ b/lmdif1_.c
@@ -0,0 +1,162 @@
+/* lmdif1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+__minpack_attr__
+void __minpack_func__(lmdif1)(__minpack_decl_fcn_mn__  const int *m, const int *n, real *x, 
+	real *fvec, const real *tol, int *info, int *iwa, 
+	real *wa, const int *lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    int mp5n, mode, nfev;
+    real ftol, gtol, xtol;
+    real epsfcn;
+    int maxfev, nprint;
+
+/*     ********** */
+
+/*     subroutine lmdif1 */
+
+/*     the purpose of lmdif1 is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of the */
+/*     levenberg-marquardt algorithm. this is done by using the more */
+/*     general least-squares solver lmdif. the user must provide a */
+/*     subroutine which calculates the functions. the jacobian is */
+/*     then calculated by a forward-difference approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmdif1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates either that the relative */
+/*         error in the sum of squares is at most tol or that */
+/*         the relative error between x and the solution is at */
+/*         most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  algorithm estimates that the relative error */
+/*                   in the sum of squares is at most tol. */
+
+/*         info = 2  algorithm estimates that the relative error */
+/*                   between x and the solution is at most tol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  fvec is orthogonal to the columns of the */
+/*                   jacobian to machine precision. */
+
+/*         info = 5  number of calls to fcn has reached or */
+/*                   exceeded 200*(n+1). */
+
+/*         info = 6  tol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  tol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*       iwa is an integer work array of length n. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than */
+/*         m*n+5*n+m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... lmdif */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --iwa;
+    --x;
+    --wa;
+
+    /* Function Body */
+    *info = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *m < *n || *tol < 0. || *lwa < *m * *n + *n * 5 + *m) {
+	/* goto L10; */
+        return;
+    }
+
+/*     call lmdif. */
+
+    maxfev = (*n + 1) * 200;
+    ftol = *tol;
+    xtol = *tol;
+    gtol = 0.;
+    epsfcn = 0.;
+    mode = 1;
+    nprint = 0;
+    mp5n = *m + *n * 5;
+    __minpack_func__(lmdif)(__minpack_param_fcn_mn__ m, n, &x[1], &fvec[1], &ftol, &xtol, &gtol, &maxfev, &
+	    epsfcn, &wa[1], &mode, &factor, &nprint, info, &nfev, &wa[mp5n + 
+	    1], m, &iwa[1], &wa[*n + 1], &wa[(*n << 1) + 1], &wa[*n * 3 + 1], 
+	    &wa[(*n << 2) + 1], &wa[*n * 5 + 1]);
+    if (*info == 8) {
+	*info = 4;
+    }
+/* L10: */
+    return;
+
+/*     last card of subroutine lmdif1. */
+
+} /* lmdif1_ */
+
diff --git a/lmdif_.c b/lmdif_.c
new file mode 100644
index 0000000..240d6ba
--- /dev/null
+++ b/lmdif_.c
@@ -0,0 +1,630 @@
+/* lmdif.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(lmdif)(__minpack_decl_fcn_mn__ const int *m, const int *n, real *x, 
+	real *fvec, const real *ftol, const real *xtol, const real *
+	gtol, const int *maxfev, const real *epsfcn, real *diag, const int *
+	mode, const real *factor, const int *nprint, int *info, int *
+	nfev, real *fjac, const int *ldfjac, int *ipvt, real *
+	qtf, real *wa1, real *wa2, real *wa3, real *
+	wa4)
+{
+    /* Table of constant values */
+
+    const int c__1 = 1;
+    const int c_true = TRUE_;
+
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p25 .25
+#define p75 .75
+#define p0001 1e-4
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+    real d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__, j, l;
+    real par, sum;
+    int iter;
+    real temp, temp1, temp2;
+    int iflag;
+    real delta;
+    real ratio;
+    real fnorm, gnorm;
+    real pnorm, xnorm, fnorm1, actred, dirder, epsmch, prered;
+
+/*     ********** */
+
+/*     subroutine lmdif */
+
+/*     the purpose of lmdif is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm. the user must provide a */
+/*     subroutine which calculates the functions. the jacobian is */
+/*     then calculated by a forward-difference approximation. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn, */
+/*                        diag,mode,factor,nprint,info,nfev,fjac, */
+/*                        ldfjac,ipvt,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions. fcn must be declared */
+/*         in an external statement in the user calling */
+/*         program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m) */
+/*         ---------- */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmdif. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       ftol is a nonnegative input variable. termination */
+/*         occurs when both the actual and predicted relative */
+/*         reductions in the sum of squares are at most ftol. */
+/*         therefore, ftol measures the relative error desired */
+/*         in the sum of squares. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. therefore, xtol measures the */
+/*         relative error desired in the approximate solution. */
+
+/*       gtol is a nonnegative input variable. termination */
+/*         occurs when the cosine of the angle between fvec and */
+/*         any column of the jacobian is at most gtol in absolute */
+/*         value. therefore, gtol measures the orthogonality */
+/*         desired between the function vector and the columns */
+/*         of the jacobian. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn is at least */
+/*         maxfev by the end of an iteration. */
+
+/*       epsfcn is an input variable used in determining a suitable */
+/*         step length for the forward-difference approximation. this */
+/*         approximation assumes that the relative errors in the */
+/*         functions are of the order of epsfcn. if epsfcn is less */
+/*         than the machine precision, it is assumed that the relative */
+/*         errors in the functions are of the order of the machine */
+/*         precision. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  both actual and predicted relative reductions */
+/*                   in the sum of squares are at most ftol. */
+
+/*         info = 2  relative error between two consecutive iterates */
+/*                   is at most xtol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  the cosine of the angle between fvec and any */
+/*                   column of the jacobian is at most gtol in */
+/*                   absolute value. */
+
+/*         info = 5  number of calls to fcn has reached or */
+/*                   exceeded maxfev. */
+
+/*         info = 6  ftol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  xtol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*         info = 8  gtol is too small. fvec is orthogonal to the */
+/*                   columns of the jacobian to machine precision. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn. */
+
+/*       fjac is an output m by n array. the upper n by n submatrix */
+/*         of fjac contains an upper triangular matrix r with */
+/*         diagonal elements of nonincreasing magnitude such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower trapezoidal */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular */
+/*         with diagonal elements of nonincreasing magnitude. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       qtf is an output array of length n which contains */
+/*         the first n elements of the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, and wa3 are work arrays of length n. */
+
+/*       wa4 is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,fdjac2,lmpar,qrfac */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --fvec;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --ipvt;
+    --diag;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    *info = 0;
+    iflag = 0;
+    *nfev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *m < *n || *ldfjac < *m || *ftol < 0. || *xtol < 0. || 
+	    *gtol < 0. || *maxfev <= 0 || *factor <= 0.) {
+	goto L300;
+    }
+    if (*mode != 2) {
+	goto L20;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (diag[j] <= 0.) {
+	    goto L300;
+	}
+/* L10: */
+    }
+L20:
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = 1;
+    fcn_mn(m, n, &x[1], &fvec[1], &iflag);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm = __minpack_func__(enorm)(m, &fvec[1]);
+
+/*     initialize levenberg-marquardt parameter and iteration counter. */
+
+    par = 0.;
+    iter = 1;
+
+/*     beginning of the outer loop. */
+
+L30:
+
+/*        calculate the jacobian matrix. */
+
+    iflag = 2;
+    __minpack_func__(fdjac2)(__minpack_param_fcn_mn__ m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &
+	    iflag, epsfcn, &wa4[1]);
+    *nfev += *n;
+    if (iflag < 0) {
+	goto L300;
+    }
+
+/*        if requested, call fcn to enable printing of iterates. */
+
+    if (*nprint <= 0) {
+	goto L40;
+    }
+    iflag = 0;
+    if ((iter - 1) % *nprint == 0) {
+	fcn_mn(m, n, &x[1], &fvec[1], &iflag);
+    }
+    if (iflag < 0) {
+	goto L300;
+    }
+L40:
+
+/*        compute the qr factorization of the jacobian. */
+
+    __minpack_func__(qrfac)(m, n, &fjac[fjac_offset], ldfjac, &c_true, &ipvt[1], n, &wa1[1], &
+	    wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+    if (iter != 1) {
+	goto L80;
+    }
+    if (*mode == 2) {
+	goto L60;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	diag[j] = wa2[j];
+	if (wa2[j] == 0.) {
+	    diag[j] = 1.;
+	}
+/* L50: */
+    }
+L60:
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = diag[j] * x[j];
+/* L70: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa3[1]);
+    delta = *factor * xnorm;
+    if (delta == 0.) {
+	delta = *factor;
+    }
+L80:
+
+/*        form (q transpose)*fvec and store the first n components in */
+/*        qtf. */
+
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	wa4[i__] = fvec[i__];
+/* L90: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    goto L120;
+	}
+	sum = 0.;
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * wa4[i__];
+/* L100: */
+	}
+	temp = -sum / fjac[j + j * fjac_dim1];
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    wa4[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L110: */
+	}
+L120:
+	fjac[j + j * fjac_dim1] = wa1[j];
+	qtf[j] = wa4[j];
+/* L130: */
+    }
+
+/*        compute the norm of the scaled gradient. */
+
+    gnorm = 0.;
+    if (fnorm == 0.) {
+	goto L170;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	if (wa2[l] == 0.) {
+	    goto L150;
+	}
+	sum = 0.;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * (qtf[i__] / fnorm);
+/* L140: */
+	}
+/* Computing MAX */
+	d__2 = gnorm, d__3 = fabs(sum / wa2[l]);
+	gnorm = max(d__2,d__3);
+L150:
+/* L160: */
+	;
+    }
+L170:
+
+/*        test for convergence of the gradient norm. */
+
+    if (gnorm <= *gtol) {
+	*info = 4;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*        rescale if necessary. */
+
+    if (*mode == 2) {
+	goto L190;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MAX */
+	d__1 = diag[j], d__2 = wa2[j];
+	diag[j] = max(d__1,d__2);
+/* L180: */
+    }
+L190:
+
+/*        beginning of the inner loop. */
+
+L200:
+
+/*           determine the levenberg-marquardt parameter. */
+
+    __minpack_func__(lmpar)(n, &fjac[fjac_offset], ldfjac, &ipvt[1], &diag[1], &qtf[1], &delta,
+	     &par, &wa1[1], &wa2[1], &wa3[1], &wa4[1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = -wa1[j];
+	wa2[j] = x[j] + wa1[j];
+	wa3[j] = diag[j] * wa1[j];
+/* L210: */
+    }
+    pnorm = __minpack_func__(enorm)(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+    if (iter == 1) {
+	delta = min(delta,pnorm);
+    }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+    iflag = 1;
+    fcn_mn(m, n, &wa2[1], &wa4[1], &iflag);
+    ++(*nfev);
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm1 = __minpack_func__(enorm)(m, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+    actred = -1.;
+    if (p1 * fnorm1 < fnorm) {
+/* Computing 2nd power */
+	d__1 = fnorm1 / fnorm;
+	actred = 1. - d__1 * d__1;
+    }
+
+/*           compute the scaled predicted reduction and */
+/*           the scaled directional derivative. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = 0.;
+	l = ipvt[j];
+	temp = wa1[l];
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    wa3[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L220: */
+	}
+/* L230: */
+    }
+    temp1 = __minpack_func__(enorm)(n, &wa3[1]) / fnorm;
+    temp2 = sqrt(par) * pnorm / fnorm;
+/* Computing 2nd power */
+    d__1 = temp1;
+/* Computing 2nd power */
+    d__2 = temp2;
+    prered = d__1 * d__1 + d__2 * d__2 / p5;
+/* Computing 2nd power */
+    d__1 = temp1;
+/* Computing 2nd power */
+    d__2 = temp2;
+    dirder = -(d__1 * d__1 + d__2 * d__2);
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+    ratio = 0.;
+    if (prered != 0.) {
+	ratio = actred / prered;
+    }
+
+/*           update the step bound. */
+
+    if (ratio > p25) {
+	goto L240;
+    }
+    if (actred >= 0.) {
+	temp = p5;
+    }
+    if (actred < 0.) {
+	temp = p5 * dirder / (dirder + p5 * actred);
+    }
+    if (p1 * fnorm1 >= fnorm || temp < p1) {
+	temp = p1;
+    }
+/* Computing MIN */
+    d__1 = delta, d__2 = pnorm / p1;
+    delta = temp * min(d__1,d__2);
+    par /= temp;
+    goto L260;
+L240:
+    if (par != 0. && ratio < p75) {
+	goto L250;
+    }
+    delta = pnorm / p5;
+    par = p5 * par;
+L250:
+L260:
+
+/*           test for successful iteration. */
+
+    if (ratio < p0001) {
+	goto L290;
+    }
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = wa2[j];
+	wa2[j] = diag[j] * x[j];
+/* L270: */
+    }
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	fvec[i__] = wa4[i__];
+/* L280: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fnorm = fnorm1;
+    ++iter;
+L290:
+
+/*           tests for convergence. */
+
+    if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1.) {
+	*info = 1;
+    }
+    if (delta <= *xtol * xnorm) {
+	*info = 2;
+    }
+    if (fabs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1. && *info 
+	    == 2) {
+	*info = 3;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           tests for termination and stringent tolerances. */
+
+    if (*nfev >= *maxfev) {
+	*info = 5;
+    }
+    if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+	*info = 6;
+    }
+    if (delta <= epsmch * xnorm) {
+	*info = 7;
+    }
+    if (gnorm <= epsmch) {
+	*info = 8;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           end of the inner loop. repeat if iteration unsuccessful. */
+
+    if (ratio < p0001) {
+	goto L200;
+    }
+
+/*        end of the outer loop. */
+
+    goto L30;
+L300:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	*info = iflag;
+    }
+    iflag = 0;
+    if (*nprint > 0) {
+	fcn_mn(m, n, &x[1], &fvec[1], &iflag);
+    }
+    return;
+
+/*     last card of subroutine lmdif. */
+
+} /* lmdif_ */
+
diff --git a/lmpar.c b/lmpar.c
new file mode 100644
index 0000000..108e687
--- /dev/null
+++ b/lmpar.c
@@ -0,0 +1,338 @@
+/* lmpar.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(lmpar)(int n, real *r, int ldr, 
+	const int *ipvt, const real *diag, const real *qtb, real delta, 
+	real *par, real *x, real *sdiag, real *wa1, 
+	real *wa2)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p001 .001
+
+    /* System generated locals */
+    real d1, d2;
+
+    /* Local variables */
+    int j, l;
+    real fp;
+    real parc, parl;
+    int iter;
+    real temp, paru, dwarf;
+    int nsing;
+    real gnorm;
+    real dxnorm;
+
+/*     ********** */
+
+/*     subroutine lmpar */
+
+/*     given an m by n matrix a, an n by n nonsingular diagonal */
+/*     matrix d, an m-vector b, and a positive number delta, */
+/*     the problem is to determine a value for the parameter */
+/*     par such that if x solves the system */
+
+/*           a*x = b ,     sqrt(par)*d*x = 0 , */
+
+/*     in the least squares sense, and dxnorm is the euclidean */
+/*     norm of d*x, then either par is zero and */
+
+/*           (dxnorm-delta) .le. 0.1*delta , */
+
+/*     or par is positive and */
+
+/*           abs(dxnorm-delta) .le. 0.1*delta . */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then lmpar expects */
+/*     the full upper triangle of r, the permutation matrix p, */
+/*     and the first n components of (q transpose)*b. on output */
+/*     lmpar also provides an upper triangular matrix s such that */
+
+/*            t   t                   t */
+/*           p *(a *a + par*d*d)*p = s *s . */
+
+/*     s is employed within lmpar and may be of separate interest. */
+
+/*     only a few iterations are generally needed for convergence */
+/*     of the algorithm. if, however, the limit of 10 iterations */
+/*     is reached, then the output par will contain the best */
+/*     value obtained so far. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag, */
+/*                        wa1,wa2) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle */
+/*         must contain the full upper triangle of the matrix r. */
+/*         on output the full upper triangle is unaltered, and the */
+/*         strict lower triangle contains the strict upper triangle */
+/*         (transposed) of the upper triangular matrix s. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       delta is a positive input variable which specifies an upper */
+/*         bound on the euclidean norm of d*x. */
+
+/*       par is a nonnegative variable. on input par contains an */
+/*         initial estimate of the levenberg-marquardt parameter. */
+/*         on output par contains the final estimate. */
+
+/*       x is an output array of length n which contains the least */
+/*         squares solution of the system a*x = b, sqrt(par)*d*x = 0, */
+/*         for the output par. */
+
+/*       sdiag is an output array of length n which contains the */
+/*         diagonal elements of the upper triangular matrix s. */
+
+/*       wa1 and wa2 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm,qrsolv */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     dwarf is the smallest positive magnitude. */
+
+    dwarf = __cminpack_func__(dpmpar)(2);
+
+/*     compute and store in x the gauss-newton direction. if the */
+/*     jacobian is rank-deficient, obtain a least squares solution. */
+
+    nsing = n;
+    for (j = 0; j < n; ++j) {
+	wa1[j] = qtb[j];
+	if (r[j + j * ldr] == 0. && nsing == n) {
+	    nsing = j;
+	}
+	if (nsing < n) {
+	    wa1[j] = 0.;
+	}
+    }
+# ifdef USE_CBLAS
+    cblas_dtrsv(CblasColMajor, CblasUpper, CblasNoTrans, CblasNonUnit, nsing, r, ldr, wa1, 1);
+# else
+    if (nsing >= 1) {
+        int k;
+        for (k = 1; k <= nsing; ++k) {
+            j = nsing - k;
+            wa1[j] /= r[j + j * ldr];
+            temp = wa1[j];
+            if (j >= 1) {
+                int i;
+                for (i = 0; i < j; ++i) {
+                    wa1[i] -= r[i + j * ldr] * temp;
+                }
+            }
+        }
+    }
+# endif
+    for (j = 0; j < n; ++j) {
+	l = ipvt[j]-1;
+	x[l] = wa1[j];
+    }
+
+/*     initialize the iteration counter. */
+/*     evaluate the function at the origin, and test */
+/*     for acceptance of the gauss-newton direction. */
+
+    iter = 0;
+    for (j = 0; j < n; ++j) {
+	wa2[j] = diag[j] * x[j];
+    }
+    dxnorm = __cminpack_enorm__(n, wa2);
+    fp = dxnorm - delta;
+    if (fp <= p1 * delta) {
+	goto TERMINATE;
+    }
+
+/*     if the jacobian is not rank deficient, the newton */
+/*     step provides a lower bound, parl, for the zero of */
+/*     the function. otherwise set this bound to zero. */
+
+    parl = 0.;
+    if (nsing >= n) {
+        for (j = 0; j < n; ++j) {
+            l = ipvt[j]-1;
+            wa1[j] = diag[l] * (wa2[l] / dxnorm);
+        }
+#     ifdef USE_CBLAS
+        cblas_dtrsv(CblasColMajor, CblasUpper, CblasTrans, CblasNonUnit, n, r, ldr, wa1, 1);
+#     else
+        for (j = 0; j < n; ++j) {
+            real sum = 0.;
+            if (j >= 1) {
+                int i;
+                for (i = 0; i < j; ++i) {
+                    sum += r[i + j * ldr] * wa1[i];
+                }
+            }
+            wa1[j] = (wa1[j] - sum) / r[j + j * ldr];
+        }
+#     endif
+        temp = __cminpack_enorm__(n, wa1);
+        parl = fp / delta / temp / temp;
+    }
+
+/*     calculate an upper bound, paru, for the zero of the function. */
+
+    for (j = 0; j < n; ++j) {
+        real sum;
+#     ifdef USE_CBLAS
+        sum = cblas_ddot(j+1, &r[j*ldr], 1, qtb, 1);
+#     else
+        int i;
+        sum = 0.;
+        for (i = 0; i <= j; ++i) {
+            sum += r[i + j * ldr] * qtb[i];
+        }
+#     endif
+        l = ipvt[j]-1;
+        wa1[j] = sum / diag[l];
+    }
+    gnorm = __cminpack_enorm__(n, wa1);
+    paru = gnorm / delta;
+    if (paru == 0.) {
+        paru = dwarf / min(delta,(real)p1) /* / p001 ??? */;
+    }
+
+/*     if the input par lies outside of the interval (parl,paru), */
+/*     set par to the closer endpoint. */
+
+    *par = max(*par,parl);
+    *par = min(*par,paru);
+    if (*par == 0.) {
+        *par = gnorm / dxnorm;
+    }
+
+/*     beginning of an iteration. */
+
+    for (;;) {
+        ++iter;
+
+/*        evaluate the function at the current value of par. */
+
+        if (*par == 0.) {
+            /* Computing MAX */
+            d1 = dwarf, d2 = p001 * paru;
+            *par = max(d1,d2);
+        }
+        temp = sqrt(*par);
+        for (j = 0; j < n; ++j) {
+            wa1[j] = temp * diag[j];
+        }
+        __cminpack_func__(qrsolv)(n, r, ldr, ipvt, wa1, qtb, x, sdiag, wa2);
+        for (j = 0; j < n; ++j) {
+            wa2[j] = diag[j] * x[j];
+        }
+        dxnorm = __cminpack_enorm__(n, wa2);
+        temp = fp;
+        fp = dxnorm - delta;
+
+/*        if the function is small enough, accept the current value */
+/*        of par. also test for the exceptional cases where parl */
+/*        is zero or the number of iterations has reached 10. */
+
+        if (fabs(fp) <= p1 * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) {
+            goto TERMINATE;
+        }
+
+/*        compute the newton correction. */
+
+#     ifdef USE_CBLAS
+        for (j = 0; j < nsing; ++j) {
+            l = ipvt[j]-1;
+            wa1[j] = diag[l] * (wa2[l] / dxnorm);
+        }
+        for (j = nsing; j < n; ++j) {
+            wa1[j] = 0.;
+        }
+        /* exchange the diagonal of r with sdiag */
+        cblas_dswap(n, r, ldr+1, sdiag, 1);
+        /* solve lower(r).x = wa1, result id put in wa1 */
+        cblas_dtrsv(CblasColMajor, CblasLower, CblasNoTrans, CblasNonUnit, nsing, r, ldr, wa1, 1);
+        /* exchange the diagonal of r with sdiag */
+        cblas_dswap( n, r, ldr+1, sdiag, 1);
+#     else /* !USE_CBLAS */
+        for (j = 0; j < n; ++j) {
+            l = ipvt[j]-1;
+            wa1[j] = diag[l] * (wa2[l] / dxnorm);
+        }
+        for (j = 0; j < n; ++j) {
+            wa1[j] /= sdiag[j];
+            temp = wa1[j];
+            if (n > j+1) {
+                int i;
+                for (i = j+1; i < n; ++i) {
+                    wa1[i] -= r[i + j * ldr] * temp;
+                }
+            }
+        }
+#     endif /* !USE_CBLAS */
+        temp = __cminpack_enorm__(n, wa1);
+        parc = fp / delta / temp / temp;
+
+/*        depending on the sign of the function, update parl or paru. */
+
+        if (fp > 0.) {
+            parl = max(parl,*par);
+        }
+        if (fp < 0.) {
+            paru = min(paru,*par);
+        }
+
+/*        compute an improved estimate for par. */
+
+        /* Computing MAX */
+        d1 = parl, d2 = *par + parc;
+        *par = max(d1,d2);
+
+/*        end of an iteration. */
+
+    }
+TERMINATE:
+
+/*     termination. */
+
+    if (iter == 0) {
+	*par = 0.;
+    }
+
+/*     last card of subroutine lmpar. */
+
+} /* lmpar_ */
+
diff --git a/lmpar_.c b/lmpar_.c
new file mode 100644
index 0000000..b3184ba
--- /dev/null
+++ b/lmpar_.c
@@ -0,0 +1,376 @@
+/* lmpar.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+
+
+__minpack_attr__
+void __minpack_func__(lmpar)(const int *n, real *r__, const int *ldr, 
+	const int *ipvt, const real *diag, const real *qtb, const real *delta, 
+	real *par, real *x, real *sdiag, real *wa1, 
+	real *wa2)
+{
+    /* Table of constant values */
+
+    const int c__2 = 2;
+
+    /* Initialized data */
+
+#define p1 .1
+#define p001 .001
+
+    /* System generated locals */
+    int r_dim1, r_offset, i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, k, l;
+    real fp;
+    int jm1, jp1;
+    real sum, parc, parl;
+    int iter;
+    real temp, paru, dwarf;
+    int nsing;
+    real gnorm;
+    real dxnorm;
+
+/*     ********** */
+
+/*     subroutine lmpar */
+
+/*     given an m by n matrix a, an n by n nonsingular diagonal */
+/*     matrix d, an m-vector b, and a positive number delta, */
+/*     the problem is to determine a value for the parameter */
+/*     par such that if x solves the system */
+
+/*           a*x = b ,     sqrt(par)*d*x = 0 , */
+
+/*     in the least squares sense, and dxnorm is the euclidean */
+/*     norm of d*x, then either par is zero and */
+
+/*           (dxnorm-delta) .le. 0.1*delta , */
+
+/*     or par is positive and */
+
+/*           abs(dxnorm-delta) .le. 0.1*delta . */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then lmpar expects */
+/*     the full upper triangle of r, the permutation matrix p, */
+/*     and the first n components of (q transpose)*b. on output */
+/*     lmpar also provides an upper triangular matrix s such that */
+
+/*            t   t                   t */
+/*           p *(a *a + par*d*d)*p = s *s . */
+
+/*     s is employed within lmpar and may be of separate interest. */
+
+/*     only a few iterations are generally needed for convergence */
+/*     of the algorithm. if, however, the limit of 10 iterations */
+/*     is reached, then the output par will contain the best */
+/*     value obtained so far. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag, */
+/*                        wa1,wa2) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle */
+/*         must contain the full upper triangle of the matrix r. */
+/*         on output the full upper triangle is unaltered, and the */
+/*         strict lower triangle contains the strict upper triangle */
+/*         (transposed) of the upper triangular matrix s. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       delta is a positive input variable which specifies an upper */
+/*         bound on the euclidean norm of d*x. */
+
+/*       par is a nonnegative variable. on input par contains an */
+/*         initial estimate of the levenberg-marquardt parameter. */
+/*         on output par contains the final estimate. */
+
+/*       x is an output array of length n which contains the least */
+/*         squares solution of the system a*x = b, sqrt(par)*d*x = 0, */
+/*         for the output par. */
+
+/*       sdiag is an output array of length n which contains the */
+/*         diagonal elements of the upper triangular matrix s. */
+
+/*       wa1 and wa2 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm,qrsolv */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa2;
+    --wa1;
+    --sdiag;
+    --x;
+    --qtb;
+    --diag;
+    --ipvt;
+    r_dim1 = *ldr;
+    r_offset = 1 + r_dim1 * 1;
+    r__ -= r_offset;
+
+    /* Function Body */
+
+/*     dwarf is the smallest positive magnitude. */
+
+    dwarf = __minpack_func__(dpmpar)(&c__2);
+
+/*     compute and store in x the gauss-newton direction. if the */
+/*     jacobian is rank-deficient, obtain a least squares solution. */
+
+    nsing = *n;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = qtb[j];
+	if (r__[j + j * r_dim1] == 0. && nsing == *n) {
+	    nsing = j - 1;
+	}
+	if (nsing < *n) {
+	    wa1[j] = 0.;
+	}
+/* L10: */
+    }
+    if (nsing < 1) {
+	goto L50;
+    }
+    i__1 = nsing;
+    for (k = 1; k <= i__1; ++k) {
+	j = nsing - k + 1;
+	wa1[j] /= r__[j + j * r_dim1];
+	temp = wa1[j];
+	jm1 = j - 1;
+	if (jm1 < 1) {
+	    goto L30;
+	}
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    wa1[i__] -= r__[i__ + j * r_dim1] * temp;
+/* L20: */
+	}
+L30:
+/* L40: */
+	;
+    }
+L50:
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	x[l] = wa1[j];
+/* L60: */
+    }
+
+/*     initialize the iteration counter. */
+/*     evaluate the function at the origin, and test */
+/*     for acceptance of the gauss-newton direction. */
+
+    iter = 0;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa2[j] = diag[j] * x[j];
+/* L70: */
+    }
+    dxnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fp = dxnorm - *delta;
+    if (fp <= p1 * *delta) {
+	goto L220;
+    }
+
+/*     if the jacobian is not rank deficient, the newton */
+/*     step provides a lower bound, parl, for the zero of */
+/*     the function. otherwise set this bound to zero. */
+
+    parl = 0.;
+    if (nsing < *n) {
+	goto L120;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	wa1[j] = diag[l] * (wa2[l] / dxnorm);
+/* L80: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	jm1 = j - 1;
+	if (jm1 < 1) {
+	    goto L100;
+	}
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += r__[i__ + j * r_dim1] * wa1[i__];
+/* L90: */
+	}
+L100:
+	wa1[j] = (wa1[j] - sum) / r__[j + j * r_dim1];
+/* L110: */
+    }
+    temp = __minpack_func__(enorm)(n, &wa1[1]);
+    parl = fp / *delta / temp / temp;
+L120:
+
+/*     calculate an upper bound, paru, for the zero of the function. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += r__[i__ + j * r_dim1] * qtb[i__];
+/* L130: */
+	}
+	l = ipvt[j];
+	wa1[j] = sum / diag[l];
+/* L140: */
+    }
+    gnorm = __minpack_func__(enorm)(n, &wa1[1]);
+    paru = gnorm / *delta;
+    if (paru == 0.) {
+	paru = dwarf / min(*delta,(real)p1);
+    }
+
+/*     if the input par lies outside of the interval (parl,paru), */
+/*     set par to the closer endpoint. */
+
+    *par = max(*par,parl);
+    *par = min(*par,paru);
+    if (*par == 0.) {
+	*par = gnorm / dxnorm;
+    }
+
+/*     beginning of an iteration. */
+
+L150:
+    ++iter;
+
+/*        evaluate the function at the current value of par. */
+
+    if (*par == 0.) {
+/* Computing MAX */
+	d__1 = dwarf, d__2 = p001 * paru;
+	*par = max(d__1,d__2);
+    }
+    temp = sqrt(*par);
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = temp * diag[j];
+/* L160: */
+    }
+    __minpack_func__(qrsolv)(n, &r__[r_offset], ldr, &ipvt[1], &wa1[1], &qtb[1], &x[1], &sdiag[
+	    1], &wa2[1]);
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa2[j] = diag[j] * x[j];
+/* L170: */
+    }
+    dxnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    temp = fp;
+    fp = dxnorm - *delta;
+
+/*        if the function is small enough, accept the current value */
+/*        of par. also test for the exceptional cases where parl */
+/*        is zero or the number of iterations has reached 10. */
+
+    if (abs(fp) <= p1 * *delta || (parl == 0. && fp <= temp && temp < 0.) ||
+	     iter == 10) {
+	goto L220;
+    }
+
+/*        compute the newton correction. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	wa1[j] = diag[l] * (wa2[l] / dxnorm);
+/* L180: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] /= sdiag[j];
+	temp = wa1[j];
+	jp1 = j + 1;
+	if (*n < jp1) {
+	    goto L200;
+	}
+	i__2 = *n;
+	for (i__ = jp1; i__ <= i__2; ++i__) {
+	    wa1[i__] -= r__[i__ + j * r_dim1] * temp;
+/* L190: */
+	}
+L200:
+/* L210: */
+	;
+    }
+    temp = __minpack_func__(enorm)(n, &wa1[1]);
+    parc = fp / *delta / temp / temp;
+
+/*        depending on the sign of the function, update parl or paru. */
+
+    if (fp > 0.) {
+	parl = max(parl,*par);
+    }
+    if (fp < 0.) {
+	paru = min(paru,*par);
+    }
+
+/*        compute an improved estimate for par. */
+
+/* Computing MAX */
+    d__1 = parl, d__2 = *par + parc;
+    *par = max(d__1,d__2);
+
+/*        end of an iteration. */
+
+    goto L150;
+L220:
+
+/*     termination. */
+
+    if (iter == 0) {
+	*par = 0.;
+    }
+    return;
+
+/*     last card of subroutine lmpar. */
+
+} /* lmpar_ */
+
diff --git a/lmstr.c b/lmstr.c
new file mode 100644
index 0000000..ec6d2a9
--- /dev/null
+++ b/lmstr.c
@@ -0,0 +1,544 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(lmstr)(__cminpack_decl_fcnderstr_mn__ void *p, int m, int n, real *x, 
+	real *fvec, real *fjac, int ldfjac, real ftol,
+	real xtol, real gtol, int maxfev, real *
+	diag, int mode, real factor, int nprint,
+	int *nfev, int *njev, int *ipvt, real *qtf, 
+	real *wa1, real *wa2, real *wa3, real *wa4)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p25 .25
+#define p75 .75
+#define p0001 1e-4
+
+    /* System generated locals */
+    real d1, d2;
+
+    /* Local variables */
+    int i, j, l;
+    real par, sum;
+    int sing;
+    int iter;
+    real temp, temp1, temp2;
+    int iflag;
+    real delta = 0.;
+    real ratio;
+    real fnorm, gnorm, pnorm, xnorm = 0., fnorm1, actred, dirder, 
+	    epsmch, prered;
+    int info;
+
+/*     ********** */
+
+/*     subroutine lmstr */
+
+/*     the purpose of lmstr is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm which uses minimal storage. */
+/*     the user must provide a subroutine which calculates the */
+/*     functions and the rows of the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */
+/*                        maxfev,diag,mode,factor,nprint,info,nfev, */
+/*                        njev,ipvt,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the rows of the jacobian. */
+/*         fcn must be declared in an external statement in the */
+/*         user calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjrow,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m),fjrow(n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmstr. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array. the upper triangle of fjac */
+/*         contains an upper triangular matrix r such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower triangular */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       ftol is a nonnegative input variable. termination */
+/*         occurs when both the actual and predicted relative */
+/*         reductions in the sum of squares are at most ftol. */
+/*         therefore, ftol measures the relative error desired */
+/*         in the sum of squares. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. therefore, xtol measures the */
+/*         relative error desired in the approximate solution. */
+
+/*       gtol is a nonnegative input variable. termination */
+/*         occurs when the cosine of the angle between fvec and */
+/*         any column of the jacobian is at most gtol in absolute */
+/*         value. therefore, gtol measures the orthogonality */
+/*         desired between the function vector and the columns */
+/*         of the jacobian. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  both actual and predicted relative reductions */
+/*                   in the sum of squares are at most ftol. */
+
+/*         info = 2  relative error between two consecutive iterates */
+/*                   is at most xtol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  the cosine of the angle between fvec and any */
+/*                   column of the jacobian is at most gtol in */
+/*                   absolute value. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached maxfev. */
+
+/*         info = 6  ftol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  xtol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*         info = 8  gtol is too small. fvec is orthogonal to the */
+/*                   columns of the jacobian to machine precision. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       qtf is an output array of length n which contains */
+/*         the first n elements of the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, and wa3 are work arrays of length n. */
+
+/*       wa4 is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,lmpar,qrfac,rwupdt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */
+/*     jorge j. more */
+
+/*     ********** */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+    info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || m < n || ldfjac < n || ftol < 0. || xtol < 0. || 
+	    gtol < 0. || maxfev <= 0 || factor <= 0.) {
+	goto TERMINATE;
+    }
+    if (mode == 2) {
+        for (j = 0; j < n; ++j) {
+            if (diag[j] <= 0.) {
+                goto TERMINATE;
+            }
+        }
+    }
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = fcnderstr_mn(p, m, n, x, fvec, wa3, 1);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto TERMINATE;
+    }
+    fnorm = __cminpack_enorm__(m, fvec);
+
+/*     initialize levenberg-marquardt parameter and iteration counter. */
+
+    par = 0.;
+    iter = 1;
+
+/*     beginning of the outer loop. */
+
+    for (;;) {
+
+/*        if requested, call fcn to enable printing of iterates. */
+
+        if (nprint > 0) {
+            iflag = 0;
+            if ((iter - 1) % nprint == 0) {
+                iflag = fcnderstr_mn(p, m, n, x, fvec, wa3, 0);
+            }
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+        }
+
+/*        compute the qr factorization of the jacobian matrix */
+/*        calculated one row at a time, while simultaneously */
+/*        forming (q transpose)*fvec and storing the first */
+/*        n components in qtf. */
+
+        for (j = 0; j < n; ++j) {
+            qtf[j] = 0.;
+            for (i = 0; i < n; ++i) {
+                fjac[i + j * ldfjac] = 0.;
+            }
+        }
+        iflag = 2;
+        for (i = 0; i < m; ++i) {
+            if (fcnderstr_mn(p, m, n, x, fvec, wa3, iflag) < 0) {
+                goto TERMINATE;
+            }
+            temp = fvec[i];
+            __cminpack_func__(rwupdt)(n, fjac, ldfjac, wa3, qtf, &temp,
+                   wa1, wa2);
+            ++iflag;
+        }
+        ++(*njev);
+
+/*        if the jacobian is rank deficient, call qrfac to */
+/*        reorder its columns and update the components of qtf. */
+
+        sing = FALSE_;
+        for (j = 0; j < n; ++j) {
+            if (fjac[j + j * ldfjac] == 0.) {
+                sing = TRUE_;
+            }
+            ipvt[j] = j+1;
+            wa2[j] = __cminpack_enorm__(j+1, &fjac[j * ldfjac + 0]);
+        }
+        if (sing) {
+            __cminpack_func__(qrfac)(n, n, fjac, ldfjac, TRUE_, ipvt, n,
+                  wa1, wa2, wa3);
+            for (j = 0; j < n; ++j) {
+                if (fjac[j + j * ldfjac] != 0.) {
+                    sum = 0.;
+                    for (i = j; i < n; ++i) {
+                        sum += fjac[i + j * ldfjac] * qtf[i];
+                    }
+                    temp = -sum / fjac[j + j * ldfjac];
+                    for (i = j; i < n; ++i) {
+                        qtf[i] += fjac[i + j * ldfjac] * temp;
+                    }
+                }
+                fjac[j + j * ldfjac] = wa1[j];
+            }
+        }
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+        if (iter == 1) {
+            if (mode != 2) {
+                for (j = 0; j < n; ++j) {
+                    diag[j] = wa2[j];
+                    if (wa2[j] == 0.) {
+                        diag[j] = 1.;
+                    }
+                }
+            }
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+            for (j = 0; j < n; ++j) {
+                wa3[j] = diag[j] * x[j];
+            }
+            xnorm = __cminpack_enorm__(n, wa3);
+            delta = factor * xnorm;
+            if (delta == 0.) {
+                delta = factor;
+            }
+        }
+
+/*        compute the norm of the scaled gradient. */
+
+        gnorm = 0.;
+        if (fnorm != 0.) {
+            for (j = 0; j < n; ++j) {
+                l = ipvt[j]-1;
+                if (wa2[l] != 0.) {
+                    sum = 0.;
+                    for (i = 0; i <= j; ++i) {
+                        sum += fjac[i + j * ldfjac] * (qtf[i] / fnorm);
+                    }
+                    /* Computing MAX */
+                    d1 = fabs(sum / wa2[l]);
+                    gnorm = max(gnorm,d1);
+                }
+            }
+        }
+
+/*        test for convergence of the gradient norm. */
+
+        if (gnorm <= gtol) {
+            info = 4;
+        }
+        if (info != 0) {
+            goto TERMINATE;
+        }
+
+/*        rescale if necessary. */
+
+        if (mode != 2) {
+            for (j = 0; j < n; ++j) {
+                /* Computing MAX */
+                d1 = diag[j], d2 = wa2[j];
+                diag[j] = max(d1,d2);
+            }
+        }
+
+/*        beginning of the inner loop. */
+
+        do {
+
+/*           determine the levenberg-marquardt parameter. */
+
+            __cminpack_func__(lmpar)(n, fjac, ldfjac, ipvt, diag, qtf, delta,
+                  &par, wa1, wa2, wa3, wa4);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+            for (j = 0; j < n; ++j) {
+                wa1[j] = -wa1[j];
+                wa2[j] = x[j] + wa1[j];
+                wa3[j] = diag[j] * wa1[j];
+            }
+            pnorm = __cminpack_enorm__(n, wa3);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+            if (iter == 1) {
+                delta = min(delta,pnorm);
+            }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+            iflag = fcnderstr_mn(p, m, n, wa2, wa4, wa3, 1);
+            ++(*nfev);
+            if (iflag < 0) {
+                goto TERMINATE;
+            }
+            fnorm1 = __cminpack_enorm__(m, wa4);
+
+/*           compute the scaled actual reduction. */
+
+            actred = -1.;
+            if (p1 * fnorm1 < fnorm) {
+                /* Computing 2nd power */
+                d1 = fnorm1 / fnorm;
+                actred = 1. - d1 * d1;
+            }
+
+/*           compute the scaled predicted reduction and */
+/*           the scaled directional derivative. */
+
+            for (j = 0; j < n; ++j) {
+                wa3[j] = 0.;
+                l = ipvt[j]-1;
+                temp = wa1[l];
+                for (i = 0; i <= j; ++i) {
+                    wa3[i] += fjac[i + j * ldfjac] * temp;
+                }
+            }
+            temp1 = __cminpack_enorm__(n, wa3) / fnorm;
+            temp2 = (sqrt(par) * pnorm) / fnorm;
+            prered = temp1 * temp1 + temp2 * temp2 / p5;
+            dirder = -(temp1 * temp1 + temp2 * temp2);
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+            ratio = 0.;
+            if (prered != 0.) {
+                ratio = actred / prered;
+            }
+
+/*           update the step bound. */
+
+            if (ratio <= p25) {
+                if (actred >= 0.) {
+                    temp = p5;
+                } else {
+                    temp = p5 * dirder / (dirder + p5 * actred);
+                }
+                if (p1 * fnorm1 >= fnorm || temp < p1) {
+                    temp = p1;
+                }
+                /* Computing MIN */
+                d1 = pnorm / p1;
+                delta = temp * min(delta,d1);
+                par /= temp;
+            } else {
+                if (par == 0. || ratio >= p75) {
+                    delta = pnorm / p5;
+                    par = p5 * par;
+                }
+            }
+
+/*           test for successful iteration. */
+
+            if (ratio >= p0001) {
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+                for (j = 0; j < n; ++j) {
+                    x[j] = wa2[j];
+                    wa2[j] = diag[j] * x[j];
+                }
+                for (i = 0; i < m; ++i) {
+                    fvec[i] = wa4[i];
+                }
+                xnorm = __cminpack_enorm__(n, wa2);
+                fnorm = fnorm1;
+                ++iter;
+            }
+
+/*           tests for convergence. */
+
+            if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) {
+                info = 1;
+            }
+            if (delta <= xtol * xnorm) {
+                info = 2;
+            }
+            if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) {
+                info = 3;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           tests for termination and stringent tolerances. */
+
+            if (*nfev >= maxfev) {
+                info = 5;
+            }
+            if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+                info = 6;
+            }
+            if (delta <= epsmch * xnorm) {
+                info = 7;
+            }
+            if (gnorm <= epsmch) {
+                info = 8;
+            }
+            if (info != 0) {
+                goto TERMINATE;
+            }
+
+/*           end of the inner loop. repeat if iteration unsuccessful. */
+
+        } while (ratio < p0001);
+
+/*        end of the outer loop. */
+
+    }
+TERMINATE:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	info = iflag;
+    }
+    if (nprint > 0) {
+	fcnderstr_mn(p, m, n, x, fvec, wa3, 0);
+    }
+    return info;
+
+/*     last card of subroutine lmstr. */
+
+} /* lmstr_ */
+
diff --git a/lmstr1.c b/lmstr1.c
new file mode 100644
index 0000000..3614a41
--- /dev/null
+++ b/lmstr1.c
@@ -0,0 +1,167 @@
+#include "cminpack.h"
+#include "cminpackP.h"
+
+__cminpack_attr__
+int __cminpack_func__(lmstr1)(__cminpack_decl_fcnderstr_mn__ void *p, int m, int n, real *x, 
+	real *fvec, real *fjac, int ldfjac, real tol, 
+	int *ipvt, real *wa, int lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* Local variables */
+    int mode, nfev, njev;
+    real ftol, gtol, xtol;
+    int maxfev, nprint;
+    int info;
+
+/*     ********** */
+
+/*     subroutine lmstr1 */
+
+/*     the purpose of lmstr1 is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm which uses minimal storage. */
+/*     this is done by using the more general least-squares solver */
+/*     lmstr. the user must provide a subroutine which calculates */
+/*     the functions and the rows of the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */
+/*                         ipvt,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the rows of the jacobian. */
+/*         fcn must be declared in an external statement in the */
+/*         user calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjrow,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m),fjrow(n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmstr1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array. the upper triangle of fjac */
+/*         contains an upper triangular matrix r such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower triangular */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates either that the relative */
+/*         error in the sum of squares is at most tol or that */
+/*         the relative error between x and the solution is at */
+/*         most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  algorithm estimates that the relative error */
+/*                   in the sum of squares is at most tol. */
+
+/*         info = 2  algorithm estimates that the relative error */
+/*                   between x and the solution is at most tol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  fvec is orthogonal to the columns of the */
+/*                   jacobian to machine precision. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached 100*(n+1). */
+
+/*         info = 6  tol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  tol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than 5*n+m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... lmstr */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */
+/*     jorge j. more */
+
+/*     ********** */
+
+/*     check the input parameters for errors. */
+
+    if (n <= 0 || m < n || ldfjac < n || tol < 0. || lwa < n * 5 + m) {
+        return 0;
+    }
+
+/*     call lmstr. */
+
+    maxfev = (n + 1) * 100;
+    ftol = tol;
+    xtol = tol;
+    gtol = 0.;
+    mode = 1;
+    nprint = 0;
+    info = __cminpack_func__(lmstr)(__cminpack_param_fcnderstr_mn__ p, m, n, x, fvec, fjac, ldfjac,
+	    ftol, xtol, gtol, maxfev, wa, mode, factor, nprint, 
+	    &nfev, &njev, ipvt, &wa[n], &wa[(n << 1)], &
+	    wa[n * 3], &wa[(n << 2)], &wa[n * 5]);
+    if (info == 8) {
+	info = 4;
+    }
+    return info;
+
+/*     last card of subroutine lmstr1. */
+
+} /* lmstr1_ */
+
diff --git a/lmstr1_.c b/lmstr1_.c
new file mode 100644
index 0000000..f644062
--- /dev/null
+++ b/lmstr1_.c
@@ -0,0 +1,189 @@
+/* lmstr1.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+__minpack_attr__
+void __minpack_func__(lmstr1)(__minpack_decl_fcnderstr_mn__  const int *m, const int *n, real *x, 
+	real *fvec, real *fjac, const int *ldfjac, const real *tol, 
+	int *info, int *ipvt, real *wa, const int *lwa)
+{
+    /* Initialized data */
+
+    const real factor = 100.;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset;
+
+    /* Local variables */
+    int mode, nfev, njev;
+    real ftol, gtol, xtol;
+    int maxfev, nprint;
+
+/*     ********** */
+
+/*     subroutine lmstr1 */
+
+/*     the purpose of lmstr1 is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm which uses minimal storage. */
+/*     this is done by using the more general least-squares solver */
+/*     lmstr. the user must provide a subroutine which calculates */
+/*     the functions and the rows of the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info, */
+/*                         ipvt,wa,lwa) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the rows of the jacobian. */
+/*         fcn must be declared in an external statement in the */
+/*         user calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjrow,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m),fjrow(n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmstr1. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array. the upper triangle of fjac */
+/*         contains an upper triangular matrix r such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower triangular */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       tol is a nonnegative input variable. termination occurs */
+/*         when the algorithm estimates either that the relative */
+/*         error in the sum of squares is at most tol or that */
+/*         the relative error between x and the solution is at */
+/*         most tol. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  algorithm estimates that the relative error */
+/*                   in the sum of squares is at most tol. */
+
+/*         info = 2  algorithm estimates that the relative error */
+/*                   between x and the solution is at most tol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  fvec is orthogonal to the columns of the */
+/*                   jacobian to machine precision. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached 100*(n+1). */
+
+/*         info = 6  tol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  tol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       wa is a work array of length lwa. */
+
+/*       lwa is a positive integer input variable not less than 5*n+m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... lmstr */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */
+/*     jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --fvec;
+    --ipvt;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --wa;
+
+    /* Function Body */
+    *info = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *m < *n || *ldfjac < *n || *tol < 0. || *lwa < *n * 5 + *
+	    m) {
+	/* goto L10; */
+        return;
+    }
+
+/*     call lmstr. */
+
+    maxfev = (*n + 1) * 100;
+    ftol = *tol;
+    xtol = *tol;
+    gtol = 0.;
+    mode = 1;
+    nprint = 0;
+    __minpack_func__(lmstr)(__minpack_param_fcnderstr_mn__ m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &
+	    ftol, &xtol, &gtol, &maxfev, &wa[1], &mode, &factor, &nprint, 
+	    info, &nfev, &njev, &ipvt[1], &wa[*n + 1], &wa[(*n << 1) + 1], &
+	    wa[*n * 3 + 1], &wa[(*n << 2) + 1], &wa[*n * 5 + 1]);
+    if (*info == 8) {
+	*info = 4;
+    }
+/* L10: */
+    return;
+
+/*     last card of subroutine lmstr1. */
+
+} /* lmstr1_ */
+
diff --git a/lmstr_.c b/lmstr_.c
new file mode 100644
index 0000000..3bec6a3
--- /dev/null
+++ b/lmstr_.c
@@ -0,0 +1,653 @@
+/* lmstr.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(lmstr)(__minpack_decl_fcnderstr_mn__ const int *m, const int *n, real *x, 
+	real *fvec, real *fjac, const int *ldfjac, const real *ftol,
+	const real *xtol, const real *gtol, const int *maxfev, real *
+	diag, const int *mode, const real *factor, const int *nprint, int *
+	info, int *nfev, int *njev, int *ipvt, real *qtf, 
+	real *wa1, real *wa2, real *wa3, real *wa4)
+{
+    /* Table of constant values */
+
+    const int c__1 = 1;
+    const int c_true = TRUE_;
+
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p25 .25
+#define p75 .75
+#define p0001 1e-4
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+    real d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__, j, l;
+    real par, sum;
+    int sing;
+    int iter;
+    real temp, temp1, temp2;
+    int iflag;
+    real delta;
+    real ratio;
+    real fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, 
+	    epsmch, prered;
+
+/*     ********** */
+
+/*     subroutine lmstr */
+
+/*     the purpose of lmstr is to minimize the sum of the squares of */
+/*     m nonlinear functions in n variables by a modification of */
+/*     the levenberg-marquardt algorithm which uses minimal storage. */
+/*     the user must provide a subroutine which calculates the */
+/*     functions and the rows of the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol, */
+/*                        maxfev,diag,mode,factor,nprint,info,nfev, */
+/*                        njev,ipvt,qtf,wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the rows of the jacobian. */
+/*         fcn must be declared in an external statement in the */
+/*         user calling program, and should be written as follows. */
+
+/*         subroutine fcn(m,n,x,fvec,fjrow,iflag) */
+/*         integer m,n,iflag */
+/*         double precision x(n),fvec(m),fjrow(n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/*         ---------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of lmstr. */
+/*         in this case set iflag to a negative integer. */
+
+/*       m is a positive integer input variable set to the number */
+/*         of functions. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of variables. n must not exceed m. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length m which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array. the upper triangle of fjac */
+/*         contains an upper triangular matrix r such that */
+
+/*                t     t           t */
+/*               p *(jac *jac)*p = r *r, */
+
+/*         where p is a permutation matrix and jac is the final */
+/*         calculated jacobian. column j of p is column ipvt(j) */
+/*         (see below) of the identity matrix. the lower triangular */
+/*         part of fjac contains information generated during */
+/*         the computation of r. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       ftol is a nonnegative input variable. termination */
+/*         occurs when both the actual and predicted relative */
+/*         reductions in the sum of squares are at most ftol. */
+/*         therefore, ftol measures the relative error desired */
+/*         in the sum of squares. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. therefore, xtol measures the */
+/*         relative error desired in the approximate solution. */
+
+/*       gtol is a nonnegative input variable. termination */
+/*         occurs when the cosine of the angle between fvec and */
+/*         any column of the jacobian is at most gtol in absolute */
+/*         value. therefore, gtol measures the orthogonality */
+/*         desired between the function vector and the columns */
+/*         of the jacobian. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. if nprint is not positive, no special calls */
+/*         of fcn with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0  improper input parameters. */
+
+/*         info = 1  both actual and predicted relative reductions */
+/*                   in the sum of squares are at most ftol. */
+
+/*         info = 2  relative error between two consecutive iterates */
+/*                   is at most xtol. */
+
+/*         info = 3  conditions for info = 1 and info = 2 both hold. */
+
+/*         info = 4  the cosine of the angle between fvec and any */
+/*                   column of the jacobian is at most gtol in */
+/*                   absolute value. */
+
+/*         info = 5  number of calls to fcn with iflag = 1 has */
+/*                   reached maxfev. */
+
+/*         info = 6  ftol is too small. no further reduction in */
+/*                   the sum of squares is possible. */
+
+/*         info = 7  xtol is too small. no further improvement in */
+/*                   the approximate solution x is possible. */
+
+/*         info = 8  gtol is too small. fvec is orthogonal to the */
+/*                   columns of the jacobian to machine precision. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       ipvt is an integer output array of length n. ipvt */
+/*         defines a permutation matrix p such that jac*p = q*r, */
+/*         where jac is the final calculated jacobian, q is */
+/*         orthogonal (not stored), and r is upper triangular. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+
+/*       qtf is an output array of length n which contains */
+/*         the first n elements of the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, and wa3 are work arrays of length n. */
+
+/*       wa4 is a work array of length m. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dpmpar,enorm,lmpar,qrfac,rwupdt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */
+/*     jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --fvec;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --ipvt;
+    --diag;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    *info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *m < *n || *ldfjac < *n || *ftol < 0. || *xtol < 0. || 
+	    *gtol < 0. || *maxfev <= 0 || *factor <= 0.) {
+	goto L340;
+    }
+    if (*mode != 2) {
+	goto L20;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (diag[j] <= 0.) {
+	    goto L340;
+	}
+/* L10: */
+    }
+L20:
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = 1;
+    fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto L340;
+    }
+    fnorm = __minpack_func__(enorm)(m, &fvec[1]);
+
+/*     initialize levenberg-marquardt parameter and iteration counter. */
+
+    par = 0.;
+    iter = 1;
+
+/*     beginning of the outer loop. */
+
+L30:
+
+/*        if requested, call fcn to enable printing of iterates. */
+
+    if (*nprint <= 0) {
+	goto L40;
+    }
+    iflag = 0;
+    if ((iter - 1) % *nprint == 0) {
+	fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag);
+    }
+    if (iflag < 0) {
+	goto L340;
+    }
+L40:
+
+/*        compute the qr factorization of the jacobian matrix */
+/*        calculated one row at a time, while simultaneously */
+/*        forming (q transpose)*fvec and storing the first */
+/*        n components in qtf. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	qtf[j] = 0.;
+	i__2 = *n;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    fjac[i__ + j * fjac_dim1] = 0.;
+/* L50: */
+	}
+/* L60: */
+    }
+    iflag = 2;
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag);
+	if (iflag < 0) {
+	    goto L340;
+	}
+	temp = fvec[i__];
+	__minpack_func__(rwupdt)(n, &fjac[fjac_offset], ldfjac, &wa3[1], &qtf[1], &temp, &wa1[
+		1], &wa2[1]);
+	++iflag;
+/* L70: */
+    }
+    ++(*njev);
+
+/*        if the jacobian is rank deficient, call qrfac to */
+/*        reorder its columns and update the components of qtf. */
+
+    sing = FALSE_;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    sing = TRUE_;
+	}
+	ipvt[j] = j;
+	wa2[j] = __minpack_func__(enorm)(&j, &fjac[j * fjac_dim1 + 1]);
+/* L80: */
+    }
+    if (! sing) {
+	goto L130;
+    }
+    __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_true, &ipvt[1], n, &wa1[1], &
+	    wa2[1], &wa3[1]);
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    goto L110;
+	}
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * qtf[i__];
+/* L90: */
+	}
+	temp = -sum / fjac[j + j * fjac_dim1];
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    qtf[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L100: */
+	}
+L110:
+	fjac[j + j * fjac_dim1] = wa1[j];
+/* L120: */
+    }
+L130:
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+    if (iter != 1) {
+	goto L170;
+    }
+    if (*mode == 2) {
+	goto L150;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	diag[j] = wa2[j];
+	if (wa2[j] == 0.) {
+	    diag[j] = 1.;
+	}
+/* L140: */
+    }
+L150:
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = diag[j] * x[j];
+/* L160: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa3[1]);
+    delta = *factor * xnorm;
+    if (delta == 0.) {
+	delta = *factor;
+    }
+L170:
+
+/*        compute the norm of the scaled gradient. */
+
+    gnorm = 0.;
+    if (fnorm == 0.) {
+	goto L210;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	if (wa2[l] == 0.) {
+	    goto L190;
+	}
+	sum = 0.;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * (qtf[i__] / fnorm);
+/* L180: */
+	}
+/* Computing MAX */
+	d__2 = gnorm, d__3 = (d__1 = sum / wa2[l], abs(d__1));
+	gnorm = max(d__2,d__3);
+L190:
+/* L200: */
+	;
+    }
+L210:
+
+/*        test for convergence of the gradient norm. */
+
+    if (gnorm <= *gtol) {
+	*info = 4;
+    }
+    if (*info != 0) {
+	goto L340;
+    }
+
+/*        rescale if necessary. */
+
+    if (*mode == 2) {
+	goto L230;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MAX */
+	d__1 = diag[j], d__2 = wa2[j];
+	diag[j] = max(d__1,d__2);
+/* L220: */
+    }
+L230:
+
+/*        beginning of the inner loop. */
+
+L240:
+
+/*           determine the levenberg-marquardt parameter. */
+
+    __minpack_func__(lmpar)(n, &fjac[fjac_offset], ldfjac, &ipvt[1], &diag[1], &qtf[1], &delta,
+	     &par, &wa1[1], &wa2[1], &wa3[1], &wa4[1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = -wa1[j];
+	wa2[j] = x[j] + wa1[j];
+	wa3[j] = diag[j] * wa1[j];
+/* L250: */
+    }
+    pnorm = __minpack_func__(enorm)(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+    if (iter == 1) {
+	delta = min(delta,pnorm);
+    }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+    iflag = 1;
+    fcnderstr_mn(m, n, &wa2[1], &wa4[1], &wa3[1], &iflag);
+    ++(*nfev);
+    if (iflag < 0) {
+	goto L340;
+    }
+    fnorm1 = __minpack_func__(enorm)(m, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+    actred = -1.;
+    if (p1 * fnorm1 < fnorm) {
+/* Computing 2nd power */
+	d__1 = fnorm1 / fnorm;
+	actred = 1. - d__1 * d__1;
+    }
+
+/*           compute the scaled predicted reduction and */
+/*           the scaled directional derivative. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = 0.;
+	l = ipvt[j];
+	temp = wa1[l];
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    wa3[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L260: */
+	}
+/* L270: */
+    }
+    temp1 = __minpack_func__(enorm)(n, &wa3[1]) / fnorm;
+    temp2 = sqrt(par) * pnorm / fnorm;
+/* Computing 2nd power */
+    d__1 = temp1;
+/* Computing 2nd power */
+    d__2 = temp2;
+    prered = d__1 * d__1 + d__2 * d__2 / p5;
+/* Computing 2nd power */
+    d__1 = temp1;
+/* Computing 2nd power */
+    d__2 = temp2;
+    dirder = -(d__1 * d__1 + d__2 * d__2);
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+    ratio = 0.;
+    if (prered != 0.) {
+	ratio = actred / prered;
+    }
+
+/*           update the step bound. */
+
+    if (ratio > p25) {
+	goto L280;
+    }
+    if (actred >= 0.) {
+	temp = p5;
+    }
+    if (actred < 0.) {
+	temp = p5 * dirder / (dirder + p5 * actred);
+    }
+    if (p1 * fnorm1 >= fnorm || temp < p1) {
+	temp = p1;
+    }
+/* Computing MIN */
+    d__1 = delta, d__2 = pnorm / p1;
+    delta = temp * min(d__1,d__2);
+    par /= temp;
+    goto L300;
+L280:
+    if (par != 0. && ratio < p75) {
+	goto L290;
+    }
+    delta = pnorm / p5;
+    par = p5 * par;
+L290:
+L300:
+
+/*           test for successful iteration. */
+
+    if (ratio < p0001) {
+	goto L330;
+    }
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = wa2[j];
+	wa2[j] = diag[j] * x[j];
+/* L310: */
+    }
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	fvec[i__] = wa4[i__];
+/* L320: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fnorm = fnorm1;
+    ++iter;
+L330:
+
+/*           tests for convergence. */
+
+    if (abs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1.) {
+	*info = 1;
+    }
+    if (delta <= *xtol * xnorm) {
+	*info = 2;
+    }
+    if (abs(actred) <= *ftol && prered <= *ftol && p5 * ratio <= 1. && *info 
+	    == 2) {
+	*info = 3;
+    }
+    if (*info != 0) {
+	goto L340;
+    }
+
+/*           tests for termination and stringent tolerances. */
+
+    if (*nfev >= *maxfev) {
+	*info = 5;
+    }
+    if (abs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+	*info = 6;
+    }
+    if (delta <= epsmch * xnorm) {
+	*info = 7;
+    }
+    if (gnorm <= epsmch) {
+	*info = 8;
+    }
+    if (*info != 0) {
+	goto L340;
+    }
+
+/*           end of the inner loop. repeat if iteration unsuccessful. */
+
+    if (ratio < p0001) {
+	goto L240;
+    }
+
+/*        end of the outer loop. */
+
+    goto L30;
+L340:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	*info = iflag;
+    }
+    iflag = 0;
+    if (*nprint > 0) {
+	fcnderstr_mn(m, n, &x[1], &fvec[1], &wa3[1], &iflag);
+    }
+    return;
+
+/*     last card of subroutine lmstr. */
+
+} /* lmstr_ */
+
diff --git a/minpack.h b/minpack.h
new file mode 100644
index 0000000..90f3c9a
--- /dev/null
+++ b/minpack.h
@@ -0,0 +1,301 @@
+#ifndef __MINPACK_H__
+#define __MINPACK_H__
+
+#include "cminpack.h"
+
+/* The default floating-point type is "double" for C/C++ and "float" for CUDA,
+   but you can change this by defining one of the following symbols when
+   compiling the library, and before including cminpack.h when using it:
+   __cminpack_double__ for double
+   __cminpack_float__ for float
+   __cminpack_half__ for half from the OpenEXR library (in this case, you must
+                     compile cminpack with a C++ compiler)
+*/
+#ifdef __cminpack_double__
+#define __minpack_func__(func) func ## _
+#endif
+
+#ifdef __cminpack_float__
+#define __minpack_func__(func) s ## func ## _
+#endif
+
+#ifdef __cminpack_half__
+#define __minpack_func__(func) h ## func ## _
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define MINPACK_EXPORT CMINPACK_EXPORT
+
+#define __minpack_real__  __cminpack_real__
+#define __minpack_attr__  __cminpack_attr__
+#if defined(__CUDA_ARCH__) || defined(__CUDACC__)
+#define __minpack_type_fcn_nn__        __minpack_attr__ void fcn_nn
+#define __minpack_type_fcnder_nn__     __minpack_attr__ void fcnder_nn
+#define __minpack_type_fcn_mn__        __minpack_attr__ void fcn_mn
+#define __minpack_type_fcnder_mn__     __minpack_attr__ void fcnder_mn
+#define __minpack_type_fcnderstr_mn__  __minpack_attr__ void fcnderstr_mn
+#define __minpack_decl_fcn_nn__
+#define __minpack_decl_fcnder_nn__
+#define __minpack_decl_fcn_mn__
+#define __minpack_decl_fcnder_mn__
+#define __minpack_decl_fcnderstr_mn__
+#define __minpack_param_fcn_nn__
+#define __minpack_param_fcnder_nn__
+#define __minpack_param_fcn_mn__
+#define __minpack_param_fcnder_mn__
+#define __minpack_param_fcnderstr_mn__
+#else
+#define __minpack_type_fcn_nn__        typedef void (*minpack_func_nn)
+#define __minpack_type_fcnder_nn__     typedef void (*minpack_funcder_nn)
+#define __minpack_type_fcn_mn__        typedef void (*minpack_func_mn)
+#define __minpack_type_fcnder_mn__     typedef void (*minpack_funcder_mn)
+#define __minpack_type_fcnderstr_mn__  typedef void (*minpack_funcderstr_mn)
+#define __minpack_decl_fcn_nn__        minpack_func_nn fcn_nn,
+#define __minpack_decl_fcnder_nn__     minpack_funcder_nn fcnder_nn,
+#define __minpack_decl_fcn_mn__        minpack_func_mn fcn_mn,
+#define __minpack_decl_fcnder_mn__     minpack_funcder_mn fcnder_mn,
+#define __minpack_decl_fcnderstr_mn__  minpack_funcderstr_mn fcnderstr_mn,
+#define __minpack_param_fcn_nn__       fcn_nn,
+#define __minpack_param_fcnder_nn__    fcnder_nn,
+#define __minpack_param_fcn_mn__       fcn_mn,
+#define __minpack_param_fcnder_mn__    fcnder_mn,
+#define __minpack_param_fcnderstr_mn__ fcnderstr_mn,
+#endif
+#undef __cminpack_type_fcn_nn__
+#undef __cminpack_type_fcnder_nn__
+#undef __cminpack_type_fcn_mn__
+#undef __cminpack_type_fcnder_mn__
+#undef __cminpack_type_fcnderstr_mn__
+#undef __cminpack_decl_fcn_nn__
+#undef __cminpack_decl_fcnder_nn__
+#undef __cminpack_decl_fcn_mn__
+#undef __cminpack_decl_fcnder_mn__
+#undef __cminpack_decl_fcnderstr_mn__
+#undef __cminpack_param_fcn_nn__
+#undef __cminpack_param_fcnder_nn__
+#undef __cminpack_param_fcn_mn__
+#undef __cminpack_param_fcnder_mn__
+#undef __cminpack_param_fcnderstr_mn__
+
+/* Declarations for minpack */
+
+/* Function types: */
+/* the iflag parameter is input-only (with respect to the FORTRAN */
+/*  version), the output iflag value is the return value of the function. */
+/* If iflag=0, the function shoulkd just print the current values (see */
+/* the nprint parameters below). */
+  
+/* for hybrd1 and hybrd: */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/* return a negative value to terminate hybrd1/hybrd */
+__minpack_type_fcn_nn__(const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, int *iflag );
+
+/* for hybrj1 and hybrj */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate hybrj1/hybrj */
+__minpack_type_fcnder_nn__(const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+                                  const int *ldfjac, int *iflag );
+
+/* for lmdif1 and lmdif */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = 1 the result is used to compute the residuals. */
+/*         if iflag = 2 the result is used to compute the Jacobian by finite differences. */
+/*         Jacobian computation requires exactly n function calls with iflag = 2. */
+/* return a negative value to terminate lmdif1/lmdif */
+__minpack_type_fcn_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec,
+                               int *iflag );
+
+/* for lmder1 and lmder */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate lmder1/lmder */
+__minpack_type_fcnder_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec,
+                                  __minpack_real__ *fjac, const int *ldfjac, int *iflag );
+
+/* for lmstr1 and lmstr */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/* return a negative value to terminate lmstr1/lmstr */
+__minpack_type_fcnderstr_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec,
+                                     __minpack_real__ *fjrow, int *iflag );
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrd1)(  __minpack_decl_fcn_nn__
+	       const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *tol, int *info,
+	       __minpack_real__ *wa, const int *lwa );
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation, more general). */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrd)( __minpack_decl_fcn_nn__
+	      const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *xtol, const int *maxfev,
+	      const int *ml, const int *mu, const __minpack_real__ *epsfcn, __minpack_real__ *diag, const int *mode,
+	      const __minpack_real__ *factor, const int *nprint, int *info, int *nfev,
+	      __minpack_real__ *fjac, const int *ldfjac, __minpack_real__ *r, const int *lr, __minpack_real__ *qtf,
+	      __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4);
+  
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrj1)( __minpack_decl_fcnder_nn__ const int *n, __minpack_real__ *x,
+	       __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, const __minpack_real__ *tol,
+	       int *info, __minpack_real__ *wa, const int *lwa );
+          
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian,
+   more general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrj)( __minpack_decl_fcnder_nn__ const int *n, __minpack_real__ *x,
+	      __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, const __minpack_real__ *xtol,
+	      const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor,
+	      const int *nprint, int *info, int *nfev, int *njev, __minpack_real__ *r,
+	      const int *lr, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2,
+	      __minpack_real__ *wa3, __minpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmdif1)( __minpack_decl_fcn_mn__
+	       const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *tol,
+	       int *info, int *iwa, __minpack_real__ *wa, const int *lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation, more
+   general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmdif)( __minpack_decl_fcn_mn__
+	      const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *ftol,
+	      const __minpack_real__ *xtol, const __minpack_real__ *gtol, const int *maxfev, const __minpack_real__ *epsfcn,
+	      __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint,
+	      int *info, int *nfev, __minpack_real__ *fjac, const int *ldfjac, int *ipvt,
+	      __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3,
+	      __minpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmder1)( __minpack_decl_fcnder_mn__
+	       const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+	       const int *ldfjac, const __minpack_real__ *tol, int *info, int *ipvt,
+	       __minpack_real__ *wa, const int *lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, more general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmder)( __minpack_decl_fcnder_mn__
+	      const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+	      const int *ldfjac, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol,
+	      const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor,
+	      const int *nprint, int *info, int *nfev, int *njev, int *ipvt,
+	      __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3,
+	      __minpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmstr1)( __minpack_decl_fcnderstr_mn__ const int *m, const int *n,
+	       __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac,
+	       const __minpack_real__ *tol, int *info, int *ipvt, __minpack_real__ *wa, const int *lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage, more general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmstr)( __minpack_decl_fcnderstr_mn__ const int *m,
+	      const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+	      const int *ldfjac, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol,
+	      const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor,
+	      const int *nprint, int *info, int *nfev, int *njev, int *ipvt,
+	      __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3,
+	      __minpack_real__ *wa4 );
+ 
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(chkder)( const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjec,
+	       const int *ldfjac, __minpack_real__ *xp, __minpack_real__ *fvecp, const int *mode,
+	       __minpack_real__ *err  );
+
+__minpack_attr__
+__minpack_real__ MINPACK_EXPORT __minpack_func__(dpmpar)( const int *i );
+
+__minpack_attr__
+__minpack_real__ MINPACK_EXPORT __minpack_func__(enorm)( const int *n, const __minpack_real__ *x );
+
+/* compute a forward-difference approximation to the m by n jacobian
+   matrix associated with a specified problem of m functions in n
+   variables. */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(fdjac2)(__minpack_decl_fcn_mn__
+	     const int *m, const int *n, __minpack_real__ *x, const __minpack_real__ *fvec, __minpack_real__ *fjac,
+	     const int *ldfjac, int *iflag, const __minpack_real__ *epsfcn, __minpack_real__ *wa);
+
+/* compute a forward-difference approximation to the n by n jacobian
+   matrix associated with a specified problem of n functions in n
+   variables. if the jacobian has a banded form, then function
+   evaluations are saved by only approximating the nonzero terms. */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(fdjac1)(__minpack_decl_fcn_nn__
+	     const int *n, __minpack_real__ *x, const __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac,
+	     int *iflag, const int *ml, const int *mu, const __minpack_real__ *epsfcn, __minpack_real__ *wa1,
+	     __minpack_real__ *wa2);
+
+/* internal MINPACK subroutines */
+__minpack_attr__
+void __minpack_func__(dogleg)(const int *n, const __minpack_real__ *r, const int *lr, 
+             const __minpack_real__ *diag, const __minpack_real__ *qtb, const __minpack_real__ *delta, __minpack_real__ *x, 
+             __minpack_real__ *wa1, __minpack_real__ *wa2);
+__minpack_attr__
+void __minpack_func__(qrfac)(const int *m, const int *n, __minpack_real__ *a, const int *
+            lda, const int *pivot, int *ipvt, const int *lipvt, __minpack_real__ *rdiag,
+            __minpack_real__ *acnorm, __minpack_real__ *wa);
+__minpack_attr__
+void __minpack_func__(qrsolv)(const int *n, __minpack_real__ *r, const int *ldr, 
+             const int *ipvt, const __minpack_real__ *diag, const __minpack_real__ *qtb, __minpack_real__ *x, 
+             __minpack_real__ *sdiag, __minpack_real__ *wa);
+__minpack_attr__
+void __minpack_func__(qform)(const int *m, const int *n, __minpack_real__ *q, const int *
+            ldq, __minpack_real__ *wa);
+__minpack_attr__
+void __minpack_func__(r1updt)(const int *m, const int *n, __minpack_real__ *s, const int *
+             ls, const __minpack_real__ *u, __minpack_real__ *v, __minpack_real__ *w, int *sing);
+__minpack_attr__
+void __minpack_func__(r1mpyq)(const int *m, const int *n, __minpack_real__ *a, const int *
+             lda, const __minpack_real__ *v, const __minpack_real__ *w);
+__minpack_attr__
+void __minpack_func__(lmpar)(const int *n, __minpack_real__ *r, const int *ldr, 
+            const int *ipvt, const __minpack_real__ *diag, const __minpack_real__ *qtb, const __minpack_real__ *delta, 
+            __minpack_real__ *par, __minpack_real__ *x, __minpack_real__ *sdiag, __minpack_real__ *wa1, 
+            __minpack_real__ *wa2);
+__minpack_attr__
+void __minpack_func__(rwupdt)(const int *n, __minpack_real__ *r, const int *ldr, 
+             const __minpack_real__ *w, __minpack_real__ *b, __minpack_real__ *alpha, __minpack_real__ *cos, 
+             __minpack_real__ *sin);
+__minpack_attr__
+void __minpack_func__(covar)(const int *n, __minpack_real__ *r, const int *ldr, 
+           const int *ipvt, const __minpack_real__ *tol, __minpack_real__ *wa);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __MINPACK_H__ */
diff --git a/qform.c b/qform.c
new file mode 100644
index 0000000..61acdeb
--- /dev/null
+++ b/qform.c
@@ -0,0 +1,116 @@
+/* qform.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(qform)(int m, int n, real *q, int
+	ldq, real *wa)
+{
+    /* System generated locals */
+    int q_dim1, q_offset;
+
+    /* Local variables */
+    int i, j, k, l, jm1, np1;
+    real sum, temp;
+    int minmn;
+
+/*     ********** */
+
+/*     subroutine qform */
+
+/*     this subroutine proceeds from the computed qr factorization of */
+/*     an m by n matrix a to accumulate the m by m orthogonal matrix */
+/*     q from its factored form. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qform(m,n,q,ldq,wa) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a and the order of q. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       q is an m by m array. on input the full lower trapezoid in */
+/*         the first min(m,n) columns of q contains the factored form. */
+/*         on output q has been accumulated into a square matrix. */
+
+/*       ldq is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array q. */
+
+/*       wa is a work array of length m. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    q_dim1 = ldq;
+    q_offset = 1 + q_dim1 * 1;
+    q -= q_offset;
+
+    /* Function Body */
+
+/*     zero out upper triangle of q in the first min(m,n) columns. */
+
+    minmn = min(m,n);
+    if (minmn >= 2) {
+        for (j = 2; j <= minmn; ++j) {
+            jm1 = j - 1;
+            for (i = 1; i <= jm1; ++i) {
+                q[i + j * q_dim1] = 0.;
+            }
+        }
+    }
+
+/*     initialize remaining columns to those of the identity matrix. */
+
+    np1 = n + 1;
+    if (m >= np1) {
+        for (j = np1; j <= m; ++j) {
+            for (i = 1; i <= m; ++i) {
+                q[i + j * q_dim1] = 0.;
+            }
+            q[j + j * q_dim1] = 1.;
+        }
+    }
+
+/*     accumulate q from its factored form. */
+
+    for (l = 1; l <= minmn; ++l) {
+	k = minmn - l + 1;
+	for (i = k; i <= m; ++i) {
+	    wa[i] = q[i + k * q_dim1];
+	    q[i + k * q_dim1] = 0.;
+	}
+	q[k + k * q_dim1] = 1.;
+	if (wa[k] != 0.) {
+            for (j = k; j <= m; ++j) {
+                sum = 0.;
+                for (i = k; i <= m; ++i) {
+                    sum += q[i + j * q_dim1] * wa[i];
+                }
+                temp = sum / wa[k];
+                for (i = k; i <= m; ++i) {
+                    q[i + j * q_dim1] -= temp * wa[i];
+                }
+            }
+        }
+    }
+
+/*     last card of subroutine qform. */
+
+} /* qform_ */
+
diff --git a/qform_.c b/qform_.c
new file mode 100644
index 0000000..1eccffb
--- /dev/null
+++ b/qform_.c
@@ -0,0 +1,145 @@
+/* qform.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+
+__minpack_attr__
+void __minpack_func__(qform)(const int *m, const int *n, real *q, const int *
+	ldq, real *wa)
+{
+    /* System generated locals */
+    int q_dim1, q_offset, i__1, i__2, i__3;
+
+    /* Local variables */
+    int i__, j, k, l, jm1, np1;
+    real sum, temp;
+    int minmn;
+
+/*     ********** */
+
+/*     subroutine qform */
+
+/*     this subroutine proceeds from the computed qr factorization of */
+/*     an m by n matrix a to accumulate the m by m orthogonal matrix */
+/*     q from its factored form. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qform(m,n,q,ldq,wa) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a and the order of q. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       q is an m by m array. on input the full lower trapezoid in */
+/*         the first min(m,n) columns of q contains the factored form. */
+/*         on output q has been accumulated into a square matrix. */
+
+/*       ldq is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array q. */
+
+/*       wa is a work array of length m. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    q_dim1 = *ldq;
+    q_offset = 1 + q_dim1 * 1;
+    q -= q_offset;
+
+    /* Function Body */
+
+/*     zero out upper triangle of q in the first min(m,n) columns. */
+
+    minmn = min(*m,*n);
+    if (minmn < 2) {
+	goto L30;
+    }
+    i__1 = minmn;
+    for (j = 2; j <= i__1; ++j) {
+	jm1 = j - 1;
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    q[i__ + j * q_dim1] = 0.;
+/* L10: */
+	}
+/* L20: */
+    }
+L30:
+
+/*     initialize remaining columns to those of the identity matrix. */
+
+    np1 = *n + 1;
+    if (*m < np1) {
+	goto L60;
+    }
+    i__1 = *m;
+    for (j = np1; j <= i__1; ++j) {
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    q[i__ + j * q_dim1] = 0.;
+/* L40: */
+	}
+	q[j + j * q_dim1] = 1.;
+/* L50: */
+    }
+L60:
+
+/*     accumulate q from its factored form. */
+
+    i__1 = minmn;
+    for (l = 1; l <= i__1; ++l) {
+	k = minmn - l + 1;
+	i__2 = *m;
+	for (i__ = k; i__ <= i__2; ++i__) {
+	    wa[i__] = q[i__ + k * q_dim1];
+	    q[i__ + k * q_dim1] = 0.;
+/* L70: */
+	}
+	q[k + k * q_dim1] = 1.;
+	if (wa[k] == 0.) {
+	    goto L110;
+	}
+	i__2 = *m;
+	for (j = k; j <= i__2; ++j) {
+	    sum = 0.;
+	    i__3 = *m;
+	    for (i__ = k; i__ <= i__3; ++i__) {
+		sum += q[i__ + j * q_dim1] * wa[i__];
+/* L80: */
+	    }
+	    temp = sum / wa[k];
+	    i__3 = *m;
+	    for (i__ = k; i__ <= i__3; ++i__) {
+		q[i__ + j * q_dim1] -= temp * wa[i__];
+/* L90: */
+	    }
+/* L100: */
+	}
+L110:
+/* L120: */
+	;
+    }
+    return;
+
+/*     last card of subroutine qform. */
+
+} /* qform_ */
+
diff --git a/qrfac.c b/qrfac.c
new file mode 100644
index 0000000..1573772
--- /dev/null
+++ b/qrfac.c
@@ -0,0 +1,285 @@
+#include "cminpack.h"
+#include <math.h>
+#ifdef USE_LAPACK
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#endif
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(qrfac)(int m, int n, real *a, int
+	lda, int pivot, int *ipvt, int lipvt, real *rdiag,
+	 real *acnorm, real *wa)
+{
+#ifdef USE_LAPACK
+    __CLPK_integer m_ = m;
+    __CLPK_integer n_ = n;
+    __CLPK_integer lda_ = lda;
+    __CLPK_integer *jpvt;
+
+    int i, j, k;
+    double t;
+    double* tau = wa;
+    const __CLPK_integer ltau = m > n ? n : m;
+    __CLPK_integer lwork = -1;
+    __CLPK_integer info = 0;
+    double* work;
+
+    if (pivot) {
+        assert( lipvt >= n );
+        if (sizeof(__CLPK_integer) != sizeof(ipvt[0])) {
+            jpvt = malloc(n*sizeof(__CLPK_integer));
+        } else {
+            /* __CLPK_integer is actually an int, just do a cast */
+            jpvt = (__CLPK_integer *)ipvt;
+        }
+        /* set all columns free */
+        memset(jpvt, 0, sizeof(int)*n);
+    }
+    
+    /* query optimal size of work */
+    lwork = -1;
+    if (pivot) {
+        dgeqp3_(&m_,&n_,a,&lda_,jpvt,tau,tau,&lwork,&info);
+        lwork = (int)tau[0];
+        assert( lwork >= 3*n+1  );
+    } else {
+        dgeqrf_(&m_,&n_,a,&lda_,tau,tau,&lwork,&info);
+        lwork = (int)tau[0];
+        assert( lwork >= 1 && lwork >= n );
+    }
+    
+    assert( info == 0 );
+    
+    /* alloc work area */
+    work = (double *)malloc(sizeof(double)*lwork);
+    assert(work != NULL);
+    
+    /* set acnorm first (from the doc of qrfac, acnorm may point to the same area as rdiag) */
+    if (acnorm != rdiag) {
+        for (j = 0; j < n; ++j) {
+            acnorm[j] = __cminpack_enorm__(m, &a[j * lda]);
+        }
+    }
+    
+    /* QR decomposition */
+    if (pivot) {
+        dgeqp3_(&m_,&n_,a,&lda_,jpvt,tau,work,&lwork,&info);
+    } else {
+        dgeqrf_(&m_,&n_,a,&lda_,tau,work,&lwork,&info);
+    }
+    assert(info == 0);
+    
+    /* set rdiag, before the diagonal is replaced */
+    memset(rdiag, 0, sizeof(double)*n);
+    for(i=0 ; i<n ; ++i) {
+        rdiag[i] = a[i*lda+i];
+    }
+    
+    /* modify lower trinagular part to look like qrfac's output */
+    for(i=0 ; i<ltau ; ++i) {
+        k = i*lda+i;
+        t = tau[i];
+        a[k] = t;
+        for(j=i+1 ; j<m ; j++) {
+            k++;
+            a[k] *= t;
+        }
+    }
+    
+    free(work);
+    if (pivot) {
+        /* convert back jpvt to ipvt */
+        if (sizeof(__CLPK_integer) != sizeof(ipvt[0])) {
+            for(i=0; i<n; ++i) {
+                ipvt[i] = jpvt[i];
+            }
+            free(jpvt);
+        }
+    }
+#else /* !USE_LAPACK */
+    /* Initialized data */
+
+#define p05 .05
+
+    /* System generated locals */
+    real d1;
+
+    /* Local variables */
+    int i, j, k, jp1;
+    real sum;
+    real temp;
+    int minmn;
+    real epsmch;
+    real ajnorm;
+
+/*     ********** */
+
+/*     subroutine qrfac */
+
+/*     this subroutine uses householder transformations with column */
+/*     pivoting (optional) to compute a qr factorization of the */
+/*     m by n matrix a. that is, qrfac determines an orthogonal */
+/*     matrix q, a permutation matrix p, and an upper trapezoidal */
+/*     matrix r with diagonal elements of nonincreasing magnitude, */
+/*     such that a*p = q*r. the householder transformation for */
+/*     column k, k = 1,2,...,min(m,n), is of the form */
+
+/*                           t */
+/*           i - (1/u(k))*u*u */
+
+/*     where u has zeros in the first k-1 positions. the form of */
+/*     this transformation and the method of pivoting first */
+/*     appeared in the corresponding linpack subroutine. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       a is an m by n array. on input a contains the matrix for */
+/*         which the qr factorization is to be computed. on output */
+/*         the strict upper trapezoidal part of a contains the strict */
+/*         upper trapezoidal part of r, and the lower trapezoidal */
+/*         part of a contains a factored form of q (the non-trivial */
+/*         elements of the u vectors described above). */
+
+/*       lda is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array a. */
+
+/*       pivot is a logical input variable. if pivot is set true, */
+/*         then column pivoting is enforced. if pivot is set false, */
+/*         then no column pivoting is done. */
+
+/*       ipvt is an integer output array of length lipvt. ipvt */
+/*         defines the permutation matrix p such that a*p = q*r. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+/*         if pivot is false, ipvt is not referenced. */
+
+/*       lipvt is a positive integer input variable. if pivot is false, */
+/*         then lipvt may be as small as 1. if pivot is true, then */
+/*         lipvt must be at least n. */
+
+/*       rdiag is an output array of length n which contains the */
+/*         diagonal elements of r. */
+
+/*       acnorm is an output array of length n which contains the */
+/*         norms of the corresponding columns of the input matrix a. */
+/*         if this information is not needed, then acnorm can coincide */
+/*         with rdiag. */
+
+/*       wa is a work array of length n. if pivot is false, then wa */
+/*         can coincide with rdiag. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm */
+
+/*       fortran-supplied ... dmax1,dsqrt,min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    (void)lipvt;
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __cminpack_func__(dpmpar)(1);
+
+/*     compute the initial column norms and initialize several arrays. */
+
+    for (j = 0; j < n; ++j) {
+	acnorm[j] = __cminpack_enorm__(m, &a[j * lda + 0]);
+	rdiag[j] = acnorm[j];
+	wa[j] = rdiag[j];
+	if (pivot) {
+	    ipvt[j] = j+1;
+	}
+    }
+
+/*     reduce a to r with householder transformations. */
+
+    minmn = min(m,n);
+    for (j = 0; j < minmn; ++j) {
+	if (pivot) {
+
+/*        bring the column of largest norm into the pivot position. */
+
+            int kmax = j;
+            for (k = j; k < n; ++k) {
+                if (rdiag[k] > rdiag[kmax]) {
+                    kmax = k;
+                }
+            }
+            if (kmax != j) {
+                for (i = 0; i < m; ++i) {
+                    temp = a[i + j * lda];
+                    a[i + j * lda] = a[i + kmax * lda];
+                    a[i + kmax * lda] = temp;
+                }
+                rdiag[kmax] = rdiag[j];
+                wa[kmax] = wa[j];
+                k = ipvt[j];
+                ipvt[j] = ipvt[kmax];
+                ipvt[kmax] = k;
+            }
+        }
+
+/*        compute the householder transformation to reduce the */
+/*        j-th column of a to a multiple of the j-th unit vector. */
+
+	ajnorm = __cminpack_enorm__(m - (j+1) + 1, &a[j + j * lda]);
+	if (ajnorm != 0.) {
+            if (a[j + j * lda] < 0.) {
+                ajnorm = -ajnorm;
+            }
+            for (i = j; i < m; ++i) {
+                a[i + j * lda] /= ajnorm;
+            }
+            a[j + j * lda] += 1.;
+
+/*        apply the transformation to the remaining columns */
+/*        and update the norms. */
+
+            jp1 = j + 1;
+            if (n > jp1) {
+                for (k = jp1; k < n; ++k) {
+                    sum = 0.;
+                    for (i = j; i < m; ++i) {
+                        sum += a[i + j * lda] * a[i + k * lda];
+                    }
+                    temp = sum / a[j + j * lda];
+                    for (i = j; i < m; ++i) {
+                        a[i + k * lda] -= temp * a[i + j * lda];
+                    }
+                    if (pivot && rdiag[k] != 0.) {
+                        temp = a[j + k * lda] / rdiag[k];
+                        /* Computing MAX */
+                        d1 = 1. - temp * temp;
+                        rdiag[k] *= sqrt((max((real)0.,d1)));
+                        /* Computing 2nd power */
+                        d1 = rdiag[k] / wa[k];
+                        if (p05 * (d1 * d1) <= epsmch) {
+                            rdiag[k] = __cminpack_enorm__(m - (j+1), &a[jp1 + k * lda]);
+                            wa[k] = rdiag[k];
+                        }
+                    }
+                }
+            }
+        }
+	rdiag[j] = -ajnorm;
+    }
+
+/*     last card of subroutine qrfac. */
+#endif /* !USE_LAPACK */
+} /* qrfac_ */
+
diff --git a/qrfac_.c b/qrfac_.c
new file mode 100644
index 0000000..5341de3
--- /dev/null
+++ b/qrfac_.c
@@ -0,0 +1,245 @@
+/* qrfac.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+__minpack_attr__
+void __minpack_func__(qrfac)(const int *m, const int *n, real *a, const int *
+	lda, const int *pivot, int *ipvt, const int *lipvt, real *rdiag,
+	 real *acnorm, real *wa)
+{
+    /* Initialized data */
+
+#define p05 .05
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2, i__3;
+    real d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__, j, k, jp1;
+    real sum;
+    int kmax;
+    real temp;
+    int minmn;
+    real epsmch;
+    real ajnorm;
+
+/*     ********** */
+
+/*     subroutine qrfac */
+
+/*     this subroutine uses householder transformations with column */
+/*     pivoting (optional) to compute a qr factorization of the */
+/*     m by n matrix a. that is, qrfac determines an orthogonal */
+/*     matrix q, a permutation matrix p, and an upper trapezoidal */
+/*     matrix r with diagonal elements of nonincreasing magnitude, */
+/*     such that a*p = q*r. the householder transformation for */
+/*     column k, k = 1,2,...,min(m,n), is of the form */
+
+/*                           t */
+/*           i - (1/u(k))*u*u */
+
+/*     where u has zeros in the first k-1 positions. the form of */
+/*     this transformation and the method of pivoting first */
+/*     appeared in the corresponding linpack subroutine. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       a is an m by n array. on input a contains the matrix for */
+/*         which the qr factorization is to be computed. on output */
+/*         the strict upper trapezoidal part of a contains the strict */
+/*         upper trapezoidal part of r, and the lower trapezoidal */
+/*         part of a contains a factored form of q (the non-trivial */
+/*         elements of the u vectors described above). */
+
+/*       lda is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array a. */
+
+/*       pivot is a logical input variable. if pivot is set true, */
+/*         then column pivoting is enforced. if pivot is set false, */
+/*         then no column pivoting is done. */
+
+/*       ipvt is an integer output array of length lipvt. ipvt */
+/*         defines the permutation matrix p such that a*p = q*r. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+/*         if pivot is false, ipvt is not referenced. */
+
+/*       lipvt is a positive integer input variable. if pivot is false, */
+/*         then lipvt may be as small as 1. if pivot is true, then */
+/*         lipvt must be at least n. */
+
+/*       rdiag is an output array of length n which contains the */
+/*         diagonal elements of r. */
+
+/*       acnorm is an output array of length n which contains the */
+/*         norms of the corresponding columns of the input matrix a. */
+/*         if this information is not needed, then acnorm can coincide */
+/*         with rdiag. */
+
+/*       wa is a work array of length n. if pivot is false, then wa */
+/*         can coincide with rdiag. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm */
+
+/*       fortran-supplied ... dmax1,dsqrt,min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    --acnorm;
+    --rdiag;
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1 * 1;
+    a -= a_offset;
+    --ipvt;
+    (void)lipvt;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+/*     compute the initial column norms and initialize several arrays. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	acnorm[j] = __minpack_func__(enorm)(m, &a[j * a_dim1 + 1]);
+	rdiag[j] = acnorm[j];
+	wa[j] = rdiag[j];
+	if (*pivot) {
+	    ipvt[j] = j;
+	}
+/* L10: */
+    }
+
+/*     reduce a to r with householder transformations. */
+
+    minmn = min(*m,*n);
+    i__1 = minmn;
+    for (j = 1; j <= i__1; ++j) {
+	if (! (*pivot)) {
+	    goto L40;
+	}
+
+/*        bring the column of largest norm into the pivot position. */
+
+	kmax = j;
+	i__2 = *n;
+	for (k = j; k <= i__2; ++k) {
+	    if (rdiag[k] > rdiag[kmax]) {
+		kmax = k;
+	    }
+/* L20: */
+	}
+	if (kmax == j) {
+	    goto L40;
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = a[i__ + j * a_dim1];
+	    a[i__ + j * a_dim1] = a[i__ + kmax * a_dim1];
+	    a[i__ + kmax * a_dim1] = temp;
+/* L30: */
+	}
+	rdiag[kmax] = rdiag[j];
+	wa[kmax] = wa[j];
+	k = ipvt[j];
+	ipvt[j] = ipvt[kmax];
+	ipvt[kmax] = k;
+L40:
+
+/*        compute the householder transformation to reduce the */
+/*        j-th column of a to a multiple of the j-th unit vector. */
+
+	i__2 = *m - j + 1;
+	ajnorm = __minpack_func__(enorm)(&i__2, &a[j + j * a_dim1]);
+	if (ajnorm == 0.) {
+	    goto L100;
+	}
+	if (a[j + j * a_dim1] < 0.) {
+	    ajnorm = -ajnorm;
+	}
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    a[i__ + j * a_dim1] /= ajnorm;
+/* L50: */
+	}
+	a[j + j * a_dim1] += 1.;
+
+/*        apply the transformation to the remaining columns */
+/*        and update the norms. */
+
+	jp1 = j + 1;
+	if (*n < jp1) {
+	    goto L100;
+	}
+	i__2 = *n;
+	for (k = jp1; k <= i__2; ++k) {
+	    sum = 0.;
+	    i__3 = *m;
+	    for (i__ = j; i__ <= i__3; ++i__) {
+		sum += a[i__ + j * a_dim1] * a[i__ + k * a_dim1];
+/* L60: */
+	    }
+	    temp = sum / a[j + j * a_dim1];
+	    i__3 = *m;
+	    for (i__ = j; i__ <= i__3; ++i__) {
+		a[i__ + k * a_dim1] -= temp * a[i__ + j * a_dim1];
+/* L70: */
+	    }
+	    if (! (*pivot) || rdiag[k] == 0.) {
+		goto L80;
+	    }
+	    temp = a[j + k * a_dim1] / rdiag[k];
+/* Computing MAX */
+/* Computing 2nd power */
+	    d__3 = temp;
+	    d__1 = 0., d__2 = 1. - d__3 * d__3;
+	    rdiag[k] *= sqrt((max(d__1,d__2)));
+/* Computing 2nd power */
+	    d__1 = rdiag[k] / wa[k];
+	    if (p05 * (d__1 * d__1) > epsmch) {
+		goto L80;
+	    }
+	    i__3 = *m - j;
+	    rdiag[k] = __minpack_func__(enorm)(&i__3, &a[jp1 + k * a_dim1]);
+	    wa[k] = rdiag[k];
+L80:
+/* L90: */
+	    ;
+	}
+L100:
+	rdiag[j] = -ajnorm;
+/* L110: */
+    }
+    return;
+
+/*     last card of subroutine qrfac. */
+
+} /* qrfac_ */
+
diff --git a/qrsolv.c b/qrsolv.c
new file mode 100644
index 0000000..6ab9e98
--- /dev/null
+++ b/qrsolv.c
@@ -0,0 +1,218 @@
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(qrsolv)(int n, real *r, int ldr, 
+	const int *ipvt, const real *diag, const real *qtb, real *x, 
+	real *sdiag, real *wa)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+
+    /* Local variables */
+    int i, j, k, l;
+    real cos, sin, sum, temp;
+    int nsing;
+    real qtbpj;
+
+/*     ********** */
+
+/*     subroutine qrsolv */
+
+/*     given an m by n matrix a, an n by n diagonal matrix d, */
+/*     and an m-vector b, the problem is to determine an x which */
+/*     solves the system */
+
+/*           a*x = b ,     d*x = 0 , */
+
+/*     in the least squares sense. */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then qrsolv expects */
+/*     the full upper triangle of r, the permutation matrix p, */
+/*     and the first n components of (q transpose)*b. the system */
+/*     a*x = b, d*x = 0, is then equivalent to */
+
+/*                  t       t */
+/*           r*z = q *b ,  p *d*p*z = 0 , */
+
+/*     where x = p*z. if this system does not have full rank, */
+/*     then a least squares solution is obtained. on output qrsolv */
+/*     also provides an upper triangular matrix s such that */
+
+/*            t   t               t */
+/*           p *(a *a + d*d)*p = s *s . */
+
+/*     s is computed within qrsolv and may be of separate interest. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle */
+/*         must contain the full upper triangle of the matrix r. */
+/*         on output the full upper triangle is unaltered, and the */
+/*         strict lower triangle contains the strict upper triangle */
+/*         (transposed) of the upper triangular matrix s. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       x is an output array of length n which contains the least */
+/*         squares solution of the system a*x = b, d*x = 0. */
+
+/*       sdiag is an output array of length n which contains the */
+/*         diagonal elements of the upper triangular matrix s. */
+
+/*       wa is a work array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+
+/*     copy r and (q transpose)*b to preserve input and initialize s. */
+/*     in particular, save the diagonal elements of r in x. */
+
+    for (j = 0; j < n; ++j) {
+	for (i = j; i < n; ++i) {
+	    r[i + j * ldr] = r[j + i * ldr];
+	}
+	x[j] = r[j + j * ldr];
+	wa[j] = qtb[j];
+    }
+
+/*     eliminate the diagonal matrix d using a givens rotation. */
+
+    for (j = 0; j < n; ++j) {
+
+/*        prepare the row of d to be eliminated, locating the */
+/*        diagonal element using p from the qr factorization. */
+
+	l = ipvt[j]-1;
+	if (diag[l] != 0.) {
+            for (k = j; k < n; ++k) {
+                sdiag[k] = 0.;
+            }
+            sdiag[j] = diag[l];
+
+/*        the transformations to eliminate the row of d */
+/*        modify only a single element of (q transpose)*b */
+/*        beyond the first n, which is initially zero. */
+
+            qtbpj = 0.;
+            for (k = j; k < n; ++k) {
+
+/*           determine a givens rotation which eliminates the */
+/*           appropriate element in the current row of d. */
+
+                if (sdiag[k] != 0.) {
+#                 ifdef USE_LAPACK
+                    dlartg_( &r[k + k * ldr], &sdiag[k], &cos, &sin, &temp );
+#                 else /* !USE_LAPACK */
+                    if (fabs(r[k + k * ldr]) < fabs(sdiag[k])) {
+                        real cotan;
+                        cotan = r[k + k * ldr] / sdiag[k];
+                        sin = p5 / sqrt(p25 + p25 * (cotan * cotan));
+                        cos = sin * cotan;
+                    } else {
+                        real tan;
+                        tan = sdiag[k] / r[k + k * ldr];
+                        cos = p5 / sqrt(p25 + p25 * (tan * tan));
+                        sin = cos * tan;
+                    }
+
+/*           compute the modified diagonal element of r and */
+/*           the modified element of ((q transpose)*b,0). */
+
+#                 endif /* !USE_LAPACK */
+                    temp = cos * wa[k] + sin * qtbpj;
+                    qtbpj = -sin * wa[k] + cos * qtbpj;
+                    wa[k] = temp;
+
+/*           accumulate the tranformation in the row of s. */
+#                 ifdef USE_CBLAS
+                    cblas_drot( n-k, &r[k + k * ldr], 1, &sdiag[k], 1, cos, sin );
+#                 else /* !USE_CBLAS */
+                    r[k + k * ldr] = cos * r[k + k * ldr] + sin * sdiag[k];
+                    if (n > k+1) {
+                        for (i = k+1; i < n; ++i) {
+                            temp = cos * r[i + k * ldr] + sin * sdiag[i];
+                            sdiag[i] = -sin * r[i + k * ldr] + cos * sdiag[i];
+                            r[i + k * ldr] = temp;
+                        }
+                    }
+#                 endif /* !USE_CBLAS */
+                }
+            }
+        }
+
+/*        store the diagonal element of s and restore */
+/*        the corresponding diagonal element of r. */
+
+	sdiag[j] = r[j + j * ldr];
+	r[j + j * ldr] = x[j];
+    }
+
+/*     solve the triangular system for z. if the system is */
+/*     singular, then obtain a least squares solution. */
+
+    nsing = n;
+    for (j = 0; j < n; ++j) {
+	if (sdiag[j] == 0. && nsing == n) {
+	    nsing = j;
+	}
+	if (nsing < n) {
+	    wa[j] = 0.;
+	}
+    }
+    if (nsing >= 1) {
+        for (k = 1; k <= nsing; ++k) {
+            j = nsing - k;
+            sum = 0.;
+            if (nsing > j+1) {
+                for (i = j+1; i < nsing; ++i) {
+                    sum += r[i + j * ldr] * wa[i];
+                }
+            }
+            wa[j] = (wa[j] - sum) / sdiag[j];
+        }
+    }
+
+/*     permute the components of z back to components of x. */
+
+    for (j = 0; j < n; ++j) {
+	l = ipvt[j]-1;
+	x[l] = wa[j];
+    }
+    return;
+
+/*     last card of subroutine qrsolv. */
+
+} /* qrsolv_ */
+
diff --git a/qrsolv_.c b/qrsolv_.c
new file mode 100644
index 0000000..2935dd3
--- /dev/null
+++ b/qrsolv_.c
@@ -0,0 +1,274 @@
+/* qrsolv.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+
+__minpack_attr__
+void __minpack_func__(qrsolv)(const int *n, real *r__, const int *ldr, 
+	const int *ipvt, const real *diag, const real *qtb, real *x, 
+	real *sdiag, real *wa)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+
+    /* System generated locals */
+    int r_dim1, r_offset, i__1, i__2, i__3;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, k, l, jp1, kp1;
+    real tan__, cos__, sin__, sum, temp, cotan;
+    int nsing;
+    real qtbpj;
+
+/*     ********** */
+
+/*     subroutine qrsolv */
+
+/*     given an m by n matrix a, an n by n diagonal matrix d, */
+/*     and an m-vector b, the problem is to determine an x which */
+/*     solves the system */
+
+/*           a*x = b ,     d*x = 0 , */
+
+/*     in the least squares sense. */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization, with column pivoting, of a. that is, if */
+/*     a*p = q*r, where p is a permutation matrix, q has orthogonal */
+/*     columns, and r is an upper triangular matrix with diagonal */
+/*     elements of nonincreasing magnitude, then qrsolv expects */
+/*     the full upper triangle of r, the permutation matrix p, */
+/*     and the first n components of (q transpose)*b. the system */
+/*     a*x = b, d*x = 0, is then equivalent to */
+
+/*                  t       t */
+/*           r*z = q *b ,  p *d*p*z = 0 , */
+
+/*     where x = p*z. if this system does not have full rank, */
+/*     then a least squares solution is obtained. on output qrsolv */
+/*     also provides an upper triangular matrix s such that */
+
+/*            t   t               t */
+/*           p *(a *a + d*d)*p = s *s . */
+
+/*     s is computed within qrsolv and may be of separate interest. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the full upper triangle */
+/*         must contain the full upper triangle of the matrix r. */
+/*         on output the full upper triangle is unaltered, and the */
+/*         strict lower triangle contains the strict upper triangle */
+/*         (transposed) of the upper triangular matrix s. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       ipvt is an integer input array of length n which defines the */
+/*         permutation matrix p such that a*p = q*r. column j of p */
+/*         is column ipvt(j) of the identity matrix. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       x is an output array of length n which contains the least */
+/*         squares solution of the system a*x = b, d*x = 0. */
+
+/*       sdiag is an output array of length n which contains the */
+/*         diagonal elements of the upper triangular matrix s. */
+
+/*       wa is a work array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    --sdiag;
+    --x;
+    --qtb;
+    --diag;
+    --ipvt;
+    r_dim1 = *ldr;
+    r_offset = 1 + r_dim1 * 1;
+    r__ -= r_offset;
+
+    /* Function Body */
+
+/*     copy r and (q transpose)*b to preserve input and initialize s. */
+/*     in particular, save the diagonal elements of r in x. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    r__[i__ + j * r_dim1] = r__[j + i__ * r_dim1];
+/* L10: */
+	}
+	x[j] = r__[j + j * r_dim1];
+	wa[j] = qtb[j];
+/* L20: */
+    }
+
+/*     eliminate the diagonal matrix d using a givens rotation. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+
+/*        prepare the row of d to be eliminated, locating the */
+/*        diagonal element using p from the qr factorization. */
+
+	l = ipvt[j];
+	if (diag[l] == 0.) {
+	    goto L90;
+	}
+	i__2 = *n;
+	for (k = j; k <= i__2; ++k) {
+	    sdiag[k] = 0.;
+/* L30: */
+	}
+	sdiag[j] = diag[l];
+
+/*        the transformations to eliminate the row of d */
+/*        modify only a single element of (q transpose)*b */
+/*        beyond the first n, which is initially zero. */
+
+	qtbpj = 0.;
+	i__2 = *n;
+	for (k = j; k <= i__2; ++k) {
+
+/*           determine a givens rotation which eliminates the */
+/*           appropriate element in the current row of d. */
+
+	    if (sdiag[k] == 0.) {
+		goto L70;
+	    }
+	    if ((d__1 = r__[k + k * r_dim1], abs(d__1)) >= (d__2 = sdiag[k], 
+		    abs(d__2))) {
+		goto L40;
+	    }
+	    cotan = r__[k + k * r_dim1] / sdiag[k];
+/* Computing 2nd power */
+	    d__1 = cotan;
+	    sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	    cos__ = sin__ * cotan;
+	    goto L50;
+L40:
+	    tan__ = sdiag[k] / r__[k + k * r_dim1];
+/* Computing 2nd power */
+	    d__1 = tan__;
+	    cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	    sin__ = cos__ * tan__;
+L50:
+
+/*           compute the modified diagonal element of r and */
+/*           the modified element of ((q transpose)*b,0). */
+
+	    r__[k + k * r_dim1] = cos__ * r__[k + k * r_dim1] + sin__ * sdiag[
+		    k];
+	    temp = cos__ * wa[k] + sin__ * qtbpj;
+	    qtbpj = -sin__ * wa[k] + cos__ * qtbpj;
+	    wa[k] = temp;
+
+/*           accumulate the tranformation in the row of s. */
+
+	    kp1 = k + 1;
+	    if (*n < kp1) {
+		goto L70;
+	    }
+	    i__3 = *n;
+	    for (i__ = kp1; i__ <= i__3; ++i__) {
+		temp = cos__ * r__[i__ + k * r_dim1] + sin__ * sdiag[i__];
+		sdiag[i__] = -sin__ * r__[i__ + k * r_dim1] + cos__ * sdiag[
+			i__];
+		r__[i__ + k * r_dim1] = temp;
+/* L60: */
+	    }
+L70:
+/* L80: */
+	    ;
+	}
+L90:
+
+/*        store the diagonal element of s and restore */
+/*        the corresponding diagonal element of r. */
+
+	sdiag[j] = r__[j + j * r_dim1];
+	r__[j + j * r_dim1] = x[j];
+/* L100: */
+    }
+
+/*     solve the triangular system for z. if the system is */
+/*     singular, then obtain a least squares solution. */
+
+    nsing = *n;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (sdiag[j] == 0. && nsing == *n) {
+	    nsing = j - 1;
+	}
+	if (nsing < *n) {
+	    wa[j] = 0.;
+	}
+/* L110: */
+    }
+    if (nsing < 1) {
+	goto L150;
+    }
+    i__1 = nsing;
+    for (k = 1; k <= i__1; ++k) {
+	j = nsing - k + 1;
+	sum = 0.;
+	jp1 = j + 1;
+	if (nsing < jp1) {
+	    goto L130;
+	}
+	i__2 = nsing;
+	for (i__ = jp1; i__ <= i__2; ++i__) {
+	    sum += r__[i__ + j * r_dim1] * wa[i__];
+/* L120: */
+	}
+L130:
+	wa[j] = (wa[j] - sum) / sdiag[j];
+/* L140: */
+    }
+L150:
+
+/*     permute the components of z back to components of x. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = ipvt[j];
+	x[l] = wa[j];
+/* L160: */
+    }
+    return;
+
+/*     last card of subroutine qrsolv. */
+
+} /* qrsolv_ */
+
diff --git a/r1mpyq.c b/r1mpyq.c
new file mode 100644
index 0000000..7b03d15
--- /dev/null
+++ b/r1mpyq.c
@@ -0,0 +1,122 @@
+/* r1mpyq.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(r1mpyq)(int m, int n, real *a, int
+	lda, const real *v, const real *w)
+{
+    /* System generated locals */
+    int a_dim1, a_offset;
+
+    /* Local variables */
+    int i, j, nm1, nmj;
+    real cos, sin, temp;
+
+/*     ********** */
+
+/*     subroutine r1mpyq */
+
+/*     given an m by n matrix a, this subroutine computes a*q where */
+/*     q is the product of 2*(n - 1) transformations */
+
+/*           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */
+
+/*     and gv(i), gw(i) are givens rotations in the (i,n) plane which */
+/*     eliminate elements in the i-th and n-th planes, respectively. */
+/*     q itself is not given, rather the information to recover the */
+/*     gv, gw rotations is supplied. */
+
+/*     the subroutine statement is */
+
+/*       subroutine r1mpyq(m,n,a,lda,v,w) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       a is an m by n array. on input a must contain the matrix */
+/*         to be postmultiplied by the orthogonal matrix q */
+/*         described above. on output a*q has replaced a. */
+
+/*       lda is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array a. */
+
+/*       v is an input array of length n. v(i) must contain the */
+/*         information necessary to recover the givens rotation gv(i) */
+/*         described above. */
+
+/*       w is an input array of length n. w(i) must contain the */
+/*         information necessary to recover the givens rotation gw(i) */
+/*         described above. */
+
+/*     subroutines called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --w;
+    --v;
+    a_dim1 = lda;
+    a_offset = 1 + a_dim1 * 1;
+    a -= a_offset;
+
+    /* Function Body */
+
+/*     apply the first set of givens rotations to a. */
+
+    nm1 = n - 1;
+    if (nm1 < 1) {
+        return;
+    }
+    for (nmj = 1; nmj <= nm1; ++nmj) {
+	j = n - nmj;
+	if (fabs(v[j]) > 1.) {
+	    cos = 1. / v[j];
+	    sin = sqrt(1. - cos * cos);
+	} else {
+	    sin = v[j];
+	    cos = sqrt(1. - sin * sin);
+	}
+	for (i = 1; i <= m; ++i) {
+	    temp = cos * a[i + j * a_dim1] - sin * a[i + n * a_dim1];
+	    a[i + n * a_dim1] = sin * a[i + j * a_dim1] + cos * a[
+		    i + n * a_dim1];
+	    a[i + j * a_dim1] = temp;
+	}
+    }
+
+/*     apply the second set of givens rotations to a. */
+
+    for (j = 1; j <= nm1; ++j) {
+	if (fabs(w[j]) > 1.) {
+	    cos = 1. / w[j];
+	    sin = sqrt(1. - cos * cos);
+	} else {
+	    sin = w[j];
+	    cos = sqrt(1. - sin * sin);
+	}
+	for (i = 1; i <= m; ++i) {
+	    temp = cos * a[i + j * a_dim1] + sin * a[i + n * a_dim1];
+	    a[i + n * a_dim1] = -sin * a[i + j * a_dim1] + cos * a[i + n * a_dim1];
+	    a[i + j * a_dim1] = temp;
+	}
+    }
+
+/*     last card of subroutine r1mpyq. */
+
+} /* r1mpyq_ */
+
diff --git a/r1mpyq_.c b/r1mpyq_.c
new file mode 100644
index 0000000..7e91141
--- /dev/null
+++ b/r1mpyq_.c
@@ -0,0 +1,155 @@
+/* r1mpyq.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+
+__minpack_attr__
+void __minpack_func__(r1mpyq)(const int *m, const int *n, real *a, const int *
+	lda, const real *v, const real *w)
+{
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, nm1, nmj;
+    real cos__, sin__, temp;
+
+/*     ********** */
+
+/*     subroutine r1mpyq */
+
+/*     given an m by n matrix a, this subroutine computes a*q where */
+/*     q is the product of 2*(n - 1) transformations */
+
+/*           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */
+
+/*     and gv(i), gw(i) are givens rotations in the (i,n) plane which */
+/*     eliminate elements in the i-th and n-th planes, respectively. */
+/*     q itself is not given, rather the information to recover the */
+/*     gv, gw rotations is supplied. */
+
+/*     the subroutine statement is */
+
+/*       subroutine r1mpyq(m,n,a,lda,v,w) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       a is an m by n array. on input a must contain the matrix */
+/*         to be postmultiplied by the orthogonal matrix q */
+/*         described above. on output a*q has replaced a. */
+
+/*       lda is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array a. */
+
+/*       v is an input array of length n. v(i) must contain the */
+/*         information necessary to recover the givens rotation gv(i) */
+/*         described above. */
+
+/*       w is an input array of length n. w(i) must contain the */
+/*         information necessary to recover the givens rotation gw(i) */
+/*         described above. */
+
+/*     subroutines called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --w;
+    --v;
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1 * 1;
+    a -= a_offset;
+
+    /* Function Body */
+
+/*     apply the first set of givens rotations to a. */
+
+    nm1 = *n - 1;
+    if (nm1 < 1) {
+	/* goto L50; */
+        return;
+    }
+    i__1 = nm1;
+    for (nmj = 1; nmj <= i__1; ++nmj) {
+	j = *n - nmj;
+	if ((d__1 = v[j], abs(d__1)) > 1.) {
+	    cos__ = 1. / v[j];
+	}
+	if ((d__1 = v[j], abs(d__1)) > 1.) {
+/* Computing 2nd power */
+	    d__2 = cos__;
+	    sin__ = sqrt(1. - d__2 * d__2);
+	}
+	if ((d__1 = v[j], abs(d__1)) <= 1.) {
+	    sin__ = v[j];
+	}
+	if ((d__1 = v[j], abs(d__1)) <= 1.) {
+/* Computing 2nd power */
+	    d__2 = sin__;
+	    cos__ = sqrt(1. - d__2 * d__2);
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = cos__ * a[i__ + j * a_dim1] - sin__ * a[i__ + *n * a_dim1];
+	    a[i__ + *n * a_dim1] = sin__ * a[i__ + j * a_dim1] + cos__ * a[
+		    i__ + *n * a_dim1];
+	    a[i__ + j * a_dim1] = temp;
+/* L10: */
+	}
+/* L20: */
+    }
+
+/*     apply the second set of givens rotations to a. */
+
+    i__1 = nm1;
+    for (j = 1; j <= i__1; ++j) {
+	if ((d__1 = w[j], abs(d__1)) > 1.) {
+	    cos__ = 1. / w[j];
+	}
+	if ((d__1 = w[j], abs(d__1)) > 1.) {
+/* Computing 2nd power */
+	    d__2 = cos__;
+	    sin__ = sqrt(1. - d__2 * d__2);
+	}
+	if ((d__1 = w[j], abs(d__1)) <= 1.) {
+	    sin__ = w[j];
+	}
+	if ((d__1 = w[j], abs(d__1)) <= 1.) {
+/* Computing 2nd power */
+	    d__2 = sin__;
+	    cos__ = sqrt(1. - d__2 * d__2);
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = cos__ * a[i__ + j * a_dim1] + sin__ * a[i__ + *n * a_dim1];
+	    a[i__ + *n * a_dim1] = -sin__ * a[i__ + j * a_dim1] + cos__ * a[
+		    i__ + *n * a_dim1];
+	    a[i__ + j * a_dim1] = temp;
+/* L30: */
+	}
+/* L40: */
+    }
+/* L50: */
+    return;
+
+/*     last card of subroutine r1mpyq. */
+
+} /* r1mpyq_ */
+
diff --git a/r1updt.c b/r1updt.c
new file mode 100644
index 0000000..8cf6b73
--- /dev/null
+++ b/r1updt.c
@@ -0,0 +1,236 @@
+/* r1updt.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(r1updt)(int m, int n, real *s, int
+	ls, const real *u, real *v, real *w, int *sing)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+
+    /* Local variables */
+    int i, j, l, jj, nm1;
+    real tan;
+    int nmj;
+    real cos, sin, tau, temp, giant, cotan;
+
+/*     ********** */
+
+/*     subroutine r1updt */
+
+/*     given an m by n lower trapezoidal matrix s, an m-vector u, */
+/*     and an n-vector v, the problem is to determine an */
+/*     orthogonal matrix q such that */
+
+/*                   t */
+/*           (s + u*v )*q */
+
+/*     is again lower trapezoidal. */
+
+/*     this subroutine determines q as the product of 2*(n - 1) */
+/*     transformations */
+
+/*           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */
+
+/*     where gv(i), gw(i) are givens rotations in the (i,n) plane */
+/*     which eliminate elements in the i-th and n-th planes, */
+/*     respectively. q itself is not accumulated, rather the */
+/*     information to recover the gv, gw rotations is returned. */
+
+/*     the subroutine statement is */
+
+/*       subroutine r1updt(m,n,s,ls,u,v,w,sing) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of s. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of s. n must not exceed m. */
+
+/*       s is an array of length ls. on input s must contain the lower */
+/*         trapezoidal matrix s stored by columns. on output s contains */
+/*         the lower trapezoidal matrix produced as described above. */
+
+/*       ls is a positive integer input variable not less than */
+/*         (n*(2*m-n+1))/2. */
+
+/*       u is an input array of length m which must contain the */
+/*         vector u. */
+
+/*       v is an array of length n. on input v must contain the vector */
+/*         v. on output v(i) contains the information necessary to */
+/*         recover the givens rotation gv(i) described above. */
+
+/*       w is an output array of length m. w(i) contains information */
+/*         necessary to recover the givens rotation gw(i) described */
+/*         above. */
+
+/*       sing is a logical output variable. sing is set true if any */
+/*         of the diagonal elements of the output s are zero. otherwise */
+/*         sing is set false. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more, */
+/*     john l. nazareth */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --w;
+    --u;
+    --v;
+    --s;
+    (void)ls;
+
+    /* Function Body */
+
+/*     giant is the largest magnitude. */
+
+    giant = __cminpack_func__(dpmpar)(3);
+
+/*     initialize the diagonal element pointer. */
+
+    jj = n * ((m << 1) - n + 1) / 2 - (m - n);
+
+/*     move the nontrivial part of the last column of s into w. */
+
+    l = jj;
+    for (i = n; i <= m; ++i) {
+	w[i] = s[l];
+	++l;
+    }
+
+/*     rotate the vector v into a multiple of the n-th unit vector */
+/*     in such a way that a spike is introduced into w. */
+
+    nm1 = n - 1;
+    if (nm1 >= 1) {
+        for (nmj = 1; nmj <= nm1; ++nmj) {
+            j = n - nmj;
+            jj -= m - j + 1;
+            w[j] = 0.;
+            if (v[j] != 0.) {
+
+/*        determine a givens rotation which eliminates the */
+/*        j-th element of v. */
+
+                if (fabs(v[n]) < fabs(v[j])) {
+                    cotan = v[n] / v[j];
+                    sin = p5 / sqrt(p25 + p25 * (cotan * cotan));
+                    cos = sin * cotan;
+                    tau = 1.;
+                    if (fabs(cos) * giant > 1.) {
+                        tau = 1. / cos;
+                    }
+                } else {
+                    tan = v[j] / v[n];
+                    cos = p5 / sqrt(p25 + p25 * (tan * tan));
+                    sin = cos * tan;
+                    tau = sin;
+                }
+
+/*        apply the transformation to v and store the information */
+/*        necessary to recover the givens rotation. */
+
+                v[n] = sin * v[j] + cos * v[n];
+                v[j] = tau;
+
+/*        apply the transformation to s and extend the spike in w. */
+
+                l = jj;
+                for (i = j; i <= m; ++i) {
+                    temp = cos * s[l] - sin * w[i];
+                    w[i] = sin * s[l] + cos * w[i];
+                    s[l] = temp;
+                    ++l;
+                }
+            }
+        }
+    }
+
+/*     add the spike from the rank 1 update to w. */
+
+    for (i = 1; i <= m; ++i) {
+	w[i] += v[n] * u[i];
+    }
+
+/*     eliminate the spike. */
+
+    *sing = FALSE_;
+    if (nm1 >= 1) {
+        for (j = 1; j <= nm1; ++j) {
+            if (w[j] != 0.) {
+
+/*        determine a givens rotation which eliminates the */
+/*        j-th element of the spike. */
+
+                if (fabs(s[jj]) < fabs(w[j])) {
+                    cotan = s[jj] / w[j];
+                    sin = p5 / sqrt(p25 + p25 * (cotan * cotan));
+                    cos = sin * cotan;
+                    tau = 1.;
+                    if (fabs(cos) * giant > 1.) {
+                        tau = 1. / cos;
+                    }
+                } else {
+                    tan = w[j] / s[jj];
+                    cos = p5 / sqrt(p25 + p25 * (tan * tan));
+                    sin = cos * tan;
+                    tau = sin;
+                }
+
+/*        apply the transformation to s and reduce the spike in w. */
+
+                l = jj;
+                for (i = j; i <= m; ++i) {
+                    temp = cos * s[l] + sin * w[i];
+                    w[i] = -sin * s[l] + cos * w[i];
+                    s[l] = temp;
+                    ++l;
+                }
+
+/*        store the information necessary to recover the */
+/*        givens rotation. */
+
+                w[j] = tau;
+            }
+
+/*        test for zero diagonal elements in the output s. */
+
+            if (s[jj] == 0.) {
+                *sing = TRUE_;
+            }
+            jj += m - j + 1;
+        }
+    }
+
+/*     move w back into the last column of the output s. */
+
+    l = jj;
+    for (i = n; i <= m; ++i) {
+	s[l] = w[i];
+	++l;
+    }
+    if (s[jj] == 0.) {
+	*sing = TRUE_;
+    }
+
+/*     last card of subroutine r1updt. */
+
+} /* __minpack_func__(r1updt) */
+
diff --git a/r1updt_.c b/r1updt_.c
new file mode 100644
index 0000000..b9114b4
--- /dev/null
+++ b/r1updt_.c
@@ -0,0 +1,283 @@
+/* r1updt.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(r1updt)(const int *m, const int *n, real *s, const int *
+	ls, const real *u, real *v, real *w, int *sing)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+    const int c__3 = 3;
+
+    /* System generated locals */
+    int i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, l, jj, nm1;
+    real tan__;
+    int nmj;
+    real cos__, sin__, tau, temp, giant, cotan;
+
+/*     ********** */
+
+/*     subroutine r1updt */
+
+/*     given an m by n lower trapezoidal matrix s, an m-vector u, */
+/*     and an n-vector v, the problem is to determine an */
+/*     orthogonal matrix q such that */
+
+/*                   t */
+/*           (s + u*v )*q */
+
+/*     is again lower trapezoidal. */
+
+/*     this subroutine determines q as the product of 2*(n - 1) */
+/*     transformations */
+
+/*           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */
+
+/*     where gv(i), gw(i) are givens rotations in the (i,n) plane */
+/*     which eliminate elements in the i-th and n-th planes, */
+/*     respectively. q itself is not accumulated, rather the */
+/*     information to recover the gv, gw rotations is returned. */
+
+/*     the subroutine statement is */
+
+/*       subroutine r1updt(m,n,s,ls,u,v,w,sing) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of s. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of s. n must not exceed m. */
+
+/*       s is an array of length ls. on input s must contain the lower */
+/*         trapezoidal matrix s stored by columns. on output s contains */
+/*         the lower trapezoidal matrix produced as described above. */
+
+/*       ls is a positive integer input variable not less than */
+/*         (n*(2*m-n+1))/2. */
+
+/*       u is an input array of length m which must contain the */
+/*         vector u. */
+
+/*       v is an array of length n. on input v must contain the vector */
+/*         v. on output v(i) contains the information necessary to */
+/*         recover the givens rotation gv(i) described above. */
+
+/*       w is an output array of length m. w(i) contains information */
+/*         necessary to recover the givens rotation gw(i) described */
+/*         above. */
+
+/*       sing is a logical output variable. sing is set true if any */
+/*         of the diagonal elements of the output s are zero. otherwise */
+/*         sing is set false. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more, */
+/*     john l. nazareth */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --w;
+    --u;
+    --v;
+    --s;
+    (void)ls;
+
+    /* Function Body */
+
+/*     giant is the largest magnitude. */
+
+    giant = __minpack_func__(dpmpar)(&c__3);
+
+/*     initialize the diagonal element pointer. */
+
+    jj = *n * ((*m << 1) - *n + 1) / 2 - (*m - *n);
+
+/*     move the nontrivial part of the last column of s into w. */
+
+    l = jj;
+    i__1 = *m;
+    for (i__ = *n; i__ <= i__1; ++i__) {
+	w[i__] = s[l];
+	++l;
+/* L10: */
+    }
+
+/*     rotate the vector v into a multiple of the n-th unit vector */
+/*     in such a way that a spike is introduced into w. */
+
+    nm1 = *n - 1;
+    if (nm1 < 1) {
+	goto L70;
+    }
+    i__1 = nm1;
+    for (nmj = 1; nmj <= i__1; ++nmj) {
+	j = *n - nmj;
+	jj -= *m - j + 1;
+	w[j] = 0.;
+	if (v[j] == 0.) {
+	    goto L50;
+	}
+
+/*        determine a givens rotation which eliminates the */
+/*        j-th element of v. */
+
+	if ((d__1 = v[*n], abs(d__1)) >= (d__2 = v[j], abs(d__2))) {
+	    goto L20;
+	}
+	cotan = v[*n] / v[j];
+/* Computing 2nd power */
+	d__1 = cotan;
+	sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	cos__ = sin__ * cotan;
+	tau = 1.;
+	if (abs(cos__) * giant > 1.) {
+	    tau = 1. / cos__;
+	}
+	goto L30;
+L20:
+	tan__ = v[j] / v[*n];
+/* Computing 2nd power */
+	d__1 = tan__;
+	cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	sin__ = cos__ * tan__;
+	tau = sin__;
+L30:
+
+/*        apply the transformation to v and store the information */
+/*        necessary to recover the givens rotation. */
+
+	v[*n] = sin__ * v[j] + cos__ * v[*n];
+	v[j] = tau;
+
+/*        apply the transformation to s and extend the spike in w. */
+
+	l = jj;
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    temp = cos__ * s[l] - sin__ * w[i__];
+	    w[i__] = sin__ * s[l] + cos__ * w[i__];
+	    s[l] = temp;
+	    ++l;
+/* L40: */
+	}
+L50:
+/* L60: */
+	;
+    }
+L70:
+
+/*     add the spike from the rank 1 update to w. */
+
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	w[i__] += v[*n] * u[i__];
+/* L80: */
+    }
+
+/*     eliminate the spike. */
+
+    *sing = FALSE_;
+    if (nm1 < 1) {
+	goto L140;
+    }
+    i__1 = nm1;
+    for (j = 1; j <= i__1; ++j) {
+	if (w[j] == 0.) {
+	    goto L120;
+	}
+
+/*        determine a givens rotation which eliminates the */
+/*        j-th element of the spike. */
+
+	if ((d__1 = s[jj], abs(d__1)) >= (d__2 = w[j], abs(d__2))) {
+	    goto L90;
+	}
+	cotan = s[jj] / w[j];
+/* Computing 2nd power */
+	d__1 = cotan;
+	sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	cos__ = sin__ * cotan;
+	tau = 1.;
+	if (abs(cos__) * giant > 1.) {
+	    tau = 1. / cos__;
+	}
+	goto L100;
+L90:
+	tan__ = w[j] / s[jj];
+/* Computing 2nd power */
+	d__1 = tan__;
+	cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	sin__ = cos__ * tan__;
+	tau = sin__;
+L100:
+
+/*        apply the transformation to s and reduce the spike in w. */
+
+	l = jj;
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    temp = cos__ * s[l] + sin__ * w[i__];
+	    w[i__] = -sin__ * s[l] + cos__ * w[i__];
+	    s[l] = temp;
+	    ++l;
+/* L110: */
+	}
+
+/*        store the information necessary to recover the */
+/*        givens rotation. */
+
+	w[j] = tau;
+L120:
+
+/*        test for zero diagonal elements in the output s. */
+
+	if (s[jj] == 0.) {
+	    *sing = TRUE_;
+	}
+	jj += *m - j + 1;
+/* L130: */
+    }
+L140:
+
+/*     move w back into the last column of the output s. */
+
+    l = jj;
+    i__1 = *m;
+    for (i__ = *n; i__ <= i__1; ++i__) {
+	s[l] = w[i__];
+	++l;
+/* L150: */
+    }
+    if (s[jj] == 0.) {
+	*sing = TRUE_;
+    }
+    return;
+
+/*     last card of subroutine r1updt. */
+
+} /* r1updt_ */
+
diff --git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..fef98bf
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,15 @@
+====== readme for minpack ======
+
+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.
+
+This directory contains the double-precision versions.
+
+Jorge More', Burt Garbow, and Ken Hillstrom at Argonne National Laboratory.
+
diff --git a/rwupdt.c b/rwupdt.c
new file mode 100644
index 0000000..2419585
--- /dev/null
+++ b/rwupdt.c
@@ -0,0 +1,141 @@
+/* rwupdt.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "cminpack.h"
+#include <math.h>
+#include "cminpackP.h"
+
+__cminpack_attr__
+void __cminpack_func__(rwupdt)(int n, real *r, int ldr, 
+	const real *w, real *b, real *alpha, real *cos, 
+	real *sin)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+
+    /* System generated locals */
+    int r_dim1, r_offset;
+
+    /* Local variables */
+    int i, j, jm1;
+    real tan, temp, rowj, cotan;
+
+/*     ********** */
+
+/*     subroutine rwupdt */
+
+/*     given an n by n upper triangular matrix r, this subroutine */
+/*     computes the qr decomposition of the matrix formed when a row */
+/*     is added to r. if the row is specified by the vector w, then */
+/*     rwupdt determines an orthogonal matrix q such that when the */
+/*     n+1 by n matrix composed of r augmented by w is premultiplied */
+/*     by (q transpose), the resulting matrix is upper trapezoidal. */
+/*     the matrix (q transpose) is the product of n transformations */
+
+/*           g(n)*g(n-1)* ... *g(1) */
+
+/*     where g(i) is a givens rotation in the (i,n+1) plane which */
+/*     eliminates elements in the (n+1)-st plane. rwupdt also */
+/*     computes the product (q transpose)*c where c is the */
+/*     (n+1)-vector (b,alpha). q itself is not accumulated, rather */
+/*     the information to recover the g rotations is supplied. */
+
+/*     the subroutine statement is */
+
+/*       subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the upper triangular part of */
+/*         r must contain the matrix to be updated. on output r */
+/*         contains the updated triangular matrix. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       w is an input array of length n which must contain the row */
+/*         vector to be added to r. */
+
+/*       b is an array of length n. on input b must contain the */
+/*         first n elements of the vector c. on output b contains */
+/*         the first n elements of the vector (q transpose)*c. */
+
+/*       alpha is a variable. on input alpha must contain the */
+/*         (n+1)-st element of the vector c. on output alpha contains */
+/*         the (n+1)-st element of the vector (q transpose)*c. */
+
+/*       cos is an output array of length n which contains the */
+/*         cosines of the transforming givens rotations. */
+
+/*       sin is an output array of length n which contains the */
+/*         sines of the transforming givens rotations. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */
+/*     jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --sin;
+    --cos;
+    --b;
+    --w;
+    r_dim1 = ldr;
+    r_offset = 1 + r_dim1 * 1;
+    r -= r_offset;
+
+    /* Function Body */
+
+    for (j = 1; j <= n; ++j) {
+	rowj = w[j];
+	jm1 = j - 1;
+
+/*        apply the previous transformations to */
+/*        r(i,j), i=1,2,...,j-1, and to w(j). */
+
+	if (jm1 >= 1) {
+            for (i = 1; i <= jm1; ++i) {
+                temp = cos[i] * r[i + j * r_dim1] + sin[i] * rowj;
+                rowj = -sin[i] * r[i + j * r_dim1] + cos[i] * rowj;
+                r[i + j * r_dim1] = temp;
+            }
+        }
+
+/*        determine a givens rotation which eliminates w(j). */
+
+	cos[j] = 1.;
+	sin[j] = 0.;
+	if (rowj != 0.) {
+            if (fabs(r[j + j * r_dim1]) < fabs(rowj)) {
+                cotan = r[j + j * r_dim1] / rowj;
+                sin[j] = p5 / sqrt(p25 + p25 * (cotan * cotan));
+                cos[j] = sin[j] * cotan;
+            } else {
+                tan = rowj / r[j + j * r_dim1];
+                cos[j] = p5 / sqrt(p25 + p25 * (tan * tan));
+                sin[j] = cos[j] * tan;
+            }
+
+/*        apply the current transformation to r(j,j), b(j), and alpha. */
+
+            r[j + j * r_dim1] = cos[j] * r[j + j * r_dim1] + sin[j] * rowj;
+            temp = cos[j] * b[j] + sin[j] * *alpha;
+            *alpha = -sin[j] * b[j] + cos[j] * *alpha;
+            b[j] = temp;
+        }
+    }
+
+/*     last card of subroutine rwupdt. */
+
+} /* rwupdt_ */
+
diff --git a/rwupdt_.c b/rwupdt_.c
new file mode 100644
index 0000000..d69da86
--- /dev/null
+++ b/rwupdt_.c
@@ -0,0 +1,162 @@
+/* rwupdt.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+
+__minpack_attr__
+void __minpack_func__(rwupdt)(const int *n, real *r__, const int *ldr, 
+	const real *w, real *b, real *alpha, real *cos__, 
+	real *sin__)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+
+    /* System generated locals */
+    int r_dim1, r_offset, i__1, i__2;
+    real d__1;
+
+    /* Local variables */
+    int i__, j, jm1;
+    real tan__, temp, rowj, cotan;
+
+/*     ********** */
+
+/*     subroutine rwupdt */
+
+/*     given an n by n upper triangular matrix r, this subroutine */
+/*     computes the qr decomposition of the matrix formed when a row */
+/*     is added to r. if the row is specified by the vector w, then */
+/*     rwupdt determines an orthogonal matrix q such that when the */
+/*     n+1 by n matrix composed of r augmented by w is premultiplied */
+/*     by (q transpose), the resulting matrix is upper trapezoidal. */
+/*     the matrix (q transpose) is the product of n transformations */
+
+/*           g(n)*g(n-1)* ... *g(1) */
+
+/*     where g(i) is a givens rotation in the (i,n+1) plane which */
+/*     eliminates elements in the (n+1)-st plane. rwupdt also */
+/*     computes the product (q transpose)*c where c is the */
+/*     (n+1)-vector (b,alpha). q itself is not accumulated, rather */
+/*     the information to recover the g rotations is supplied. */
+
+/*     the subroutine statement is */
+
+/*       subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an n by n array. on input the upper triangular part of */
+/*         r must contain the matrix to be updated. on output r */
+/*         contains the updated triangular matrix. */
+
+/*       ldr is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array r. */
+
+/*       w is an input array of length n which must contain the row */
+/*         vector to be added to r. */
+
+/*       b is an array of length n. on input b must contain the */
+/*         first n elements of the vector c. on output b contains */
+/*         the first n elements of the vector (q transpose)*c. */
+
+/*       alpha is a variable. on input alpha must contain the */
+/*         (n+1)-st element of the vector c. on output alpha contains */
+/*         the (n+1)-st element of the vector (q transpose)*c. */
+
+/*       cos is an output array of length n which contains the */
+/*         cosines of the transforming givens rotations. */
+
+/*       sin is an output array of length n which contains the */
+/*         sines of the transforming givens rotations. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, dudley v. goetschel, kenneth e. hillstrom, */
+/*     jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --sin__;
+    --cos__;
+    --b;
+    --w;
+    r_dim1 = *ldr;
+    r_offset = 1 + r_dim1 * 1;
+    r__ -= r_offset;
+
+    /* Function Body */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	rowj = w[j];
+	jm1 = j - 1;
+
+/*        apply the previous transformations to */
+/*        r(i,j), i=1,2,...,j-1, and to w(j). */
+
+	if (jm1 < 1) {
+	    goto L20;
+	}
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = cos__[i__] * r__[i__ + j * r_dim1] + sin__[i__] * rowj;
+	    rowj = -sin__[i__] * r__[i__ + j * r_dim1] + cos__[i__] * rowj;
+	    r__[i__ + j * r_dim1] = temp;
+/* L10: */
+	}
+L20:
+
+/*        determine a givens rotation which eliminates w(j). */
+
+	cos__[j] = 1.;
+	sin__[j] = 0.;
+	if (rowj == 0.) {
+	    goto L50;
+	}
+	if ((d__1 = r__[j + j * r_dim1], abs(d__1)) >= abs(rowj)) {
+	    goto L30;
+	}
+	cotan = r__[j + j * r_dim1] / rowj;
+/* Computing 2nd power */
+	d__1 = cotan;
+	sin__[j] = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	cos__[j] = sin__[j] * cotan;
+	goto L40;
+L30:
+	tan__ = rowj / r__[j + j * r_dim1];
+/* Computing 2nd power */
+	d__1 = tan__;
+	cos__[j] = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	sin__[j] = cos__[j] * tan__;
+L40:
+
+/*        apply the current transformation to r(j,j), b(j), and alpha. */
+
+	r__[j + j * r_dim1] = cos__[j] * r__[j + j * r_dim1] + sin__[j] * 
+		rowj;
+	temp = cos__[j] * b[j] + sin__[j] * *alpha;
+	*alpha = -sin__[j] * b[j] + cos__[j] * *alpha;
+	b[j] = temp;
+L50:
+/* L60: */
+	;
+    }
+    return;
+
+/*     last card of subroutine rwupdt. */
+
+} /* rwupdt_ */
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cminpack.git



More information about the debian-science-commits mailing list