def gcd1d_arr(arr_tup):
    """
    A tuple of one-D arrays are passed with equal size and the gcd of
    their rows is computed

    Parameters
    ---------------
    arr_tup: tuple
        one-D arrays of integers of equal size.

    Returns
    -----------
    GCD of rows of 1D arrays of integers
    """
    asz = len(arr_tup)
    gc1 = arr_tup[0].astype(dtype='int64')
    for ct1 in range(asz - 1):
        gc1 = np.copy(np.column_stack((gc1,
                                       arr_tup[ct1+1].astype(dtype='int64'))))

    if gc1.ndim == 1:
        gc1 = np.reshape(gc1, (1, np.size(gc1)))

    t1 = int_man.gcd_array(gc1, 'rows')
    return np.reshape(t1, (np.size(t1), ))
Exemple #2
0
def gcd1d_arr(arr_tup):
    """
    A tuple of one-D arrays are passed with equal size and the gcd of
    their rows is computed

    Parameters
    ---------------
    arr_tup: tuple
        one-D arrays of integers of equal size.

    Returns
    -----------
    GCD of rows of 1D arrays of integers
    """
    asz = len(arr_tup)
    gc1 = arr_tup[0].astype(dtype='int64')
    for ct1 in range(asz - 1):
        gc1 = np.copy(
            np.column_stack((gc1, arr_tup[ct1 + 1].astype(dtype='int64'))))

    if gc1.ndim == 1:
        gc1 = np.reshape(gc1, (1, np.size(gc1)))

    t1 = int_man.gcd_array(gc1, 'rows')
    return np.reshape(t1, (np.size(t1), ))
def eliminate_mults(quad_int):
    """
    Divide all the integer quadruples by their corresponding least common
    multiples and return the unique set of integer quadruples
    """
    quad_gcd = int_man.gcd_array(quad_int.astype(dtype='int64'), 'columns')
    quad_gcd = np.tile(quad_gcd, (4, 1))

    a = quad_int / quad_gcd
    a = a.transpose()
    b = np.ascontiguousarray(a).view(np.dtype((np.void,
                                               a.dtype.itemsize * a.shape[1])))
    quad_int = np.unique(b).view(a.dtype).reshape(-1, a.shape[1])
    quad_int = quad_int.transpose()

    return quad_int
def eliminate_mults(quad_int):
    """
    Divide all the integer quadruples by their corresponding least common
    multiples and return the unique set of integer quadruples
    """
    quad_gcd = int_man.gcd_array(quad_int.astype(int), 'columns')
    quad_gcd = np.tile(quad_gcd, (4, 1))

    a = quad_int / quad_gcd
    a = a.transpose()
    b = np.ascontiguousarray(a).view(
        np.dtype((np.void, a.dtype.itemsize * a.shape[1])))
    quad_int = np.unique(b).view(a.dtype).reshape(-1, a.shape[1])
    quad_int = quad_int.transpose()

    return quad_int