Skip to content
Snippets Groups Projects
Commit 3110c11b authored by Julien Malik's avatar Julien Malik
Browse files

ENG: use vnl_svd instead of sparse system solver

parent f9a55585
Branches
Tags
No related merge requests found
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
#include "otbImageKeywordlist.h" #include "otbImageKeywordlist.h"
#include "base/ossimKeywordlist.h" #include "base/ossimKeywordlist.h"
#include <vnl/algo/vnl_lsqr.h> #include <vnl/algo/vnl_svd.h>
#include <vnl/vnl_sparse_matrix_linear_system.h>
#include <vnl/vnl_least_squares_function.h>
namespace otb namespace otb
{ {
...@@ -150,8 +148,9 @@ SarParametricMapFunction<TInputImage, TCoordRep> ...@@ -150,8 +148,9 @@ SarParametricMapFunction<TInputImage, TCoordRep>
unsigned int nbRecords = pointSet->GetNumberOfPoints(); unsigned int nbRecords = pointSet->GetNumberOfPoints();
unsigned int nbCoef = m_Coeff.Rows() * m_Coeff.Cols(); unsigned int nbCoef = m_Coeff.Rows() * m_Coeff.Cols();
vnl_sparse_matrix<double> a(nbRecords, nbCoef); vnl_matrix<double> a(nbRecords, nbCoef);
vnl_vector<double> b(nbRecords), bestParams(nbCoef); vnl_vector<double> b(nbRecords), bestParams(nbCoef);
a.fill(0);
b.fill(0); b.fill(0);
bestParams.fill(0); bestParams.fill(0);
...@@ -176,12 +175,9 @@ SarParametricMapFunction<TInputImage, TCoordRep> ...@@ -176,12 +175,9 @@ SarParametricMapFunction<TInputImage, TCoordRep>
} }
} }
// Create the linear system // Solve linear system with SVD decomposition
vnl_sparse_matrix_linear_system<double> linearSystem(a, b); vnl_svd<double> svd(a);
bestParams = svd.solve(b);
// And solve it
vnl_lsqr linearSystemSolver(linearSystem);
linearSystemSolver.minimize(bestParams);
for (unsigned int xcoeff = 0; xcoeff < m_Coeff.Cols(); ++xcoeff) for (unsigned int xcoeff = 0; xcoeff < m_Coeff.Cols(); ++xcoeff)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment