LCOV - code coverage report
Current view: top level - svd/tests - test2.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 29 29 100.0 %
Date: 2024-05-03 00:51:52 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : 
      11             : static char help[] = "Test SVD with different builds with a matrix loaded from a file"
      12             :   " (matrices available in PETSc's distribution).\n\n";
      13             : 
      14             : #include <slepcsvd.h>
      15             : 
      16           8 : int main(int argc,char **argv)
      17             : {
      18           8 :   Mat            A;               /* operator matrix */
      19           8 :   SVD            svd;             /* singular value problem solver context */
      20           8 :   char           filename[PETSC_MAX_PATH_LEN];
      21           8 :   const char     *prefix,*scalar,*ints,*floats;
      22           8 :   PetscReal      tol=PETSC_SMALL;
      23           8 :   PetscViewer    viewer;
      24             : 
      25           8 :   PetscFunctionBeginUser;
      26           8 :   PetscCall(SlepcInitialize(&argc,&argv,(char*)0,help));
      27             : 
      28             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      29             :         Load the matrix for which the SVD must be computed
      30             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      31             : #if defined(PETSC_USE_COMPLEX)
      32             :   prefix = "nh";
      33             :   scalar = "complex";
      34             : #else
      35           8 :   prefix = "ns";
      36           8 :   scalar = "real";
      37             : #endif
      38             : #if defined(PETSC_USE_64BIT_INDICES)
      39             :   ints   = "int64";
      40             : #else
      41           8 :   ints   = "int32";
      42             : #endif
      43             : #if defined(PETSC_USE_REAL_DOUBLE)
      44           8 :   floats = "float64";
      45             : #elif defined(PETSC_USE_REAL_SINGLE)
      46             :   floats = "float32";
      47             : #endif
      48             : 
      49           8 :   PetscCall(PetscSNPrintf(filename,sizeof(filename),"%s/share/petsc/datafiles/matrices/%s-%s-%s-%s",PETSC_DIR,prefix,scalar,ints,floats));
      50           8 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nReading matrix from binary file...\n\n"));
      51           8 :   PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer));
      52           8 :   PetscCall(MatCreate(PETSC_COMM_WORLD,&A));
      53           8 :   PetscCall(MatSetFromOptions(A));
      54           8 :   PetscCall(MatLoad(A,viewer));
      55           8 :   PetscCall(PetscViewerDestroy(&viewer));
      56             : 
      57             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      58             :                      Create the SVD solver
      59             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      60           8 :   PetscCall(SVDCreate(PETSC_COMM_WORLD,&svd));
      61           8 :   PetscCall(SVDSetOperators(svd,A,NULL));
      62           8 :   PetscCall(SVDSetTolerances(svd,tol,PETSC_DEFAULT));
      63           8 :   PetscCall(SVDSetFromOptions(svd));
      64             : 
      65             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      66             :                 Compute the singular triplets and display solution
      67             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      68           8 :   PetscCall(SVDSolve(svd));
      69           8 :   PetscCall(SVDErrorView(svd,SVD_ERROR_RELATIVE,NULL));
      70           8 :   PetscCall(SVDDestroy(&svd));
      71           8 :   PetscCall(MatDestroy(&A));
      72           8 :   PetscCall(SlepcFinalize());
      73             :   return 0;
      74             : }
      75             : 
      76             : /*TEST
      77             : 
      78             :    build:
      79             :       requires: !__float128
      80             : 
      81             :    test:
      82             :       args: -svd_nsv 7 -svd_type {{lanczos trlanczos cross cyclic lapack randomized}}
      83             :       requires: !single
      84             : 
      85             :    testset:
      86             :       args: -svd_nsv 7 -svd_mpd 11 -svd_type primme
      87             :       requires: primme !single
      88             :       output_file: output/test2_1.out
      89             :       test:
      90             :          suffix: 1_primme
      91             :       test:
      92             :          suffix: 1_primme_args
      93             :          args: -svd_primme_blocksize 2 -svd_primme_method hybrid
      94             : 
      95             : TEST*/

Generated by: LCOV version 1.14