From 92ea220d2d8b2a0c22537331e492375775bfd42b Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Thu, 13 Mar 2025 00:13:47 +0100 Subject: [PATCH] enhanced VSCode settings and updated matrix path in arnoldi.c --- .vscode/settings.json | 17 ++++++++++++++++- arnoldi.c | 11 +++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e401cb..3e5f9e5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,18 @@ { - "clangd.arguments": ["-background-index", "-compile-commands-dir=build/"] + "clangd.arguments": ["-background-index", "-compile-commands-dir=build/"], + "cSpell.words": [ + "Arnoldi", + "AXPY", + "DHSEQR", + "Hessenberg", + "Krylov", + "LAPACK", + "LAPACKE", + "MATDENSE", + "MATMPIAIJ", + "PETSC", + "PETSCVIEWERHDF", + "Reorthogonalization", + "VECMPI" + ] } diff --git a/arnoldi.c b/arnoldi.c index 3e26a0b..b956510 100644 --- a/arnoldi.c +++ b/arnoldi.c @@ -2,8 +2,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -38,8 +40,8 @@ void swap(double *a, double *b) { PetscErrorCode ArnoldiIteration(Mat A, Vec b, PetscInt n, PetscInt m, Vec *Q, double *h); int main(int argc, char **argv) { - Vec b; PetscInt n, l; + char matrix_name[PETSC_MAX_PATH_LEN]; PetscFunctionBeginUser; PetscInitialize(&argc, &argv, (char *)0, help); @@ -53,6 +55,10 @@ int main(int argc, char **argv) { if (!flg) l = 10; + PetscOptionsGetString(NULL, NULL, "-matrix_path", matrix_name, sizeof(matrix_name), &flg); + if (!flg) + snprintf(matrix_name, sizeof(matrix_name), "./matrices/laplacian/laplacian-discretization-3d.mat"); + Mat A; MatCreate(PETSC_COMM_WORLD, &A); PetscViewer v; @@ -61,7 +67,7 @@ int main(int argc, char **argv) { PetscCall(PetscViewerPushFormat(v, PETSC_VIEWER_HDF5_MAT)); PetscCall(PetscViewerSetFromOptions(v)); PetscCall(PetscViewerFileSetMode(v, FILE_MODE_READ)); - PetscCall(PetscViewerFileSetName(v, "../matrices/laplacian/laplacian-discretization-3d.mat")); + PetscCall(PetscViewerFileSetName(v, "./matrices/laplacian/laplacian-discretization-3d.mat")); PetscCall(MatSetOptionsPrefix(A, "a_")); PetscCall(PetscObjectSetName((PetscObject)A, "A")); @@ -77,6 +83,7 @@ int main(int argc, char **argv) { MatGetSize(A, &n, NULL); } + Vec b; VecCreate(PETSC_COMM_WORLD, &b); VecSetSizes(b, PETSC_DECIDE, n); VecSetType(b, VECMPI);