Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vectors in IntegralLattice compute norm incorrectly #38543

Open
yyyyx4 opened this issue Aug 21, 2024 · 4 comments
Open

vectors in IntegralLattice compute norm incorrectly #38543

yyyyx4 opened this issue Aug 21, 2024 · 4 comments

Comments

@yyyyx4
Copy link
Member

yyyyx4 commented Aug 21, 2024

From here:

sage: L = IntegralLattice(matrix([[1000,0],[0,1]]))
sage: v = L.0; v
(1, 0)
sage: v.parent()
Lattice of degree 2 and rank 2 over Integer Ring
Standard basis
Inner product matrix:
[1000    0]
[   0    1]
sage: v.norm()
1
sage: v.inner_product(v)
1000

The .parent() is set to the lattice in question, and .inner_product() behaves as expected, but the .norm() computes the standard Euclidean norm. This inconsistency causes confusion and bugs.

Cc: @grhkm21

@grhkm21
Copy link
Contributor

grhkm21 commented Aug 22, 2024

Hi. Yes, that. Also v.inner_product(v) gives the last line (1000).

@yyyyx4
Copy link
Member Author

yyyyx4 commented Aug 22, 2024

One issue in trying to fix this is that v.norm() currently returns essentially v.dot_product(v).sqrt(), so changing it to v.inner_product(v) in the IntegralLattice case would introduce some inconsistency...

@DaveWitteMorris
Copy link
Member

This is not a bug, because the method is doing exactly what the documentation says it will do: the documentation of the norm method states that (by default) it returns the Euclidean norm (i.e., the ell^2-norm) of the vector.

If the name of the method is causing confusion, then perhaps it should be changed to something like p_norm, but anything like this would require discussion and a deprecation period.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Sep 2, 2024

Calling .norm() should compute whatever the correct meaning of "norm" is in the vector's assigned .parent() structure, IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants