update
This commit is contained in:
80
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/Image.h
Normal file
80
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/Image.h
Normal file
@@ -0,0 +1,80 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef EIGEN_MISC_IMAGE_H
|
||||
#define EIGEN_MISC_IMAGE_H
|
||||
|
||||
// IWYU pragma: private
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
/** \class image_retval_base
|
||||
*
|
||||
*/
|
||||
template <typename DecompositionType>
|
||||
struct traits<image_retval_base<DecompositionType> > {
|
||||
typedef typename DecompositionType::MatrixType MatrixType;
|
||||
typedef Matrix<typename MatrixType::Scalar,
|
||||
MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose
|
||||
// dimension is the number of rows of the original matrix
|
||||
Dynamic, // we don't know at compile time the dimension of the image (the rank)
|
||||
traits<MatrixType>::Options,
|
||||
MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original
|
||||
// matrix,
|
||||
MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
|
||||
>
|
||||
ReturnType;
|
||||
};
|
||||
|
||||
template <typename DecompositionType_>
|
||||
struct image_retval_base : public ReturnByValue<image_retval_base<DecompositionType_> > {
|
||||
typedef DecompositionType_ DecompositionType;
|
||||
typedef typename DecompositionType::MatrixType MatrixType;
|
||||
typedef ReturnByValue<image_retval_base> Base;
|
||||
|
||||
image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix)
|
||||
: m_dec(dec), m_rank(dec.rank()), m_cols(m_rank == 0 ? 1 : m_rank), m_originalMatrix(originalMatrix) {}
|
||||
|
||||
inline Index rows() const { return m_dec.rows(); }
|
||||
inline Index cols() const { return m_cols; }
|
||||
inline Index rank() const { return m_rank; }
|
||||
inline const DecompositionType& dec() const { return m_dec; }
|
||||
inline const MatrixType& originalMatrix() const { return m_originalMatrix; }
|
||||
|
||||
template <typename Dest>
|
||||
inline void evalTo(Dest& dst) const {
|
||||
static_cast<const image_retval<DecompositionType>*>(this)->evalTo(dst);
|
||||
}
|
||||
|
||||
protected:
|
||||
const DecompositionType& m_dec;
|
||||
Index m_rank, m_cols;
|
||||
const MatrixType& m_originalMatrix;
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \
|
||||
typedef typename DecompositionType::MatrixType MatrixType; \
|
||||
typedef typename MatrixType::Scalar Scalar; \
|
||||
typedef typename MatrixType::RealScalar RealScalar; \
|
||||
typedef Eigen::internal::image_retval_base<DecompositionType> Base; \
|
||||
using Base::dec; \
|
||||
using Base::originalMatrix; \
|
||||
using Base::rank; \
|
||||
using Base::rows; \
|
||||
using Base::cols; \
|
||||
image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) : Base(dec, originalMatrix) {}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
#endif // EIGEN_MISC_IMAGE_H
|
||||
@@ -0,0 +1,3 @@
|
||||
#ifndef EIGEN_CORE_MODULE_H
|
||||
#error "Please include Eigen/Core instead of including headers inside the src directory directly."
|
||||
#endif
|
||||
77
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/Kernel.h
Normal file
77
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/Kernel.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef EIGEN_MISC_KERNEL_H
|
||||
#define EIGEN_MISC_KERNEL_H
|
||||
|
||||
// IWYU pragma: private
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
/** \class kernel_retval_base
|
||||
*
|
||||
*/
|
||||
template <typename DecompositionType>
|
||||
struct traits<kernel_retval_base<DecompositionType> > {
|
||||
typedef typename DecompositionType::MatrixType MatrixType;
|
||||
typedef Matrix<typename MatrixType::Scalar,
|
||||
MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix"
|
||||
// is the number of cols of the original matrix
|
||||
// so that the product "matrix * kernel = zero" makes sense
|
||||
Dynamic, // we don't know at compile-time the dimension of the kernel
|
||||
traits<MatrixType>::Options,
|
||||
MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
|
||||
MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space,
|
||||
// whose dimension is the number of columns of the original matrix
|
||||
>
|
||||
ReturnType;
|
||||
};
|
||||
|
||||
template <typename DecompositionType_>
|
||||
struct kernel_retval_base : public ReturnByValue<kernel_retval_base<DecompositionType_> > {
|
||||
typedef DecompositionType_ DecompositionType;
|
||||
typedef ReturnByValue<kernel_retval_base> Base;
|
||||
|
||||
explicit kernel_retval_base(const DecompositionType& dec)
|
||||
: m_dec(dec), m_rank(dec.rank()), m_cols(m_rank == dec.cols() ? 1 : dec.cols() - m_rank) {}
|
||||
|
||||
inline Index rows() const { return m_dec.cols(); }
|
||||
inline Index cols() const { return m_cols; }
|
||||
inline Index rank() const { return m_rank; }
|
||||
inline const DecompositionType& dec() const { return m_dec; }
|
||||
|
||||
template <typename Dest>
|
||||
inline void evalTo(Dest& dst) const {
|
||||
static_cast<const kernel_retval<DecompositionType>*>(this)->evalTo(dst);
|
||||
}
|
||||
|
||||
protected:
|
||||
const DecompositionType& m_dec;
|
||||
Index m_rank, m_cols;
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
|
||||
typedef typename DecompositionType::MatrixType MatrixType; \
|
||||
typedef typename MatrixType::Scalar Scalar; \
|
||||
typedef typename MatrixType::RealScalar RealScalar; \
|
||||
typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \
|
||||
using Base::dec; \
|
||||
using Base::rank; \
|
||||
using Base::rows; \
|
||||
using Base::cols; \
|
||||
kernel_retval(const DecompositionType& dec) : Base(dec) {}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
#endif // EIGEN_MISC_KERNEL_H
|
||||
@@ -0,0 +1,53 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||
// Copyright (C) 2013-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef EIGEN_REALSVD2X2_H
|
||||
#define EIGEN_REALSVD2X2_H
|
||||
|
||||
// IWYU pragma: private
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename MatrixType, typename RealScalar, typename Index>
|
||||
void real_2x2_jacobi_svd(const MatrixType &matrix, Index p, Index q, JacobiRotation<RealScalar> *j_left,
|
||||
JacobiRotation<RealScalar> *j_right) {
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
Matrix<RealScalar, 2, 2> m;
|
||||
m << numext::real(matrix.coeff(p, p)), numext::real(matrix.coeff(p, q)), numext::real(matrix.coeff(q, p)),
|
||||
numext::real(matrix.coeff(q, q));
|
||||
JacobiRotation<RealScalar> rot1;
|
||||
RealScalar t = m.coeff(0, 0) + m.coeff(1, 1);
|
||||
RealScalar d = m.coeff(1, 0) - m.coeff(0, 1);
|
||||
|
||||
if (abs(d) < (std::numeric_limits<RealScalar>::min)()) {
|
||||
rot1.s() = RealScalar(0);
|
||||
rot1.c() = RealScalar(1);
|
||||
} else {
|
||||
// If d!=0, then t/d cannot overflow because the magnitude of the
|
||||
// entries forming d are not too small compared to the ones forming t.
|
||||
RealScalar u = t / d;
|
||||
RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u));
|
||||
rot1.s() = RealScalar(1) / tmp;
|
||||
rot1.c() = u / tmp;
|
||||
}
|
||||
m.applyOnTheLeft(0, 1, rot1);
|
||||
j_right->makeJacobi(m, 0, 1);
|
||||
*j_left = rot1 * j_right->transpose();
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
#endif // EIGEN_REALSVD2X2_H
|
||||
97
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/blas.h
Normal file
97
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/blas.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef EIGEN_MISC_BLAS_H
|
||||
#define EIGEN_MISC_BLAS_H
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define BLASFUNC(FUNC) FUNC##_
|
||||
|
||||
/* Level 1 routines */
|
||||
|
||||
void BLASFUNC(saxpy)(const int *, const float *, const float *, const int *, float *, const int *);
|
||||
void BLASFUNC(daxpy)(const int *, const double *, const double *, const int *, double *, const int *);
|
||||
void BLASFUNC(caxpy)(const int *, const float *, const float *, const int *, float *, const int *);
|
||||
void BLASFUNC(zaxpy)(const int *, const double *, const double *, const int *, double *, const int *);
|
||||
|
||||
/* Level 2 routines */
|
||||
|
||||
void BLASFUNC(sgemv)(const char *, const int *, const int *, const float *, const float *, const int *, const float *,
|
||||
const int *, const float *, float *, const int *);
|
||||
void BLASFUNC(dgemv)(const char *, const int *, const int *, const double *, const double *, const int *,
|
||||
const double *, const int *, const double *, double *, const int *);
|
||||
void BLASFUNC(cgemv)(const char *, const int *, const int *, const float *, const float *, const int *, const float *,
|
||||
const int *, const float *, float *, const int *);
|
||||
void BLASFUNC(zgemv)(const char *, const int *, const int *, const double *, const double *, const int *,
|
||||
const double *, const int *, const double *, double *, const int *);
|
||||
|
||||
void BLASFUNC(strmv)(const char *, const char *, const char *, const int *, const float *, const int *, float *,
|
||||
const int *);
|
||||
void BLASFUNC(dtrmv)(const char *, const char *, const char *, const int *, const double *, const int *, double *,
|
||||
const int *);
|
||||
void BLASFUNC(ctrmv)(const char *, const char *, const char *, const int *, const float *, const int *, float *,
|
||||
const int *);
|
||||
void BLASFUNC(ztrmv)(const char *, const char *, const char *, const int *, const double *, const int *, double *,
|
||||
const int *);
|
||||
|
||||
void BLASFUNC(ssymv)(const char *, const int *, const float *, const float *, const int *, const float *, const int *,
|
||||
const float *, float *, const int *);
|
||||
void BLASFUNC(dsymv)(const char *, const int *, const double *, const double *, const int *, const double *,
|
||||
const int *, const double *, double *, const int *);
|
||||
|
||||
void BLASFUNC(chemv)(const char *, const int *, const float *, const float *, const int *, const float *, const int *,
|
||||
const float *, float *, const int *);
|
||||
void BLASFUNC(zhemv)(const char *, const int *, const double *, const double *, const int *, const double *,
|
||||
const int *, const double *, double *, const int *);
|
||||
|
||||
/* Level 3 routines */
|
||||
|
||||
void BLASFUNC(sgemm)(const char *, const char *, const int *, const int *, const int *, const float *, const float *,
|
||||
const int *, const float *, const int *, const float *, float *, const int *);
|
||||
void BLASFUNC(dgemm)(const char *, const char *, const int *, const int *, const int *, const double *, const double *,
|
||||
const int *, const double *, const int *, const double *, double *, const int *);
|
||||
void BLASFUNC(cgemm)(const char *, const char *, const int *, const int *, const int *, const float *, const float *,
|
||||
const int *, const float *, const int *, const float *, float *, const int *);
|
||||
void BLASFUNC(zgemm)(const char *, const char *, const int *, const int *, const int *, const double *, const double *,
|
||||
const int *, const double *, const int *, const double *, double *, const int *);
|
||||
|
||||
void BLASFUNC(strsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
|
||||
const float *, const int *, float *, const int *);
|
||||
void BLASFUNC(dtrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
|
||||
const double *, const int *, double *, const int *);
|
||||
void BLASFUNC(ctrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
|
||||
const float *, const int *, float *, const int *);
|
||||
void BLASFUNC(ztrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
|
||||
const double *, const int *, double *, const int *);
|
||||
|
||||
void BLASFUNC(strmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
|
||||
const float *, const int *, float *, const int *);
|
||||
void BLASFUNC(dtrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
|
||||
const double *, const int *, double *, const int *);
|
||||
void BLASFUNC(ctrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
|
||||
const float *, const int *, float *, const int *);
|
||||
void BLASFUNC(ztrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
|
||||
const double *, const int *, double *, const int *);
|
||||
|
||||
void BLASFUNC(ssymm)(const char *, const char *, const int *, const int *, const float *, const float *, const int *,
|
||||
const float *, const int *, const float *, float *, const int *);
|
||||
void BLASFUNC(dsymm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *,
|
||||
const double *, const int *, const double *, double *, const int *);
|
||||
|
||||
void BLASFUNC(ssyrk)(const char *, const char *, const int *, const int *, const float *, const float *, const int *,
|
||||
const float *, float *, const int *);
|
||||
void BLASFUNC(dsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *,
|
||||
const double *, double *, const int *);
|
||||
|
||||
void BLASFUNC(chemm)(const char *, const char *, const int *, const int *, const float *, const float *, const int *,
|
||||
const float *, const int *, const float *, float *, const int *);
|
||||
void BLASFUNC(zhemm)(const char *, const char *, const int *, const int *, const double *, const double *, const int *,
|
||||
const double *, const int *, const double *, double *, const int *);
|
||||
|
||||
void BLASFUNC(cherk)(const char *, const char *, const int *, const int *, const float *, const float *, const int *,
|
||||
const float *, float *, const int *);
|
||||
void BLASFUNC(zherk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *,
|
||||
const double *, double *, const int *);
|
||||
|
||||
#undef BLASFUNC
|
||||
}
|
||||
|
||||
#endif
|
||||
10085
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/lapacke.h
Normal file
10085
2025.09.22_cpp_with_eigen_package/Eigen/src/misc/lapacke.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,163 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2021 Erik Schultheis <erik.schultheis@aalto.fi>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef EIGEN_LAPACKE_HELPERS_H
|
||||
#define EIGEN_LAPACKE_HELPERS_H
|
||||
|
||||
// IWYU pragma: private
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
#ifdef EIGEN_USE_MKL
|
||||
#include "mkl_lapacke.h"
|
||||
#else
|
||||
#include "lapacke.h"
|
||||
#endif
|
||||
|
||||
namespace Eigen {
|
||||
namespace internal {
|
||||
/**
|
||||
* \internal
|
||||
* \brief Implementation details and helper functions for the lapacke glue code.
|
||||
*/
|
||||
namespace lapacke_helpers {
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Translation from Eigen to Lapacke for types and constants
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// For complex numbers, the types in Eigen and Lapacke are different, but layout compatible.
|
||||
template <typename Scalar>
|
||||
struct translate_type_imp;
|
||||
template <>
|
||||
struct translate_type_imp<float> {
|
||||
using type = float;
|
||||
};
|
||||
template <>
|
||||
struct translate_type_imp<double> {
|
||||
using type = double;
|
||||
};
|
||||
template <>
|
||||
struct translate_type_imp<std::complex<double>> {
|
||||
using type = lapack_complex_double;
|
||||
};
|
||||
template <>
|
||||
struct translate_type_imp<std::complex<float>> {
|
||||
using type = lapack_complex_float;
|
||||
};
|
||||
|
||||
/// Given an Eigen types, this is defined to be the corresponding, layout-compatible lapack type
|
||||
template <typename Scalar>
|
||||
using translated_type = typename translate_type_imp<Scalar>::type;
|
||||
|
||||
/// These functions convert their arguments from Eigen to Lapack types
|
||||
/// This function performs conversion for any of the translations defined above.
|
||||
template <typename Source, typename Target = translated_type<Source>>
|
||||
EIGEN_ALWAYS_INLINE auto to_lapack(Source value) {
|
||||
return static_cast<Target>(value);
|
||||
}
|
||||
|
||||
/// This function performs conversions for pointer types corresponding to the translations abovce.
|
||||
/// This is valid because the translations are between layout-compatible types.
|
||||
template <typename Source, typename Target = translated_type<Source>>
|
||||
EIGEN_ALWAYS_INLINE auto to_lapack(Source *value) {
|
||||
return reinterpret_cast<Target *>(value);
|
||||
}
|
||||
|
||||
/// This function converts the Eigen Index to a lapack index, with possible range checks
|
||||
/// \sa internal::convert_index
|
||||
EIGEN_ALWAYS_INLINE lapack_int to_lapack(Index index) { return convert_index<lapack_int>(index); }
|
||||
|
||||
/// translates storage order of the given Eigen object to the corresponding lapack constant
|
||||
template <typename Derived>
|
||||
EIGEN_ALWAYS_INLINE constexpr lapack_int lapack_storage_of(const EigenBase<Derived> &) {
|
||||
return Derived::IsRowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Automatic generation of low-level wrappers
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Helper type to facilitate the wrapping of raw LAPACKE functions for different types into a single, overloaded
|
||||
* C++ function. This is achieved in combination with \r EIGEN_MAKE_LAPACKE_WRAPPER \details This implementation works
|
||||
* by providing an overloaded call function that just forwards its arguments to the underlying lapack function. Each of
|
||||
* these overloads is enabled only if the call is actually well formed. Because these lapack functions take pointers to
|
||||
* the underlying scalar type as arguments, even though the actual Scalars would be implicitly convertible, the pointers
|
||||
* are not and therefore only a single overload can be valid at the same time. Thus, despite all functions taking fully
|
||||
* generic `Args&&... args` as arguments, there is never any ambiguity.
|
||||
*/
|
||||
template <typename DoubleFn, typename SingleFn, typename DoubleCpxFn, typename SingleCpxFn>
|
||||
struct WrappingHelper {
|
||||
// The naming of double, single, double complex and single complex is purely for readability
|
||||
// and doesn't actually affect the workings of this class. In principle, the arguments can
|
||||
// be supplied in any permuted order.
|
||||
DoubleFn double_;
|
||||
SingleFn single_;
|
||||
DoubleCpxFn double_cpx_;
|
||||
SingleCpxFn single_cpx_;
|
||||
|
||||
template <typename... Args>
|
||||
auto call(Args &&...args) -> decltype(double_(std::forward<Args>(args)...)) {
|
||||
return double_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto call(Args &&...args) -> decltype(single_(std::forward<Args>(args)...)) {
|
||||
return single_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto call(Args &&...args) -> decltype(double_cpx_(std::forward<Args>(args)...)) {
|
||||
return double_cpx_(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto call(Args &&...args) -> decltype(single_cpx_(std::forward<Args>(args)...)) {
|
||||
return single_cpx_(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
/** \internal Helper function that generates a `WrappingHelper` object with the given function pointers and
|
||||
* invokes its `call` method, thus selecting one of the overloads.
|
||||
* \sa EIGEN_MAKE_LAPACKE_WRAPPER
|
||||
*/
|
||||
template <typename DoubleFn, typename SingleFn, typename DoubleCpxFn, typename SingleCpxFn, typename... Args>
|
||||
EIGEN_ALWAYS_INLINE auto call_wrapper(DoubleFn df, SingleFn sf, DoubleCpxFn dcf, SingleCpxFn scf, Args &&...args) {
|
||||
WrappingHelper<DoubleFn, SingleFn, DoubleCpxFn, SingleCpxFn> helper{df, sf, dcf, scf};
|
||||
return helper.call(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal
|
||||
* Generates a new function `Function` that dispatches to the corresponding LAPACKE_? prefixed functions.
|
||||
* \sa WrappingHelper
|
||||
*/
|
||||
#define EIGEN_MAKE_LAPACKE_WRAPPER(FUNCTION) \
|
||||
template <typename... Args> \
|
||||
EIGEN_ALWAYS_INLINE auto FUNCTION(Args &&...args) { \
|
||||
return call_wrapper(LAPACKE_d##FUNCTION, LAPACKE_s##FUNCTION, LAPACKE_z##FUNCTION, LAPACKE_c##FUNCTION, \
|
||||
std::forward<Args>(args)...); \
|
||||
}
|
||||
|
||||
// Now with this macro and the helper wrappers, we can generate the dispatch for all the lapacke functions that are
|
||||
// used in Eigen.
|
||||
// We define these here instead of in the files where they are used because this allows us to #undef the macro again
|
||||
// right here
|
||||
EIGEN_MAKE_LAPACKE_WRAPPER(potrf)
|
||||
EIGEN_MAKE_LAPACKE_WRAPPER(getrf)
|
||||
EIGEN_MAKE_LAPACKE_WRAPPER(geqrf)
|
||||
EIGEN_MAKE_LAPACKE_WRAPPER(gesdd)
|
||||
|
||||
#undef EIGEN_MAKE_LAPACKE_WRAPPER
|
||||
} // namespace lapacke_helpers
|
||||
} // namespace internal
|
||||
} // namespace Eigen
|
||||
|
||||
#endif // EIGEN_LAPACKE_HELPERS_H
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef LAPACK_HEADER_INCLUDED
|
||||
#define LAPACK_HEADER_INCLUDED
|
||||
|
||||
#ifndef LAPACK_GLOBAL
|
||||
#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_)
|
||||
#define LAPACK_GLOBAL(lcname, UCNAME) lcname##_
|
||||
#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER)
|
||||
#define LAPACK_GLOBAL(lcname, UCNAME) UCNAME
|
||||
#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE)
|
||||
#define LAPACK_GLOBAL(lcname, UCNAME) lcname
|
||||
#else
|
||||
#define LAPACK_GLOBAL(lcname, UCNAME) lcname##_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user