code: def __set_svd(self):
          
          if self.isdiagonal:
              x = np.diag(self.x.flatten())
          else:
              # just a pointer to x
              x = self.x
          try:
  
              u, s, v = la.svd(x, full_matrices=True)
              v = v.transpose()
          except Exception as e:
              print("standard SVD failed: {0}".format(str(e)))
              try:
                  v, s, u = la.svd(x.transpose(), full_matrices=True)
                  u = u.transpose()
              except Exception as e:
                  np.savetxt("failed_svd.dat",x,fmt="%15.6E")
                  raise Exception("Matrix.__set_svd(): " +
                                  "unable to compute SVD of self.x, " +
                                  "saved matrix to 'failed_svd.dat' -- {0}".\
                                  format(str(e)))
  
          col_names = ["left_sing_vec_" + str(i + 1) for i in range(u.shape[1])]
          self.__u = Matrix(x=u, row_names=self.row_names,
                            col_names=col_names, autoalign=False)
  
          sing_names = ["sing_val_" + str(i + 1) for i in range(s.shape[0])]
          self.__s = Matrix(x=np.atleast_2d(s).transpose(), row_names=sing_names,
                            col_names=sing_names, isdiagonal=True,
                            autoalign=False)
  
          col_names = ["right_sing_vec_" + str(i + 1) for i in range(v.shape[0])]
          self.__v = Matrix(v, row_names=self.col_names, col_names=col_names,
                            autoalign=False)
docs: private method to set SVD components.
  
          Note: this should not be called directly