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: 2026-03-03 11:25:29 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      217844 : Ket::Ket(double energy, double f, double m, Parity p)
      13      217844 :     : 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      195156 : bool Ket::has_quantum_number_m() const {
      20      195156 :     return quantum_number_m != std::numeric_limits<double>::max();
      21             : }
      22             : 
      23           0 : bool Ket::has_parity() const { return parity != Parity::UNKNOWN; }
      24             : 
      25      135743 : double Ket::get_energy() const { return energy; }
      26             : 
      27      400668 : double Ket::get_quantum_number_f() const { return quantum_number_f; }
      28             : 
      29      429712 : double Ket::get_quantum_number_m() const { return quantum_number_m; }
      30             : 
      31      400609 : Parity Ket::get_parity() const { return parity; }
      32             : 
      33        1469 : bool Ket::operator==(const Ket &other) const {
      34        1398 :     return energy == other.energy && quantum_number_f == other.quantum_number_f &&
      35        2867 :         quantum_number_m == other.quantum_number_m && parity == other.parity;
      36             : }
      37             : 
      38      201349 : size_t Ket::hash::operator()(const Ket &k) const {
      39      201349 :     size_t seed = 0;
      40      201349 :     utils::hash_combine(seed, k.energy);
      41      201349 :     utils::hash_combine(seed, k.quantum_number_f);
      42      201349 :     utils::hash_combine(seed, k.quantum_number_m);
      43      201349 :     utils::hash_combine(seed, static_cast<int>(k.parity));
      44      201349 :     return seed;
      45             : }
      46             : } // namespace pairinteraction

Generated by: LCOV version 1.16