#! /usr/bin/env python # def ubvec_unrank_gray ( rank, n ): #*****************************************************************************80 # ## UBVEC_UNRANK_GRAY unranks a UBVEC. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 23 November 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer RANK, the rank of the UBVEC. # 0 <= RANK < 2^N. # # Input, integer N, the size of the UBVEC. # # Output, integer UBVEC(N), the UBVEC of given rank. # from ui4_to_ubvec import ui4_to_ubvec from ui4_unrank_gray import ui4_unrank_gray ui4 = ui4_unrank_gray ( rank ) ubvec = ui4_to_ubvec ( ui4, n ) return ubvec def ubvec_unrank_gray_test ( ): #*****************************************************************************80 # ## UBVEC_UNRANK_GRAY_TEST tests UBVEC_UNRANK_GRAY. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 23 November 2015 # # Author: # # John Burkardt # import platform n = 5 print ( '' ) print ( 'UBVEC_UNRANK_GRAY_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' UBVEC_UNRANK_GRAY unranks a UBVEC.' ) print ( '' ) print ( ' Rank UBVEC' ) print ( '' ) for rank in range ( 0, 32 ): ubvec = ubvec_unrank_gray ( rank, n ) print ( ' %4d ' % ( rank ), end = '' ) for j in range ( 0, n ): print ( '%2d' % ( ubvec[j] ), end = '' ) print ( '' ) # # Terminate. # print ( '' ) print ( 'UBVEC_UNRANK_GRAY_TEST' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) ubvec_unrank_gray_test ( ) timestamp ( )