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

Improve counting of local solutions for QuadraticForm at p=2 #38680

Merged
merged 7 commits into from
Oct 26, 2024

Conversation

WvanWoerden
Copy link
Contributor

Fixes #38679.

Introduces new method CountAllLocalGoodTypesNormalForm(Q, p, k, m, zvec, nzvec) to compute the number of local solutions of 'good type' for Q[v] = m mod p^k when Q is in local normal form at p.
This replaces the use of the slow brute-force function CountAllLocalTypesNaive indirectly used in local_good_density_congruence_even for (p,k)=(2,3) .

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@@ -228,27 +228,27 @@ cdef local_solution_type_cdef(Q, p, w, zvec, nzvec):
i += 1

if not nonzero_flag:
return <long> 0
return < long > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not wanted, keep <long>


# Error if we get here! =o
print(" Solution vector is " + str(w))
print(" and Q is \n" + str(Q) + "\n")
raise RuntimeError("Error in IsLocalSolutionType: Should not execute this line... =( \n")


def CountAllLocalGoodTypesNormalForm(Q, p, k, m, zvec, nzvec):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not use CamelCase name for functions

Copy link

github-actions bot commented Sep 20, 2024

Documentation preview for this PR (built with commit b945f4b; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@fchapoton
Copy link
Contributor

one failing doctest

The old doctest failed the input assumption that Q is given in local diagonal form. Now gives such a local diagonal form to the function. The new output has also been verified with the old code.
@WvanWoerden
Copy link
Contributor Author

Should be resolved now. The old doctest failed the (already existing) input assumption that Q is given in local diagonal form. The new code uses this assumption and therefore gave unexpected results. Now the local diagonal form is passed to the function in the doctest. I verified the results also with release version 10.4.

@WvanWoerden
Copy link
Contributor Author

The previous build resulted in an error because some .coverage file was missing (see https://github.com/sagemath/sage/actions/runs/10962048022/job/30442695828 ).
Is there something I can do to fix this? The coverage report is fine on my local machine and it is unclear to me what this error is referring to.

I also merged the latest develop branch again, maybe this will already resolve the issue.

@WvanWoerden
Copy link
Contributor Author

That seems to have fixed it, should be good to merge now.

@fchapoton
Copy link
Contributor

the documentation in count_local_2 is not looking right ; you can see it by clicking above and navigating to that file in the reference manual

Comment on lines 295 to 303
- ``Q`` -- quadratic form over `\ZZ` in local normal form at p with no zero blocks mod m_range
- ``p`` -- prime number > 0
- ``k`` -- integer > 0
- ``m`` -- integer >= 0 (depending only on mod `p^k`)
- ``zvec``, ``nzvec`` -- list of integers in ``range(Q.dim())``, or ``None``

OUTPUT:

an integer '\ge 0' representing the solutions of Good type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things here:

  • If I see it correctly, m_range is always p^k here, so it might be nicer to write "mod p^k" in the first line
  • In the output line '\ge 0' is not displaying properly since the wrong ticks are used; it should be \ge 0, or alternatively you could also write "a non-negative integer" instead (I think the latter is slightly better, but either should be fine)
  • Not sure if it is common to say "representing the solutions" for the count of solutions, but maybe "giving the number of solutions" would be a bit more explicit?

@WvanWoerden
Copy link
Contributor Author

Thank you both for noticing this and for the suggestions. I've updated the docs accordingly.

@S17A05
Copy link
Member

S17A05 commented Oct 17, 2024

Thank you both for noticing this and for the suggestions. I've updated the docs accordingly.

Thanks for the changes, looks good to me now! Not sure why the workflows require approval, but since the last commit only changed documentation and the tests ran correctly before, I'll set this to positive review.

vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 18, 2024
…rm at p=2

    
Fixes sagemath#38679.

Introduces new method `CountAllLocalGoodTypesNormalForm(Q, p, k, m,
zvec, nzvec)` to compute the number of local solutions of 'good type'
for Q[v] = m mod p^k when Q is in local normal form at p.
This replaces the use of the slow brute-force function
`CountAllLocalTypesNaive` indirectly used in
`local_good_density_congruence_even` for (p,k)=(2,3) .

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies
    
URL: sagemath#38680
Reported by: WvanWoerden
Reviewer(s): Frédéric Chapoton, Sebastian A. Spindler
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 20, 2024
…rm at p=2

    
Fixes sagemath#38679.

Introduces new method `CountAllLocalGoodTypesNormalForm(Q, p, k, m,
zvec, nzvec)` to compute the number of local solutions of 'good type'
for Q[v] = m mod p^k when Q is in local normal form at p.
This replaces the use of the slow brute-force function
`CountAllLocalTypesNaive` indirectly used in
`local_good_density_congruence_even` for (p,k)=(2,3) .

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies
    
URL: sagemath#38680
Reported by: WvanWoerden
Reviewer(s): Frédéric Chapoton, Sebastian A. Spindler
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 23, 2024
…rm at p=2

    
Fixes sagemath#38679.

Introduces new method `CountAllLocalGoodTypesNormalForm(Q, p, k, m,
zvec, nzvec)` to compute the number of local solutions of 'good type'
for Q[v] = m mod p^k when Q is in local normal form at p.
This replaces the use of the slow brute-force function
`CountAllLocalTypesNaive` indirectly used in
`local_good_density_congruence_even` for (p,k)=(2,3) .

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies
    
URL: sagemath#38680
Reported by: WvanWoerden
Reviewer(s): Frédéric Chapoton, Sebastian A. Spindler
@vbraun vbraun merged commit 5c90b60 into sagemath:develop Oct 26, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve counting of local solutions for QuadraticForm at p=2
5 participants