Skip to main content
. 2021 Mar 12;21(6):2024. doi: 10.3390/s21062024
Algorithm 1Y(Vn,D): Subroutine to encode 0 or a power of 2
  • Input:

    Value to be encoded Vn, size of a vector D

  • Ensure:

    D3, Vn is 0 or a power of 2 in the range R[0,2D2]

  • Output:

    D-dimensional vector with an encoded value y=(y0,,yD1)

  • 1:

    if Vn=0 then

  • 2:

    p0 {p: Position of 1}

  • 3:

    else

  • 4:

    plog2Vn+1

  • 5:

    end if

  • 6:

    fori=0 to D do {0i<D}

  • 7:

    if i=p then

  • 8:

    yi1

  • 9:

    else

  • 10:

    yi0

  • 11:

    end if

  • 12:

    end for

  • 13:

    return y