Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Copyright 2011-2013 Kwant authors. 

2# 

3# This file is part of Kwant. It is subject to the license terms in the file 

4# LICENSE.rst found in the top-level directory of this distribution and at 

5# https://kwant-project.org/license. A list of Kwant authors can be found in 

6# the file AUTHORS.rst at the top-level directory of this distribution and at 

7# https://kwant-project.org/authors. 

8 

9__all__ = ['gen_eig'] 

10 

11from . import lapack 

12 

13 

14def gen_eig(a, b, left=False, right=True, overwrite_ab=False): 

15 """Compute the eigenvalues and -vectors of the matrix pencil (a,b), i.e. of 

16 the generalized (unsymmetric) eigenproblem a v = lambda b v where a and b 

17 are square (unsymmetric) matrices, v the eigenvector and lambda the 

18 eigenvalues. 

19 

20 The eigenvalues are returned as numerator alpha and denominator beta, 

21 i.e. lambda = alpha/beta. This is advantageous, as lambda can be infinity 

22 which is well-defined in this case as beta = 0. 

23 

24 Parameters 

25 ---------- 

26 a : array, shape (M, M) 

27 b : array, shape (M, M) 

28 `a` and `b` are the two matrices defining the generalized eigenproblem 

29 left : boolean 

30 Whether to calculate and return left eigenvectors 

31 right : boolean 

32 Whether to calculate and return right eigenvectors 

33 

34 overwrite_ab : boolean 

35 Whether to overwrite data in `a` and `b` (may improve performance) 

36 

37 Returns 

38 ------- 

39 alpha : complex array, shape (M,) 

40 beta : real or complex array, shape (M,) 

41 The eigenvalues in the form ``alpha/beta`` 

42 

43 (if left == True) 

44 vl : double or complex array, shape (M, M) 

45 The left eigenvector corresponding to the eigenvalue 

46 ``alpha[i]/beta[i]`` is the column ``vl[:,i]``. 

47 

48 (if right == True) 

49 vr : double or complex array, shape (M, M) 

50 The right eigenvector corresponding to the eigenvalue 

51 ``alpha[i]/beta[i]`` is the column ``vr[:,i]``. 

52 """ 

53 a, b = lapack.prepare_for_lapack(overwrite_ab, a, b) 

54 return lapack.ggev(a, b, left, right)