DGtal  1.2.0
Public Types | Static Public Member Functions
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 321 of file IntegerConverter.h.

Member Typedef Documentation

◆ Integer

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

Definition at line 322 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 370 of file IntegerConverter.h.

371  {
372  return i;
373  }

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

327  {
328  return DGtal::BigInteger( i );
329  }
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 347 of file IntegerConverter.h.

348  {
349  DGtal::BigInteger tmp;
350  detail::mpz_set_sll( tmp.get_mpz_t(), i );
351  return tmp;
352  }
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 381 of file IntegerConverter.h.

382  {
383  return p;
384  }

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

338  {
339  PointVector< dim, DGtal::BigInteger > q;
340  for ( DGtal::Dimension i = 0; i < dim; i++ )
341  q[ i ] = cast( p[ i ] );
342  return q;
343  }
DGtal::uint32_t Dimension
Definition: Common.h:137
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 360 of file IntegerConverter.h.

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

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


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