Esempio n. 1
0
print(len(comparators))

inputs = list(range(N))
result = True
for i in range(1):
	random.shuffle(inputs)

	#print(inputs)

	#for c in comparators:
	#	if len(c) != 2:
	#		print(c)

	#for (i,j) in comparators: #Allow reverse comparators, important from bitonic sort
	#	if inputs[i] > inputs[j]:
	#		inputs[i], inputs[j] = inputs[j], inputs[i]

	for (i,j) in comparators: #Disallow reverse comparators, important for SimpleAKS
		inputs[min(i,j)], inputs[max(i,j)] = min(inputs[j], inputs[i]), max(inputs[j], inputs[i])

 	
	result = result and inputs == sorted(inputs)

print(result)


for c, (i, j) in enumerate(layerize(BitonicSort(range(8)),8)):
	pass
	#print('{0}: CE({1},{2})'.format(c, i, j))
Esempio n. 2
0
        else:
            commands.append('CE({}, {})'.format(A[0], B[0]))
            Buffer = (A[1:], B[1:])


def Flush():
    global Buffer, commands
    for i, j in zip(Buffer[0], Buffer[1]):
        commands.append('CE({}, {})'.format(i, j))


with open(args.fname) as f:
    content = f.readlines()

operations = []

for line in content:
    match = re.match(r"\((\d+),(\d+)\)", line)
    operations.append((int(match.group(1)), int(match.group(2))))

if layer:
    n = max(max(i, j) for i, j in operations) + 1
    operations = layerize(operations, n)

for i, j in operations:
    Handle(i, j)

Flush()

for c, command in enumerate(commands):
    print('{}: {}'.format(c, command))
Esempio n. 3
0
            commands.append("CE({}, {})".format(A[0], B[0]))
            Buffer = (A[1:], B[1:])


def Flush():
    global Buffer, commands
    for i, j in zip(Buffer[0], Buffer[1]):
        commands.append("CE({}, {})".format(i, j))


with open(args.fname) as f:
    content = f.readlines()

operations = []

for line in content:
    match = re.match(r"\((\d+),(\d+)\)", line)
    operations.append((int(match.group(1)), int(match.group(2))))

if layer:
    n = max(max(i, j) for i, j in operations) + 1
    operations = layerize(operations, n)

for i, j in operations:
    Handle(i, j)

Flush()

for c, command in enumerate(commands):
    print("{}: {}".format(c, command))