int main() { std::vector<double> val = {4, 1, 1, 4, 1, 1, 4}; std::vector<int> i_idx = {0, 0, 1, 1, 1, 2, 2}; std::vector<int> j_idx = {0, 1, 0, 1, 2, 1, 2}; std::vector<double> val2 = {4, 1, 1, 2, 2, 1, 1, 4}; std::vector<int> i_idx2 = {0, 0, 1, 1, 1, 1, 2, 2}; std::vector<int> j_idx2 = {0, 1, 0, 1, 1, 2, 1, 2}; COO2CSR(val, i_idx, j_idx); COO2CSR(val2, i_idx2, j_idx2); /* Matrix without accumulated value */ for (auto v : val) std::cout << v << " "; std::cout << std::endl; for (auto j : j_idx) std::cout << j << " "; std::cout << std::endl; for (auto i : i_idx) std::cout << i << " "; std::cout << std::endl; /* Matrix with accumulated value */ for (auto v : val2) std::cout << v << " "; std::cout << std::endl; for (auto j : j_idx2) std::cout << j << " "; std::cout << std::endl; for (auto i : i_idx2) std::cout << i << " "; std::cout << std::endl; return 0; }
/* Method to convert COO matrix to CSR format using provided function */ void SparseMatrix::ConvertToCSR() { COO2CSR(a, i_idx, j_idx); }