<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FEigen%2FLevenbergMarquardtNumerical</id>
		<title>CPP/Eigen/LevenbergMarquardtNumerical - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FEigen%2FLevenbergMarquardtNumerical"/>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/Eigen/LevenbergMarquardtNumerical&amp;action=history"/>
		<updated>2026-08-05T04:01:16Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://programmingexamples.net/w/index.php?title=CPP/Eigen/LevenbergMarquardtNumerical&amp;diff=4989&amp;oldid=prev</id>
		<title>Daviddoria at 13:55, 5 November 2011</title>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/Eigen/LevenbergMarquardtNumerical&amp;diff=4989&amp;oldid=prev"/>
				<updated>2011-11-05T13:55:36Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 13:55, 5 November 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; epsilon(0) = 1e-5;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; epsilon(0) = 1e-5;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; Eigen::VectorXf fvec1;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; Eigen::VectorXf fvec1&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(1)&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; operator()(x + epsilon, fvec1);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; operator()(x + epsilon, fvec1);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; Eigen::VectorXf fvec2;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; Eigen::VectorXf fvec2&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(1)&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; operator()(x - epsilon, fvec2);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; operator()(x - epsilon, fvec2);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; fjac = (fvec1 - fvec2)/2.0f;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; fjac = (fvec1 - fvec2)/2.0f;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	<entry>
		<id>http://programmingexamples.net/w/index.php?title=CPP/Eigen/LevenbergMarquardtNumerical&amp;diff=4987&amp;oldid=prev</id>
		<title>Daviddoria: Created page with '==LevenbergMarquardtNumerical.cpp== &lt;source lang=&quot;cpp&quot;&gt; #include &lt;iostream&gt;  #include &lt;Eigen/Dense&gt;  #include &lt;unsupported/Eigen/NonLinearOptimization&gt;  // LM minimize for sum_i …'</title>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/Eigen/LevenbergMarquardtNumerical&amp;diff=4987&amp;oldid=prev"/>
				<updated>2011-11-05T13:53:08Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;==LevenbergMarquardtNumerical.cpp== &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;lt;iostream&amp;gt;  #include &amp;lt;Eigen/Dense&amp;gt;  #include &amp;lt;unsupported/Eigen/NonLinearOptimization&amp;gt;  // LM minimize for sum_i …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==LevenbergMarquardtNumerical.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;Eigen/Dense&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;unsupported/Eigen/NonLinearOptimization&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// LM minimize for sum_i (f_i(x))^2&lt;br /&gt;
&lt;br /&gt;
struct MyFunctor&lt;br /&gt;
{&lt;br /&gt;
  int operator()(const Eigen::VectorXf &amp;amp;x, Eigen::VectorXf &amp;amp;fvec) const&lt;br /&gt;
  {&lt;br /&gt;
    // Implement y = (x-5)^2 (remember, operator() should return the value BEFORE it is squared.&lt;br /&gt;
    fvec(0) = x(0) - 5.0;&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  int df(const Eigen::VectorXf &amp;amp;x, Eigen::MatrixXf &amp;amp;fjac) const&lt;br /&gt;
  {&lt;br /&gt;
    Eigen::VectorXf epsilon(1);&lt;br /&gt;
    epsilon(0) = 1e-5;&lt;br /&gt;
&lt;br /&gt;
    Eigen::VectorXf fvec1;&lt;br /&gt;
    operator()(x + epsilon, fvec1);&lt;br /&gt;
    Eigen::VectorXf fvec2;&lt;br /&gt;
    operator()(x - epsilon, fvec2);&lt;br /&gt;
    fjac = (fvec1 - fvec2)/2.0f;&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  int inputs() const { return 1; }// inputs is the dimension of x.&lt;br /&gt;
  int values() const { return 1; } // &amp;quot;values&amp;quot; is the number of f_i and &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
  Eigen::VectorXf x(1);&lt;br /&gt;
  x(0) = 2;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;x: &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  MyFunctor functor;&lt;br /&gt;
  Eigen::LevenbergMarquardt&amp;lt;MyFunctor, float&amp;gt; lm(functor);&lt;br /&gt;
  lm.minimize(x);&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;x that minimizes the function: &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
PROJECT(NumericalDerivative)&lt;br /&gt;
include_directories(/media/portable/src/Eigen)&lt;br /&gt;
# FIND_PACKAGE(Eigen3 REQUIRED)&lt;br /&gt;
# INCLUDE(${Eigen_USE_FILE})&lt;br /&gt;
&lt;br /&gt;
include_directories(${EIGEN3_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}/unsupported/)&lt;br /&gt;
SET(CMAKE_CXX_FLAGS &amp;quot;${CMAKE_CXX_FLAGS} -DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(NumericalDerivative NumericalDerivative.cpp )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	</feed>