LCOV - code coverage report
Current view: top level - pairinteraction - Basisnames.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 21 21 100.0 %
Date: 2024-04-29 00:41:50 Functions: 17 17 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Sebastian Weber, Henri Menke. All rights reserved.
       3             :  *
       4             :  * This file is part of the pairinteraction library.
       5             :  *
       6             :  * The pairinteraction library is free software: you can redistribute it and/or modify
       7             :  * it under the terms of the GNU Lesser General Public License as published by
       8             :  * the Free Software Foundation, either version 3 of the License, or
       9             :  * (at your option) any later version.
      10             :  *
      11             :  * The pairinteraction library is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  * GNU Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public License
      17             :  * along with the pairinteraction library. If not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #ifndef BASISNAMES_H
      21             : #define BASISNAMES_H
      22             : 
      23             : #include "ConfParser.hpp"
      24             : #include "Iter.hpp"
      25             : #include "StateOld.hpp"
      26             : 
      27             : #include <fstream>
      28             : #include <memory>
      29             : #include <set>
      30             : #include <string>
      31             : #include <unordered_set>
      32             : #include <vector>
      33             : 
      34             : template <class T>
      35             : class Basisnames {
      36             : public:
      37          11 :     Basisnames() = default;
      38          11 :     void configure(const Configuration &config) {
      39          11 :         conf["deltaNSingle"] << config["deltaNSingle"];
      40          11 :         conf["deltaLSingle"] << config["deltaLSingle"];
      41          11 :         conf["deltaJSingle"] << config["deltaJSingle"];
      42          11 :         conf["deltaMSingle"] << config["deltaMSingle"];
      43          11 :         conf["deltaNSingle"] >> delta_n;
      44          11 :         conf["deltaLSingle"] >> delta_l;
      45          11 :         conf["deltaJSingle"] >> delta_j;
      46          11 :         conf["deltaMSingle"] >> delta_m;
      47          11 :         conf["missingCalc"] << config["missingCalc"];
      48          11 :         conf["missingWhittaker"] << config["missingWhittaker"];
      49          11 :     }
      50          39 :     size_t size() const { return names_.size(); }
      51          82 :     size_t dim() const { return dim_; }
      52        2162 :     T &get(size_t idx) { return names_[idx]; }
      53    12964540 :     const T &get(size_t idx) const { return names_[idx]; }
      54             :     void set(size_t i, const T &v) { names_[i] = v; }
      55        3730 :     ConstIter<Basisnames, T> begin() const { return ConstIter<Basisnames, T>(this, 0); }
      56        3730 :     ConstIter<Basisnames, T> end() const { return ConstIter<Basisnames, T>(this, names_.size()); }
      57             :     const Configuration &
      58          13 :     getConf() const { // TODO in Configurable Klasse auslagern, von der geerbt werrden soll
      59          13 :         return conf;
      60             :     }
      61             : 
      62             : protected:
      63             :     int delta_n, delta_l, delta_j, delta_m;
      64             :     Configuration conf;
      65             :     std::vector<T> names_;
      66             :     size_t dim_;
      67             : };
      68             : 
      69             : class BasisnamesTwo;
      70             : 
      71             : class BasisnamesOne : public Basisnames<StateOneOld> {
      72             : public:
      73             :     /*BasisnamesOne(const Configuration &config, const StateOne &startstate);
      74             :     BasisnamesOne(const Configuration &config, const StateTwo &startstate);*/
      75             :     static BasisnamesOne fromStates(const std::vector<StateOneOld> &names); // TODO
      76             :     static BasisnamesOne fromFirst(const Configuration &config);
      77             :     static BasisnamesOne fromFirst(const std::shared_ptr<const BasisnamesTwo> &basis_two);
      78             :     static BasisnamesOne fromSecond(const Configuration &config);
      79             :     static BasisnamesOne fromSecond(const std::shared_ptr<const BasisnamesTwo> &basis_two);
      80             :     static BasisnamesOne fromBoth(const Configuration &config);
      81             :     const std::vector<StateOneOld> &initial() const;
      82             :     void removeUnnecessaryStates(const std::vector<bool> &is_necessary);
      83             :     bool constructedFromFirst();
      84             :     void save(const std::string &path);
      85             : 
      86             : private:
      87             :     BasisnamesOne();
      88             :     void build(StateOneOld startstate, const std::string &species);
      89             :     void build(StateOneOld startstate, const std::string &species,
      90             :                const std::shared_ptr<const BasisnamesTwo> &basis_two, int i);
      91             :     void build(StateTwoOld startstate, const std::string &species);
      92             :     std::vector<StateOneOld> states_initial;
      93             :     bool _constructedFromFirst;
      94             : };
      95             : 
      96             : class BasisnamesTwo : public Basisnames<StateTwoOld> {
      97             : public:
      98             :     BasisnamesTwo(const std::shared_ptr<const BasisnamesOne> &basis_one1,
      99             :                   const std::shared_ptr<const BasisnamesOne> &basis_one2);
     100             :     BasisnamesTwo(const std::shared_ptr<const BasisnamesOne> &basis_one1);
     101             :     const StateTwoOld &initial() const;
     102             :     void removeUnnecessaryStates(const std::vector<bool> &is_necessary);
     103             :     void removeUnnecessaryStatesKeepIdx(const std::vector<bool> &is_necessary);
     104             :     void save(const std::string &path);
     105             : 
     106             : protected:
     107             :     void build(StateTwoOld startstate, std::array<std::string, 2> species,
     108             :                const std::shared_ptr<const BasisnamesOne> &basis_one1,
     109             :                const std::shared_ptr<const BasisnamesOne> &basis_one2);
     110             : 
     111             : private:
     112             :     StateTwoOld state_initial;
     113             : };
     114             : 
     115             : #endif

Generated by: LCOV version 1.14