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:55 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       28307 : Ket::Ket(double energy, double f, double m, Parity p)
      13       28307 :     : 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       18930 : bool Ket::has_quantum_number_m() const {
      20       18930 :     return quantum_number_m != std::numeric_limits<double>::max();
      21             : }
      22             : 
      23           0 : bool Ket::has_parity() const { return parity != Parity::UNKNOWN; }
      24             : 
      25       46988 : double Ket::get_energy() const { return energy; }
      26             : 
      27       47406 : double Ket::get_quantum_number_f() const { return quantum_number_f; }
      28             : 
      29       55192 : double Ket::get_quantum_number_m() const { return quantum_number_m; }
      30             : 
      31       47394 : Parity Ket::get_parity() const { return parity; }
      32             : 
      33         486 : bool Ket::operator==(const Ket &other) const {
      34         483 :     return energy == other.energy && quantum_number_f == other.quantum_number_f &&
      35         969 :         quantum_number_m == other.quantum_number_m && parity == other.parity;
      36             : }
      37             : 
      38       24124 : size_t Ket::hash::operator()(const Ket &k) const {
      39       24124 :     size_t seed = 0;
      40       24124 :     utils::hash_combine(seed, k.energy);
      41       24124 :     utils::hash_combine(seed, k.quantum_number_f);
      42       24124 :     utils::hash_combine(seed, k.quantum_number_m);
      43       24124 :     utils::hash_combine(seed, static_cast<int>(k.parity));
      44       24124 :     return seed;
      45             : }
      46             : } // namespace pairinteraction

Generated by: LCOV version 1.16