Finding positive kernel

81 views
Skip to first unread message

Doaa El-Sakout

unread,
Apr 24, 2012, 9:36:04 AM4/24/12
to sage-s...@googlegroups.com
Hi

I am using right_kernel to find a kernel, for example the result is
[ 1 0 1 0 -1 0 0]
[ 0 1 1 0 0 0 0]
[ 0 0 0 1 1 0 0]
[ 0 0 0 0 0 1 1]

How can I (for an arbitrary kernel) get positive entries only,
by making a linear combination of rows?

Regards,
Doaa

Jason Grout

unread,
Apr 24, 2012, 9:44:45 AM4/24/12
to sage-s...@googlegroups.com

I'm not quite sure what you're asking. When you use right_kernel, you
get a vector space, not a matrix. What types of matrices are you
dealing with (matrices with rational entries?)? If you're dealing with
matrices having rational entries, then since the kernel is a subspace,
the kernel will have vectors with negative entries.

Thanks,

Jason

P Purkayastha

unread,
Apr 25, 2012, 7:08:30 AM4/25/12
to sage-s...@googlegroups.com
I guess what the OP means is that he wants a set of basis vectors with non-negative entries. For instance in the above example, adding the third row to the first will give such a matrix.

I don't know if there is any ready made method for doing that. An easy way would be to get the rref (the example given is already in rref form) and then try to remove the non-negative entries in any row, say r_1, by replacing the row with r_1+a*r_i for any possible i, and some scalar a. Starting from the bottom row (that is turning the bottom row into a non-negative vector, and then the 2nd last row, etc) would be a good way to proceed IMHO.

Volker Braun

unread,
Apr 25, 2012, 8:05:37 AM4/25/12
to sage-s...@googlegroups.com
Note that this is a question about convex polyhedra since it involves inequalities! You can't solve it with linear algebra alone. A simple way is to intersect your null space with the positive orthant, which gives you a cone in your null space whose elements have all positive entries:

sage: kernel = Polyhedron(lines=[
....:   [ 1,  0,  1,  0, -1,  0,  0],
....:   [ 0,  1,  1,  0,  0,  0,  0],
....:   [ 0,  0,  0,  1,  1,  0,  0],
....:   [ 0,  0,  0,  0,  0,  1,  1]])
sage: positive = Polyhedron(rays=identity_matrix(7).columns())
sage: pos_ker = kernel.intersection(positive)
sage: pos_ker
A 4-dimensional polyhedron in ZZ^7 defined as the convex hull of 1 vertex and 4 rays
sage: pos_ker.rays()
(A ray in the direction (0, 0, 0, 0, 0, 1, 1), A ray in the direction (0, 0, 0, 1, 1, 0, 0), A ray in the direction (0, 1, 1, 0, 0, 0, 0), A ray in the direction (1, 0, 1, 1, 0, 0, 0))

Doaa El-Sakout

unread,
Apr 25, 2012, 9:42:49 AM4/25/12
to sage-s...@googlegroups.com
Dear Volker Braun,
Thanks so much that is what I need
Thanks
Doaa

> --
> To post to this group, send email to sage-s...@googlegroups.com
> To unsubscribe from this group, send email to
> sage-support...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org

Reply all
Reply to author
Forward
0 new messages