DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions
DGtal::IntegerConverter< dim, DGtal::int64_t > Struct Template Reference

#include <DGtal/kernel/IntegerConverter.h>

Public Types

typedef DGtal::int64_t Integer
 

Static Public Member Functions

static DGtal::int64_t cast (DGtal::int32_t i)
 
static PointVector< dim, DGtal::int64_tcast (PointVector< dim, DGtal::int32_t > p)
 
static DGtal::int64_t cast (DGtal::int64_t i)
 
static PointVector< dim, DGtal::int64_tcast (PointVector< dim, DGtal::int64_t > p)
 
static DGtal::int64_t cast (DGtal::BigInteger i)
 
static PointVector< dim, DGtal::int64_tcast (PointVector< dim, DGtal::BigInteger > p)
 

Detailed Description

template<DGtal::Dimension dim>
struct DGtal::IntegerConverter< dim, DGtal::int64_t >

Allows seamless conversion of integral types and lattice points, while checking for errors when going from a more precise to a less precise type.

Specialized version for int64_t.

Template Parameters
dimstatic constant of type DGtal::Dimension that specifies the static dimension of the space and thus the number of elements of the Point or Vector.

Definition at line 236 of file IntegerConverter.h.

Member Typedef Documentation

◆ Integer

Definition at line 237 of file IntegerConverter.h.

Member Function Documentation

◆ cast() [1/6]

template<DGtal::Dimension dim>
static DGtal::int64_t DGtal::IntegerConverter< dim, DGtal::int64_t >::cast ( DGtal::BigInteger  i)
inlinestatic
Parameters
iany integer
Returns
the same integer

Definition at line 281 of file IntegerConverter.h.

282 {
283 DGtal::int64_t r = detail::mpz_get_sll( i.get_mpz_t() );
285 detail::mpz_set_sll( tmp.get_mpz_t(), r );
286 if ( tmp != i )
287 trace.warning() << "Bad integer conversion: " << i << " -> " << r
288 << std::endl;
289 return r;
290 }
std::ostream & warning()
static void mpz_set_sll(mpz_t n, long long sll)
----------— GMP SPECIALIZED SERVICES -------------------------—
static long long mpz_get_sll(mpz_t n)
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
Trace trace
Definition: Common.h:154
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Definition: BasicTypes.h:79

References DGtal::detail::mpz_get_sll(), DGtal::detail::mpz_set_sll(), DGtal::trace, and DGtal::Trace::warning().

◆ cast() [2/6]

template<DGtal::Dimension dim>
static DGtal::int64_t DGtal::IntegerConverter< dim, DGtal::int64_t >::cast ( DGtal::int32_t  i)
inlinestatic
Parameters
iany integer
Returns
the same integer

Definition at line 241 of file IntegerConverter.h.

242 {
243 return i;
244 }

◆ cast() [3/6]

template<DGtal::Dimension dim>
static DGtal::int64_t DGtal::IntegerConverter< dim, DGtal::int64_t >::cast ( DGtal::int64_t  i)
inlinestatic
Parameters
iany integer
Returns
the same integer

Definition at line 262 of file IntegerConverter.h.

263 {
264 return i;
265 }

◆ cast() [4/6]

Conversion of a lattice point.

Parameters
pany point
Returns
the same point

Definition at line 298 of file IntegerConverter.h.

299 {
300 PointVector< dim, DGtal::int64_t > q;
301 for ( DGtal::Dimension i = 0; i < dim; i++ )
302 q[ i ] = cast( p[ i ] );
303 return q;
304 }
DGtal::uint32_t Dimension
Definition: Common.h:137
static DGtal::int64_t cast(DGtal::int32_t i)

References DGtal::IntegerConverter< dim, TInteger >::cast(), and dim.

◆ cast() [5/6]

Conversion of a lattice point.

Parameters
pany point
Returns
the same point

Definition at line 252 of file IntegerConverter.h.

253 {
254 PointVector< dim, DGtal::int64_t > q;
255 for ( DGtal::Dimension i = 0; i < dim; i++ )
256 q[ i ] = cast( p[ i ] );
257 return q;
258 }

References DGtal::IntegerConverter< dim, TInteger >::cast(), and dim.

◆ cast() [6/6]

Conversion of a lattice point.

Parameters
pany point
Returns
the same point

Definition at line 273 of file IntegerConverter.h.

274 {
275 return p;
276 }

The documentation for this struct was generated from the following file: