LCOV - code coverage report
Current view: top level - src/ket - Ket.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 21 85.7 %
Date: 2025-05-02 21:49:25 Functions: 8 10 80.0 %

          Line data    Source code
       1             : // SPDX-FileCopyrightText: 2024 Pairinteraction Developers
       2             : // SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4             : #include "pairinteraction/ket/Ket.hpp"
       5             : 
       6             : #include "pairinteraction/enums/Parity.hpp"
       7             : #include "pairinteraction/utils/hash.hpp"
       8             : 
       9             : #include <limits>
      10             : 
      11             : namespace pairinteraction {
      12       10319 : Ket::Ket(double energy, double f, double m, Parity p)
      13       10319 :     : energy(energy), quantum_number_f(f), quantum_number_m(m), parity(p) {}
      14             : 
      15           0 : bool Ket::has_quantum_number_f() const {
      16           0 :     return quantum_number_f != std::numeric_limits<double>::max();
      17             : }
      18             : 
      19        9101 : bool Ket::has_quantum_number_m() const {
      20        9101 :     return quantum_number_m != std::numeric_limits<double>::max();
      21             : }
      22             : 
      23           0 : bool Ket::has_parity() const { return parity != Parity::UNKNOWN; }
      24             : 
      25        3033 : double Ket::get_energy() const { return energy; }
      26             : 
      27       19383 : double Ket::get_quantum_number_f() const { return quantum_number_f; }
      28             : 
      29       20450 : double Ket::get_quantum_number_m() const { return quantum_number_m; }
      30             : 
      31       19383 : Parity Ket::get_parity() const { return parity; }
      32             : 
      33          76 : bool Ket::operator==(const Ket &other) const {
      34          73 :     return energy == other.energy && quantum_number_f == other.quantum_number_f &&
      35         149 :         quantum_number_m == other.quantum_number_m && parity == other.parity;
      36             : }
      37             : 
      38        9749 : size_t Ket::hash::operator()(const Ket &k) const {
      39        9749 :     size_t seed = 0;
      40        9749 :     utils::hash_combine(seed, k.energy);
      41        9749 :     utils::hash_combine(seed, k.quantum_number_f);
      42        9749 :     utils::hash_combine(seed, k.quantum_number_m);
      43        9749 :     utils::hash_combine(seed, static_cast<int>(k.parity));
      44        9749 :     return seed;
      45             : }
      46             : } // namespace pairinteraction

Generated by: LCOV version 1.16