Fill Csr Matrix with raw data #1795
-
|
Hello, I'm brand new to ginkgo - thanks for providing thus a promising solver! I have a own csr matrix with raw pointers. How can I fill a ginkgo Csr with this raw pointer? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The first thing you need to do is to create a ginkgo array with this raw pointer. This example shows how to do that: auto view = gko::make_array_view(exec, size, raw_pointer);where You then need to create ginkgo arrays for the row pointers, the column indices, and the values. If you have them, you can create a CSR matrix with: auto row_ptr_view = ...;
auto col_idxs_view = ...;
auto values_view = ...;
auto csr = gko::matrix::Csr<>::create(exec, gko::dim<2>(num_rows, num_cols),
std::move(values_view), std::move(col_idxs_view),
std::move(row_ptrs_view)); |
Beta Was this translation helpful? Give feedback.
The first thing you need to do is to create a ginkgo array with this raw pointer. This example shows how to do that:
auto view = gko::make_array_view(exec, size, raw_pointer);where
sizeis the number of elements allocated at theraw_pointer. Theexecis agko::Executor. You have to make sure that theexecmatches the memory space of the raw_pointer. So, if the raw pointer points to CPU memory, it needs to be anOmpExecutoror aReferenceExecutor. If it points to GPU memory, you need to useCudaExecutorfor example.You then need to create ginkgo arrays for the row pointers, the column indices, and the values. If you have them, you can create a CSR matrix with: