Closed Rhythmicc closed 1 year ago
Good question.
As of today there are three ways to handle diagonal elements of symmetric matrices:
These are controlled by read_options::generalize_symmetry
and read_options::generalize_coordinate_diagnonal_values
, see https://github.com/alugowski/fast_matrix_market/blob/88fcc15b509265345e6db6a780b12da4cd9bc5f0/include/fast_matrix_market/types.hpp#L76
There is no "just one element" option at the moment because such an option is more tricky to implement than it seems, largely because there is no way to know how many diagonal elements there are without reading the entire file.
A common next step after loading is to convert to something like CSR, with a sum of duplicate elements. Hence the default behavior works well for that.
If you don't allow explicit zeros, then use your library's method to drop those. Again, that's often called anyway since the matrix market format allows explicit zeros.
If neither of those apply, then you can do what the Python bindings do. Disable FMM symmetry generalization, then do it yourself. Since you know your datastructure, you can iterate it to count how many elements need to be added, resize the matrix in whatever way your datastructure requires, and duplicate the non-diagonal elements.
Though having written that last paragraph and scanned through the code a little, it seems possible to add that feature for most already supported bindings, including the one you're using. I'll have a crack at it.
Thank you very much for your reply, I did in fact convert the read to CSR format and skipped the handling of the zero elements. What I'm thinking is that there has to be a place for FMM or user call code to add additional judgment conditions, and perhaps a configuration option could be added to weed out the extra zero elements.
I added an option to handle symmetric files at the binding level, and nearly all bindings (including the triplet one you're using) no longer create those zero elements.
@Rhythmicc The change is in main
and on by default, would you be able to test that it works for you?
Sure, and my test results were fine.
Great!
On Mon, Oct 16, 2023 at 9:18 PM HaochengLian @.***> wrote:
Closed #49 https://github.com/alugowski/fast_matrix_market/issues/49 as completed.
— Reply to this email directly, view it on GitHub https://github.com/alugowski/fast_matrix_market/issues/49#event-10672984138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU2S7DHLKXXBIXPWJNV7QLX7YBKJAVCNFSM6AAAAAA56ZXTD2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQGY3TEOJYGQYTGOA . You are receiving this because you commented.Message ID: @.***>
I used a symmetric matrix file to test this, called as follows:
I noticed that the elements on the diagonal are also copied and the value is set to 0; does fmm provide a way to avoid this problem?