Opened 12 years ago

Last modified 7 years ago

#7163 new defect

right kernel does not respect sparse=True

Reported by: mhansen Owned by: tbd
Priority: major Milestone: sage-6.4
Component: linear algebra Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


<Submarine> hi
<Submarine> sage: ker=m.right_kernel(sparse=True)
<Submarine> sage: type(ker.basis_matrix())
<Submarine> <type 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'>
<Submarine> Is it normal I'm getting a dense matrix?

Change History (6)

comment:1 Changed 12 years ago by was

The "sparse=True" option you are passing to right_kernel isn't
implemented at all.

In fact, the way right_kernel is implemented you can make up an
options you want and they will be silently ignored:

sage: ker=m.right_kernel(foobar=True, stand_on_your_head=True,
use_the_force=True, super_sparse=True, dumb=False)

In the meantime you can get a sparse matrix as follows:

sage: ker=m.right_kernel().basis_matrix().sparse_matrix()
sage: type(ker)
<type 'sage.matrix.matrix_rational_sparse.Matrix_rational_sparse'>
sage: ker.row_module()
Sparse vector space of degree 100 and dimension 99 over Rational Field
Basis matrix:
99 x 100 sparse matrix over Rational Field

Here's the relevant code for "right_kernel", which as you can see does
nothing with sparseness...

Obviously it would be desirable for somebody to fix the right_kernel
command so one gets errors for all unused options, and all options
that should be supported are supported.

       if R.is_field():
           E = self.echelon_form(*args, **kwds)
           pivots = E.pivots()
           pivots_set = set(pivots)
           basis = []
           V = R ** self.ncols()
           ONE = R(1)
           for i in xrange(self._ncols):
               if not (i in pivots_set):
                   v = V(0)
                   v[i] = ONE
                   for r in range(len(pivots)):
                       v[pivots[r]] = -E[r,i]
           W = V.submodule(basis)
           if W.dimension() != len(basis):
               raise RuntimeError, "bug in right_kernel function in
matrix2.pyx -- basis from echelon form is not a basis."
           self.cache('right_kernel', W)
           return W

comment:2 Changed 12 years ago by AlexGhitza

  • Component changed from algebra to linear algebra

comment:3 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:6 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.