# [SciPy-dev] ARPACK wrapper

Nils Wagner nwagner at iam.uni-stuttgart.de
Mon Nov 20 08:47:54 CST 2006

```Aric Hagberg wrote:
> On Mon, Nov 20, 2006 at 09:45:47AM +0100, Nils Wagner wrote:
>
>> Hi Neilen,
>>
>> In order to compare the results with the workhorse eig I have used a
>> very small
>> order n. The number of desired eigenpairs is equal to k=4 in my example,
>> but the
>> shape of the array of eigenvectors is (n,k+1) and for the eigenvalues it
>> is (k+1,).
>> The eigenvectors returned by arpack.eigen are zero.
>>
>> Nils
>>
>
> Hi Nils,
>
> The size of the return arrays are intentional (k+1).  This is
> the way ARPACK returns eigenvalues and eigenvectors for nonsymmetric
> matrices.  I think the idea is that the k'th eigenvalue
> (largest, smallest, etc) might be a complex conjugate pair and
> then you might want k+1 (the conjugate).  Else, if the k'th
> eigenvalue is real that entry is zero.
>
> I can run your test example successfully.  Do the tests in
> arpack/tests/test_arpack.py work for you?
>
> Aric
>
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
help (arpack.eigen) yields
eigen(A, k=6, M=None, ncv=None, which='LM', maxiter=None, tol=0,
return_eigenvectors=True)
Return k eigenvalues and eigenvectors of the matrix A.

Solves A * x[i] = w[i] * x[i], the standard eigenvalue problem for
w[i] eigenvalues with corresponding eigenvectors x[i].

Inputs:

A --  A matrix, array or an object with matvec(x) method to perform
the matrix vector product A * x.  The sparse matrix formats
in scipy.sparse are appropriate for A.

k -- The number of eigenvalue/eigenvectors desired

M -- (Not implemented)
A symmetric positive-definite matrix for the generalized
eigenvalue problem A * x = w * M * x

Outputs:

w -- An array of k eigenvalues

v -- An array of k eigenvectors, k[i] is the eigenvector corresponding
to the eigenvector w[i]

This info doesn't match with your explanation.

Concerning the tests I get

/usr/bin/python
/usr/lib64/python2.4/site-packages/scipy/sandbox/arpack/tests/test_speigs.py
Found 1 tests for __main__

_naupd: Number of update iterations taken
-----------------------------------------
1 -    1:    17

_naupd: Number of wanted "converged" Ritz values
------------------------------------------------
1 -    1:     4

_naupd: Real part of the final Ritz values
------------------------------------------
1 -    4:   1.033E+00   7.746E-01   5.164E-01   2.582E-01

_naupd: Imaginary part of the final Ritz values
-----------------------------------------------
1 -    4:   0.000E+00   0.000E+00   0.000E+00   0.000E+00

_naupd: Associated Ritz estimates
---------------------------------
1 -    4:   4.508E-17   7.450E-22   7.087E-26   4.834E-29

=============================================
= Nonsymmetric implicit Arnoldi update code =
= Version Number:  2.4                      =
= Version Date:    07/31/96                 =
=============================================
= Summary of timing statistics              =
=============================================

Total number update iterations             =    17
Total number of OP*x operations            =    59
Total number of B*x operations             =     0
Total number of reorthogonalization steps  =    58
Total number of iterative refinement steps =     0
Total number of restart steps              =     0
Total time in user OP*x operation          =     0.004000
Total time in user B*x operation           =     0.000000
Total time in Arnoldi update routine       =     0.008000
Total time in naup2 routine                =     0.008000
Total time in basic Arnoldi iteration loop =     0.004000
Total time in reorthogonalization phase    =     0.000000
Total time in (re)start vector generation  =     0.000000
Total time in Hessenberg eig. subproblem   =     0.000000
Total time in getting the shifts           =     0.000000
Total time in applying the shifts          =     0.000000
Total time in convergence testing          =     0.000000
Total time in computing final Ritz vectors =     0.000000

.
----------------------------------------------------------------------
Ran 1 test in 0.107s

OK

/usr/bin/python
/usr/lib64/python2.4/site-packages/scipy/sandbox/arpack/tests/test_arpack.py
Found 5 tests for __main__
.....
----------------------------------------------------------------------
Ran 5 tests in 0.039s

OK

Nils

```