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-09-03 06:42:31 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       85921 : Ket::Ket(double energy, double f, double m, Parity p)
      13       85921 :     : 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       74467 : bool Ket::has_quantum_number_m() const {
      20       74467 :     return quantum_number_m != std::numeric_limits<double>::max();
      21             : }
      22             : 
      23           0 : bool Ket::has_parity() const { return parity != Parity::UNKNOWN; }
      24             : 
      25       57657 : double Ket::get_energy() const { return energy; }
      26             : 
      27      162031 : double Ket::get_quantum_number_f() const { return quantum_number_f; }
      28             : 
      29      170251 : double Ket::get_quantum_number_m() const { return quantum_number_m; }
      30             : 
      31      161995 : Parity Ket::get_parity() const { return parity; }
      32             : 
      33         922 : bool Ket::operator==(const Ket &other) const {
      34         855 :     return energy == other.energy && quantum_number_f == other.quantum_number_f &&
      35        1777 :         quantum_number_m == other.quantum_number_m && parity == other.parity;
      36             : }
      37             : 
      38       81552 : size_t Ket::hash::operator()(const Ket &k) const {
      39       81552 :     size_t seed = 0;
      40       81552 :     utils::hash_combine(seed, k.energy);
      41       81552 :     utils::hash_combine(seed, k.quantum_number_f);
      42       81552 :     utils::hash_combine(seed, k.quantum_number_m);
      43       81552 :     utils::hash_combine(seed, static_cast<int>(k.parity));
      44       81552 :     return seed;
      45             : }
      46             : } // namespace pairinteraction

Generated by: LCOV version 1.16