[petsc-users] How to get the eigenvectors in Slepc

Jose E. Roman jroman at dsic.upv.es
Sun Apr 14 10:40:30 CDT 2013


El 14/04/2013, a las 17:11, Sonya Blade escribió:

> >If the eigenvector is complex then of course the eigenvalue is complex as well 
> >(I assume your matrix is real non-symmetric). You have to get both the real and >imaginary parts of the eigenvalue.
> >http://www.grycap.upv.es/slepc/documentation/current/docs/manualpages/EPS/EPSGetEigenpair.html
> >An alternative is to do all the computation in complex arithmetic (configure --with-scalar-type=complex).
> >Jose
> 
> Hi Jose,
> 
> Probably you misunderstood my question my problem is: ierr = EPSGetEigenvalue(eps,i,&eigen_r,&eigen_i);CHKERRQ(ierr);
> returns all eigenvalues for each iteration where there is no imaginary parts (and set to zeros in eigen_i as expected).
> 
> I cross checked that with another algorithm which proves that all the eigenvalues are correct (no imaginary parts),but 
> glitch is with trying to fetch the eigenvectors. Eigenvectors obtained from the code below are mostly filled with zeros 
> and only the 11th row(Slepc returns 11 eigenvalue) has real and imaginary part which is not possible.
> 
>   
> for (j=0;j<test_int;j++)
>   {
>    ierr = EPSGetEigenvector(eps,j,&vec[0],&vec1[0]);CHKERRQ(ierr);
>     PetscPrintf(MPI_COMM_WORLD," %d || %4.8f || %4.8f \n",j,vec[j],vec1[j]);
>   }
>  
>  
> I also provide you the main code and required files.
> 
> Your help will be appreciated,
> 
> Regards,
> <main.c><IN.txt><mass.txt>


As Matt said, read the manual section on vectors. Page 43 "Basic Vector operations":

"On occasion, the user needs to access the actual elements of the vector. The routine VecGetArray() returns a pointer to the elements local to the process:
 VecGetArray(Vec v,PetscScalar **array);
When access to the array is no longer needed, the user should call
 VecRestoreArray(Vec v, PetscScalar **array);
"

Then have a look at any of the examples, for instance those listed here
http://www.mcs.anl.gov/petsc/petsc-3.3/docs/manualpages/Vec/VecGetArray.html

Please read the documentation. We cannot develop your code for you.

Jose



More information about the petsc-users mailing list