Apply clang-format

This commit is contained in:
Tobias Wood
2023-11-29 11:12:48 +00:00
parent 9ea520fc45
commit f38e16c193
534 changed files with 103368 additions and 116934 deletions

View File

@@ -13,40 +13,36 @@
// IWYU pragma: private
#include "./InternalHeaderCheck.h"
namespace Eigen {
namespace Eigen {
namespace internal {
/** \class image_retval_base
*
*/
template<typename DecompositionType>
struct traits<image_retval_base<DecompositionType> >
{
*
*/
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)
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;
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)
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_> >
{
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)
{}
: 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; }
@@ -54,32 +50,31 @@ template<typename DecompositionType_> struct image_retval_base
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
{
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;
protected:
const DecompositionType& m_dec;
Index m_rank, m_cols;
const MatrixType& m_originalMatrix;
};
} // end namespace internal
} // end namespace internal
#define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \
typedef typename DecompositionType::MatrixType MatrixType; \
typedef typename MatrixType::Scalar Scalar; \
typedef typename MatrixType::RealScalar RealScalar; \
#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) {}
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
} // end namespace Eigen
#endif // EIGEN_MISC_IMAGE_H
#endif // EIGEN_MISC_IMAGE_H

View File

@@ -13,70 +13,65 @@
// IWYU pragma: private
#include "./InternalHeaderCheck.h"
namespace Eigen {
namespace Eigen {
namespace internal {
/** \class kernel_retval_base
*
*/
template<typename DecompositionType>
struct traits<kernel_retval_base<DecompositionType> >
{
*
*/
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
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;
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
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_> >
{
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)
{}
: 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
{
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;
protected:
const DecompositionType& m_dec;
Index m_rank, m_cols;
};
} // end namespace internal
} // end namespace internal
#define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \
typedef typename DecompositionType::MatrixType MatrixType; \
typedef typename MatrixType::Scalar Scalar; \
typedef typename MatrixType::RealScalar RealScalar; \
#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; \
using Base::dec; \
using Base::rank; \
using Base::rows; \
using Base::cols; \
kernel_retval(const DecompositionType& dec) : Base(dec) {}
} // end namespace Eigen
} // end namespace Eigen
#endif // EIGEN_MISC_KERNEL_H
#endif // EIGEN_MISC_KERNEL_H

View File

@@ -18,27 +18,22 @@ 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::sqrt;
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;
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));
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);
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)())
{
if (abs(d) < (std::numeric_limits<RealScalar>::min)()) {
rot1.s() = RealScalar(0);
rot1.c() = RealScalar(1);
}
else
{
} 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;
@@ -46,13 +41,13 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q,
rot1.s() = RealScalar(1) / tmp;
rot1.c() = u / tmp;
}
m.applyOnTheLeft(0,1,rot1);
j_right->makeJacobi(m,0,1);
m.applyOnTheLeft(0, 1, rot1);
j_right->makeJacobi(m, 0, 1);
*j_left = rot1 * j_right->transpose();
}
} // end namespace internal
} // end namespace internal
} // end namespace Eigen
} // end namespace Eigen
#endif // EIGEN_REALSVD2X2_H
#endif // EIGEN_REALSVD2X2_H

View File

@@ -7,60 +7,91 @@ extern "C" {
/* Level 1 routines */
int BLASFUNC(saxpy)(const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(saxpy)(const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(daxpy)(const int *, const double *, const double *, const int *, double *, const int *);
int BLASFUNC(caxpy)(const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(caxpy)(const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(zaxpy)(const int *, const double *, const double *, const int *, double *, const int *);
/* Level 2 routines */
int BLASFUNC(sgemv)(const char *, const int *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *);
int BLASFUNC(dgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);
int BLASFUNC(cgemv)(const char *, const int *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *);
int BLASFUNC(zgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);
int BLASFUNC(sgemv)(const char *, const int *, const int *, const float *, const float *, const int *, const float *,
const int *, const float *, float *, const int *);
int BLASFUNC(dgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *,
const int *, const double *, double *, const int *);
int BLASFUNC(cgemv)(const char *, const int *, const int *, const float *, const float *, const int *, const float *,
const int *, const float *, float *, const int *);
int BLASFUNC(zgemv)(const char *, const int *, const int *, const double *, const double *, const int *, const double *,
const int *, const double *, double *, const int *);
int BLASFUNC(strmv)(const char *, const char *, const char *, const int *, const float *, const int *, float *, const int *);
int BLASFUNC(dtrmv)(const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);
int BLASFUNC(ctrmv)(const char *, const char *, const char *, const int *, const float *, const int *, float *, const int *);
int BLASFUNC(ztrmv)(const char *, const char *, const char *, const int *, const double *, const int *, double *, const int *);
int BLASFUNC(strmv)(const char *, const char *, const char *, const int *, const float *, const int *, float *,
const int *);
int BLASFUNC(dtrmv)(const char *, const char *, const char *, const int *, const double *, const int *, double *,
const int *);
int BLASFUNC(ctrmv)(const char *, const char *, const char *, const int *, const float *, const int *, float *,
const int *);
int BLASFUNC(ztrmv)(const char *, const char *, const char *, const int *, const double *, const int *, double *,
const int *);
int BLASFUNC(ssymv)(const char *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *);
int BLASFUNC(dsymv)(const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);
int BLASFUNC(ssymv)(const char *, const int *, const float *, const float *, const int *, const float *, const int *,
const float *, float *, const int *);
int BLASFUNC(dsymv)(const char *, const int *, const double *, const double *, const int *, const double *, const int *,
const double *, double *, const int *);
int BLASFUNC(chemv)(const char *, const int *, const float *, const float *, const int *, const float *, const int *, const float *, float *, const int *);
int BLASFUNC(zhemv)(const char *, const int *, const double *, const double *, const int *, const double *, const int *, const double *, double *, const int *);
int BLASFUNC(chemv)(const char *, const int *, const float *, const float *, const int *, const float *, const int *,
const float *, float *, const int *);
int BLASFUNC(zhemv)(const char *, const int *, const double *, const double *, const int *, const double *, const int *,
const double *, double *, const int *);
/* Level 3 routines */
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int BLASFUNC(strsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(dtrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);
int BLASFUNC(ctrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(ztrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);
int BLASFUNC(strsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
const float *, const int *, float *, const int *);
int BLASFUNC(dtrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
const double *, const int *, double *, const int *);
int BLASFUNC(ctrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
const float *, const int *, float *, const int *);
int BLASFUNC(ztrsm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
const double *, const int *, double *, const int *);
int BLASFUNC(strmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(dtrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);
int BLASFUNC(ctrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *, const float *, const int *, float *, const int *);
int BLASFUNC(ztrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *, const double *, const int *, double *, const int *);
int BLASFUNC(strmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
const float *, const int *, float *, const int *);
int BLASFUNC(dtrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
const double *, const int *, double *, const int *);
int BLASFUNC(ctrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const float *,
const float *, const int *, float *, const int *);
int BLASFUNC(ztrmm)(const char *, const char *, const char *, const char *, const int *, const int *, const double *,
const double *, const int *, double *, const int *);
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int BLASFUNC(ssyrk)(const char *, const char *, const int *, const int *, const float *, const float *, const int *, const float *, float *, const int *);
int BLASFUNC(dsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);
int BLASFUNC(ssyrk)(const char *, const char *, const int *, const int *, const float *, const float *, const int *,
const float *, float *, const int *);
int BLASFUNC(dsyrk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *,
const double *, double *, const int *);
int 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 *);
int 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 *);
int 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 *);
int 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 *);
int BLASFUNC(cherk)(const char *, const char *, const int *, const int *, const float *, const float *, const int *, const float *, float *, const int *);
int BLASFUNC(zherk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *, const double *, double *, const int *);
int BLASFUNC(cherk)(const char *, const char *, const int *, const int *, const float *, const float *, const int *,
const float *, float *, const int *);
int BLASFUNC(zherk)(const char *, const char *, const int *, const int *, const double *, const double *, const int *,
const double *, double *, const int *);
#undef BLASFUNC
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -32,47 +32,49 @@ namespace lapacke_helpers {
// ---------------------------------------------------------------------------------------------------------------------
// For complex numbers, the types in Eigen and Lapacke are different, but layout compatible.
template<typename Scalar>
template <typename Scalar>
struct translate_type_imp;
template<>
template <>
struct translate_type_imp<float> {
using type = float;
using type = float;
};
template<>
template <>
struct translate_type_imp<double> {
using type = double;
using type = double;
};
template<>
template <>
struct translate_type_imp<std::complex<double>> {
using type = lapack_complex_double;
using type = lapack_complex_double;
};
template<>
template <>
struct translate_type_imp<std::complex<float>> {
using type = lapack_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>
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); }
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); }
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);
}
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>
template <typename Derived>
EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR lapack_int lapack_storage_of(const EigenBase<Derived> &) {
return Derived::IsRowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR;
}
@@ -83,38 +85,41 @@ EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR lapack_int lapack_storage_of(const EigenBase
/*!
* \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.
* \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>
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_;
DoubleFn double_;
SingleFn single_;
DoubleCpxFn double_cpx_;
SingleCpxFn single_cpx_;
template<typename... Args>
auto call(Args&&... args) -> decltype(double_(std::forward<Args>(args)...)) {
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)...)){
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)...)){
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)...)){
template <typename... Args>
auto call(Args &&...args) -> decltype(single_cpx_(std::forward<Args>(args)...)) {
return single_cpx_(std::forward<Args>(args)...);
}
};
@@ -123,8 +128,8 @@ struct WrappingHelper {
* 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) {
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)...);
}
@@ -134,9 +139,12 @@ EIGEN_ALWAYS_INLINE auto call_wrapper(DoubleFn df, SingleFn sf, DoubleCpxFn dcf,
* 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)...); }
#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.
@@ -148,8 +156,8 @@ 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
#endif // EIGEN_LAPACKE_HELPERS_H

View File

@@ -3,15 +3,14 @@
#ifndef LAPACK_GLOBAL
#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_)
#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
#define LAPACK_GLOBAL(lcname, UCNAME) lcname##_
#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER)
#define LAPACK_GLOBAL(lcname,UCNAME) UCNAME
#define LAPACK_GLOBAL(lcname, UCNAME) UCNAME
#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE)
#define LAPACK_GLOBAL(lcname,UCNAME) lcname
#define LAPACK_GLOBAL(lcname, UCNAME) lcname
#else
#define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
#define LAPACK_GLOBAL(lcname, UCNAME) lcname##_
#endif
#endif
#endif