~ubuntu-branches/ubuntu/oneiric/python-scipy/oneiric-proposed

« back to all changes in this revision

Viewing changes to scipy/sparse/bsr.py

  • Committer: Bazaar Package Importer
  • Author(s): Sameer Morar
  • Date: 2011-02-03 04:28:09 UTC
  • mfrom: (9.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110203042809-qs95kuod7723re62
Tags: 0.8.0+dfsg1-1ubuntu1
* Merge from debian experimental (LP: #696403). Remaining changes:
  - debian/patches/stdc_format_macros.patch: Fix FTBFS issue with python 2.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
490
490
    # utility functions
491
491
    def _binopt(self, other, op, in_shape=None, out_shape=None):
492
492
        """apply the binary operation fn to two sparse matrices"""
493
 
        other = self.__class__(other,blocksize=self.blocksize)
494
 
 
495
 
        if in_shape is None:
496
 
            in_shape = self.shape
497
 
        if out_shape is None:
498
 
            out_shape = self.shape
499
 
 
500
 
        self.sort_indices()
501
 
        other.sort_indices()
 
493
 
 
494
        # ideally we'd take the GCDs of the blocksize dimensions
 
495
        # and explode self and other to match
 
496
        other = self.__class__(other, blocksize=self.blocksize)
502
497
 
503
498
        # e.g. bsr_plus_bsr, etc.
504
499
        fn = getattr(sparsetools, self.format + op + self.format)
510
505
        indices = np.empty(max_bnnz, dtype=np.intc)
511
506
        data    = np.empty(R*C*max_bnnz, dtype=upcast(self.dtype,other.dtype))
512
507
 
513
 
        fn(in_shape[0]/R, in_shape[1]/C, R, C, \
 
508
        fn(self.shape[0]/R, self.shape[1]/C, R, C,
514
509
                self.indptr,  self.indices,  np.ravel(self.data),
515
510
                other.indptr, other.indices, np.ravel(other.data),
516
511
                indptr,       indices,       data)
525
520
 
526
521
        data = data.reshape(-1,R,C)
527
522
 
528
 
        return self.__class__((data, indices, indptr), shape=out_shape)
 
523
        return self.__class__((data, indices, indptr), shape=self.shape)
529
524
 
530
525
    # needed by _data_matrix
531
526
    def _with_data(self,data,copy=True):