def synthesis_mat(a, b): """ gives conbination of two matrix a and b Parameters ---------- a, b : scipy.sparse.occ_matrix a and b must be square matrix and Returns ------- out : scipy.sparse.occ_matrix """ (na_row, na_col) = a.shape (nb_row, nb_col) = b.shape n_row = na_row * nb_row n_col = na_col * nb_col num = len(a.data)*len(b.data) ncol = na_col*b.col col = bspline_bind.outer_sum(ncol, a.col) nrow = na_row*b.row row = outer_sum(nrow, a.row) data = np.reshape(np.outer(b.data, a.data), (num)) return coo_matrix((data, (row, col)), shape=(n_row, n_col))
def outer_sum(a, b): """ gives summation version of outer product {a_i+b_j}_{i, j} Parameters ---------- a, b : 1D numpay.array Results ------- out : 1D numarray.array """ return bspline_bind.outer_sum(a, b)