diff --git a/matrix_powers_mv/matrix_powers_mv.cpp b/matrix_powers_mv/matrix_powers_mv.cpp index 20cf8e8..c7bdee9 100644 --- a/matrix_powers_mv/matrix_powers_mv.cpp +++ b/matrix_powers_mv/matrix_powers_mv.cpp @@ -1,10 +1,10 @@ #include "matrix_powers_mv.h" -int ReorderMatrix(const SparseMatrix& sp_matrix) { +int ReorderMatrix(const SparseMatrix& sp_matrix, idx_t* perm, idx_t* iperm) { SparseMatrix a_no_diag; sp_matrix.RemoveDiag(a_no_diag); - idx_t* perm = new idx_t[a_no_diag.row_cnt_]; - idx_t* iperm = new idx_t[a_no_diag.row_cnt_]; + perm = new idx_t[a_no_diag.row_cnt_]; + iperm = new idx_t[a_no_diag.row_cnt_]; idx_t options[METIS_NOPTIONS]; METIS_SetDefaultOptions(options); options[METIS_OPTION_NUMBERING] = 0; diff --git a/matrix_powers_mv/matrix_powers_mv.h b/matrix_powers_mv/matrix_powers_mv.h index 16a4836..57a9ed4 100644 --- a/matrix_powers_mv/matrix_powers_mv.h +++ b/matrix_powers_mv/matrix_powers_mv.h @@ -4,5 +4,5 @@ #include #include -int ReorderMatrix(const SparseMatrix& sp_matrix); +int ReorderMatrix(const SparseMatrix& sp_matrix, idx_t* perm, idx_t* iperm); void MatrixPowersMV(const SparseMatrix& sp_matrix, const Vector& x, const Vector*>& res); \ No newline at end of file diff --git a/matrix_powers_mv/test.cpp b/matrix_powers_mv/test.cpp index 6747b27..85f98e5 100644 --- a/matrix_powers_mv/test.cpp +++ b/matrix_powers_mv/test.cpp @@ -12,6 +12,8 @@ static void Test(const uint32_t n) { SparseMatrix a_no_diag; SparseMatrix a; + idx_t* perm{nullptr}; + idx_t* iperm{nullptr}; { std::stringstream file_name; file_name << std::filesystem::current_path().string() << "/../" << "matrix_examples/sparse_spd/" << n; @@ -21,29 +23,29 @@ static void Test(const uint32_t n) { fstream >> a; fstream.close(); REQUIRE(a.data_); - SparseMatrix a_no_diag; - a.RemoveDiag(a_no_diag); - idx_t* perm = new idx_t[a_no_diag.row_cnt_]; - idx_t* iperm = new idx_t[a_no_diag.row_cnt_]; - idx_t options[METIS_NOPTIONS]; - METIS_SetDefaultOptions(options); - options[METIS_OPTION_NUMBERING] = 0; - // int METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, - // idx_t *options, idx_t *perm, idx_t *iperm); + // SparseMatrix a_no_diag; + // a.RemoveDiag(a_no_diag); + // idx_t* perm = new idx_t[a_no_diag.row_cnt_]; + // idx_t* iperm = new idx_t[a_no_diag.row_cnt_]; + // idx_t options[METIS_NOPTIONS]; + // METIS_SetDefaultOptions(options); + // options[METIS_OPTION_NUMBERING] = 0; + // // int METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, + // // idx_t *options, idx_t *perm, idx_t *iperm); - int result = METIS_NodeND( - &a_no_diag.row_cnt_ - , a_no_diag.i_a_ - , a_no_diag.j_a_ - , nullptr - , options - , perm - , iperm - ); - REQUIRE(result == METIS_OK); + // int result = METIS_NodeND( + // &a_no_diag.row_cnt_ + // , a_no_diag.i_a_ + // , a_no_diag.j_a_ + // , nullptr + // , options + // , perm + // , iperm + // ); + // REQUIRE(result == METIS_OK); } - // REQUIRE(ReorderMatrix(a_no_diag) == METIS_OK); + REQUIRE(ReorderMatrix(a, perm, iperm) == METIS_OK); } TEST_CASE("Size 128") {