flintlib / flint

FLINT (Fast Library for Number Theory)
http://www.flintlib.org
GNU Lesser General Public License v3.0
441 stars 245 forks source link

Revise printing methods as they are not coherent #1056

Open albinahlback opened 2 years ago

albinahlback commented 2 years ago

Printing fmpz_mat and fmpq_mat gives the following

**fmpz_mat_print_pretty**
[[0 0 0]
[0 0 0]
[0 0 0]
]

**fmpz_mat_print**
3 3  0 0 0 0 0 0 0 0 0

**fmpq_mat_print**
<3 x 3 matrix over Q>
[0, 0, 0]
[0, 0, 0]
[0, 0, 0]

Some questions:

Perhaps it goes for other types, I have not checked them out yet.

I suppose these are kind of breaking changes, but they need to be coherent at least (in my opinion).

wbhart commented 2 years ago

I agree. We need to check what all the other printing methods do though. Probably one of these methods is inconsistent with all the others.

albinahlback commented 2 years ago

Wrong documentation for fmpq_poly_fprint_pretty (also note FILT instead of FILE): https://flintlib.org/doc/fmpq_poly.html?highlight=print#c.fmpq_poly_fprint_pretty

albinahlback commented 2 years ago

I think the "ugly" versions are important and should be there to ease parsing. With that being said, I think fmpz_[mat/vec]_print does the correct thing, and thus think that fmpq_mat_print should print something very similar.

Thus, I think it remains to discuss the formatting of the output for the pretty printing. For matrix/vector-type objects, I am in favor of using one pair of brackets for each row (vectors can be interpretted as rows in order to not output so many newline-characters). I also think that commas are nice.

wbhart commented 2 years ago

I thought the issue was consistency. The only way to achieve that is to check what all the other functions are doing.

albinahlback commented 2 years ago

Yeah, we could either investigate how everything is printed and then do something about it. Or we could try to come up with a standardized format for everything based, and change it from there.