diff -rc v5/Makefile v6.1/Makefile *** v5/Makefile Tue Nov 11 09:24:59 2008 --- v6.1/Makefile Wed Nov 19 03:03:52 2008 *************** *** 1,21 **** all: Pub/.copied ! SOURCES=makeindex.php.txt hilbert.py hilbert_test.py Makefile ! PUBFILES=${SOURCES} index.html hilbert_thumb.gif v4_v5_diff.txt ! v4_v5_diff.txt: old/v5/.copied ! (cd old; diff -rc v4 v5 >../v4_v5_diff.txt; true) ! old/v5/.copied: ${SOURCES} ! cp ${SOURCES} old/v5 ! touch old/v5/.copied Pub/.copied: ${PUBFILES} cp ${PUBFILES} Pub touch Pub/.copied ! index.html: makeindex.php.txt rm -f index.html touch datefile ! php makeindex.php.txt >index.html chmod a-w index.html --- 1,36 ---- all: Pub/.copied ! VERNUM=6.1 ! PREVNUM=5 ! VER=v${VERNUM} ! PREV=v${PREVNUM} ! SOURCES=makeindex.php.txt hilbert.py hilbert_test.py hilbert_pic.py \ ! Makefile ! DIFFS=v4_${VER}_diff.txt ${PREV}_${VER}_diff.txt ! ! PUBFILES=${SOURCES} ${DIFFS} index.html hilbert_thumb.gif hilbert_pic.pdf ! ! v4_${VER}_diff.txt: old/${VER}/.copied ! (cd old; diff -rc v4 ${VER} >../v4_${VER}_diff.txt; true) ! ! ${PREV}_${VER}_diff.txt: old/${VER}/.copied ! (cd old; diff -rc ${PREV} ${VER} >../${PREV}_${VER}_diff.txt; true) ! ! old/${VER}/.copied: ${SOURCES} ! cp ${SOURCES} old/${VER} ! touch old/${VER}/.copied Pub/.copied: ${PUBFILES} cp ${PUBFILES} Pub touch Pub/.copied ! index.html: ${SOURCES} ${DIFFS} rm -f index.html touch datefile ! php makeindex.php.txt ${VERNUM} >index.html chmod a-w index.html + + hilbert_pic.pdf: hilbert.py hilbert_pic.py + hilbert_pic.py >hilbert_pic.pdf diff -rc v5/hilbert.py v6.1/hilbert.py *** v5/hilbert.py Tue Nov 11 09:24:59 2008 --- v6.1/hilbert.py Wed Nov 19 03:03:52 2008 *************** *** 4,9 **** --- 4,11 ---- # int_to_Hilbert( 0, nD ) ==> ( 0, 0, 0, ... 0 ) Start at origin. # int_to_Hilbert( 1, nD ) ==> ( 1, 0, 0, ... 0 ) 1st step is along x. # Hilbert_to_int( ( x, y, z ) ) ==> i + # Steve Witham ess doubleyou at tiac remove-this dot net. + # http://www.tiac.net/~sw/2008/10/Hilbert from sys import argv Only in v5: hilbert.pyc Only in v6.1: hilbert_pic.py diff -rc v5/hilbert_test.py v6.1/hilbert_test.py *** v5/hilbert_test.py Tue Nov 11 09:24:59 2008 --- v6.1/hilbert_test.py Wed Nov 19 03:03:52 2008 *************** *** 121,160 **** # # visited is a dictionary (or "hash" or associative array) whose key # is a tuple representing the point coordinates. Prefix is a list ! # of coordinates that's built up by recursion to the right size. ! # "tuple(prefix) in visited" converts the list to a tuple # and asks whether an entry with that key is in the dictionary. ! def check_visited( visited, prefix, size, nD ): if nD > 0: ! for i in range( size ): ! check_visited( visited, prefix + [i], size, nD - 1 ) else: if not tuple( prefix ) in visited: print "missing", prefix ! def int_to_Hilbert_test( n, nD ): ! ld = int( n ** (1./nD) ) ! assert ld ** nD == n visited = {} for i in range( n ): pt = tuple( int_to_Hilbert( i, nD ) ) ! print pt, ! visited[ pt ] = True # Add pt to visited dictionary. j = Hilbert_to_int( pt ) if j != i: print "BZZT, decodes to", j, ! if i > 0: nDiffs = sum( [ pt[k] != prev_pt[k] for k in range( nD ) ] ) if nDiffs != 1: print "BZZT, different along", nDiffs, "dimensions", maxDiff = max( [ abs(pt[k] - prev_pt[k]) for k in range( nD ) ] ) if maxDiff != 1: print "BZZT, max difference is", maxDiff, prev_pt = pt ! if ( i + 1 ) % 8 == 0: ! print ! check_visited( visited, [], ld, nD ) if argv[0].endswith( "/hilbert_test.py" ) or argv[0] == "hilbert.py": --- 121,173 ---- # # visited is a dictionary (or "hash" or associative array) whose key # is a tuple representing the point coordinates. Prefix is a list ! # of coordinates that's built up by recursion to the right number of ! # dimensions. "tuple(prefix) in visited" converts the list to a tuple # and asks whether an entry with that key is in the dictionary. ! def check_visited( visited, prefix, linear_size, nD ): if nD > 0: ! for i in range( linear_size ): ! check_visited( visited, prefix + [i], linear_size, nD - 1 ) else: if not tuple( prefix ) in visited: print "missing", prefix ! def tuple_print_width( n ): # tuple with n 1-digit numbers and trailing sp ! if n == 0: return 3 # ()_ ! if n == 1: return 5 # (1,)_ special case ! else: return n * 3 + 1 ! ! ! def int_to_Hilbert_test( n, nD, doPrint=True ): ! tups_per_line = 2**( int( log( 80 / tuple_print_width( nD ), 2 ) ) ) ! linear_size = int( ( n + .5 ) ** (1./nD) ) ! isCube = linear_size ** nD == n ! if not isCube: ! print "(This is not a complete cube:)" visited = {} for i in range( n ): pt = tuple( int_to_Hilbert( i, nD ) ) ! if doPrint: print pt, ! visited[ pt ] = True # Add pt to "visited" dictionary. j = Hilbert_to_int( pt ) if j != i: print "BZZT, decodes to", j, ! ! if i > 0: # Check that we have stepped one unit, along one dim: nDiffs = sum( [ pt[k] != prev_pt[k] for k in range( nD ) ] ) if nDiffs != 1: print "BZZT, different along", nDiffs, "dimensions", maxDiff = max( [ abs(pt[k] - prev_pt[k]) for k in range( nD ) ] ) if maxDiff != 1: print "BZZT, max difference is", maxDiff, + prev_pt = pt ! if ( i + 1 ) % tups_per_line == 0: ! if doPrint: print ! ! if isCube: ! check_visited( visited, [], linear_size, nD ) if argv[0].endswith( "/hilbert_test.py" ) or argv[0] == "hilbert.py": *************** *** 166,175 **** print int_to_Hilbert_test( 64, 3 ) print for nD in [ 2, 3, 4, 5 ]: pt = [ 0 ] * nD ! pt[0] = 1000000 x = Hilbert_to_int( pt ) print x, log( x, 10 ) ! print int_to_Hilbert( 1000000, nD ) --- 179,205 ---- print int_to_Hilbert_test( 64, 3 ) print + int_to_Hilbert_test( 4096, 3, doPrint=False ) # nChunks > nD + print + int_to_Hilbert_test( 4096, 4, doPrint=False ) + print + k = 10**12 # definitely a long for nD in [ 2, 3, 4, 5 ]: + # Decode point ( k, 0, 0... ) to an int...how many digits?: pt = [ 0 ] * nD ! pt[0] = k x = Hilbert_to_int( pt ) print x, log( x, 10 ) ! # Double-check: ! pt2 = list( int_to_Hilbert( x, nD ) ) ! if pt2 != pt: ! print "BZZT! Encodes to ", pt2 ! ! # Encode k to an nD point: ! pt = int_to_Hilbert( k, nD ) ! print pt ! # Double-check: ! y = Hilbert_to_int( pt ) ! if y != k: ! print "BZZT! Decodes to", y diff -rc v5/makeindex.php.txt v6.1/makeindex.php.txt *** v5/makeindex.php.txt Tue Nov 11 09:24:59 2008 --- v6.1/makeindex.php.txt Wed Nov 19 03:03:52 2008 *************** *** 1,5 **** index.html ?>