Skip to content
Snippets Groups Projects
Select Git revision
  • 927f93b7d5292c5e7aa8de817d02bf3d9c1af799
  • master default protected
  • parallel_trapping
  • offload_trapping
  • script_devel
  • unify_iterations
  • containers-m10
  • magma_refinement
  • release9
  • enable_svd
  • parallel_angles_gmu
  • containers-m8
  • parallel_angles
  • profile_omp_leonardo
  • test_nvidia_profiler
  • containers
  • shaditest
  • test1
  • main
  • 3-error-in-run-the-program
  • experiment
  • NP_TMcode-M10a.03
  • NP_TMcode-M10a.02
  • NP_TMcode-M10a.01
  • NP_TMcode-M10a.00
  • NP_TMcode-M9.01
  • NP_TMcode-M9.00
  • NP_TMcode-M8.03
  • NP_TMcode-M8.02
  • NP_TMcode-M8.01
  • NP_TMcode-M8.00
  • NP_TMcode-M7.00
  • v0.0
33 results

test_TTMS.cpp

Blame
  • test_TTMS.cpp 1.55 KiB
    //! \file test_TTMS.cpp
    
    #include <complex>
    #include <cstdio>
    #include <exception>
    #include <hdf5.h>
    #include <string>
    
    #ifndef INCLUDE_ERRORS_H_
    #include "../include/errors.h"
    #endif
    
    #ifndef INCLUDE_LIST_H_
    #include "../include/List.h"
    #endif
    
    #ifndef INCLUDE_FILE_IO_H_
    #include "../include/file_io.h"
    #endif
    
    #ifndef INCLUDE_TRANSITIONMATRIX_H_
    #include "../include/TransitionMatrix.h"
    #endif
    
    using namespace std;
    
    /*! \brief Main program execution body.
     *
     * This program executes a test to compare whether two transition
     * matrix instances, loaded respectively from a legacy and a HDF5
     * binary file are actually equivalent. The test writes a result
     * message to `stdout` then it returns 0 (OS flag for a successful
     * process) or 1 (OS flag for failing process) depending on whether
     * the two instances were considered equivalent or not.
     *
     * \param argc: `int` Number of command line arguments
     * \param argv: `char **` Array of command argument character strings.
     * \return result: `int` Can be 0 (files are equal) or 1 (files are
     * different).
     */
    int main(int argc, char **argv) {
      int result = 0;
      TransitionMatrix *a, *b;
      string legacy_file = "c_TTMS";
      string hdf5_file = "c_TTMS.hd5";
      if (argc == 3) {
        legacy_file = string(argv[1]);
        hdf5_file = string(argv[2]);
      }
      a = TransitionMatrix::from_binary(legacy_file);
      b = TransitionMatrix::from_binary(hdf5_file, "HDF5");
      if (*a == *b) printf("Transition matrices a and b are equal.\n");
      else {
        printf("Transition matrices a and b are different.\n");
        result = 1;
      }
      return result;
    }