When I gave insufficient size of matrices to matsolve(M, B)
method, I took a segmentation fault instead of warning.
*** matsolve: bug in PARI/GP (Segmentation Fault), please report.
With correct size of matrices, I got wrong result. Here is my test code:
{
w = ffgen(w^7 + w^2 + Mod(2,3)*w + Mod(1,3));
info = [
2*w^6 + 2*w^5 + 2*w^4 + 2*w^3 + 2*w^2 + w, w^6 + w^5 + w^4 + 2*w^2 + 2;
w^4 + w^3 + 2*w^2 + w + 1, w^6 + 2*w^5 + 2*w^4 + w^3 + 2*w^2;
2*w^6 + w^5 + w^4 + w^3 + 2, 2*w^5 + 2*w^4 + 2*w^3 + 2*w + 2;
w^5 + w^3 + 2*w^2 + w, w^6 + 2*w^5 + 2*w^4 + 2*w^3 + w^2 + 1;
w^3 + w^2 + 2*w + 1, 2*w^6 + w^5 + 2*w^3 + w;
2*w^6 + 2*w^5 + w^4 + 2*w^3 + 2*w + 2, w^6 + 2*w^4 + 2*w^2 + 1;
w^6 + 2*w^5 + 2*w^4 + 2*w^3 + 2*w^2 + 2*w + 1, w^6 + 2*w^4 + 2*w^3 + w^2 + w + 1
];
result = [
w^6 + 2*w^5 + w^3 + 2*w;
2*w^6 + w^2 + w;
w^4 + 2*w^2 + 2*w + 2;
2*w^6 + 2*w^5 + w^4 + w^3 + 2*w^2;
2*w^5 + w^4 + w;
w^5 + 2*w^2 + w + 2;
2*w^6 + w^5 + 2*w^4 + 2*w^3 + 2*w^2 + w
];
\\ lamda * info = result
lamda = matsolve(info, result);
calculated_result = mattranspose(mattranspose(lamda) *
mattranspose(info));
}
And the output is:
? result
[ w^6 + 2*w^5 + w^3 + 2*w]
[ 2*w^6 + w^2 + w]
[ w^4 + 2*w^2 + 2*w + 2]
[ 2*w^6 + 2*w^5 + w^4 + w^3 + 2*w^2]
[ 2*w^5 + w^4 + w]
[ w^5 + 2*w^2 + w + 2]
[2*w^6 + w^5 + 2*w^4 + 2*w^3 + 2*w^2 + w]
? calculated_result
[ w^6 + 2*w^5 + w^3 + 2*w]
[ 2*w^6 + w^2 + w]
[ 2*w^5 + w^4 + w^3 + w^2 + 2*w + 2]
[w^6 + w^5 + 2*w^4 + 2*w^3 + 2*w^2 + w]
[ w^6 + w^4 + w^3 + w^2 + 2*w + 1]
[ 2*w^4 + 2*w^3 + w^2 + 2*w + 1]
[ 2*w^4 + w^3 + w + 1]
Only the first two rows of results are same, rest of them are different. I guess, for given info(n x k) and result(k x 1) matrices, GP ignores the last (n - k) rows of the info matrix.