DGtal  1.2.0
Public Types | Static Public Member Functions | Static Public Attributes
DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable > Struct Template Reference

Specialization of NumberTraitsImpl for DGtal::BigInteger. More...

#include <DGtal/kernel/NumberTraits.h>

Public Types

typedef TagTrue IsIntegral
 A BigInteger is of integral type. More...
 
typedef TagFalse IsBounded
 A BigInteger is not bounded. More...
 
typedef TagTrue IsUnsigned
 A BigInteger can be signed and unsigned. More...
 
typedef TagTrue IsSigned
 a BigInteger can be signed and unsigned. More...
 
typedef TagTrue IsSpecialized
 Is that a number type with specific traits. More...
 
typedef DGtal::BigInteger SignedVersion
 Alias to the signed version of a BigInteger (aka a BigInteger). More...
 
typedef DGtal::BigInteger UnsignedVersion
 Alias to the unsigned version of a BigInteger (aka a BigInteger). More...
 
typedef DGtal::BigInteger ReturnType
 Alias to the type that should be used as return type. More...
 
typedef boost::call_traits< BigInteger >::param_type ParamType
 Defines a type that represents the "best" way to pass a parameter of type T to a function. More...
 

Static Public Member Functions

static ReturnType zero () noexcept
 Return the zero of this integer. More...
 
static ReturnType one () noexcept
 Return the one of this integer. More...
 
static ReturnType min () noexcept
 Return the minimum possible value (trigger an error since BitInteger is unbounded). More...
 
static ReturnType max () noexcept
 Return the maximum possible value (trigger an error since BitInteger is unbounded). More...
 
static unsigned int digits () noexcept
 Return the number of significant binary digits (trigger an error since BitInteger is unbounded). More...
 
static BoundEnum isBounded () noexcept
 Return the bounding type of the number. More...
 
static SignEnum isSigned () noexcept
 Return the sign type of the number. More...
 
static DGtal::int64_t castToInt64_t (const DGtal::BigInteger &aT) noexcept
 Cast method to DGtal::int64_t (for I/O or board export uses only). More...
 
static double castToDouble (const DGtal::BigInteger &aT) noexcept
 Cast method to double (for I/O or board export uses only). More...
 
static bool even (ParamType aT) noexcept
 Check the parity of a number. More...
 
static bool odd (ParamType aT) noexcept
 Check the parity of a number. More...
 

Static Public Attributes

static const DGtal::BigInteger ZERO = 0
 Constant Zero. More...
 
static const DGtal::BigInteger ONE = 1
 Constant One. More...
 

Detailed Description

template<typename Enable>
struct DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >

Specialization of NumberTraitsImpl for DGtal::BigInteger.

Note that DGtal::BigInteger represents signed and unsigned arbitrary-size integers. Therefore both IsUnsigned and IsSigned are TagTrue.

Definition at line 387 of file NumberTraits.h.

Member Typedef Documentation

◆ IsBounded

template<typename Enable >
typedef TagFalse DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::IsBounded

A BigInteger is not bounded.

Definition at line 390 of file NumberTraits.h.

◆ IsIntegral

template<typename Enable >
typedef TagTrue DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::IsIntegral

A BigInteger is of integral type.

Definition at line 389 of file NumberTraits.h.

◆ IsSigned

template<typename Enable >
typedef TagTrue DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::IsSigned

a BigInteger can be signed and unsigned.

Definition at line 392 of file NumberTraits.h.

◆ IsSpecialized

template<typename Enable >
typedef TagTrue DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::IsSpecialized

Is that a number type with specific traits.

Definition at line 393 of file NumberTraits.h.

◆ IsUnsigned

template<typename Enable >
typedef TagTrue DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::IsUnsigned

A BigInteger can be signed and unsigned.

Definition at line 391 of file NumberTraits.h.

◆ ParamType

template<typename Enable >
typedef boost::call_traits<BigInteger>::param_type DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::ParamType

Defines a type that represents the "best" way to pass a parameter of type T to a function.

Definition at line 402 of file NumberTraits.h.

◆ ReturnType

template<typename Enable >
typedef DGtal::BigInteger DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::ReturnType

Alias to the type that should be used as return type.

Definition at line 397 of file NumberTraits.h.

◆ SignedVersion

template<typename Enable >
typedef DGtal::BigInteger DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::SignedVersion

Alias to the signed version of a BigInteger (aka a BigInteger).

Definition at line 395 of file NumberTraits.h.

◆ UnsignedVersion

template<typename Enable >
typedef DGtal::BigInteger DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::UnsignedVersion

Alias to the unsigned version of a BigInteger (aka a BigInteger).

Definition at line 396 of file NumberTraits.h.

Member Function Documentation

◆ castToDouble()

template<typename Enable >
static double DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::castToDouble ( const DGtal::BigInteger aT)
inlinestaticnoexcept

Cast method to double (for I/O or board export uses only).

Definition at line 483 of file NumberTraits.h.

484  {
485  return aT.get_d();
486  }

◆ castToInt64_t()

template<typename Enable >
static DGtal::int64_t DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::castToInt64_t ( const DGtal::BigInteger aT)
inlinestaticnoexcept

Cast method to DGtal::int64_t (for I/O or board export uses only).

Definition at line 473 of file NumberTraits.h.

474  {
475  return aT.get_si();
476  }

◆ digits()

template<typename Enable >
static unsigned int DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::digits ( )
inlinestaticnoexcept

Return the number of significant binary digits (trigger an error since BitInteger is unbounded).

Definition at line 442 of file NumberTraits.h.

443  {
444  FATAL_ERROR_MSG(false, "UnBounded interger type does not support digits() function");
445  return 0;
446  }

◆ even()

template<typename Enable >
static bool DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::even ( ParamType  aT)
inlinestaticnoexcept

Check the parity of a number.

Parameters
aTany number.
Returns
'true' iff the number is even.

Definition at line 494 of file NumberTraits.h.

495  {
496  return mpz_even_p( aT.get_mpz_t() );
497  }

◆ isBounded()

template<typename Enable >
static BoundEnum DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::isBounded ( )
inlinestaticnoexcept

Return the bounding type of the number.

Returns
BOUNDED, UNBOUNDED, or BOUND_UNKNOWN.

Definition at line 453 of file NumberTraits.h.

454  {
455  return UNBOUNDED;
456  }
@ UNBOUNDED
Definition: NumberTraits.h:54

References DGtal::UNBOUNDED.

◆ isSigned()

template<typename Enable >
static SignEnum DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::isSigned ( )
inlinestaticnoexcept

Return the sign type of the number.

Returns
SIGNED, UNSIGNED or SIGN_UNKNOWN.

Definition at line 463 of file NumberTraits.h.

464  {
465  return SIGNED;
466  }
@ SIGNED
Definition: NumberTraits.h:57

References DGtal::SIGNED.

◆ max()

template<typename Enable >
static ReturnType DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::max ( )
inlinestaticnoexcept

Return the maximum possible value (trigger an error since BitInteger is unbounded).

Definition at line 434 of file NumberTraits.h.

435  {
436  FATAL_ERROR_MSG(false, "UnBounded interger type does not support max() function");
437  return ZERO;
438  }
static const DGtal::BigInteger ZERO
Constant Zero.
Definition: NumberTraits.h:405

References DGtal::NumberTraitsImpl< T, Enable >::ZERO.

◆ min()

template<typename Enable >
static ReturnType DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::min ( )
inlinestaticnoexcept

Return the minimum possible value (trigger an error since BitInteger is unbounded).

Definition at line 426 of file NumberTraits.h.

427  {
428  FATAL_ERROR_MSG(false, "UnBounded interger type does not support min() function");
429  return ZERO;
430  }

References DGtal::NumberTraitsImpl< T, Enable >::ZERO.

◆ odd()

template<typename Enable >
static bool DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::odd ( ParamType  aT)
inlinestaticnoexcept

Check the parity of a number.

Parameters
aTany number.
Returns
'true' iff the number is odd.

Definition at line 505 of file NumberTraits.h.

506  {
507  return mpz_odd_p( aT.get_mpz_t() );
508  }

◆ one()

template<typename Enable >
static ReturnType DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::one ( )
inlinestaticnoexcept

Return the one of this integer.

Definition at line 419 of file NumberTraits.h.

420  {
421  return ONE;
422  }
static const DGtal::BigInteger ONE
Constant One.
Definition: NumberTraits.h:408

References DGtal::NumberTraitsImpl< T, Enable >::ONE.

◆ zero()

template<typename Enable >
static ReturnType DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::zero ( )
inlinestaticnoexcept

Return the zero of this integer.

Definition at line 412 of file NumberTraits.h.

413  {
414  return ZERO;
415  }

References DGtal::NumberTraitsImpl< T, Enable >::ZERO.

Field Documentation

◆ ONE

template<typename Enable >
const DGtal::BigInteger DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::ONE = 1
static

Constant One.

Definition at line 408 of file NumberTraits.h.

◆ ZERO

template<typename Enable >
const DGtal::BigInteger DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::ZERO = 0
static

Constant Zero.

Definition at line 405 of file NumberTraits.h.


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