Skip to content
Snippets Groups Projects
Select Git revision
  • fc13d4a0502c89b697d8a8ffdfbd6ba631bdbed4
  • main default protected
  • polar_bug_update
  • 553
  • subpixelapi
  • dev
  • rq
  • 602-replace-print-warnings-with-proper-logging
  • dependabot/pip/protobuf-3.15.0
  • github/fork/readthedocs-assistant/update-rtd-config-assistant
  • github/fork/acpaquette/scipy_0.19_update
  • github/fork/gsn9/loggingForMatcher
  • ladoramkershner-logos
  • jlaura-patch-1
  • 1.2.2
  • v1.2.1
  • v1.2.0
  • v1.1.0
  • v1.0.2
  • 1.0.1
  • v1.0.0-rc2
  • v1.0.0-rc1
  • v0.7.1
  • v0.7.0
  • v0.6.0
  • v0.4.0
  • 0.1.0
27 results

setup.py

Blame
  • tfrfme.cpp 33.08 KiB
    /*! \file tfrfme.cpp
     *
     * \brief Implementation of the trapping calculation objects.
     */
    
    #include <complex>
    #include <exception>
    #include <fstream>
    #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_TFRFME_H_
    #include "../include/tfrfme.h"
    #endif
    
    #ifndef INCLUDE_FILE_IO_H_
    #include "../include/file_io.h"
    #endif
    
    using namespace std;
    
    // >>> START OF Swap1 CLASS IMPLEMENTATION <<<
    Swap1::Swap1(int lm, int _nkv) {
      nkv = _nkv;
      nlmmt = 2 * lm * (lm + 2);
      const int size = nkv * nkv * nlmmt;
      wk = new complex<double>[size]();
      last_index = 0;
    }
    
    Swap1* Swap1::from_binary(string file_name, string mode) {
      Swap1 *instance = NULL;
      if (mode.compare("LEGACY") == 0) {
        instance = from_legacy(file_name);
      } else if (mode.compare("HDF5") == 0) {
        instance = from_hdf5(file_name);
      } else {
        string message = "Unknown format mode: \"" + mode + "\"";
        throw UnrecognizedFormatException(message);
      }
      return instance;
    }
    
    Swap1* Swap1::from_hdf5(string file_name) {
      Swap1 *instance = NULL;
      unsigned int flags = H5F_ACC_RDONLY;
      HDFFile *hdf_file = new HDFFile(file_name, flags);
      herr_t status = hdf_file->get_status();
      double *elements;
      string str_type;
      int _nlmmt, _nkv, lm, num_elements, index;
      complex<double> value;
      complex<double> *_wk = NULL;
      if (status == 0) {
        status = hdf_file->read("NLMMT", "INT32", &_nlmmt);
        status = hdf_file->read("NKV", "INT32", &_nkv);
        lm = (int)((-2.0 + sqrt(4.0 + 2.0 * _nlmmt)) / 2.0);
        num_elements = 2 * _nlmmt * _nkv * _nkv;
        instance = new Swap1(lm, _nkv);
        _wk = instance->get_vector();
        elements = new double[num_elements]();
        str_type = "FLOAT64_(" + to_string(num_elements) + ")";