@@ -578,63 +578,78 @@ def mb05md(a, delta, balanc='N'):
578578
579579 Matrix exponential for a real non-defective matrix
580580
581- To compute exp(A*delta) where A is a real N-by-N non-defective
581+ To compute `` exp(A*delta)`` where `A` is a real N-by-N non-defective
582582 matrix with real or complex eigenvalues and delta is a scalar
583583 value. The routine also returns the eigenvalues and eigenvectors
584- of A as well as (if all eigenvalues are real) the matrix product
585- exp(Lambda*delta) times the inverse of the eigenvector matrix of
586- A , where Lambda is the diagonal matrix of eigenvalues.
584+ of `A` as well as (if all eigenvalues are real) the matrix product
585+ `` exp(Lambda*delta)`` times the inverse of the eigenvector matrix of
586+ `A` , where ` Lambda` is the diagonal matrix of eigenvalues.
587587 Optionally, the routine computes a balancing transformation to
588588 improve the conditioning of the eigenvalues and eigenvectors.
589589
590- Required arguments:
591- A : input rank-2 array('d') with bounds (n,n)
592- Square matrix
593- delta : input 'd'
594- The scalar value delta of the problem.
595-
596- Optional arguments:
597- balanc : input char*1
598- Indicates how the input matrix should be diagonally scaled
599- to improve the conditioning of its eigenvalues as follows:
600- = 'N': Do not diagonally scale;
601- = 'S': Diagonally scale the matrix, i.e. replace A by
602- D*A*D**(-1), where D is a diagonal matrix chosen
603- to make the rows and columns of A more equal in
604- norm. Do not permute.
590+ Parameters
591+ ----------
592+ A : (n, n) array_like
593+ Square matrix
594+ delta : float
595+ The scalar value delta of the problem.
596+ balanc : {'N', 'S'}, optional
597+ Indicates how the input matrix should be diagonally scaled
598+ to improve the conditioning of its eigenvalues as follows:
599+
600+ : = 'N': Do not diagonally scale;
601+ : = 'S': Diagonally scale the matrix, i.e. replace `A` by
602+ `` D*A*D**(-1)`` , where `D` is a diagonal matrix chosen
603+ to make the rows and columns of A more equal in
604+ norm. Do not permute.
605605
606- Return objects:
607- Ar : output rank-2 array('d') with bounds (n,n)
608- Contains the solution matrix exp(A*delta)
609- Vr : output rank-2 array('d') with bounds (n,n)
610- Contains the eigenvector matrix for A. If the k-th
611- eigenvalue is real the k-th column of the eigenvector
612- matrix holds the eigenvector corresponding to the k-th
613- eigenvalue. Otherwise, the k-th and (k+1)-th eigenvalues
614- form a complex conjugate pair and the k-th and (k+1)-th
615- columns of the eigenvector matrix hold the real and
616- imaginary parts of the eigenvectors corresponding to these
617- eigenvalues as follows. If p and q denote the k-th and
618- (k+1)-th columns of the eigenvector matrix, respectively,
619- then the eigenvector corresponding to the complex
620- eigenvalue with positive (negative) imaginary value is
621- given by
622- p + q*j (p - q*j), where j^2 = -1.
623- Yr : output rank-2 array('d') with bounds (n,n)
624- contains an intermediate result for computing the matrix
625- exponential. Specifically, exp(A*delta) is obtained as the
626- product V*Y, where V is the matrix stored in the leading
627- N-by-N part of the array V. If all eigenvalues of A are
628- real, then the leading N-by-N part of this array contains
629- the matrix product exp(Lambda*delta) times the inverse of
630- the (right) eigenvector matrix of A, where Lambda is the
631- diagonal matrix of eigenvalues.
632-
633- VAL : output rank-1 array('c') with bounds (n)
634- Contains the eigenvalues of the matrix A. The eigenvalues
635- are unordered except that complex conjugate pairs of values
636- appear consecutively with the eigenvalue having positive
637- imaginary part first.
606+ Returns
607+ -------
608+ Ar : (n, n) ndarray
609+ Contains the solution matrix ``exp(A*delta)``
610+ Vr : (n, n) ndarray
611+ Contains the eigenvector matrix for `A`. If the `k`-th
612+ eigenvalue is real the `k`-th column of the eigenvector
613+ matrix holds the eigenvector corresponding to the `k`-th
614+ eigenvalue. Otherwise, the `k`-th and `(k+1)`-th eigenvalues
615+ form a complex conjugate pair and the k-th and `(k+1)`-th
616+ columns of the eigenvector matrix hold the real and
617+ imaginary parts of the eigenvectors corresponding to these
618+ eigenvalues as follows. If `p` and `q` denote the `k`-th and
619+ `(k+1)`-th columns of the eigenvector matrix, respectively,
620+ then the eigenvector corresponding to the complex
621+ eigenvalue with positive (negative) imaginary value is
622+ given by
623+ ``p + q*j (p - q*j), where j^2 = -1.``
624+ Yr : (n, n) ndarray
625+ contains an intermediate result for computing the matrix
626+ exponential. Specifically, ``exp(A*delta)`` is obtained as the
627+ product ``V*Y``, where `V` is the matrix stored in the leading
628+ `n`-by-`n` part of the array `V`. If all eigenvalues of `A` are
629+ real, then the leading `n`-by-`n` part of this array contains
630+ the matrix product ``exp(Lambda*delta)`` times the inverse of
631+ the (right) eigenvector matrix of `A`, where `Lambda` is the
632+ diagonal matrix of eigenvalues.
633+
634+ VAL : (n,) real or complex ndarray
635+ Contains the eigenvalues of the matrix `A`. The eigenvalues
636+ are unordered except that complex conjugate pairs of values
637+ appear consecutively with the eigenvalue having positive
638+ imaginary part first.
639+
640+ Warns
641+ ------
642+ SlycotResultWarning : e
643+ :0 < e.info <=n:
644+ the QR algorithm failed to compute all
645+ the eigenvalues; no eigenvectors have been computed;
646+ w[{e.info:n}] contains eigenvalues which have converged;
647+ :e.info == n+1:
648+ The inverse of the eigenvector matrix could not
649+ be formed due to an attempt to divide by zero, i.e.,
650+ the eigenvector matrix is singular;
651+ :e.info == n+2:
652+ Matrix A is defective, possibly due to rounding errors.
638653 """
639654 hidden = ' (hidden by the wrapper)'
640655 arg_list = ['balanc' , 'n' , 'delta' , 'a' , 'lda' + hidden , 'v' , 'ldv' + hidden ,
@@ -647,17 +662,9 @@ def mb05md(a, delta, balanc='N'):
647662 delta = delta ,
648663 a = a )
649664
650- raise_if_slycot_error (INFO , arg_list )
651-
652- if INFO > 0 and INFO <= n :
653- raise SlycotArithmeticError ("Incomplete eigenvalue calculation, "
654- "missing {} eigenvalues" .format (INFO ),
655- INFO )
656- elif INFO == n + 1 :
657- raise SlycotArithmeticError ("Eigenvector matrix singular" , INFO )
658- elif INFO == n + 2 :
659- raise SlycotArithmeticError ("Matrix A is defective, "
660- "possibly due to rounding errors." , INFO )
665+ raise_if_slycot_error (INFO , arg_list ,
666+ docstring = mb05md .__doc__ , checkvars = locals ())
667+
661668 if not all (VALi == 0 ):
662669 VAL = VALr + 1J * VALi
663670 else :
0 commit comments