DigitBase API
Index
SymBasis.DigitBase.BaseIntSymBasis.DigitBase.BaseIntRangeBase.copyBase.countBase.countBase.readBase.readBase.writeBase.writeSymBasis.DigitBase.decSymBasis.DigitBase.decSymBasis.DigitBase.flipSymBasis.DigitBase.flipSymBasis.DigitBase.flipSymBasis.DigitBase.flipSymBasis.DigitBase.incSymBasis.DigitBase.incSymBasis.DigitBase.num_digits_in_baseSymBasis.DigitBase.permuteSymBasis.DigitBase.permuteSymBasis.DigitBase.permuteSymBasis.DigitBase.@bi_str
SymBasis.DigitBase.BaseInt — Type
BaseInt{T<:Integer,Ti<:Integer,B}
BaseInt(
value::T;
base::Integer=2,
Ti=Int
) where T<:IntegerA 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 baseB.
Constructor Arguments
value::T: The integer value to be represented in baseB.
Constructor Keyword Arguments
base::Integer=2: The base in which to represent the integer. Default is2.Ti=Int: The integer type used for indexing digits. Default isInt.
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newBaseIntinstance.
The constructor checks that the base is at least 2.
SymBasis.DigitBase.BaseIntRange — Type
BaseIntRange{T<:Integer,Ti<:Integer,B}A range of SymBasis.DigitBase.BaseInt{T,Ti,B} numbers with specified first, step, and last elements.
Fields
first::SymBasis.DigitBase.BaseInt{T,Ti,B}: The first element of the range.step::SymBasis.DigitBase.BaseInt{T,Ti,B}: The step size between consecutive elements.last::SymBasis.DigitBase.BaseInt{T,Ti,B}: The last element of the range.
Base.copy — Method
Base.copy(b::SymBasis.DigitBase.BaseInt{T,Ti,B}) where {T,Ti,B}Create a copy of the SymBasis.DigitBase.BaseInt instance b.
Arguments
b::SymBasis.DigitBase.BaseInt{T,Ti,B}: TheSymBasis.DigitBase.BaseIntinstance to copy.
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the same value asb.
Base.count — Method
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-Binteger.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 ind.
Base.count — Method
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-Binteger.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 digitdat the specified positions.
Base.read — Method
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-Binteger.pos::AbstractVector{Ti}: The positions of the digits to read (1-based indexing).
Returns
Vector{Int}: The digits at the specified positions.
Base.read — Method
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
b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-Binteger.pos::Ti: The position of the digit to read (1-based indexing).
Returns
Int: The digit at the specified position.
Base.write — Method
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-Binteger.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
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digits written.
Base.write — Method
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-Binteger.pos::Ti: The position of the digit to write (1-based indexing).d::Integer: The digit to write at the specified position.
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digit written.
SymBasis.DigitBase.dec — Method
dec(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::AbstractVector{Ti}) where {T,Ti,B}Decrement 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-Binteger.pos::AbstractVector{Ti}: The positions of the digits to decrement (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digits decremented.
SymBasis.DigitBase.dec — Method
dec(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::Ti) where {T,Ti,B}Decrement the digit at position pos in the base-B representation of the integer b.
Arguments
b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-Binteger.pos::Ti: The position of the digit to decrement (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digit decremented.
SymBasis.DigitBase.flip — Method
flip(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::AbstractVector{Ti}) where {T,Ti,B}Flip 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-Binteger.pos::AbstractVector{Ti}: The positions of the digits to flip (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digits flipped.
SymBasis.DigitBase.flip — Method
flip(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::Ti) where {T,Ti,B}Flip the digit at position pos in the base-B representation of the integer b.
Arguments
b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-Binteger.pos::Ti: The position of the digit to flip (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digit flipped.
SymBasis.DigitBase.flip — Method
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
SymBasis.DigitBase.BaseInt{T,Ti,2}: A newSymBasis.DigitBase.BaseIntinstance with the specified bits flipped.
SymBasis.DigitBase.flip — Method
flip(b::SymBasis.DigitBase.BaseInt{T,Ti,2}, pos::Ti) where {T,Ti}Flip the bit at position pos 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::Ti: The position of the bit to flip (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,2}: A newSymBasis.DigitBase.BaseIntinstance with the specified bit flipped.
SymBasis.DigitBase.inc — Method
inc(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::AbstractVector{Ti}) where {T,Ti,B}Increment 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-Binteger.pos::AbstractVector{Ti}: The positions of the digits to increment (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digits incremented.
SymBasis.DigitBase.inc — Method
inc(b::SymBasis.DigitBase.BaseInt{T,Ti,B}, pos::Ti) where {T,Ti,B}Increment the digit at position pos in the base-B representation of the integer b.
Arguments
b::SymBasis.DigitBase.BaseInt{T,Ti,B}: The base-Binteger.pos::Ti: The position of the digit to increment (1-based indexing).
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digit incremented.
SymBasis.DigitBase.num_digits_in_base — Method
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 representnin basebase.
SymBasis.DigitBase.permute — Method
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-Binteger.pos::AbstractVector{Ti}: The positions of the digits to permute (1-based indexing).perm::AbstractVector{<:Integer}: The permutation vector, where thei-th element indicates the new value for the digit originally equal toi-1.
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digits permuted according toperm.
SymBasis.DigitBase.permute — Method
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-Binteger.perm::AbstractVector{Ti}: The permutation vector, where thei-th element indicates the new position for the digit originally at positioni.
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the digits permuted according toperm.
SymBasis.DigitBase.permute — Method
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-Binteger.pos::Ti: The position of the digit to permute (1-based indexing).perm::AbstractVector{<:Integer}: The permutation vector, where thei-th element indicates the new value for the digit originally equal toi-1.
Returns
SymBasis.DigitBase.BaseInt{T,Ti,B}: A newSymBasis.DigitBase.BaseIntinstance with the specified digit permuted according toperm.
SymBasis.DigitBase.@bi_str — Macro
bi"..."BCreate a SymBasis.DigitBase.BaseInt instance from a string representation of a number in the specified base B.
Arguments
str::String: The string representation of the number.B::Integer: The base in which the number is represented.
Returns
SymBasis.DigitBase.BaseInt{UInt,Int,B}: TheSymBasis.DigitBase.BaseIntinstance representing the number.