Hecke.jl icon indicating copy to clipboard operation
Hecke.jl copied to clipboard

`issquare`/`is_square` vs `issquare_matrix`

Open fingolfin opened this issue 2 years ago • 6 comments

There is a helper function issquare_matrix in Hecke which is only used locally in one place. OTOH in AbstractAlgebra, there is an issquare (now: is_square) method for matrices which does exactly the same thing.

I first wanted to replace issquare_matrix here, but the more I think about it, the more I wonder if we shouldn't do the reverse: after all, for a square matrix, it would also make sense to ask if it is the square of some other matrix, leading to ambiguity.

On the other hand, we also have isdiagonal (and not isdiagonal_matrix), is_symmetric, is_upper_triangular, etc.

CC @fieker @wbhart @thofma

fingolfin avatar May 06 '22 14:05 fingolfin

I don't mind, but I don't actually know an algorithm to check if a matrix is the square of another. I am also not sure of applications.

But that is not what you are asking though. On the naming convention, I have no real opinion.

wbhart avatar May 06 '22 15:05 wbhart

Well, over fields: one can go to Jordan normal form (may require working in a field extension, of course) and for these square roots can be decided. In general there may be multiple square roots now (depending on the number and types of Jordan blocks).

But yeah, as you correctly pointed out, Bill, it doesn't really matter: the only applications of square roots of matrices I know are for symmetric positive definite matrices in char 0, and in general I then don't care about testing this, but rather for computing the square root.

So in principle I am fine with leaving is_square for matrices as it is -- I just thought it would be good to (briefly) discuss this explicitly and thus document whatever decision we arrive at.

fingolfin avatar May 06 '22 15:05 fingolfin

two functions: is_square and is_a_square?

tthsqe12 avatar May 06 '22 15:05 tthsqe12

Oh no, this whole CAS business is madness. I guess if we ever need it, we can still use is_square_with_sqrt. I would keep is_square.

thofma avatar May 06 '22 16:05 thofma

The CAS is sane. It's only the people who use it without reading every single line of the documentation at 8am every day to see if anything changed who are not sane.

wbhart avatar May 06 '22 16:05 wbhart

On Fri, May 06, 2022 at 08:12:07AM -0700, wbhart wrote:

I don't mind, but I don't actually know an algorithm to check if a matrix is the square of another. I am also not sure of applications. It happens in numerics/ diff. eqns (at least there). Just evaluate the power series for square-root at the matrix - and do this via jordan form

But that is not what you are asking though. On the naming convention, I have no real opinion.

-- Reply to this email directly or view it on GitHub: https://github.com/thofma/Hecke.jl/issues/685#issuecomment-1119725971 You are receiving this because you were mentioned.

Message ID: @.***>

fieker avatar May 09 '22 06:05 fieker

I will close this for now. I also could not find the issquare_matrix in the source code anymore (because it was removed in https://github.com/thofma/Hecke.jl/pull/688).

thofma avatar Aug 26 '22 16:08 thofma