/* examples/C/ssmfe/shift_invert.c */ /* Laplacian on a rectangular grid by shift-invert via LDLT factorization */ #include "spral.h" #include #include #include #include /* Headers that implements Laplacian and preconditioners and LDLT support */ #include "laplace2d.h" #include "ldltf.h" int main(void) { const int nx = 8; /* grid points along x */ const int ny = 8; /* grid points along y */ const int n = nx*ny; /* problem size */ const double sigma = 1.0; /* shift */ int *ipiv = malloc(n * sizeof(*ipiv)); /* LDLT pivot index */ double *lambda = malloc(n * sizeof(*lambda)); /* eigenvalues */ double (*X)[n][n] = malloc(sizeof(*X)); /* eigenvectors */ double (*A)[n][n] = malloc(sizeof(*A)); /* matrix */ double (*LDLT)[n][n] = malloc(sizeof(*LDLT)); /* factors */ double (*work)[n][n] = malloc(sizeof(*work)); /* work array for dsytrf */ struct spral_ssmfe_options options; /* eigensolver options */ struct spral_ssmfe_inform inform; /* information */ struct spral_ssmfe_rcid rci; /* reverse communication data */ void *keep; /* private data */ /* Initialize options to default values */ spral_ssmfe_default_options(&options); /* Set up then perform LDLT factorization of the shifted matrix */ set_laplacian_matrix(nx, ny, n, A); for(int j=0; j