DGtal  1.5.beta
DGtal::IntegerConverter< dim, DGtal::BigInteger > Struct Template Reference

#include <DGtal/kernel/IntegerConverter.h>

Public Types

typedef DGtal::BigInteger Integer
 

Static Public Member Functions

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

Detailed Description

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

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 BigInteger

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 320 of file IntegerConverter.h.

Member Typedef Documentation

◆ Integer

template<DGtal::Dimension dim>
typedef DGtal::BigInteger DGtal::IntegerConverter< dim, DGtal::BigInteger >::Integer

Definition at line 321 of file IntegerConverter.h.

Member Function Documentation

◆ cast() [1/6]

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

Definition at line 369 of file IntegerConverter.h.

370  {
371  return i;
372  }

◆ cast() [2/6]

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

Definition at line 325 of file IntegerConverter.h.

326  {
327  return DGtal::BigInteger( i );
328  }
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Definition: BasicTypes.h:79

◆ cast() [3/6]

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

Definition at line 346 of file IntegerConverter.h.

347  {
348  DGtal::BigInteger tmp;
349  detail::mpz_set_sll( tmp.get_mpz_t(), i );
350  return tmp;
351  }
static void mpz_set_sll(mpz_t n, long long sll)
----------— GMP SPECIALIZED SERVICES -------------------------—

References DGtal::detail::mpz_set_sll().

◆ cast() [4/6]

template<DGtal::Dimension dim>
static PointVector< dim, DGtal::BigInteger > DGtal::IntegerConverter< dim, DGtal::BigInteger >::cast ( PointVector< dim, DGtal::BigInteger p)
inlinestatic

Conversion of a lattice point.

Parameters
pany point
Returns
the same point

Definition at line 380 of file IntegerConverter.h.

381  {
382  return p;
383  }

◆ cast() [5/6]

template<DGtal::Dimension dim>
static PointVector< dim, DGtal::BigInteger > DGtal::IntegerConverter< dim, DGtal::BigInteger >::cast ( PointVector< dim, DGtal::int32_t p)
inlinestatic

Conversion of a lattice point.

Parameters
pany point
Returns
the same point

Definition at line 336 of file IntegerConverter.h.

337  {
338  PointVector< dim, DGtal::BigInteger > q;
339  for ( DGtal::Dimension i = 0; i < dim; i++ )
340  q[ i ] = cast( p[ i ] );
341  return q;
342  }
DGtal::uint32_t Dimension
Definition: Common.h:136
static DGtal::BigInteger cast(DGtal::int32_t i)
unsigned int dim(const Vector &z)

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

◆ cast() [6/6]

template<DGtal::Dimension dim>
static PointVector< dim, DGtal::BigInteger > DGtal::IntegerConverter< dim, DGtal::BigInteger >::cast ( PointVector< dim, DGtal::int64_t p)
inlinestatic

Conversion of a lattice point.

Parameters
pany point
Returns
the same point

Definition at line 359 of file IntegerConverter.h.

360  {
361  PointVector< dim, DGtal::BigInteger > q;
362  for ( DGtal::Dimension i = 0; i < dim; i++ )
363  q[ i ] = cast( p[ i ] );
364  return q;
365  }

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


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