DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Data Structures | Functions
DGtal::detail Namespace Reference

Data Structures

struct  HasNestedType
 Aim: Checks whether type has a nested type called 'Type' or not. NB: from en.wikipedia.org/wiki/Substitution_failure_is_not_an_error. More...
struct  IsCirculator
 Aim: Checks whether type is a circular or a classical iterator. NB: from en.wikipedia.org/wiki/Substitution_failure_is_not_an_error. More...
struct  IsCirculator< IC, true >
struct  IteratorCirculatorTypeImpl
 Aim: Defines the Iterator or Circulator type as a nested type according to the value of b. More...
struct  IteratorCirculatorTypeImpl< true >
struct  LabelledMapMemFunctor
class  PosIndepScaleIndepSCEstimator
class  PosIndepScaleDepSCEstimator
class  PosDepScaleIndepSCEstimator
class  PosDepScaleDepSCEstimator
struct  TangentAngleFromDSS
struct  NormalizedTangentVectorFromDSS
struct  TangentVectorFromDSS
struct  CurvatureFromDCA
struct  CurvatureFromDCA< false >
struct  NormalVectorFromDCA
struct  TangentVectorFromDCA
struct  DistanceFromDCA
struct  CurvatureFromDSSLength
struct  CurvatureFromDSSLengthAndWidth
class  CurvatureFromDSSBaseEstimator

Functions

template<typename IC >
bool isNotEmpty (const IC &itb, const IC &ite, IteratorType)
template<typename IC >
bool isNotEmpty (const IC &c1, const IC &c2, CirculatorType)
template<typename TData >
std::pair< unsigned int,
unsigned int > 
argminLabelledMapMemoryUsageForGeometricDistribution (unsigned int L, double prob_no_data, double prob_one_data)

Function Documentation

template<typename TData >
std::pair< unsigned int, unsigned int > DGtal::detail::argminLabelledMapMemoryUsageForGeometricDistribution ( unsigned int  L,
double  prob_no_data,
double  prob_one_data 
)

Tries to find the best values N and M which will minimized the memory usage of a LabelledMap, for the distribution specified by the parameters.

Template Parameters:
TValuethe type of data that will be stored.
Parameters:
Lthe total number of labels.
prob_no_dataProbability that there is no data at this location.
prob_one_dataIf there is a possibility to have a data, this probability is used to define a geometric distribution that defines the number of data (ie valid labels) at this place. The smaller, the higher is the expectation. 0.5 means E(X) = 1.
Returns:
the pair (N,M) that minimizes the memory usage of a LabelledMap for the given distribution.

Definition at line 1225 of file LabelledMap.ih.

References DGtal::detail::LabelledMapMemFunctor::fctNM().

{
unsigned int sL = 2 * ( ( ( L - 1 ) / 16 ) + 1 ); // word of 16bits
// std::cerr << "L=" << L << " sL=" << sL << std::endl;
LabelledMapMemFunctor F( prob_one_data, prob_no_data, sL, sizeof( TData ),
sizeof( TData* ), 2 );
double m = -1.0;
unsigned int Nopt = 0;
unsigned int Mopt = 0;
for ( unsigned int N = 1; N < L; ++N )
for ( unsigned int M = 2; M < (L-N); ++M )
{
// std::cerr << "Fmem(" << N << "," << M << ")="
// << F.fctNM( N, M ) << std::endl;
if ( ( m < 0.0 ) || ( F.fctNM( N, M ) < m ) )
{
Nopt = N; Mopt = M;
m = F.fctNM( Nopt, Mopt );
}
}
return std::make_pair( Nopt, Mopt );
}
template<typename IC >
bool DGtal::detail::isNotEmpty ( const IC &  itb,
const IC &  ite,
IteratorType   
)
inline
template<typename IC >
bool DGtal::detail::isNotEmpty ( const IC &  c1,
const IC &  c2,
CirculatorType   
)
inline

Definition at line 63 of file IteratorFunctions.h.

{
// using isValid method does not work with reverse circulator
//(generally speaking adapters of circulators that does not have any isValid method)
// return ( ( c1.isValid() ) && ( c2.isValid() ) );
IC c; //c is not valid
return ( (c1 != c) && (c2 != c) );
}