Generate matrices whose null spaces are non-zero integer vectors

153 Views Asked by At

I am trying to generate 500 matrices whose null spaces are non-zero, integer vectors.

I currently generate the matrices by using rand() to choose a number between 1 and 5. I find the kernel by passing the matrix to EigenLib's kernel() function. However, my matrix generation algorithm is entirely insufficient because (generally) 19/20 of the kernels are the zero vector.

How do I generate matrices whose null spaces will have integer, non-zero vectors?

1

There are 1 best solutions below

3
On BEST ANSWER

First choose a column vector $v$ with integer entries that is to be in the null space. Then find a matrix whose rows are orthogonal to $v$. The simplest case will be if some element $v_k$ of $v$ is $\pm 1$. Then you can choose the entries $a_{ij}$ for $j \ne k$ randomly, and take $a_{ik} = \mp \sum_{j \ne k} a_{ij} v_j$.