10 #ifndef EIGEN_LAPACKE_HELPERS_H 11 #define EIGEN_LAPACKE_HELPERS_H 14 #include "./InternalHeaderCheck.h" 17 #include "mkl_lapacke.h" 28 namespace lapacke_helpers {
35 template <
typename Scalar>
36 struct translate_type_imp;
38 struct translate_type_imp<float> {
42 struct translate_type_imp<double> {
46 struct translate_type_imp<
std::complex<double>> {
47 using type = lapack_complex_double;
50 struct translate_type_imp<
std::complex<float>> {
51 using type = lapack_complex_float;
55 template <
typename Scalar>
56 using translated_type =
typename translate_type_imp<Scalar>::type;
60 template <
typename Source,
typename Target = translated_type<Source>>
61 EIGEN_ALWAYS_INLINE
auto to_lapack(Source value) {
62 return static_cast<Target
>(value);
67 template <
typename Source,
typename Target = translated_type<Source>>
68 EIGEN_ALWAYS_INLINE
auto to_lapack(Source *value) {
69 return reinterpret_cast<Target *
>(value);
74 EIGEN_ALWAYS_INLINE lapack_int to_lapack(
Index index) {
return convert_index<lapack_int>(index); }
77 template <
typename Derived>
78 EIGEN_ALWAYS_INLINE constexpr lapack_int lapack_storage_of(
const EigenBase<Derived> &) {
79 return Derived::IsRowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR;
96 template <
typename DoubleFn,
typename SingleFn,
typename DoubleCpxFn,
typename SingleCpxFn>
97 struct 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)...);
131 template <
typename DoubleFn,
typename SingleFn,
typename DoubleCpxFn,
typename SingleCpxFn,
typename... Args>
132 EIGEN_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)...); \ 153 EIGEN_MAKE_LAPACKE_WRAPPER(potrf)
154 EIGEN_MAKE_LAPACKE_WRAPPER(getrf)
155 EIGEN_MAKE_LAPACKE_WRAPPER(geqrf)
156 EIGEN_MAKE_LAPACKE_WRAPPER(gesdd)
158 #undef EIGEN_MAKE_LAPACKE_WRAPPER 163 #endif // EIGEN_LAPACKE_HELPERS_H Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Definition: BFloat16.h:231
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82