algorithms
algorithms copied to clipboard
[Smith normal form] wrong calculation
Enter the 2x2 matrix
[[3, 13], [16, 34]]
Your script will give B = [[1, 0], [0,4]] S = {{0,1},{1,-3}} A = {{3,13},{16,34}} T = {{0,1},{1,-3}}
But B != SAT!
See http://www.wolframalpha.com/input/?i=%7B%7B0%2C1%7D%2C%7B1%2C-3%7D%7D*%7B%7B3%2C13%7D%2C%7B16%2C34%7D%7D*%7B%7B0%2C1%7D%2C%7B1%2C-3%7D%7D
Another testcase (from "2009 Zahlentheorie Klausur.pdf", Aufgabe 3):
[[-5,5,-50],[-10,5,45],[10,-5,-30]]
should give (for matrix B)
[[5,0,0],[0,5,0],[0,0,15]]
By the way, you can create random testcases like this:
- Get a correct implementation for calculating determinants
- fill matrix A with random integer entries
- calculate det(A)
- check if product elementary divisors = det(A)
Added this testcase. @MartinThoma do you want to write a fix?
Not at the moment. (I still have a lot of exams which I didn't try)