LCOV - code coverage report
Current view: top level - src/interfaces - TransformationBuilderInterface.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 27 66.7 %
Date: 2026-08-17 11:38:34 Functions: 9 12 75.0 %

          Line data    Source code
       1             : // SPDX-FileCopyrightText: 2024 PairInteraction Developers
       2             : // SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4             : #include "pairinteraction/interfaces/TransformationBuilderInterface.hpp"
       5             : 
       6             : #include "pairinteraction/enums/TransformationType.hpp"
       7             : 
       8             : namespace pairinteraction {
       9             : 
      10        1330 : IndicesOfBlock::IndicesOfBlock(size_t start, size_t end) : start(start), end(end) {}
      11             : 
      12        2684 : size_t IndicesOfBlock::size() const { return end - start; }
      13             : 
      14         632 : IndicesOfBlocksCreator::IndicesOfBlocksCreator(std::initializer_list<size_t> boundaries)
      15         632 :     : boundaries(boundaries) {}
      16             : 
      17         711 : void IndicesOfBlocksCreator::add(size_t boundary) { boundaries.insert(boundary); }
      18             : 
      19         632 : std::vector<IndicesOfBlock> IndicesOfBlocksCreator::create() const {
      20         632 :     std::vector<IndicesOfBlock> blocks;
      21         632 :     if (boundaries.empty()) {
      22           0 :         return blocks;
      23             :     }
      24             : 
      25         625 :     auto it = boundaries.begin();
      26         631 :     size_t start = *it++;
      27             : 
      28        1928 :     while (it != boundaries.end()) {
      29        1313 :         blocks.emplace_back(start, *it);
      30        1308 :         start = *it++;
      31             :     }
      32             : 
      33         622 :     return blocks;
      34           0 : }
      35             : 
      36           0 : size_t IndicesOfBlocksCreator::size() const {
      37           0 :     return boundaries.empty() ? 0 : boundaries.size() - 1;
      38             : }
      39             : 
      40             : template <typename Scalar>
      41        2054 : Transformation<Scalar>::Transformation(Eigen::SparseMatrix<Scalar, Eigen::RowMajor> matrix,
      42             :                                        std::vector<TransformationType> transformation_type)
      43        2054 :     : matrix(std::move(matrix)), transformation_type(std::move(transformation_type)) {}
      44             : 
      45             : template <typename Scalar>
      46         649 : Transformation<Scalar>::Transformation(Eigen::SparseMatrix<Scalar, Eigen::RowMajor> matrix)
      47         649 :     : matrix(std::move(matrix)), transformation_type({TransformationType::ARBITRARY}) {}
      48             : 
      49           0 : Sorting::Sorting(Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> matrix,
      50           0 :                  std::vector<TransformationType> transformation_type)
      51           0 :     : matrix(std::move(matrix)), transformation_type(std::move(transformation_type)) {}
      52             : 
      53           0 : Sorting::Sorting(Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> matrix)
      54           0 :     : matrix(std::move(matrix)), transformation_type({TransformationType::ARBITRARY}) {}
      55             : 
      56             : // Explicit instantiations
      57             : // NOLINTBEGIN(bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
      58             : #define INSTANTIATE_TRANSFORMATION(SCALAR)                                                         \
      59             :     template struct Transformation<SCALAR>;                                                        \
      60             :     template class TransformationBuilderInterface<SCALAR>;
      61             : // NOLINTEND(bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
      62             : 
      63             : INSTANTIATE_TRANSFORMATION(double)
      64             : INSTANTIATE_TRANSFORMATION(std::complex<double>)
      65             : 
      66             : #undef INSTANTIATE_TRANSFORMATION
      67             : } // namespace pairinteraction

Generated by: LCOV version 1.16