static char help[] = "Test LAPACK routine DSTEBZ() and DTEIN(). \n\n"; #include #include extern PetscErrorCode CkEigenSolutions(PetscInt,Mat,PetscInt,PetscInt,PetscScalar*,Vec*,PetscReal*); int main(int argc,char **args) { #if defined(PETSC_USE_COMPLEX) || defined(PETSC_MISSING_LAPACK_STEBZ) || defined(PETSC_MISSING_LAPACK_STEIN) PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP_SYS,"This example requires LAPACK routines dstebz and stien and real numbers"); #else PetscReal *work,tols[2]; PetscInt i,j; PetscBLASInt n,il=1,iu=5,*iblock,*isplit,*iwork,nevs,*ifail,cklvl=2; PetscMPIInt size; PetscBool flg; Vec *evecs; PetscScalar *evecs_array,*D,*E,*evals; Mat T; PetscReal vl=0.0,vu=4.0,tol= 1000*PETSC_MACHINE_EPSILON; PetscBLASInt nsplit,info; PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCheck(size == 1,PETSC_COMM_WORLD, PETSC_ERR_WRONG_MPI_SIZE,"This is a uniprocessor example only!"); n = 100; nevs = iu - il; PetscCall(PetscMalloc1(3*n+1,&D)); E = D + n; evals = E + n; PetscCall(PetscMalloc1(5*n+1,&work)); PetscCall(PetscMalloc1(3*n+1,&iwork)); PetscCall(PetscMalloc1(3*n+1,&iblock)); isplit = iblock + n; /* Set symmetric tridiagonal matrix */ for (i=0; i dot_max) dot_max = PetscAbsScalar(dot); #if defined(DEBUG_CkEigenSolutions) if (dot > tols[1]) { PetscCall(VecNorm(evec[i],NORM_INFINITY,&norm)); PetscCall(PetscPrintf(PETSC_COMM_SELF,"|delta(%d,%d)|: %g, norm: %d\n",i,j,(double)dot,(double)norm)); } #endif } } PetscCall(PetscPrintf(PETSC_COMM_SELF," max|(x_j^T*x_i) - delta_ji|: %g\n",(double)dot_max)); case 1: norm_max = 0.0; for (i = il; i< iu; i++) { PetscCall(MatMult(A, evec[i], vt1)); PetscCall(VecCopy(evec[i], vt2)); tmp = -eval[i]; PetscCall(VecAXPY(vt1,tmp,vt2)); PetscCall(VecNorm(vt1, NORM_INFINITY, &norm)); norm = PetscAbsReal(norm); if (norm > norm_max) norm_max = norm; #if defined(DEBUG_CkEigenSolutions) if (norm > tols[0]) { PetscCall(PetscPrintf(PETSC_COMM_SELF," residual violation: %d, resi: %g\n",i, norm)); } #endif } PetscCall(PetscPrintf(PETSC_COMM_SELF," max_resi: %g\n", (double)norm_max)); break; default: PetscCall(PetscPrintf(PETSC_COMM_SELF,"Error: cklvl=%d is not supported \n",cklvl)); } PetscCall(VecDestroy(&vt2)); PetscCall(VecDestroy(&vt1)); PetscFunctionReturn(0); }