DGtal 1.4.0
Loading...
Searching...
No Matches
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.
 
typedef TagFalse IsBounded
 A BigInteger is not bounded.
 
typedef TagTrue IsUnsigned
 A BigInteger can be signed and unsigned.
 
typedef TagTrue IsSigned
 a BigInteger can be signed and unsigned.
 
typedef TagTrue IsSpecialized
 Is that a number type with specific traits.
 
typedef DGtal::BigInteger SignedVersion
 Alias to the signed version of a BigInteger (aka a BigInteger).
 
typedef DGtal::BigInteger UnsignedVersion
 Alias to the unsigned version of a BigInteger (aka a BigInteger).
 
typedef DGtal::BigInteger ReturnType
 Alias to the type that should be used as return type.
 
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.
 

Static Public Member Functions

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

Static Public Attributes

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

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 407 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 410 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 409 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 412 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 413 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 411 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 422 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 417 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 415 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 416 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 514 of file NumberTraits.h.

515 {
516 return aT.get_d();
517 }

◆ 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 493 of file NumberTraits.h.

494 {
495 return aT.get_si();
496 }

◆ castToUInt64_t()

template<typename Enable >
static DGtal::uint64_t DGtal::NumberTraitsImpl< DGtal::BigInteger, Enable >::castToUInt64_t ( const DGtal::BigInteger & aT)
inlinestaticnoexcept

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

Definition at line 503 of file NumberTraits.h.

504 {
505 return aT.get_ui();
506 }

◆ 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 462 of file NumberTraits.h.

463 {
464 FATAL_ERROR_MSG(false, "UnBounded interger type does not support digits() function");
465 return 0;
466 }

◆ 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 525 of file NumberTraits.h.

526 {
527 return mpz_even_p( aT.get_mpz_t() );
528 }

◆ 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 473 of file NumberTraits.h.

474 {
475 return UNBOUNDED;
476 }
@ UNBOUNDED

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 483 of file NumberTraits.h.

484 {
485 return SIGNED;
486 }

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 454 of file NumberTraits.h.

455 {
456 FATAL_ERROR_MSG(false, "UnBounded interger type does not support max() function");
457 return ZERO;
458 }
static const DGtal::BigInteger ZERO
Constant Zero.

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 446 of file NumberTraits.h.

447 {
448 FATAL_ERROR_MSG(false, "UnBounded interger type does not support min() function");
449 return ZERO;
450 }

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 536 of file NumberTraits.h.

537 {
538 return mpz_odd_p( aT.get_mpz_t() );
539 }

◆ one()

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

Return the one of this integer.

Definition at line 439 of file NumberTraits.h.

440 {
441 return ONE;
442 }
static const DGtal::BigInteger ONE
Constant One.

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 432 of file NumberTraits.h.

433 {
434 return ZERO;
435 }

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 428 of file NumberTraits.h.

◆ ZERO

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

Constant Zero.

Definition at line 425 of file NumberTraits.h.


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