Commit 74c560ad authored by sfritschi's avatar sfritschi
Browse files

Removed unnecessary copies from astype

parent d1a483c6
......@@ -36,12 +36,12 @@ def solve_py(A, b, PetscScalar rtol, PetscInt maxiter, PetscInt n_rows):
cdef PetscScalar [::1] solution = np.empty(n_rows, dtype=np.dtype("d"))
# Memory views of numpy arrays (contiguous)
# Need to specify datatype: d -> double, i -> int32
cdef const PetscScalar [::1] data = A.data.astype(np.dtype("d"))
cdef const PetscScalar [::1] rhs = b.astype(np.dtype("d"))
# Datatypes: data: double, indptr, indices: int32
cdef const PetscScalar [::1] data = A.data
cdef const PetscScalar [::1] rhs = b
cdef const PetscInt [::1] row_ptr = A.indptr.astype(np.dtype("i"))
cdef const PetscInt [::1] col_indices = A.indices.astype(np.dtype("i"))
cdef const PetscInt [::1] row_ptr = A.indptr
cdef const PetscInt [::1] col_indices = A.indices
# TODO: Check error code returned by solve
solve(&data[0], &col_indices[0], &row_ptr[0], &rhs[0], &solution[0], \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment