I'm trying to write a program in which one part is related to calculation of kernel of a matrix. Its output and expected output are different. For example,
$$ A = \begin{pmatrix}1&0&1\\ 1&0&0\\ 0&1&1\\ 0&1&0\\ 0&0&1\\ -1&0&0\\ 0&0&-1\\ 0&-1&1\\ 0&-1&0\\ -1&0&1\end{pmatrix} $$
When I calculate its kernel with some programs they give output different, my program is as well. But, when I try to calculate its kernel some others, like SAGE, give output,
1 0 0 0 0 0 0 -2 2 1
0 1 0 0 0 0 0 -1 1 1
0 0 1 0 0 0 0 -1 2 0
0 0 0 1 0 0 0 0 1 0
0 0 0 0 1 0 0 -1 1 0
0 0 0 0 0 1 0 1 -1 -1
0 0 0 0 0 0 1 1 -1 0
The above one is what I expect as output. What is the point that I may overlook?
@Edit, It's my algorithm,
A.transposeInPlace();
FullPivLU<MatrixXf> lu(A);
MatrixXf A_null_space = lu.kernel();
A_null_space.transposeInPlace();
when I run, it gives
0.5 0 -1 1 0 0 0 0 0 0.5
-0.5 0 -0 0 1 0 0 0 0 -0.5
0.5 0 -0 0 0 1 0 0 0 -0.5
0.5 0 -0 0 0 0 1 0 0 0.5
-1 0 1 0 0 0 0 1 0 -1
-0.5 0 1 0 0 0 0 0 1 -0.5
-0.5 1 -0 0 0 0 0 0 0 0.5
@Edit 2, I'm really but really confused because both matrix seem right! How come?


It sounds like you may have missed a transpose along with way. Your matrix $A$ is 10 x 3, it has rank 3, and as such it will have a kernel of rank 0 by the Rank Nullity Theorem.
However, if you were looking for the kernel of $A^T$, this would have rank 7, and the basis of that kernel would line up with the seven row vectors you provided.