<?xml version="1.0" encoding="UTF-8"?>
<hdevelop file_version="1.1" halcon_version="13.0">
<procedure name="update_levenberg_marquardt">
<interface>
<ic>
<par name="JacobiMat" base_type="ctrl" dimension="0"/>
<par name="Lambda" base_type="ctrl" dimension="0"/>
<par name="FuncValue" base_type="ctrl" dimension="0"/>
<par name="EPS" base_type="ctrl" dimension="0"/>
</ic>
<oc>
<par name="Update" base_type="ctrl" dimension="0"/>
</oc>
</interface>
<body>
<c> * Copyright (c) MVTec Software GmbH.  All rights reserved.</c>
<c> *</c>
<c> * All use of this software is subject to the terms of the revised BSD</c>
<c> * license.  You should have received a copy of this license along</c>
<c> * with this source code in a file named "license.txt."</c>
<c></c>
<c>* Computes the update in a Levenberg-Marquardt minimization </c>
<c>* of the square norm of a (possibly vector-valued) function F.</c>
<c>* It solves the equation (J^T*J+Lambda*diag(J^T*J))Delta = J^T*F for Delta</c>
<c>* with</c>
<c>* Delta = update step (control parameter Update)</c>
<c>* J = Jacobi matrix at the current point (control parameter JacobiMat)</c>
<c>* Lambda = dampening factor (control parameter Lambda)</c>
<c>* F = value of the function F at the current point (control parameter FuncValue)</c>
<c></c>
<c>* compute (J^T*J+Lambda*diag(J^T*J))   (which will be stored in JTJ)</c>
<l>mult_matrix (JacobiMat, JacobiMat, 'ATB', JTJ)</l>
<l>get_diagonal_matrix (JTJ, 0, DiagVector)</l>
<l>scale_matrix (DiagVector, 1+Lambda, DiagLambda)</l>
<l>clear_matrix (DiagVector)</l>
<c>* overwrite diagonal of JTJ</c>
<l>set_diagonal_matrix (JTJ, DiagLambda, 0)</l>
<l>clear_matrix (DiagLambda)</l>
<c>* right hand side of the equation</c>
<l>mult_matrix (JacobiMat, FuncValue, 'ATB', RHS)</l>
<c></c>
<c>* solve the equation</c>
<l>solve_matrix (JTJ, 'general', EPS, RHS, Update)</l>
<c></c>
<c>* clean up</c>
<l>clear_matrix (JTJ)</l>
<l>clear_matrix (RHS)</l>
<c></c>
<c></c>
<c></c>
<l>return ()</l>
</body>
<docu id="update_levenberg_marquardt">
<parameters>
<parameter id="EPS"/>
<parameter id="FuncValue">
<default_type>integer</default_type>
<mixed_type>false</mixed_type>
<sem_type>matrix</sem_type>
<type_list>
<item>integer</item>
</type_list>
</parameter>
<parameter id="JacobiMat">
<default_type>integer</default_type>
<mixed_type>false</mixed_type>
<sem_type>matrix</sem_type>
<type_list>
<item>integer</item>
</type_list>
</parameter>
<parameter id="Lambda">
<default_type>real</default_type>
<mixed_type>false</mixed_type>
<multivalue>false</multivalue>
<sem_type>real</sem_type>
<type_list>
<item>real</item>
</type_list>
</parameter>
<parameter id="Update">
<default_type>integer</default_type>
<mixed_type>false</mixed_type>
<sem_type>matrix</sem_type>
<type_list>
<item>integer</item>
</type_list>
</parameter>
</parameters>
</docu>
</procedure>
</hdevelop>
