LCOV - code coverage report
Current view: top level - include/pairinteraction/interfaces - TransformationBuilderInterface.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 3 66.7 %
Date: 2026-08-14 15:36:24 Functions: 3 7 42.9 %

          Line data    Source code
       1             : // SPDX-FileCopyrightText: 2024 PairInteraction Developers
       2             : // SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4             : #pragma once
       5             : 
       6             : #include "pairinteraction/utils/eigen_assertion.hpp"
       7             : #include "pairinteraction/utils/traits.hpp"
       8             : 
       9             : #include <Eigen/SparseCore>
      10             : #include <complex>
      11             : #include <initializer_list>
      12             : #include <set>
      13             : #include <vector>
      14             : 
      15             : namespace pairinteraction {
      16             : enum class TransformationType : unsigned char;
      17             : 
      18             : template <typename Scalar>
      19             : struct Transformation {
      20           0 :     Transformation() = default;
      21             :     Transformation(Eigen::SparseMatrix<Scalar, Eigen::RowMajor> matrix,
      22             :                    std::vector<TransformationType> transformation_type);
      23             :     Transformation(Eigen::SparseMatrix<Scalar, Eigen::RowMajor> matrix);
      24             :     Eigen::SparseMatrix<Scalar, Eigen::RowMajor> matrix;
      25             :     std::vector<TransformationType> transformation_type;
      26             : };
      27             : 
      28             : struct Sorting {
      29        1198 :     Sorting() = default;
      30             :     Sorting(Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> matrix,
      31             :             std::vector<TransformationType> transformation_type);
      32             :     Sorting(Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> matrix);
      33             :     Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> matrix;
      34             :     std::vector<TransformationType> transformation_type;
      35             : };
      36             : 
      37             : struct IndicesOfBlock {
      38             :     IndicesOfBlock(size_t start, size_t end);
      39             :     size_t size() const;
      40             :     size_t start;
      41             :     size_t end;
      42             : };
      43             : 
      44             : class IndicesOfBlocksCreator {
      45             : public:
      46             :     IndicesOfBlocksCreator(std::initializer_list<size_t> boundaries);
      47             :     void add(size_t boundary);
      48             :     std::vector<IndicesOfBlock> create() const;
      49             :     size_t size() const;
      50             : 
      51             : private:
      52             :     std::set<size_t> boundaries;
      53             : };
      54             : 
      55             : template <typename Scalar>
      56             : class TransformationBuilderInterface {
      57             : public:
      58             :     static_assert(traits::NumTraits<Scalar>::from_floating_point_v);
      59             : 
      60             :     using real_t = typename traits::NumTraits<Scalar>::real_t;
      61             : 
      62        9207 :     virtual ~TransformationBuilderInterface() = default;
      63             :     virtual const Transformation<Scalar> &get_transformation() const = 0;
      64             :     virtual Sorting get_sorter(const std::vector<TransformationType> &labels) const = 0;
      65             :     virtual std::vector<IndicesOfBlock>
      66             :     get_indices_of_blocks(const std::vector<TransformationType> &labels) const = 0;
      67             : };
      68             : 
      69             : extern template struct Transformation<double>;
      70             : extern template struct Transformation<std::complex<double>>;
      71             : 
      72             : extern template class TransformationBuilderInterface<double>;
      73             : extern template class TransformationBuilderInterface<std::complex<double>>;
      74             : } // namespace pairinteraction

Generated by: LCOV version 1.16