Talk:Defactoring algorithms: Difference between revisions
Cmloegcmluin (talk | contribs) No edit summary |
re |
||
| Line 126: | Line 126: | ||
::::::: You can find an example of us computing the entire thing by hand in the article. No pseudoinverse is required. --[[User:Cmloegcmluin|Cmloegcmluin]] ([[User talk:Cmloegcmluin|talk]]) 22:12, 10 February 2023 (UTC) | ::::::: You can find an example of us computing the entire thing by hand in the article. No pseudoinverse is required. --[[User:Cmloegcmluin|Cmloegcmluin]] ([[User talk:Cmloegcmluin|talk]]) 22:12, 10 February 2023 (UTC) | ||
:::::::: Oh, allow me to correct myself. After some trial and errors it turns out the pseudoinverse doesn't get you the unimodular matrix, but a singular matrix, so it doesn't work. The correct way seems to be using the augmented matrix to track the elementary row operations in HNF: (A|I) → (H|U), as you pointed out and as one of them showed in the development thread. Here's my implementation of the column Hermite method: | |||
:::::::: <syntaxhighlight lang="python"> | |||
def __sat (main): | |||
r = Matrix (main).rank () | |||
unimodular = __hnf (np.hstack ((main.T, np.eye (main.shape[1], dtype = int))))[:, r:] | |||
return np.rint (linalg.inv (unimodular).T[:r]).astype (int) | |||
</syntaxhighlight> | |||
:::::::: As I said, "Hermite decomposition" isn't a single operation. Here it involves concatenation, HNF, and slice, tho it doesn't involve the pseudoinverse. Compare Pernet-Stein: | |||
:::::::: <syntaxhighlight lang="python"> | |||
def __sat (main): | |||
r = Matrix (main).rank () | |||
return np.rint (linalg.inv (__hnf (main.T)[:r].T) @ main).astype (int) | |||
</syntaxhighlight> | |||
:::::::: Note the slice and thus computing the rank are redundant; they're there just for futureproofness. | |||
:::::::: [[User:FloraC|FloraC]] ([[User talk:FloraC|talk]]) 10:58, 11 February 2023 (UTC) | |||