本文整理汇总了Python中BitVector.reverse方法的典型用法代码示例。如果您正苦于以下问题:Python BitVector.reverse方法的具体用法?Python BitVector.reverse怎么用?Python BitVector.reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector.reverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pattern_to_dest
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import reverse [as 别名]
def pattern_to_dest(self,pattern,X):
# return -1 is reserved for random
bit_len = math.ceil(math.log(self.mesh_width*self.mesh_height,2))
bv = BitVector(intVal=X,size=bit_len)
if(pattern==Traffic_Patterns.random):
return -1;
elif(pattern==Traffic_Patterns.bit_complement):
return int(~bv)
elif(pattern==Traffic_Patterns.bit_reverse):
return int(bv.reverse())
elif(pattern==Traffic_Patterns.bit_rotation):
return int(bv<<1)
elif(pattern==Traffic_Patterns.transpose):
return 1
elif(pattern==Traffic_Patterns.shuffle):
t = bv[bit_len-1]
bv[bit_len-1] = bv[0]
bv[0] = t
return int(bv)
elif(pattern==Traffic_Patterns.manual):
return self.PE_dest[X]
示例2: get_c_byte_step
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import reverse [as 别名]
def get_c_byte_step( byte, encrypt ) :
byte = byte.reverse()
if(encrypt) :
c_d_byte = BitVector( bitstring = '11000110' )
xor_base = BitVector( bitstring = '10001111' )
else :
c_d_byte = BitVector( bitstring = '10100000' )
xor_base = BitVector( bitstring = '00100101' )
newByte = BitVector( bitstring = '00000000' )
xor_lists = [xor_base.deep_copy() >> x for x in range(8)]
for i, xor_list in enumerate(xor_lists) :
temp = xor_list & byte
newBit = get_xor_of_single_bv(temp)
newBit = newBit ^ c_d_byte[i]
newByte[i] = newBit
newByte = newByte.reverse()
return newByte
示例3: print
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import reverse [as 别名]
print("\nTesting rank_of_bit_set_at_index():")
bv = BitVector(bitstring='01010101011100')
print(bv.rank_of_bit_set_at_index(10)) # 6
print("\nTesting is_power_of_2():")
bv = BitVector(bitstring='10000000001110')
print("int value: " + str(int(bv))) # 826
print(bv.is_power_of_2()) # False
print("\nTesting is_power_of_2_sparse():")
print(bv.is_power_of_2_sparse()) # False
print("\nTesting reverse():")
bv = BitVector(bitstring='0001100000000000001')
print("original bv: " + str(bv)) # 0001100000000000001
print("reversed bv: " + str(bv.reverse())) # 1000000000000011000
print("\nTesting Greatest Common Divisor (gcd):")
bv1 = BitVector(bitstring='01100110')
print("first arg bv: " + str(bv1) +
" of int value: " + str(int(bv1))) # 102
bv2 = BitVector(bitstring='011010')
print("second arg bv: " + str(bv2) +
" of int value: " + str(int(bv2))) # 26
bv = bv1.gcd(bv2)
print("gcd bitvec is: " + str(bv) + " of int value: " + str(int(bv))) # 2
print("\nTesting multiplicative_inverse:")
bv_modulus = BitVector(intVal=32)
print("modulus is bitvec: " + str(bv_modulus) +
" of int value: " + str(int(bv_modulus)))