当我给matsolve(M, B)
方法提供的矩阵大小不足时,我采取了分段错误而不是警告。
*** matsolve: bug in PARI/GP (Segmentation Fault), please report.
使用正确大小的矩阵,我得到了错误的结果。这是我的测试代码:
{
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));
}
输出是:
? 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]
只有前两行结果相同,其余的结果不同。我猜,对于给定的 info(nxk) 和 result(kx 1) 矩阵,GP 会忽略 info 矩阵的最后 (n - k) 行。