0

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?

enter image description here

enter image description here

1 Answers1

1

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.

  • I've edited the question, could you take a look again? – Soner from The Ottoman Empire Nov 15 '17 at 17:01
  • Looks good I think. A simple way to verify your kernel basis is to check that all vectors are pairwise orthogonal (i.e. they have a dot product of zero), which looks like the case to me. – Chris Tynan Nov 15 '17 at 17:05
  • Sir, AFAIU, I've tried what you mentioned, could you look at the question again? I'm really confused. How come it is possible? And, how can I obtain the yellowed one's? @Chris Tynan – Soner from The Ottoman Empire Nov 15 '17 at 17:22
  • Both matrices are correct. The basis for the kernel does not have a unique representation, as with any orthogonal basis. You can multiply individual rows by a scalar, as well as permuting the order of the columns or rotating the whole matrix, and you will still have a valid basis. – Chris Tynan Nov 15 '17 at 17:37
  • Actually I'm creating two cones from the matrix and a same sized identity matrices, respectively. Then from their equations and inequalities, I create another cone(intersection of two cones). So does it mean I get same result as a final result? @Chris Tynan – Soner from The Ottoman Empire Nov 15 '17 at 17:46
  • I'm sorry but I'm not sure what you're referring to by cones. You'd need to provide more context but perhaps ask a separate question if the content is sufficiently different – Chris Tynan Nov 15 '17 at 17:53
  • It's already been sir, really thank you for your time, the link, the other link @Chris Tynan – Soner from The Ottoman Empire Nov 15 '17 at 17:54
  • Unfortunately I'm not really familiar with these concepts so I'm not able to help you. Hopefully someone else can! – Chris Tynan Nov 15 '17 at 18:12