Actual source code: lmvm_test.c
1: const char help[] = "Coverage and edge case test for LMVM";
3: #include <petscksp.h>
4: #include <petscmath.h>
6: int main(int argc, char **argv)
7: {
8: PetscInt type = 0, n = 10;
9: Mat B;
11: PetscCall(PetscInitialize(&argc, &argv, NULL, help));
12: PetscOptionsBegin(PETSC_COMM_WORLD, NULL, help, "KSP");
13: /* LMVM Types. 0: LMVMDBFGS, 1: LMVMDDFP, 2: LMVMDQN */
14: PetscCall(PetscOptionsInt("-type", "LMVM Type", __FILE__, type, &type, NULL));
15: PetscOptionsEnd();
16: if (type == 0) {
17: PetscCall(MatCreateLMVMDBFGS(PETSC_COMM_WORLD, PETSC_DECIDE, n, &B));
18: } else if (type == 1) {
19: PetscCall(MatCreateLMVMDDFP(PETSC_COMM_WORLD, PETSC_DECIDE, n, &B));
20: } else if (type == 2) {
21: PetscCall(MatCreateLMVMDQN(PETSC_COMM_WORLD, PETSC_DECIDE, n, &B));
22: } else {
23: SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_INCOMP, "Incompatible LMVM Type.");
24: }
25: PetscCall(MatSetFromOptions(B));
26: PetscCall(MatSetUp(B));
27: PetscCall(MatLMVMDenseSetType(B, MAT_LMVM_DENSE_INPLACE));
28: PetscCall(MatDestroy(&B));
29: PetscCall(PetscFinalize());
30: return 0;
31: }
33: /*TEST
35: test:
36: suffix: 0
37: output_file: output/lmvm_test.out
38: nsize: {{1 2}}
39: args: -mat_lmvm_scale_type {{none scalar diagonal}} -type {{0 1 2}}
41: TEST*/