![]() Registered Member ![]()
|
Hello,
I'm still new in c++ programming but my job need me to use it to solve generalized eigen analysis for sparse matrices. I must use Arpack package to solve this problem as requested by my supervisor. I managed to get and solve the solution for standard eigenvalues and eigenvectors (mode=1). However, until now (almost 2 months) I still have a problem to solve for mode 2 and 3 which to solve A*x = lambda*M*x. From my understanding (based on the arpack documentation), the code maybe should be written as below, (A) in the main routine (for mode 2); do { dsaupd_(&ido, bmat, &n, which, &nev, &tol, resid, &ncv, v, &ldv, iparam, ipntr, workd, workl, &lworkl, &info); if ((ido==1)||(ido==-1)) { av(n, workd+ipntr[0]-1, temp_array); temp_copy(n, temp_array, workd+ipntr[0]-1); solM(n, temp_array, workd+ipntr[1]-1); } if (ido==2) mv(n, workd+ipntr[0]-1, workd+ipntr[1]-1); } while ((ido==1)||(ido==-1)||(ido==2)); (B) Sub routines void av(int n, double *in, double *out) { int i; for (i=0; i<n; i++) out[i] = 0; for (i=0; i<nnzA; i++) out[(int)A[i][0]] += in[(int)A[i][1]] * A[i][2]; } void temp_copy(int n, double *temp, double *in) { int i; for (i=0; i<n; i++) in[i] = temp[i]; } void mv(int n, double *in, double *out) { int i; for (i=0; i<n; i++) out[i] = 0; for (i=0; i<nnzM; i++) out[(int)M[i][0]] += in[(int)M[i][1]] * M[i][2]; } void solM(int n, double *in, double *out) { // Maybe this is the sub-routine which need to develop to solve mode 2 and 3 // I tried so many way but still failed to understand the concept for this part } Could anybody please assist/guide me to get better understanding to solve this part. To be honest, I'm not looking for straight away solution by giving me the code but would like to get deep understanding on how to solve this y = M^(-1)*A*x using Arpack for mode 2 and 3. I'm really appreciate your help. Thanks |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell