GraphBLAS / graphblas-api-c

Other
7 stars 3 forks source link

GrB_PRINTSTRING #82

Open rayegun opened 8 months ago

rayegun commented 8 months ago

Something that would be nice for container objects to provide a formatted string summary using the GrB_get interface.

eriknw commented 8 months ago

That seems like a good use for GrB_get 👍

DrTimothyAldenDavis commented 8 months ago

How long of a string would this be? My GxB_print mechanism could be revised to print to a string instead of a FILE * pointer, but it has control parameter that defines how much detail is desired (one-line, a few lines, the first ~30 entries, or the whole thing). Would you want to control this somehow, perhaps with a GrB_set to set the print level, and then GrB_get to get the size of the string, and then another GrB_get to get the string?

rayegun commented 8 months ago

An initial GrB_set may be good, but of course that adds a field to each object. Maybe multiple different GrB_STRING_SUMMARY and GrB_STRING_LONG etc is better.

I think I strongly prefer to proliferate field enums than actual fields in the object

DrTimothyAldenDavis commented 8 months ago

Oh, yes of course, that's a much better suggestion than mine.

GrB_get could use, say, 3 strings: GrB_STRING_SUMMARY (say 1 or a few lines at most), GrB_STRING_SHORT (which I would use to print about 30 entries of a matrix then "..."), and GrB_STRING_LONG (or GrB_STRING_FULL or GrB_STRING_VERBOSE) which would be a string that fully describes the object; it could take GBytes for a huge matrix.

If we add such a GrB_get, it would also be good to be able to use GrB_set to set a user-defined function that can print a single entry to a string. Currently there is no way to print a user-defined data value, not even in my GxB extensions.

rayegun commented 8 months ago

The udt printer is in my opinion slightly harder to justify for the same reason mentioned above, making GrB_Type heavier.

But still plenty of reason to do it I think