-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Tests to see if ideal in quaternion algebra is primitive (cyclic) #37112
Conversation
Your docstrings are not formatted properly. I have reformatted your
|
Also if you look at the tests ^, and in particular "Lint / lint (pull_request)", it fails for several formatting reasons. Please also edit them :) It's simple things like "blank line contains whitespace" and "trailing whitespace". PS: This indicates your editor is messed up - it should remove these for you. |
O_basis = self.left_order().basis_matrix() | ||
|
||
# Write I in the basis of its left order via rref | ||
M = block_matrix(1,2,[O_basis.transpose(),I_basis.transpose()]).rref()[:,4:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is just M = O_basis.solve_left(I_basis)
?
|
||
# Write I in the basis of its left order via rref | ||
M = block_matrix(1,2,[O_basis.transpose(),I_basis.transpose()]).rref()[:,4:] | ||
g = Integer(gcd((gcd(M_row) for M_row in M))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shorter way: g = Integer(gcd(M.list()))
.
g = Integer(gcd((gcd(M_row) for M_row in M))) | ||
|
||
# If g is 1 then the ideal is primitive | ||
if g == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test g.is_one()
is significantly faster than g == 1
, since the latter goes through the type coercion system to find a common parent type to do the comparison in.
if self.__left_order is not None: | ||
return all([b in self.left_order() for b in self.basis()]) | ||
elif self.__right_order is not None: | ||
return all([b in self.right_order() for b in self.basis()]) | ||
else: | ||
self_square = self**2 | ||
return all([b in self for b in self_square.basis()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of these tests should be equivalent to one of the form A.free_module() <= B.free_module()
. (See also #37113.)
|
||
""" | ||
_,g = self.primitive_decomposition() | ||
return 1 == g |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, using .is_one()
is faster.
In this small commit I inserted all the improvements pointed out previously by @yyyyx4 (many thanks!)
TESTS:: | ||
|
||
Checks on random crafted ideals that they decompose as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more linter failure:
TESTS:: | |
Checks on random crafted ideals that they decompose as expected. | |
TESTS: | |
Checks on random crafted ideals that they decompose as expected:: |
(The ::
syntax only indicates that an indented block is about to follow, so here it should be moved down as indicated instead of sticking to the TESTS:
header.)
@@ -56,7 +56,7 @@ | |||
from sage.structure.category_object import normalize_names | |||
from sage.structure.parent import Parent | |||
from sage.matrix.matrix_space import MatrixSpace | |||
from sage.matrix.constructor import diagonal_matrix, matrix | |||
from sage.matrix.constructor import diagonal_matrix, matrix, block_matrix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import of block_matrix
is now unused and can be removed.
Documentation preview for this PR (built with commit 09d352e; changes) is ready! 🎉 |
Looks good to me, thanks! |
I have implemented the `automatic size labeler`, which now assigns labels to pull requests based on the number of lines changed **Minimal** Typically involves very small changes, bug fixes, or updates that require only a few lines of code, often less than 50. sagemath#37208 sagemath#37146 sagemath#37043 **Small** Involves more substantial changes than minimal, potentially adding new features or making modifications to existing ones. The range is usually between 50 to 100 lines of code. sagemath#37152 sagemath#37132 **Moderate** Represents a significant portion of the codebase being modified, such as adding new features, refactoring, or making extensive changes to existing functionalities. This might involve between 100 to 300 lines of code. sagemath#36919 sagemath#37112 **Large** Involves substantial and complex changes across various parts of the codebase. This could include major architectural changes, the introduction of new modules, or a significant overhaul of existing features, often exceeding 300 lines of code. sagemath#37125 sagemath#36977 sagemath#36972 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. Fixes: sagemath#37254 URL: sagemath#37262 Reported by: Aman Moon Reviewer(s): Sebastian Oehms
I have implemented the `automatic size labeler`, which now assigns labels to pull requests based on the number of lines changed **Minimal** Typically involves very small changes, bug fixes, or updates that require only a few lines of code, often less than 50. sagemath#37208 sagemath#37146 sagemath#37043 **Small** Involves more substantial changes than minimal, potentially adding new features or making modifications to existing ones. The range is usually between 50 to 100 lines of code. sagemath#37152 sagemath#37132 **Moderate** Represents a significant portion of the codebase being modified, such as adding new features, refactoring, or making extensive changes to existing functionalities. This might involve between 100 to 300 lines of code. sagemath#36919 sagemath#37112 **Large** Involves substantial and complex changes across various parts of the codebase. This could include major architectural changes, the introduction of new modules, or a significant overhaul of existing features, often exceeding 300 lines of code. sagemath#37125 sagemath#36977 sagemath#36972 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. Fixes: sagemath#37254 URL: sagemath#37262 Reported by: Aman Moon Reviewer(s): Sebastian Oehms
I have implemented the `automatic size labeler`, which now assigns labels to pull requests based on the number of lines changed **Minimal** Typically involves very small changes, bug fixes, or updates that require only a few lines of code, often less than 50. sagemath#37208 sagemath#37146 sagemath#37043 **Small** Involves more substantial changes than minimal, potentially adding new features or making modifications to existing ones. The range is usually between 50 to 100 lines of code. sagemath#37152 sagemath#37132 **Moderate** Represents a significant portion of the codebase being modified, such as adding new features, refactoring, or making extensive changes to existing functionalities. This might involve between 100 to 300 lines of code. sagemath#36919 sagemath#37112 **Large** Involves substantial and complex changes across various parts of the codebase. This could include major architectural changes, the introduction of new modules, or a significant overhaul of existing features, often exceeding 300 lines of code. sagemath#37125 sagemath#36977 sagemath#36972 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. Fixes: sagemath#37254 URL: sagemath#37262 Reported by: Aman Moon Reviewer(s): Sebastian Oehms
New methods for
QuaternionFractionalIdeal_rational
:QuaternionFractionalIdeal_rational.is_integral()
QuaternionFractionalIdeal_rational.is_primitive()
QuaternionFractionalIdeal_rational.primitive_decomposition()
These methods verify if an ideal in quaternion rational algebra is integral, primitive (cyclic) and decompose it as a primitive ideal. Part of the code came from https://learningtosqi.github.io.
Also added the Quaternion Algebras book by J. Voight in the bibliography.
Done with @gioella
#sd123