lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.generator.MixedRadixInt Class Reference

Representation of a permuted mixed radix (PMR) integer. More...

Public Member Functions

MixedRadixInt copy ()
boolean equals (Object obj)
int get ()
 Get the value as an integer.
int get (int n)
 Get the value as an integer after dropping the first n digits.
List< Integer > getDigits ()
 Return the digits.
List< Integer > getPermutation ()
 Return the permutation list.
List< Integer > getRadixes ()
 Return the radixes.
int hashCode ()
void increment ()
 Increment the number by one, using the permutation vector to determine the order in which the digits are incremented.
int magnitude ()
 Return the magnitude of this PMR, which is defined to be the number of times that increment() would need to invoked starting with zero before the value returned by get() would be reached.
 MixedRadixInt (List< Integer > digits, List< Integer > radixes, List< Integer > permutation)
 Create a mixed radix number with the specified digits and radixes, which are given low-order digits first.
int numDigits ()
 Return the number of digits in this mixed radix number.
void set (int v)
 Set the value of this number to equal that of the specified integer.
void setMagnitude (int v)
 Set the magnitude of this number to equal that of the specified integer, which is the number of times that increment must be invoked from zero for the value returned by get() to equal v.
String toString ()
 Give a string representation of the number, where each digit is represented as nr, where r is the radix.

Static Public Attributes

static final MixedRadixInt ZERO = new MixedRadixInt(null, List.of(1), null)
 A zero-valued mixed radix number with just one digit will radix 1.

Detailed Description

Representation of a permuted mixed radix (PMR) integer.

A mixed radix number is a number representation where each digit can have a distinct radix. The radixes are given by a list of numbers, r0, r1, ... , rn, where r0 is the radix of the lowest-order digit and rn is the radix of the highest order digit that has a specified radix.

A PMR is a mixed radix number that, when incremented, increments the digits in the order given by the permutation matrix. For an ordinary mixed radix number, the permutation matrix is [0, 1, ..., n-1]. The permutation matrix may be any permutation of these digits, [d0, d1, ..., dn-1], in which case, when incremented, the d0 digit will be incremented first. If it overflows, it will be set to 0 and the d1 digit will be incremented. If it overflows, the next digit is incremented. If the last digit overflows, then the number wraps around so that all digits become zero.

This implementation realizes a finite set of numbers, where incrementing past the end of the range wraps around to the beginning. As a consequence, the increment() function from any starting point is guaranteed to eventually cover all possible values.

The toString() method gives a string representation of the number where each digit is represented by the string "d%r", where d is the digit and r is the radix. For example, the number "1%2, 2%3, 1%4" has value 11, 1 + (2*2) + (1*2*3).

Author
Edward A. Lee

Constructor & Destructor Documentation

◆ MixedRadixInt()

org.lflang.generator.MixedRadixInt.MixedRadixInt ( List< Integer > digits,
List< Integer > radixes,
List< Integer > permutation )

Create a mixed radix number with the specified digits and radixes, which are given low-order digits first.

If there is one more digit than radixes, throw an exception.

Parameters
digitsThe digits, or null to get a zero-valued number.
radixesThe radixes.
permutationThe permutation matrix, or null for the default permutation.

Member Function Documentation

◆ copy()

MixedRadixInt org.lflang.generator.MixedRadixInt.copy ( )

◆ equals()

boolean org.lflang.generator.MixedRadixInt.equals ( Object obj)

◆ get() [1/2]

int org.lflang.generator.MixedRadixInt.get ( )

Get the value as an integer.

◆ get() [2/2]

int org.lflang.generator.MixedRadixInt.get ( int n)

Get the value as an integer after dropping the first n digits.

Parameters
nThe number of digits to drop.

◆ getDigits()

List< Integer > org.lflang.generator.MixedRadixInt.getDigits ( )

Return the digits.

This is assured of returning as many digits as there are radixes.

◆ getPermutation()

List< Integer > org.lflang.generator.MixedRadixInt.getPermutation ( )

Return the permutation list.

◆ getRadixes()

List< Integer > org.lflang.generator.MixedRadixInt.getRadixes ( )

Return the radixes.

◆ hashCode()

int org.lflang.generator.MixedRadixInt.hashCode ( )

◆ increment()

void org.lflang.generator.MixedRadixInt.increment ( )

Increment the number by one, using the permutation vector to determine the order in which the digits are incremented.

If an overflow occurs, then a radix-infinity digit will be added to the digits array if there isn't one there already.

◆ magnitude()

int org.lflang.generator.MixedRadixInt.magnitude ( )

Return the magnitude of this PMR, which is defined to be the number of times that increment() would need to invoked starting with zero before the value returned by get() would be reached.

◆ numDigits()

int org.lflang.generator.MixedRadixInt.numDigits ( )

Return the number of digits in this mixed radix number.

This is the size of the radixes list.

◆ set()

void org.lflang.generator.MixedRadixInt.set ( int v)

Set the value of this number to equal that of the specified integer.

Parameters
vThe ordinary integer value of this number.

◆ setMagnitude()

void org.lflang.generator.MixedRadixInt.setMagnitude ( int v)

Set the magnitude of this number to equal that of the specified integer, which is the number of times that increment must be invoked from zero for the value returned by get() to equal v.

Parameters
vThe new magnitude of this number.

◆ toString()

String org.lflang.generator.MixedRadixInt.toString ( )

Give a string representation of the number, where each digit is represented as nr, where r is the radix.

Member Data Documentation

◆ ZERO

final MixedRadixInt org.lflang.generator.MixedRadixInt.ZERO = new MixedRadixInt(null, List.of(1), null)
static

A zero-valued mixed radix number with just one digit will radix 1.


The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/generator/MixedRadixInt.java