Esempio n. 1
0
File: dok.py Progetto: 7924102/scipy
 def _mul_scalar(self, other):
     res_dtype = upcast_scalar(self.dtype, other)
     # Multiply this scalar by every element.
     new = dok_matrix(self.shape, dtype=res_dtype)
     for (key, val) in iteritems(self):
         new[key] = val * other
     return new
Esempio n. 2
0
 def conjtransp(self):
     """Return the conjugate transpose."""
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     dict.update(new, (((right, left), np.conj(val))
                       for (left, right), val in iteritems(self)))
     return new
Esempio n. 3
0
 def __truediv__(self, other):
     if isscalarlike(other):
         res_dtype = upcast_scalar(self.dtype, other)
         new = dok_matrix(self.shape, dtype=res_dtype)
         dict.update(new, ((k, v / other) for k, v in iteritems(self)))
         return new
     return self.tocsr() / other
Esempio n. 4
0
File: dok.py Progetto: rproepp/scipy
 def conjtransp(self):
     """ Return the conjugate transpose
     """
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     for key, value in iteritems(self):
         new[key[1], key[0]] = np.conj(value)
     return new
Esempio n. 5
0
File: dok.py Progetto: 7924102/scipy
 def _mul_multivector(self, other):
     # matrix * multivector
     M,N = self.shape
     n_vecs = other.shape[1]  # number of column vectors
     result = np.zeros((M,n_vecs), dtype=upcast(self.dtype,other.dtype))
     for (i,j),v in iteritems(self):
         result[i,:] += v * other[j,:]
     return result
Esempio n. 6
0
 def _mul_multivector(self, other):
     # matrix * multivector
     result_shape = (self.shape[0], other.shape[1])
     result_dtype = upcast(self.dtype, other.dtype)
     result = np.zeros(result_shape, dtype=result_dtype)
     for (i, j), v in iteritems(self):
         result[i,:] += v * other[j,:]
     return result
Esempio n. 7
0
File: dok.py Progetto: rproepp/scipy
 def _mul_multivector(self, other):
     # matrix * multivector
     M,N = self.shape
     n_vecs = other.shape[1]  # number of column vectors
     result = np.zeros((M,n_vecs), dtype=upcast(self.dtype,other.dtype))
     for (i,j),v in iteritems(self):
         result[i,:] += v * other[j,:]
     return result
Esempio n. 8
0
File: dok.py Progetto: 7924102/scipy
 def transpose(self):
     """ Return the transpose
     """
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     for key, value in iteritems(self):
         new[key[1], key[0]] = value
     return new
Esempio n. 9
0
File: dok.py Progetto: rproepp/scipy
 def transpose(self):
     """ Return the transpose
     """
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     for key, value in iteritems(self):
         new[key[1], key[0]] = value
     return new
Esempio n. 10
0
 def _mul_multivector(self, other):
     # matrix * multivector
     result_shape = (self.shape[0], other.shape[1])
     result_dtype = upcast(self.dtype, other.dtype)
     result = np.zeros(result_shape, dtype=result_dtype)
     for (i, j), v in iteritems(self):
         result[i,:] += v * other[j,:]
     return result
Esempio n. 11
0
File: dok.py Progetto: 7924102/scipy
 def conjtransp(self):
     """ Return the conjugate transpose
     """
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     for key, value in iteritems(self):
         new[key[1], key[0]] = np.conj(value)
     return new
Esempio n. 12
0
File: dok.py Progetto: 7924102/scipy
 def __itruediv__(self, other):
     if isscalarlike(other):
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             self[key] = val / other
         return self
     else:
         return NotImplemented
Esempio n. 13
0
File: dok.py Progetto: rproepp/scipy
 def __itruediv__(self, other):
     if isscalarlike(other):
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             self[key] = val / other
         return self
     else:
         return NotImplemented
Esempio n. 14
0
File: dok.py Progetto: 7924102/scipy
 def __imul__(self, other):
     if isscalarlike(other):
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             self[key] = val * other
         # new.dtype.char = self.dtype.char
         return self
     else:
         return NotImplemented
Esempio n. 15
0
 def __imul__(self, other):
     if isscalarlike(other):
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             self[key] = val * other
         # new.dtype.char = self.dtype.char
         return self
     else:
         return NotImplemented
Esempio n. 16
0
 def __truediv__(self, other):
     if isscalarlike(other):
         res_dtype = upcast_scalar(self.dtype, other)
         new = dok_matrix(self.shape, dtype=res_dtype)
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             new[key] = val / other
         # new.dtype.char = self.dtype.char
         return new
     else:
         return self.tocsr() / other
Esempio n. 17
0
    def transpose(self, axes=None, copy=False):
        if axes is not None:
            raise ValueError("Sparse matrices do not support "
                             "an 'axes' parameter because swapping "
                             "dimensions is the only logical permutation.")

        M, N = self.shape
        new = dok_matrix((N, M), dtype=self.dtype, copy=copy)
        dict.update(new, (((right, left), val)
                          for (left, right), val in iteritems(self)))
        return new
Esempio n. 18
0
File: dok.py Progetto: 7924102/scipy
 def __truediv__(self, other):
     if isscalarlike(other):
         res_dtype = upcast_scalar(self.dtype, other)
         new = dok_matrix(self.shape, dtype=res_dtype)
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             new[key] = val / other
         # new.dtype.char = self.dtype.char
         return new
     else:
         return self.tocsr() / other
Esempio n. 19
0
    def transpose(self, axes=None, copy=False):
        if axes is not None:
            raise ValueError("Sparse matrices do not support "
                             "an 'axes' parameter because swapping "
                             "dimensions is the only logical permutation.")

        M, N = self.shape
        new = dok_matrix((N, M), dtype=self.dtype, copy=copy)
        dict.update(new, (((right, left), val)
                          for (left, right), val in iteritems(self)))
        return new
Esempio n. 20
0
    def transpose(self, axes=None, copy=False):
        if axes is not None:
            raise ValueError(("Sparse matrices do not support "
                              "an 'axes' parameter because swapping "
                              "dimensions is the only logical permutation."))

        M, N = self.shape
        new = dok_matrix((N, M), dtype=self.dtype, copy=copy)

        for key, value in iteritems(self):
            new[key[1], key[0]] = value

        return new
Esempio n. 21
0
    def transpose(self, axes=None, copy=False):
        if axes is not None:
            raise ValueError(("Sparse matrices do not support "
                              "an 'axes' parameter because swapping "
                              "dimensions is the only logical permutation."))

        M, N = self.shape
        new = dok_matrix((N, M), dtype=self.dtype, copy=copy)

        for key, value in iteritems(self):
            new[key[1], key[0]] = value

        return new
Esempio n. 22
0
 def _mul_scalar(self, other):
     res_dtype = upcast_scalar(self.dtype, other)
     # Multiply this scalar by every element.
     new = dok_matrix(self.shape, dtype=res_dtype)
     dict.update(new, ((k, v * other) for k, v in iteritems(self)))
     return new
Esempio n. 23
0
 def __itruediv__(self, other):
     if isscalarlike(other):
         dict.update(self, ((k, v / other) for k, v in iteritems(self)))
         return self
     return NotImplemented
Esempio n. 24
0
 def _mul_vector(self, other):
     # matrix * vector
     result = np.zeros(self.shape[0], dtype=upcast(self.dtype, other.dtype))
     for (i, j), v in iteritems(self):
         result[i] += v * other[j]
     return result
Esempio n. 25
0
 def _mul_vector(self, other):
     # matrix * vector
     result = np.zeros(self.shape[0], dtype=upcast(self.dtype, other.dtype))
     for (i, j), v in iteritems(self):
         result[i] += v * other[j]
     return result
Esempio n. 26
0
 def _mul_scalar(self, other):
     res_dtype = upcast_scalar(self.dtype, other)
     # Multiply this scalar by every element.
     new = dok_matrix(self.shape, dtype=res_dtype)
     dict.update(new, ((k, v * other) for k, v in iteritems(self)))
     return new
Esempio n. 27
0
 def __itruediv__(self, other):
     if isscalarlike(other):
         dict.update(self, ((k, v / other) for k, v in iteritems(self)))
         return self
     return NotImplemented