LCOV - code coverage report
Current view: top level - core/include/scipp/core - eigen.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 14 57.1 %
Date: 2024-12-01 01:56:34 Functions: 3 6 50.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : /// @file
       4             : /// @author Simon Heybrock
       5             : #pragma once
       6             : 
       7             : // Warnings are raised by eigen headers with gcc12
       8             : #ifdef __GNUC__
       9             : #pragma GCC diagnostic push
      10             : #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
      11             : #endif
      12             : #include <Eigen/Core>
      13             : #ifdef __GNUC__
      14             : #pragma GCC diagnostic pop
      15             : #endif
      16             : 
      17             : #include <Eigen/Geometry>
      18             : 
      19             : #include "scipp/common/numeric.h"
      20             : #include "scipp/core/bucket.h"
      21             : #include "scipp/core/dtype.h"
      22             : #include "scipp/core/spatial_transforms.h"
      23             : 
      24             : namespace scipp::core {
      25             : 
      26             : template <> inline constexpr DType dtype<Eigen::Vector3d>{4000};
      27             : // 4001-4004 defined in spatial_transforms.h
      28             : template <>
      29             : inline constexpr DType dtype<scipp::span<const Eigen::Vector3d>>{4100};
      30             : template <> inline constexpr DType dtype<scipp::span<Eigen::Vector3d>>{4200};
      31             : 
      32       78007 : constexpr bool is_structured(DType tp) {
      33      233905 :   return tp == dtype<Eigen::Vector3d> || tp == dtype<Eigen::Matrix3d> ||
      34      233783 :          tp == dtype<scipp::core::Quaternion> || tp == dtype<Eigen::Affine3d> ||
      35      233883 :          tp == dtype<scipp::core::Translation> || tp == dtype<index_pair>;
      36             : }
      37             : 
      38             : } // namespace scipp::core
      39             : 
      40             : namespace scipp::numeric {
      41             : 
      42          28 : template <> inline bool isnan<Eigen::Vector3d>(const Eigen::Vector3d &x) {
      43          28 :   return x.hasNaN();
      44             : }
      45             : 
      46          14 : template <> inline bool isfinite<Eigen::Vector3d>(const Eigen::Vector3d &x) {
      47          14 :   return x.allFinite();
      48             : }
      49             : 
      50           0 : template <> inline bool isinf<Eigen::Vector3d>(const Eigen::Vector3d &x) {
      51           0 :   return !isfinite(x) && !isnan(x);
      52             : }
      53             : 
      54           0 : [[nodiscard]] inline bool operator==(const Eigen::Affine3d &a,
      55             :                                      const Eigen::Affine3d &b) {
      56           0 :   return a.matrix() == b.matrix();
      57             : }
      58             : 
      59           0 : [[nodiscard]] inline bool operator!=(const Eigen::Affine3d &a,
      60             :                                      const Eigen::Affine3d &b) {
      61           0 :   return a.matrix() != b.matrix();
      62             : }
      63             : 
      64             : } // namespace scipp::numeric

Generated by: LCOV version 1.14