code: def pseudoinverse(self):
          
          transform = False
          if self.get_width() > self.get_height():
              transform = True
              u, sigma, v = self.transform().svd()
          else:
              u, sigma, v = self.svd()
          # calculate inverse of sigma
          for i in xrange(min(sigma.get_height(), sigma.get_width())):
              val = sigma.get_value(i, i)
              # divide only if the value is not 0 or close to zero (rounding errors)
              eps = 1.e-15
              if eps < val or val < -eps:
                  sigma.set_value(i, i, 1 / val)
          if transform:
              return (v * sigma * u.transform()).transform()
          else:
              return v * sigma * u.transform()
docs: Return the pseudoinverse (Moore-Penrose-Inverse).
  
          The singular value decomposition is used to calculate the pseudoinverse.