def small_superlu():
    vals = numpy.array([
        10., -2., 3., 9., 3., 7., 8., 7., 3., 8., 7., 5., 8., 9., 9., 13., 4.,
        2., -1.
    ])
    col_idx = numpy.array(
        [0, 4, 0, 1, 5, 1, 2, 3, 0, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5],
        dtype='int32')
    row_idx = numpy.array([0, 2, 5, 8, 12, 16, 19], dtype='int32')
    size_n = len(row_idx) - 1

    superlu_mat = LinearAlgebraTools.SparseMat(size_n, size_n, len(vals), vals,
                                               col_idx, row_idx)
    yield superlu_mat
Exemple #2
0
def test_superlu_2_petsc():
    """ Tests the function superlu_2_petsc4py """
    vals = numpy.array([
        10., -2., 3., 9., 3., 7., 8., 7., 3., 8., 7., 5., 8., 9., 9., 13., 4.,
        2., -1.
    ])
    col_idx = numpy.array(
        [0, 4, 0, 1, 5, 1, 2, 3, 0, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5],
        dtype='int32')
    row_idx = numpy.array([0, 2, 5, 8, 12, 16, 19], dtype='int32')
    size_n = len(row_idx) - 1

    superlu_mat = LinearAlgebraTools.SparseMat(size_n, size_n, len(vals), vals,
                                               col_idx, row_idx)
    petsc4py_mat = LinearAlgebraTools.superlu_2_petsc4py(superlu_mat)

    dense_mat = LinearAlgebraTools.petsc4py_sparse_2_dense(petsc4py_mat)
    comparison_mat = numpy.loadtxt(
        os.path.join(os.path.dirname(__file__), 'sparse_mat_1.txt'))
    assert numpy.allclose(dense_mat, comparison_mat)