[SciPy-dev] _cs_matrix._matvec()

Robert Cimrman cimrman3@ntc.zcu...
Mon Sep 10 03:07:17 CDT 2007

hi again,

looking at _cs_matrix class in sparse.py, I noticed
    def _matvec(self, other, fn):
        if isdense(other):
            # This check is too harsh -- it prevents a column vector from
            # being created on-the-fly like dense matrix objects can.
            #if len(other) != self.shape[1]:
            #    raise ValueError, "dimension mismatch"
            oth = numpy.ravel(other)
            y = fn(self.shape[0], self.shape[1], \
                   self.indptr, self.indices, self.data, oth)
            if isinstance(other, matrix):
                y = asmatrix(y)
            if other.ndim == 2 and other.shape[1] == 1:
                # If 'other' was an (nx1) column vector, transpose the
                # to obtain an (mx1) column vector.
                y = y.T
            return y

I do not see a reason for the commenting out of the lines
            #if len(other) != self.shape[1]:
            #    raise ValueError, "dimension mismatch"
as the function silently passes with wrong input.

Could anybody explain this? I would uncomment the lines, but maybe there
is a reason...


More information about the Scipy-dev mailing list