예제 #1
0
 def __init__(self, pgf, args):
     self.voice = None
     iLang = args.input.capitalize()
     oLang = args.output.capitalize()
     self.gf1 = GF(pgf, iLang, 'Sage', 'Command', lexer=commandsLex)
     self.gf2 = GF(pgf, 'Sage', oLang, 'Answer')
     self.args = args
     self.environment = ContextStack()
     self.environment.new('toplevel')
     self.environment.gf1 = self.gf1  # From prompt to change
     self.environment.kernel = None  # to be set on evaluation
예제 #2
0
파일: utils.py 프로젝트: jiegev5/CE7490_2
def gen_q(data_ndarray, ndim):
    """
    generate q using GF^8
    :param data_ndarray: the data ndarray
    :param ndim: real dim
    :return: q_ndarray with shape=(1, byte_ndarray.shape[1])
    """
    transposed = np.transpose(data_ndarray)
    # print(data_ndarray.shape)
    get_logger().info('transposed\n{}'.format(transposed))
    gf = GF()
    q_list = []
    for _1darray in transposed:
        bv_list = []
        for i, arr_val in enumerate(_1darray):
            res_i = gf.multiply(gf.generator[i % gf.circle], int(arr_val))
            # print('i={}, arr_val={}, res_i={}'.format(i, arr_val, res_i))
            bv_list.append(res_i)
            # map(lambda i: print(i), bv_list)
        q_value = reduce(operator.xor, bv_list)
        q_list.append(q_value)
    arr = np.array(q_list, ndmin=ndim, dtype=config.BYTE_TYPE)
    get_logger().info("arr={}".format(arr))
    # assert arr.shape[1] == data_ndarray.shape[1]
    return arr
예제 #3
0
파일: utils.py 프로젝트: jiegev5/CE7490_2
def gf_a_multiply_list(a, l):
    """
    multiplication of a and l
    :param a: scala type
    :param l:
    :return: list of int
    """
    gf = GF()
    return [gf.multiply(int(i), a) for i in l]
예제 #4
0
 def __init__(self, N):
     assert 4 <= N
     super(RAID6, self).__init__(N)
     # gf object
     self.gf = GF()