-
Notifications
You must be signed in to change notification settings - Fork 66
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
Bugs in Order(...) #1223
Comments
Another idea: First, run one of the algorithms with vector spaces over Q to find a set of n linearly independent elements of the order. That gives you a finite index submodule of the order, allowing you to use modular Hermite reduction from the beginning. |
Maybe there's a probabilistic (Las Vegas) algorithm using the following lemma that's faster than the one described above under "More efficient methods?" by a factor of Lemma. Let G be a finite abelian group of order s. Then, k random elements of G generate the group G with probability So if you have a rank n module To obtain a Las Vegas algorithm with guaranteed correctness, at the end of the algorithm, check that I haven't tried to rigorously analyze the running time. Of course, one would need to also keep track of the number of digits of all numbers involved in the computation. |
Thanks for the report and the analysis. I have a feeling I will try to cook up a simpler implementation to fix the bugs that you reported. I am also currently collecting all |
On Mon, Sep 25, 2023 at 01:00:41AM -0700, Tommy Hofmann wrote:
Thanks for the report and the analysis. I have a feeling `phase = 1` refers to "not full rank yet" and `phase = 2` to "full rank". Why some of the things should be done only in the first case, I do not know.
In phase 1 we're adding also powers of elements (possibly all n in one
go), in phase only products are added. Rationale: if you're creating an
equation order, adding (and HNFing) 1, a, then a^2, ... is painful.
Keeping track of redundant products is also hard
…
I will try to cook up a simpler implementation to fix the bugs that you reported.
I am also currently collecting all `Order(K, [...])` calls that occur in the test suite. This should be helpful when trying to improve the algorithm.
--
Reply to this email directly or view it on GitHub:
#1223 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Here are some bugs in the current
Order(...)
function, a discussion of the algorithm and some half-baked ideas. I could try to implement a fix, but wanted to first ask for opinions about what the algorithm should actually be...Issues
There are several (more or less separate) bugs in the
Order(...)
function that in a given number field K should compute the order generated by a given list of elements.Issue 1: Running
K,w=NumberField(x,"w"); Order(K,[1])
should produce the order Z in the number field Q, but gives:The problem is that although
bas
is initialized to the basis1
of Q, the matrixB
still has zero rows:Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Lines 1027 to 1028 in d23dfff
Issue 2: Running
K,w=NumberField(x,"w"); Order(K,[])
should also produce the order Z in the number field Q, but gives:I think this is a type confusion. Somehow,
map(K, [])
returns an object of typeVector{Any}
instead ofVector{nf_elem}
. (Why?) That's why this functionHecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Lines 770 to 779 in d23dfff
keeps calling itself instead of calling
Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Lines 750 to 751 in d23dfff
Issue 3: Running$K=\mathbb Q(\sqrt2,\sqrt3)$ , the elements $a=\sqrt2$ , $b=\sqrt3$ , and return the order $\mathbb Z[a,b]$ of $K$ . Instead, it fails:
K,w=NumberField(x^4-10*x^2+1,"w"); a=1//2*w^3-9//2*w; b=1//2*w^3-11//2*w; Order(K,[a,b])
should compute the field(Both
Order(K,[a,b,a*b])
andOrder(K,[a,b],check=false)
actually succeed and produce the correct output.)In this function, when check=true, the function
_order(...)
actually never reaches "phase 2". It never computes the product a*b, only produces the Z-module generated by 1,a,b, which is indeed not an order. I'm confused about the purpose of the whole phase management. (See below.)Issue 4: This coincidentally doesn't produce any serious problems, but I think there's a mistyped variable name. Compare these lines:
Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Line 1009 in d23dfff
Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Line 1016 in d23dfff
This branch, which would use the modular Hermite normal form optimization, is never taken:
Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Line 1069 in d23dfff
Regardless of this typo, I don't understand why this optimization should be used only when we're extending an order. (See below.)
There are also some unnecessary checks in the code, as was already pointed out by @fieker in inline comments:
Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Line 1052 in d23dfff
Hecke.jl/src/NumFieldOrd/NfOrd/NfOrd.jl
Lines 1091 to 1092 in d23dfff
Fixed algorithm
I don't know if the current algorithm is documented anywhere, so here's an outline in pseudocode for what I think the function was trying to do to compute the order generated by the elements in a given vector
gens
, where the number field K has degree n:The Z-submodules of K are represented by Hermite-reduced bases. One can use a modular HNF algorithm (the optimization mentioned above) as soon as B has full rank. (Using "the determinant of B" as the modulus.)
If you append k rows to an$n\times n$ Hermite reduced matrix and apply Hermite reduction to the result, I think the algorithm might do about $n^3 + kn^2$ operations in Z. (The summand $n^3$ arises because all diagonal entries might decrease, and then all the off-diagonal entries have to be reduced.)
Hence, it is faster by a factor of ~n to append n rows and Hermite reduce once than to n times append one row and reduce. The attempt to implement such an optimization is the root of all evil in the current implementation. :)
One easy way to solve this issue (if one is willing to sacrifice a constant factor in the running time) should be to represent a Z-module by a list of generators which is not necessarily Hermite reduced. Only apply Hermite reduction after line 12 if we have accumulated$\geq2n$ generators, and once at the end of the algorithm. It's okay to just skip the checks in lines 8-11 if the current list of generators of B hasn't been reduced, yet.
More efficient methods?
I feel like there must be more efficient algorithms for this problem, at least when the number r of generators is large. Consider the total number N of rows in all calls to the Hermine normalization function
hnf
.If you run the above algorithm (or the currently implemented one) with r >= 2 generators, I suppose N could be on the order of$rn^2$ . (After the first generator, A can have rank n, so we then have to append ~n rows, for i=1,...,n, for each generator.)
Here's an algorithm with$N=\mathcal O(r+n^2\log(rn))$ :
(Computing$\leq n^2$ rows.)
A*A
involves a matrix withThe text was updated successfully, but these errors were encountered: