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

BUG: workaround for dlclose issue #418

Avoid
Inconsistency detected by ld.so: dl-close.c: 737: _dl_close: Assertion
`map->l_init_called' failed!
when unloading application in the ApplicationEngine framework

This error is seen on Linux platform with gcc >= 4.5
and appears to be caused by STB_GNU_UNIQUE symbols
in the LineSegmentDetection application, a recent gcc feature.

nm otbapp_LineSegmentDetection.so | grep " u "
shows that these symbols comes from the use of Boost.Math
in Code/FeatureExtraction/otbLineSegmentDetector.txx
to compute some mathematical special functions values.

Those special functions are actually provided by netlib/slantec
in the ITK Utilities.
parent 7516ec3f
Branches
Tags
No related merge requests found
......@@ -18,8 +18,6 @@
#ifndef __otbLineSegmentDetector_txx
#define __otbLineSegmentDetector_txx
#include <boost/math/special_functions/beta.hpp>
#include "otbLineSegmentDetector.h"
#include "itkImageRegionIterator.h"
#include "itkNumericTraits.h"
......@@ -38,6 +36,10 @@
#include "itkMatrix.h"
#include "itkSymmetricEigenAnalysis.h"
extern "C" double dlngam_(double *x);
extern "C" double dbetai_(double *x, double *a, double *b);
namespace otb
{
......@@ -1018,12 +1020,20 @@ LineSegmentDetector<TInputImage, TPrecision>
if (k == 0)
return -logNT;
val = -logNT - log10( boost::math::ibeta(k_d, n_d - k_d + 1, p) );
double x = p;
double a = k_d;
double b = n_d - k_d + 1.0;
val = -logNT - log10( dbetai_(&p, &a, &b) );
if (vnl_math_isinf(val)) /* approximate by the first term of the tail */
val = -logNT - (boost::math::lgamma(n_d + 1.0) - boost::math::lgamma(k_d + 1) - boost::math::lgamma(n_d - k_d + 1)) / CONST_LN10
- k_d * log10(p) - (n_d - k_d) * log10(1.0 - p);
{
double x1 = n_d + 1.0;
double x2 = k_d + 1.0;
double x3 = n_d - k_d + 1.0;
val = -logNT - (dlngam_(&x1) - dlngam_(&x2) - dlngam_(&x3)) / CONST_LN10
- k_d * log10(p) - (n_d - k_d) * log10(1.0 - p);
}
return val;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment