Ejemplo n.º 1
0
 def svd(self, *a, **kw):
     if self.ndim == 2:
         _svd = self.tensor.svd(*a, **kw)
         return LabeledSVD2DResults.layer_on(_svd, self)
     else:
         # The unfoldings will take care of labeling.
         from csc.divisi.svd import svd_sparse
         return svd_sparse(self, *a, **kw)
Ejemplo n.º 2
0
    def svd(self, *a, **kw):
        if self.ndim == 2:
            _svd = self.tensor.svd(*a, **kw)
            return LabeledSVD2DResults.layer_on(_svd, self)
        else:
            # The unfoldings will take care of labeling.
            from csc.divisi.svd import svd_sparse

            return svd_sparse(self, *a, **kw)
Ejemplo n.º 3
0
    def svd(self, *a, **kw):
        '''
        Computes the SVD of the blend. Builds the tensor if necessary
        and it is not yet built.

        When the keys never overlap, this uses an optimized routine.
        '''
        if not self._keys_never_overlap or self._tensor is not None:
            # Slow case
            self.logger.info('Non-optimized svd')
            if self._tensor is None: self.build_tensor()
            return super(Blend, self).svd(*a, **kw)

        # No overlap, so iteritems is straightforward. Exploit that
        # for some speed.
        from csc.divisi.svd import svd_sparse
        from csc.divisi.labeled_view import LabeledSVD2DResults
        self.logger.info('Optimized svd')
        _svd = svd_sparse(self.fake_tensor(), *a, **kw)
        return LabeledSVD2DResults.layer_on(_svd, self)
Ejemplo n.º 4
0
    def svd(self, *a, **kw):
        '''
        Computes the SVD of the blend. Builds the tensor if necessary
        and it is not yet built.

        When the keys never overlap, this uses an optimized routine.
        '''
        if not self._keys_never_overlap or self._tensor is not None:
            # Slow case
            self.logger.info('Non-optimized svd')
            if self._tensor is None: self.build_tensor()
            return super(Blend, self).svd(*a, **kw)

        # No overlap, so iteritems is straightforward. Exploit that
        # for some speed.
        from csc.divisi.svd import svd_sparse
        from csc.divisi.labeled_view import LabeledSVD2DResults
        self.logger.info('Optimized svd')
        _svd = svd_sparse(self.fake_tensor(), *a, **kw)
        return LabeledSVD2DResults.layer_on(_svd, self)
Ejemplo n.º 5
0
 def svd(self, k=50, *a, **kw):
     from csc.divisi.svd import svd_sparse
     return svd_sparse(self, k, *a, **kw)