Skip to content

Commit 1ce3813

Browse files
authored
Merge pull request #37 from uonrobotics/hotfix-eigen-usage
Hotfix eigen usage
2 parents b1df786 + a15aed0 commit 1ce3813

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

ctmd/core/broadcast.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <optional>
4+
35
#include "submdspan.hpp"
46
#include "type.hpp"
57

ctmd/linalg/matmul.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ inline constexpr void matmul_impl(const in1_t &in1, const in2_t &in2,
6161
core::eigen::eigen_mappable_mdspan_c<out_t>) {
6262
if (!std::is_constant_evaluated() && 8 <= out.extent(0) + out.extent(1))
6363
[[likely]] {
64-
const auto ein1 = core::eigen::to_eigen(in1);
65-
const auto ein2 = core::eigen::to_eigen(in2);
64+
using common_t = std::common_type_t<typename in1_t::value_type,
65+
typename in2_t::value_type>;
66+
const auto ein1 =
67+
core::eigen::to_eigen(in1).template cast<common_t>();
68+
const auto ein2 =
69+
core::eigen::to_eigen(in2).template cast<common_t>();
6670
auto eout = core::eigen::to_eigen(out);
6771
eout = ein1 * ein2;
6872
return;

ctmd/linalg/matvec.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ inline constexpr void matvec_impl(const in1_t &in1, const in2_t &in2,
5858
core::eigen::eigen_mappable_mdspan_c<in2_t> &&
5959
core::eigen::eigen_mappable_mdspan_c<out_t>) {
6060
if (!std::is_constant_evaluated() && 1 <= out.extent(0)) [[likely]] {
61-
const auto ein1 = core::eigen::to_eigen(in1);
62-
const auto ein2 = core::eigen::to_eigen(in2);
61+
using common_t = std::common_type_t<typename in1_t::value_type,
62+
typename in2_t::value_type>;
63+
const auto ein1 =
64+
core::eigen::to_eigen(in1).template cast<common_t>();
65+
const auto ein2 =
66+
core::eigen::to_eigen(in2).template cast<common_t>();
6367
auto eout = core::eigen::to_eigen(out);
6468
eout = ein1 * ein2;
6569
return;

ctmd/linalg/vecmat.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ inline constexpr void vecmat_impl(const in1_t &in1, const in2_t &in2,
5858
core::eigen::eigen_mappable_mdspan_c<in2_t> &&
5959
core::eigen::eigen_mappable_mdspan_c<out_t>) {
6060
if (!std::is_constant_evaluated() && 1 <= out.extent(0)) [[likely]] {
61-
const auto ein1 = core::eigen::to_eigen(in1);
62-
const auto ein2 = core::eigen::to_eigen(in2);
61+
using common_t = std::common_type_t<typename in1_t::value_type,
62+
typename in2_t::value_type>;
63+
const auto ein1 =
64+
core::eigen::to_eigen(in1).template cast<common_t>();
65+
const auto ein2 =
66+
core::eigen::to_eigen(in2).template cast<common_t>();
6367
auto eout = core::eigen::to_eigen(out);
6468
eout = ein1 * ein2;
6569
return;

0 commit comments

Comments
 (0)