Added functions to get HNF transformation matrices#1879
Added functions to get HNF transformation matrices#1879jstriete wants to merge 1 commit intothofma:masterfrom
Conversation
thofma
left a comment
There was a problem hiding this comment.
Thanks! I left a few minor comments. Apart from these things and adding tests, this looks good.
| Like a snf without the divisibility condition. | ||
| """ | ||
| function diagonal_form(A::SMat{ZZRingElem}) | ||
| function diagonal_form(A::SMat{ZZRingElem}, with_right_trafo = false, with_left_trafo = false) |
There was a problem hiding this comment.
I guess this is not used anymore, right?
| # | ||
| ################################################################################ | ||
|
|
||
| function diagonal_form_with_transform(A::SMat, left=false, right=false) |
There was a problem hiding this comment.
Can you add a docstring or comment in the code?
| end | ||
| hnf_with_trafo!(A, I, truncate=false, full_hnf=true, auto=false) | ||
| R = sparse_matrix(base_ring(C), nrows(I), ncols(C)) | ||
| for (i, row) in enumerate(I.rows) |
There was a problem hiding this comment.
| for (i, row) in enumerate(I.rows) | |
| for (i, row) in enumerate(I) |
| if left == false | ||
| hnf!(A, truncate=false, full_hnf=true, auto=false) | ||
| else | ||
| I = sparse_matrix(ZZ, 0, nrows(A)) |
There was a problem hiding this comment.
| I = sparse_matrix(ZZ, 0, nrows(A)) | |
| I = sparse_matrix(ZZ, 0, nrows(A)) |
| end | ||
| hnf_with_trafo!(A, I, truncate=false, full_hnf=true, auto=false) | ||
| R = sparse_matrix(base_ring(D), nrows(I), ncols(D)) | ||
| for (i, row) in enumerate(I.rows) |
There was a problem hiding this comment.
| for (i, row) in enumerate(I.rows) | |
| for (i, row) in enumerate(I) |
| if n % 2 == 0 | ||
| A = transpose(A) | ||
| end | ||
| if left == true && right == true |
There was a problem hiding this comment.
| if left == true && right == true | |
| if left && right |
| if left == true && right == true | ||
| return C, A, transpose(D) | ||
| end | ||
| if left == true |
There was a problem hiding this comment.
| if left == true | |
| if left |
| if left == true | ||
| return C, A | ||
| end | ||
| if right == true |
There was a problem hiding this comment.
| if right == true | |
| if right |
|
|
||
| function diagonal_form_with_transform(A::SMat, left=false, right=false) | ||
| n = 1 | ||
| if left == true |
There was a problem hiding this comment.
| if left == true | |
| if left |
| push!(C, sparse_row(ZZ, [(i, ZZ(1))])) | ||
| end | ||
| end | ||
| if right == true |
There was a problem hiding this comment.
| if right == true | |
| if right |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1879 +/- ##
==========================================
- Coverage 76.54% 76.46% -0.08%
==========================================
Files 364 364
Lines 115639 115720 +81
==========================================
- Hits 88513 88489 -24
- Misses 27126 27231 +105
🚀 New features to boost your workflow:
|
| C = sparse_matrix(ZZ, 0, nrows(A)) | ||
| for i in 1:nrows(A) | ||
| push!(C, sparse_row(ZZ, [(i, ZZ(1))])) | ||
| end |
There was a problem hiding this comment.
| C = sparse_matrix(ZZ, 0, nrows(A)) | |
| for i in 1:nrows(A) | |
| push!(C, sparse_row(ZZ, [(i, ZZ(1))])) | |
| end | |
| C = identity_matrix(SMat, ZZ, nrows(A)) |
| D = sparse_matrix(ZZ, 0, ncols(A)) | ||
| for i in 1:ncols(A) | ||
| push!(D, sparse_row(ZZ, [(i, ZZ(1))])) | ||
| end |
There was a problem hiding this comment.
| D = sparse_matrix(ZZ, 0, ncols(A)) | |
| for i in 1:ncols(A) | |
| push!(D, sparse_row(ZZ, [(i, ZZ(1))])) | |
| end | |
| D = identity_matrix(SMat, ZZ, ncols(A)) |
| push!(D, sparse_row(ZZ, [(i, ZZ(1))])) | ||
| end | ||
| end | ||
| while(!is_diagonal(A)) |
There was a problem hiding this comment.
| while(!is_diagonal(A)) | |
| while !is_diagonal(A) |
| I = sparse_matrix(ZZ, 0, nrows(A)) | ||
| for i in 1:nrows(A) | ||
| push!(I, sparse_row(ZZ, [(i, ZZ(1))])) | ||
| end |
There was a problem hiding this comment.
| I = sparse_matrix(ZZ, 0, nrows(A)) | |
| for i in 1:nrows(A) | |
| push!(I, sparse_row(ZZ, [(i, ZZ(1))])) | |
| end | |
| I = identity_matrix(SMat, ZZ, nrows(A)) |
| I = sparse_matrix(ZZ, 0, ncols(A)) | ||
| for i in 1:ncols(A) | ||
| push!(I, sparse_row(ZZ, [(i, ZZ(1))])) | ||
| end |
There was a problem hiding this comment.
| I = sparse_matrix(ZZ, 0, ncols(A)) | |
| for i in 1:ncols(A) | |
| push!(I, sparse_row(ZZ, [(i, ZZ(1))])) | |
| end | |
| I = identity_matrix(SMat, ZZ, ncols(A)) |
Edits HNF.jl and UpperTriangular.jl to add some functions that will return requested transformation matrices for the HNF decomposition.