Get zero-copy Eigen::Map view of data.
276{
277 return std::visit([](const auto& vec) -> std::optional<Eigen::Map<const EigenType>> {
278 using T =
typename std::decay_t<
decltype(vec)>::value_type;
279
280 if (vec.empty()) {
281 return std::nullopt;
282 }
283
284 if constexpr (std::is_same_v<EigenType, Eigen::VectorXd>) {
285 if constexpr (std::is_same_v<T, double>) {
286 return Eigen::Map<const Eigen::VectorXd>(vec.data(), vec.size());
287 }
288 } else if constexpr (std::is_same_v<EigenType, Eigen::VectorXf>) {
289 if constexpr (std::is_same_v<T, float>) {
290 return Eigen::Map<const Eigen::VectorXf>(vec.data(), vec.size());
291 }
292 } else if constexpr (std::is_same_v<EigenType, Eigen::VectorXcd>) {
293 if constexpr (std::is_same_v<T, std::complex<double>>) {
294 return Eigen::Map<const Eigen::VectorXcd>(
295 reinterpret_cast<const std::complex<double>*>(vec.data()),
296 vec.size());
297 }
298 } else if constexpr (std::is_same_v<EigenType, Eigen::VectorXcf>) {
299 if constexpr (std::is_same_v<T, std::complex<float>>) {
300 return Eigen::Map<const Eigen::VectorXcf>(
301 reinterpret_cast<const std::complex<float>*>(vec.data()),
302 vec.size());
303 }
304 }
305
306 return std::nullopt;
307 },
309}
const Kakshya::DataVariant & m_variant