DigitBase API

Index

SymBasis.DigitBase.BaseIntType
BaseInt{T<:Integer,Ti<:Integer,B}
BaseInt(
    value::T;
    base::Integer=2,
    Ti=Int
) where T<:Integer

A type representing an integer in base B, where T is the underlying integer type used to store the value, and Ti is the integer type used for indexing digits.

Fields

  • value::T: The integer value representing the number in base B.

Constructor Arguments

  • value::T: The integer value to be represented in base B.

Constructor Keyword Arguments

  • base::Integer=2: The base in which to represent the integer. Default is 2.
  • Ti=Int: The integer type used for indexing digits. Default is Int.

Returns

The constructor checks that the base is at least 2.

source
Base.countMethod
Base.count(
    b::SymBasis.BaseInt{T,Ti,B},
    pos::AbstractVector{Ti},
    d::AbstractVector{<:Integer}
) where {T,Ti,B}

Count the occurrences of each digit in d at the specified positions in the base-B representation of the integer b.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::AbstractVector{Ti}: The positions of the digits to check (1-based indexing).
  • d::AbstractVector{<:Integer}: The digits to count.

Returns

  • Vector{Int}: A vector containing the counts of occurrences for each digit in d.
source
Base.countMethod
Base.count(
    b::SymBasis.DigitBase.BaseInt{T,Ti,B},
    pos::AbstractVector{Ti},
    d::Integer
) where {T,Ti,B}

Count the occurrences of the digit d at the specified positions in the base-B representation of the integer b.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::AbstractVector{Ti}: The positions of the digits to check (1-based indexing).
  • d::Integer: The digit to count.

Returns

  • Int: The count of occurrences of the digit d at the specified positions.
source
Base.readMethod
Base.read(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::AbstractVector{Ti}) where {T,Ti,B}

Read the digits at the specified positions in the base-B representation of the integer b.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::AbstractVector{Ti}: The positions of the digits to read (1-based indexing).

Returns

  • Vector{Int}: The digits at the specified positions.
source
Base.readMethod
Base.read(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::Ti) where {T,Ti,B}

Read the digit at position pos in the base-B representation of the integer b.

Arguments

Returns

  • Int: The digit at the specified position.
source
Base.writeMethod
Base.write(
    b::SymBasis.BaseInt{T,Ti,B},
    pos::AbstractVector{Ti},
    d::AbstractVector{<:Integer}
) where {T,Ti,B}

Write the digits d at the specified positions in the base-B representation of the integer b.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::AbstractVector{Ti}: The positions of the digits to write (1-based indexing).
  • d::AbstractVector{<:Integer}: The digits to write at the specified positions.

Returns

source
Base.writeMethod
Base.write(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::Ti, d::Integer) where {T,Ti,B}

Write the digit d at position pos in the base-B representation of the integer b.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::Ti: The position of the digit to write (1-based indexing).
  • d::Integer: The digit to write at the specified position.

Returns

source
SymBasis.DigitBase.flipMethod
flip(b::SymBasis.DigitBase.BaseInt{T,Ti,2}, pos::AbstractVector{Ti}) where {T,Ti}

Flip the bits at the specified positions in the base-2 representation of the integer b. This is an optimized specialization for base-2, using bitwise XOR.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,2}: The base-2 integer.
  • pos::AbstractVector{Ti}: The positions of the bits to flip (1-based indexing).

Returns

source
SymBasis.DigitBase.num_digits_in_baseMethod
num_digits_in_base(n::Integer, base::Int)

Return the number of digits required to represent the integer n in the specified base base.

Arguments

  • n::Integer: The integer to evaluate.
  • base::Int: The base for representation.

Returns

  • Int: The number of digits required to represent n in base base.
source
SymBasis.DigitBase.permuteMethod
permute(
    b::SymBasis.DigitBase.BaseInt{T,Ti,B},
    pos::AbstractVector{Ti},
    perm::AbstractVector{<:Integer}
) where {T,Ti,B}

Permute the digits at the specified positions in the base-B representation of the integer b according to the permutation vector perm.

Note: This function permutes the values of the digits at the specified positions, rather than their positions.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::AbstractVector{Ti}: The positions of the digits to permute (1-based indexing).
  • perm::AbstractVector{<:Integer}: The permutation vector, where the i-th element indicates the new value for the digit originally equal to i-1.

Returns

source
SymBasis.DigitBase.permuteMethod
permute(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, perm::AbstractVector{Ti}) where {T,Ti,B}

Permute the positions of the digits in the base-B representation of the integer b according to the permutation vector perm.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • perm::AbstractVector{Ti}: The permutation vector, where the i-th element indicates the new position for the digit originally at position i.

Returns

source
SymBasis.DigitBase.permuteMethod
permute(
    b::SymBasis.DigitBase.BaseInt{T,Ti,B},
    pos::Ti,
    perm::AbstractVector{<:Integer}
) where {T,Ti,B}

Permute the digit at position pos in the base-B representation of the integer b according to the permutation vector perm.

Note: This function permutes the value of the digit at the specified position, rather than its position.

Arguments

  • b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-B integer.
  • pos::Ti: The position of the digit to permute (1-based indexing).
  • perm::AbstractVector{<:Integer}: The permutation vector, where the i-th element indicates the new value for the digit originally equal to i-1.

Returns

source