Skip to content
Snippets Groups Projects
Commit 9580b36b authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

BUG: avoid segfault : minimize an empty vector causes a crash

parent b7d826ff
Branches
Tags
No related merge requests found
...@@ -141,17 +141,21 @@ SarParametricMapFunction<TInputImage, TCoordRep> ...@@ -141,17 +141,21 @@ SarParametricMapFunction<TInputImage, TCoordRep>
} }
} }
if(this->GetCoeff()->GetNumberOfPoints()>0)
{
// Create the linear system // Create the linear system
vnl_sparse_matrix_linear_system<double> linearSystem(a, b); vnl_sparse_matrix_linear_system<double> linearSystem(a, b);
vnl_lsqr linearSystemSolver(linearSystem); vnl_lsqr linearSystemSolver(linearSystem);
// And solve it // And solve it
linearSystemSolver.minimize(bestParams); if(this->GetCoeff()->GetNumberOfPoints()>1)
linearSystemSolver.minimize(bestParams);
for(unsigned int pointId = 0; pointId < nbCoef; ++pointId) for(unsigned int pointId = 0; pointId < nbCoef; ++pointId)
{ {
this->GetCoeff()->SetPointData(pointId,bestParams[pointId]); this->GetCoeff()->SetPointData(pointId,bestParams[pointId]);
} }
}
m_IsInitialize = true; m_IsInitialize = true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment