10#ifndef EIGEN_LAPACKE_HELPERS_H
11#define EIGEN_LAPACKE_HELPERS_H
14#include "./InternalHeaderCheck.h"
17#include "mkl_lapacke.h"
28namespace lapacke_helpers {
35template <
typename Scalar>
36struct translate_type_imp;
38struct translate_type_imp<float> {
42struct translate_type_imp<double> {
46struct translate_type_imp<std::complex<double>> {
47 using type = lapack_complex_double;
50struct translate_type_imp<std::complex<float>> {
51 using type = lapack_complex_float;
55template <
typename Scalar>
56using translated_type =
typename translate_type_imp<Scalar>::type;
60template <
typename Source,
typename Target = translated_type<Source>>
61EIGEN_ALWAYS_INLINE
auto to_lapack(Source value) {
62 return static_cast<Target
>(value);
67template <
typename Source,
typename Target = translated_type<Source>>
68EIGEN_ALWAYS_INLINE
auto to_lapack(Source *value) {
69 return reinterpret_cast<Target *
>(value);
74EIGEN_ALWAYS_INLINE lapack_int to_lapack(Index index) {
return convert_index<lapack_int>(index); }
77template <
typename Derived>
78EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR lapack_int lapack_storage_of(
const EigenBase<Derived> &) {
79 return Derived::IsRowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR;
96template <
typename DoubleFn,
typename SingleFn,
typename DoubleCpxFn,
typename SingleCpxFn>
97struct WrappingHelper {
103 DoubleCpxFn double_cpx_;
104 SingleCpxFn single_cpx_;
106 template <
typename... Args>
107 auto call(Args &&...args) ->
decltype(double_(std::forward<Args>(args)...)) {
108 return double_(std::forward<Args>(args)...);
111 template <
typename... Args>
112 auto call(Args &&...args) ->
decltype(single_(std::forward<Args>(args)...)) {
113 return single_(std::forward<Args>(args)...);
116 template <
typename... Args>
117 auto call(Args &&...args) ->
decltype(double_cpx_(std::forward<Args>(args)...)) {
118 return double_cpx_(std::forward<Args>(args)...);
121 template <
typename... Args>
122 auto call(Args &&...args) ->
decltype(single_cpx_(std::forward<Args>(args)...)) {
123 return single_cpx_(std::forward<Args>(args)...);
131template <
typename DoubleFn,
typename SingleFn,
typename DoubleCpxFn,
typename SingleCpxFn,
typename... Args>
132EIGEN_ALWAYS_INLINE
auto call_wrapper(DoubleFn df, SingleFn sf, DoubleCpxFn dcf, SingleCpxFn scf, Args &&...args) {
133 WrappingHelper<DoubleFn, SingleFn, DoubleCpxFn, SingleCpxFn> helper{df, sf, dcf, scf};
134 return helper.call(std::forward<Args>(args)...);
142#define EIGEN_MAKE_LAPACKE_WRAPPER(FUNCTION) \
143 template <typename... Args> \
144 EIGEN_ALWAYS_INLINE auto FUNCTION(Args &&...args) { \
145 return call_wrapper(LAPACKE_d##FUNCTION, LAPACKE_s##FUNCTION, LAPACKE_z##FUNCTION, LAPACKE_c##FUNCTION, \
146 std::forward<Args>(args)...); \
153EIGEN_MAKE_LAPACKE_WRAPPER(potrf)
154EIGEN_MAKE_LAPACKE_WRAPPER(getrf)
155EIGEN_MAKE_LAPACKE_WRAPPER(geqrf)
156EIGEN_MAKE_LAPACKE_WRAPPER(gesdd)
158#undef EIGEN_MAKE_LAPACKE_WRAPPER
Namespace containing all symbols from the Eigen library.
Definition Core:137