Exemple #1
0
 def get_tridiagonal(self, cutoff=None, residual=False, get_trafo=False):
     """
         Main interface. Computes the tridiagonal elements of the matrix A and returns them
     :param cutoff: How many diagonal elements for the resulting tridiagonal elements should be computed
                    If left unchanged the entire matrix is tridiagonalized
     :param residual: If set True computes a residual. See utils.residual.orth_residual for details
     :param get_trafo: If set True computes and returns the transformaion matrix
     :return: diag (diagonal elements of the computed tridiagonal matrix), offdiag (offdiagonal elements
              of the computed tridiagonal matrix), info dict with keys 'trafo' and 'res', which
              contain the corresponding transformation matrix and residual of the computation respectively
     """
     if cutoff is None:
         cutoff = self.max_cutoff
     else:
         assert 0 < cutoff <= self.max_cutoff
     info = dict()
     info['trafo'] = None
     info['res'] = None
     if residual or get_trafo:
         diag, offdiag, V = self._core_loop_with_trafo(cutoff)
         if get_trafo:
             info['trafo'] = V
         if residual:
             info['res'] = orth_residual(V)
     else:
         diag, offdiag = self._core_loop(cutoff)
     return diag, offdiag, info
Exemple #2
0
 def get_tridiagonal(self, cutoff=None, residual=False, get_trafo=False):
     if cutoff is None:
         cutoff = self.max_cutoff
     else:
         assert 0 < cutoff <= self.max_cutoff
     info = dict()
     info['trafo'] = None
     info['res'] = None
     if residual or get_trafo:
         diag, offdiag, V = self._core_loop_with_trafo(cutoff)
         if get_trafo:
             info['trafo'] = V
         if residual:
             info['res'] = orth_residual(V)
     else:
         diag, offdiag = self._core_loop(cutoff)
     return diag, offdiag, info
Exemple #3
0
 def get_tridiagonal(self,
                     cutoff=None,
                     residual=False,
                     get_trafo=False,
                     positive=True):
     """
         Main interface. Computes the tridiagonal elements of the matrix A and returns them
     :param cutoff: How many diagonal elements for the resulting tridiagonal elements should be computed
                    If left unchanged the entire matrix is tridiagonalized
     :param residual: If set True computes a residual. See utils.residual.orth_residual for details
     :param get_trafo: If set True computes and returns the transformaion matrix
     :param positive: If set True ensures that the offdiagonal elements are chosen to be positive
     :return: diag (diagonal elements of the computed tridiagonal matrix), offdiag (offdiagonal elements
              of the computed tridiagonal matrix), info dict with keys 'trafo' and 'res', which
              contain the corresponding transformation matrix and residual of the computation respectively
     """
     if cutoff is None:
         cutoff = self.n
     else:
         assert 0 < cutoff <= self.n
     info = dict()
     info['trafo'] = None
     info['res'] = None
     if residual or get_trafo:
         diag, offdiag, Q = self._construct_hessenberg_with_trafo(cutoff)
         if positive and get_trafo:
             diag, offdiag, Q = self._make_positive(diag, offdiag, trafo=Q)
         else:
             diag, offdiag = self._make_positive(diag, offdiag)
         if get_trafo:
             info['trafo'] = Q
         if residual:
             info['res'] = orth_residual(Q)
     else:
         diag, offdiag = self._construct_hessenberg(cutoff)
         if positive:
             diag, offdiag = self._make_positive(diag, offdiag)
     return diag, offdiag, info