ADD: added other eigen lib
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#ifndef EIGEN_DETERMINANT_H
|
||||
#define EIGEN_DETERMINANT_H
|
||||
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
@@ -80,8 +82,8 @@ template<typename Derived> struct determinant_impl<Derived, 4>
|
||||
Scalar d3_1 = det3(m, 0,d2_23, 2,d2_03, 3,d2_02);
|
||||
Scalar d3_2 = det3(m, 0,d2_13, 1,d2_03, 3,d2_01);
|
||||
Scalar d3_3 = det3(m, 0,d2_12, 1,d2_02, 2,d2_01);
|
||||
return internal::pmadd(-m(0,3),d3_0, m(1,3)*d3_1) +
|
||||
internal::pmadd(-m(2,3),d3_2, m(3,3)*d3_3);
|
||||
return internal::pmadd(static_cast<Scalar>(-m(0,3)),d3_0, static_cast<Scalar>(m(1,3)*d3_1)) +
|
||||
internal::pmadd(static_cast<Scalar>(-m(2,3)),d3_2, static_cast<Scalar>(m(3,3)*d3_3));
|
||||
}
|
||||
protected:
|
||||
static EIGEN_DEVICE_FUNC
|
||||
@@ -93,7 +95,7 @@ protected:
|
||||
static EIGEN_DEVICE_FUNC
|
||||
Scalar det3(const Derived& m, Index i0, const Scalar& d0, Index i1, const Scalar& d1, Index i2, const Scalar& d2)
|
||||
{
|
||||
return internal::pmadd(m(i0,2), d0, internal::pmadd(-m(i1,2), d1, m(i2,2)*d2));
|
||||
return internal::pmadd(m(i0,2), d0, internal::pmadd(static_cast<Scalar>(-m(i1,2)), d1, static_cast<Scalar>(m(i2,2)*d2)));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,7 +111,7 @@ inline typename internal::traits<Derived>::Scalar MatrixBase<Derived>::determina
|
||||
{
|
||||
eigen_assert(rows() == cols());
|
||||
typedef typename internal::nested_eval<Derived,Base::RowsAtCompileTime>::type Nested;
|
||||
return internal::determinant_impl<typename internal::remove_all<Nested>::type>::run(derived());
|
||||
return internal::determinant_impl<internal::remove_all_t<Nested>>::run(derived());
|
||||
}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
#ifndef EIGEN_LU_H
|
||||
#define EIGEN_LU_H
|
||||
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
template<typename _MatrixType> struct traits<FullPivLU<_MatrixType> >
|
||||
: traits<_MatrixType>
|
||||
template<typename MatrixType_> struct traits<FullPivLU<MatrixType_> >
|
||||
: traits<MatrixType_>
|
||||
{
|
||||
typedef MatrixXpr XprKind;
|
||||
typedef SolverStorage StorageKind;
|
||||
@@ -30,7 +32,7 @@ template<typename _MatrixType> struct traits<FullPivLU<_MatrixType> >
|
||||
*
|
||||
* \brief LU decomposition of a matrix with complete pivoting, and related features
|
||||
*
|
||||
* \tparam _MatrixType the type of the matrix of which we are computing the LU decomposition
|
||||
* \tparam MatrixType_ the type of the matrix of which we are computing the LU decomposition
|
||||
*
|
||||
* This class represents a LU decomposition of any matrix, with complete pivoting: the matrix A is
|
||||
* decomposed as \f$ A = P^{-1} L U Q^{-1} \f$ where L is unit-lower-triangular, U is
|
||||
@@ -57,11 +59,11 @@ template<typename _MatrixType> struct traits<FullPivLU<_MatrixType> >
|
||||
*
|
||||
* \sa MatrixBase::fullPivLu(), MatrixBase::determinant(), MatrixBase::inverse()
|
||||
*/
|
||||
template<typename _MatrixType> class FullPivLU
|
||||
: public SolverBase<FullPivLU<_MatrixType> >
|
||||
template<typename MatrixType_> class FullPivLU
|
||||
: public SolverBase<FullPivLU<MatrixType_> >
|
||||
{
|
||||
public:
|
||||
typedef _MatrixType MatrixType;
|
||||
typedef MatrixType_ MatrixType;
|
||||
typedef SolverBase<FullPivLU> Base;
|
||||
friend class SolverBase<FullPivLU>;
|
||||
|
||||
@@ -419,10 +421,7 @@ template<typename _MatrixType> class FullPivLU
|
||||
|
||||
protected:
|
||||
|
||||
static void check_template_parameters()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
|
||||
}
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
||||
|
||||
void computeInPlace();
|
||||
|
||||
@@ -487,8 +486,6 @@ FullPivLU<MatrixType>::FullPivLU(EigenBase<InputType>& matrix)
|
||||
template<typename MatrixType>
|
||||
void FullPivLU<MatrixType>::computeInPlace()
|
||||
{
|
||||
check_template_parameters();
|
||||
|
||||
// the permutations are stored as int indices, so just to be sure:
|
||||
eigen_assert(m_lu.rows()<=NumTraits<int>::highest() && m_lu.cols()<=NumTraits<int>::highest());
|
||||
|
||||
@@ -522,7 +519,7 @@ void FullPivLU<MatrixType>::computeInPlace()
|
||||
row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner,
|
||||
col_of_biggest_in_corner += k; // need to add k to them.
|
||||
|
||||
if(biggest_in_corner==Score(0))
|
||||
if(numext::is_exactly_zero(biggest_in_corner))
|
||||
{
|
||||
// before exiting, make sure to initialize the still uninitialized transpositions
|
||||
// in a sane state without destroying what we already have.
|
||||
@@ -613,15 +610,15 @@ MatrixType FullPivLU<MatrixType>::reconstructedMatrix() const
|
||||
/********* Implementation of kernel() **************************************************/
|
||||
|
||||
namespace internal {
|
||||
template<typename _MatrixType>
|
||||
struct kernel_retval<FullPivLU<_MatrixType> >
|
||||
: kernel_retval_base<FullPivLU<_MatrixType> >
|
||||
template<typename MatrixType_>
|
||||
struct kernel_retval<FullPivLU<MatrixType_> >
|
||||
: kernel_retval_base<FullPivLU<MatrixType_> >
|
||||
{
|
||||
EIGEN_MAKE_KERNEL_HELPERS(FullPivLU<_MatrixType>)
|
||||
EIGEN_MAKE_KERNEL_HELPERS(FullPivLU<MatrixType_>)
|
||||
|
||||
enum { MaxSmallDimAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(
|
||||
MatrixType::MaxColsAtCompileTime,
|
||||
MatrixType::MaxRowsAtCompileTime)
|
||||
enum { MaxSmallDimAtCompileTime = min_size_prefer_fixed(
|
||||
MatrixType::MaxColsAtCompileTime,
|
||||
MatrixType::MaxRowsAtCompileTime)
|
||||
};
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
@@ -699,15 +696,15 @@ struct kernel_retval<FullPivLU<_MatrixType> >
|
||||
|
||||
/***** Implementation of image() *****************************************************/
|
||||
|
||||
template<typename _MatrixType>
|
||||
struct image_retval<FullPivLU<_MatrixType> >
|
||||
: image_retval_base<FullPivLU<_MatrixType> >
|
||||
template<typename MatrixType_>
|
||||
struct image_retval<FullPivLU<MatrixType_> >
|
||||
: image_retval_base<FullPivLU<MatrixType_> >
|
||||
{
|
||||
EIGEN_MAKE_IMAGE_HELPERS(FullPivLU<_MatrixType>)
|
||||
EIGEN_MAKE_IMAGE_HELPERS(FullPivLU<MatrixType_>)
|
||||
|
||||
enum { MaxSmallDimAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(
|
||||
MatrixType::MaxColsAtCompileTime,
|
||||
MatrixType::MaxRowsAtCompileTime)
|
||||
enum { MaxSmallDimAtCompileTime = min_size_prefer_fixed(
|
||||
MatrixType::MaxColsAtCompileTime,
|
||||
MatrixType::MaxRowsAtCompileTime)
|
||||
};
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
@@ -740,9 +737,9 @@ struct image_retval<FullPivLU<_MatrixType> >
|
||||
} // end namespace internal
|
||||
|
||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||
template<typename _MatrixType>
|
||||
template<typename MatrixType_>
|
||||
template<typename RhsType, typename DstType>
|
||||
void FullPivLU<_MatrixType>::_solve_impl(const RhsType &rhs, DstType &dst) const
|
||||
void FullPivLU<MatrixType_>::_solve_impl(const RhsType &rhs, DstType &dst) const
|
||||
{
|
||||
/* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1}.
|
||||
* So we proceed as follows:
|
||||
@@ -787,9 +784,9 @@ void FullPivLU<_MatrixType>::_solve_impl(const RhsType &rhs, DstType &dst) const
|
||||
dst.row(permutationQ().indices().coeff(i)).setZero();
|
||||
}
|
||||
|
||||
template<typename _MatrixType>
|
||||
template<typename MatrixType_>
|
||||
template<bool Conjugate, typename RhsType, typename DstType>
|
||||
void FullPivLU<_MatrixType>::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const
|
||||
void FullPivLU<MatrixType_>::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const
|
||||
{
|
||||
/* The decomposition PAQ = LU can be rewritten as A = P^{-1} L U Q^{-1},
|
||||
* and since permutations are real and unitary, we can write this
|
||||
|
||||
3
libs/eigen/Eigen/src/LU/InternalHeaderCheck.h
Normal file
3
libs/eigen/Eigen/src/LU/InternalHeaderCheck.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#ifndef EIGEN_LU_MODULE_H
|
||||
#error "Please include Eigen/LU instead of including headers inside the src directory directly."
|
||||
#endif
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef EIGEN_INVERSE_IMPL_H
|
||||
#define EIGEN_INVERSE_IMPL_H
|
||||
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
@@ -309,13 +311,13 @@ struct Assignment<DstXprType, Inverse<XprType>, internal::assign_op<typename Dst
|
||||
if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
|
||||
dst.resize(dstRows, dstCols);
|
||||
|
||||
const int Size = EIGEN_PLAIN_ENUM_MIN(XprType::ColsAtCompileTime,DstXprType::ColsAtCompileTime);
|
||||
const int Size = plain_enum_min(XprType::ColsAtCompileTime, DstXprType::ColsAtCompileTime);
|
||||
EIGEN_ONLY_USED_FOR_DEBUG(Size);
|
||||
eigen_assert(( (Size<=1) || (Size>4) || (extract_data(src.nestedExpression())!=extract_data(dst)))
|
||||
&& "Aliasing problem detected in inverse(), you need to do inverse().eval() here.");
|
||||
|
||||
typedef typename internal::nested_eval<XprType,XprType::ColsAtCompileTime>::type ActualXprType;
|
||||
typedef typename internal::remove_all<ActualXprType>::type ActualXprTypeCleanded;
|
||||
typedef internal::remove_all_t<ActualXprType> ActualXprTypeCleanded;
|
||||
|
||||
ActualXprType actual_xpr(src.nestedExpression());
|
||||
|
||||
@@ -385,11 +387,11 @@ inline void MatrixBase<Derived>::computeInverseAndDetWithCheck(
|
||||
eigen_assert(rows() == cols());
|
||||
// for 2x2, it's worth giving a chance to avoid evaluating.
|
||||
// for larger sizes, evaluating has negligible cost and limits code size.
|
||||
typedef typename internal::conditional<
|
||||
typedef std::conditional_t<
|
||||
RowsAtCompileTime == 2,
|
||||
typename internal::remove_all<typename internal::nested_eval<Derived, 2>::type>::type,
|
||||
internal::remove_all_t<typename internal::nested_eval<Derived, 2>::type>,
|
||||
PlainObject
|
||||
>::type MatrixType;
|
||||
> MatrixType;
|
||||
internal::compute_inverse_and_det_with_check<MatrixType, ResultType>::run
|
||||
(derived(), absDeterminantThreshold, inverse, determinant, invertible);
|
||||
}
|
||||
|
||||
@@ -11,16 +11,18 @@
|
||||
#ifndef EIGEN_PARTIALLU_H
|
||||
#define EIGEN_PARTIALLU_H
|
||||
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
template<typename _MatrixType> struct traits<PartialPivLU<_MatrixType> >
|
||||
: traits<_MatrixType>
|
||||
template<typename MatrixType_> struct traits<PartialPivLU<MatrixType_> >
|
||||
: traits<MatrixType_>
|
||||
{
|
||||
typedef MatrixXpr XprKind;
|
||||
typedef SolverStorage StorageKind;
|
||||
typedef int StorageIndex;
|
||||
typedef traits<_MatrixType> BaseTraits;
|
||||
typedef traits<MatrixType_> BaseTraits;
|
||||
enum {
|
||||
Flags = BaseTraits::Flags & RowMajorBit,
|
||||
CoeffReadCost = Dynamic
|
||||
@@ -46,7 +48,7 @@ struct enable_if_ref<Ref<T>,Derived> {
|
||||
*
|
||||
* \brief LU decomposition of a matrix with partial pivoting, and related features
|
||||
*
|
||||
* \tparam _MatrixType the type of the matrix of which we are computing the LU decomposition
|
||||
* \tparam MatrixType_ the type of the matrix of which we are computing the LU decomposition
|
||||
*
|
||||
* This class represents a LU decomposition of a \b square \b invertible matrix, with partial pivoting: the matrix A
|
||||
* is decomposed as A = PLU where L is unit-lower-triangular, U is upper-triangular, and P
|
||||
@@ -73,12 +75,12 @@ struct enable_if_ref<Ref<T>,Derived> {
|
||||
*
|
||||
* \sa MatrixBase::partialPivLu(), MatrixBase::determinant(), MatrixBase::inverse(), MatrixBase::computeInverse(), class FullPivLU
|
||||
*/
|
||||
template<typename _MatrixType> class PartialPivLU
|
||||
: public SolverBase<PartialPivLU<_MatrixType> >
|
||||
template<typename MatrixType_> class PartialPivLU
|
||||
: public SolverBase<PartialPivLU<MatrixType_> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef _MatrixType MatrixType;
|
||||
typedef MatrixType_ MatrixType;
|
||||
typedef SolverBase<PartialPivLU> Base;
|
||||
friend class SolverBase<PartialPivLU>;
|
||||
|
||||
@@ -265,10 +267,7 @@ template<typename _MatrixType> class PartialPivLU
|
||||
|
||||
protected:
|
||||
|
||||
static void check_template_parameters()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
|
||||
}
|
||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
||||
|
||||
void compute();
|
||||
|
||||
@@ -334,12 +333,12 @@ namespace internal {
|
||||
template<typename Scalar, int StorageOrder, typename PivIndex, int SizeAtCompileTime=Dynamic>
|
||||
struct partial_lu_impl
|
||||
{
|
||||
static const int UnBlockedBound = 16;
|
||||
static const bool UnBlockedAtCompileTime = SizeAtCompileTime!=Dynamic && SizeAtCompileTime<=UnBlockedBound;
|
||||
static const int ActualSizeAtCompileTime = UnBlockedAtCompileTime ? SizeAtCompileTime : Dynamic;
|
||||
static constexpr int UnBlockedBound = 16;
|
||||
static constexpr bool UnBlockedAtCompileTime = SizeAtCompileTime!=Dynamic && SizeAtCompileTime<=UnBlockedBound;
|
||||
static constexpr int ActualSizeAtCompileTime = UnBlockedAtCompileTime ? SizeAtCompileTime : Dynamic;
|
||||
// Remaining rows and columns at compile-time:
|
||||
static const int RRows = SizeAtCompileTime==2 ? 1 : Dynamic;
|
||||
static const int RCols = SizeAtCompileTime==2 ? 1 : Dynamic;
|
||||
static constexpr int RRows = SizeAtCompileTime==2 ? 1 : Dynamic;
|
||||
static constexpr int RCols = SizeAtCompileTime==2 ? 1 : Dynamic;
|
||||
typedef Matrix<Scalar, ActualSizeAtCompileTime, ActualSizeAtCompileTime, StorageOrder> MatrixType;
|
||||
typedef Ref<MatrixType> MatrixTypeRef;
|
||||
typedef Ref<Matrix<Scalar, Dynamic, Dynamic, StorageOrder> > BlockType;
|
||||
@@ -379,7 +378,7 @@ struct partial_lu_impl
|
||||
|
||||
row_transpositions[k] = PivIndex(row_of_biggest_in_col);
|
||||
|
||||
if(biggest_in_corner != Score(0))
|
||||
if(!numext::is_exactly_zero(biggest_in_corner))
|
||||
{
|
||||
if(k != row_of_biggest_in_col)
|
||||
{
|
||||
@@ -405,7 +404,7 @@ struct partial_lu_impl
|
||||
{
|
||||
Index k = endk;
|
||||
row_transpositions[k] = PivIndex(k);
|
||||
if (Scoring()(lu(k, k)) == Score(0) && first_zero_pivot == -1)
|
||||
if (numext::is_exactly_zero(Scoring()(lu(k, k))) && first_zero_pivot == -1)
|
||||
first_zero_pivot = k;
|
||||
}
|
||||
|
||||
@@ -515,7 +514,7 @@ void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, t
|
||||
partial_lu_impl
|
||||
< typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor,
|
||||
typename TranspositionType::StorageIndex,
|
||||
EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime)>
|
||||
internal::min_size_prefer_fixed(MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime)>
|
||||
::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions);
|
||||
}
|
||||
|
||||
@@ -524,8 +523,6 @@ void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, t
|
||||
template<typename MatrixType>
|
||||
void PartialPivLU<MatrixType>::compute()
|
||||
{
|
||||
check_template_parameters();
|
||||
|
||||
// the row permutation is stored as int indices, so just to be sure:
|
||||
eigen_assert(m_lu.rows()<NumTraits<int>::highest());
|
||||
|
||||
|
||||
@@ -33,48 +33,61 @@
|
||||
#ifndef EIGEN_PARTIALLU_LAPACK_H
|
||||
#define EIGEN_PARTIALLU_LAPACK_H
|
||||
|
||||
#include "./InternalHeaderCheck.h"
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
/** \internal Specialization for the data types supported by LAPACKe */
|
||||
namespace lapacke_helpers {
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
// Generic lapacke partial lu implementation that converts arguments and dispatches to the function above
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define EIGEN_LAPACKE_LU_PARTPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \
|
||||
template<int StorageOrder> \
|
||||
struct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int> \
|
||||
{ \
|
||||
/* \internal performs the LU decomposition in-place of the matrix represented */ \
|
||||
static lapack_int blocked_lu(Index rows, Index cols, EIGTYPE* lu_data, Index luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \
|
||||
{ \
|
||||
EIGEN_UNUSED_VARIABLE(maxBlockSize);\
|
||||
lapack_int matrix_order, first_zero_pivot; \
|
||||
lapack_int m, n, lda, *ipiv, info; \
|
||||
EIGTYPE* a; \
|
||||
/* Set up parameters for ?getrf */ \
|
||||
matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
|
||||
lda = convert_index<lapack_int>(luStride); \
|
||||
a = lu_data; \
|
||||
ipiv = row_transpositions; \
|
||||
m = convert_index<lapack_int>(rows); \
|
||||
n = convert_index<lapack_int>(cols); \
|
||||
nb_transpositions = 0; \
|
||||
\
|
||||
info = LAPACKE_##LAPACKE_PREFIX##getrf( matrix_order, m, n, (LAPACKE_TYPE*)a, lda, ipiv ); \
|
||||
\
|
||||
for(int i=0;i<m;i++) { ipiv[i]--; if (ipiv[i]!=i) nb_transpositions++; } \
|
||||
\
|
||||
eigen_assert(info >= 0); \
|
||||
/* something should be done with nb_transpositions */ \
|
||||
\
|
||||
first_zero_pivot = info; \
|
||||
return first_zero_pivot; \
|
||||
} \
|
||||
template<typename Scalar, int StorageOrder>
|
||||
struct lapacke_partial_lu {
|
||||
/** \internal performs the LU decomposition in-place of the matrix represented */
|
||||
static lapack_int blocked_lu(Index rows, Index cols, Scalar* lu_data, Index luStride, lapack_int* row_transpositions,
|
||||
lapack_int& nb_transpositions, lapack_int maxBlockSize=256)
|
||||
{
|
||||
EIGEN_UNUSED_VARIABLE(maxBlockSize);
|
||||
// Set up parameters for getrf
|
||||
lapack_int matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR;
|
||||
lapack_int lda = to_lapack(luStride);
|
||||
Scalar* a = lu_data;
|
||||
lapack_int* ipiv = row_transpositions;
|
||||
lapack_int m = to_lapack(rows);
|
||||
lapack_int n = to_lapack(cols);
|
||||
nb_transpositions = 0;
|
||||
|
||||
lapack_int info = getrf(matrix_order, m, n, to_lapack(a), lda, ipiv );
|
||||
eigen_assert(info >= 0);
|
||||
|
||||
for(int i=0; i<m; i++) {
|
||||
ipiv[i]--;
|
||||
if (ipiv[i] != i) nb_transpositions++;
|
||||
}
|
||||
lapack_int first_zero_pivot = info;
|
||||
return first_zero_pivot;
|
||||
}
|
||||
};
|
||||
} // end namespace lapacke_helpers
|
||||
|
||||
EIGEN_LAPACKE_LU_PARTPIV(double, double, d)
|
||||
EIGEN_LAPACKE_LU_PARTPIV(float, float, s)
|
||||
EIGEN_LAPACKE_LU_PARTPIV(dcomplex, lapack_complex_double, z)
|
||||
EIGEN_LAPACKE_LU_PARTPIV(scomplex, lapack_complex_float, c)
|
||||
/*
|
||||
* Here, we just put the generic implementation from lapacke_partial_lu into a partial specialization of the partial_lu_impl
|
||||
* type. This specialization is more specialized than the generic implementations that Eigen implements, so if the
|
||||
* Scalar type matches they will be chosen.
|
||||
*/
|
||||
#define EIGEN_LAPACKE_PARTIAL_LU(EIGTYPE) \
|
||||
template<int StorageOrder> \
|
||||
struct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int, Dynamic> : public lapacke_helpers::lapacke_partial_lu<EIGTYPE, StorageOrder> {};
|
||||
|
||||
EIGEN_LAPACKE_PARTIAL_LU(double)
|
||||
EIGEN_LAPACKE_PARTIAL_LU(float)
|
||||
EIGEN_LAPACKE_PARTIAL_LU(std::complex<double>)
|
||||
EIGEN_LAPACKE_PARTIAL_LU(std::complex<float>)
|
||||
|
||||
#undef EIGEN_LAPACKE_PARTIAL_LU
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
|
||||
@@ -35,6 +35,15 @@
|
||||
#ifndef EIGEN_INVERSE_SIZE_4_H
|
||||
#define EIGEN_INVERSE_SIZE_4_H
|
||||
|
||||
#include "../InternalHeaderCheck.h"
|
||||
|
||||
#if EIGEN_COMP_GNUC_STRICT
|
||||
// These routines requires bit manipulation of the sign, which is not compatible
|
||||
// with fastmath.
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("no-fast-math")
|
||||
#endif
|
||||
|
||||
namespace Eigen
|
||||
{
|
||||
namespace internal
|
||||
@@ -48,7 +57,7 @@ struct compute_inverse_size4<Architecture::Target, float, MatrixType, ResultType
|
||||
ResultAlignment = traits<ResultType>::Alignment,
|
||||
StorageOrdersMatch = (MatrixType::Flags & RowMajorBit) == (ResultType::Flags & RowMajorBit)
|
||||
};
|
||||
typedef typename conditional<(MatrixType::Flags & LinearAccessBit), MatrixType const &, typename MatrixType::PlainObject>::type ActualMatrixType;
|
||||
typedef std::conditional_t<(MatrixType::Flags & LinearAccessBit), MatrixType const &, typename MatrixType::PlainObject> ActualMatrixType;
|
||||
|
||||
static void run(const MatrixType &mat, ResultType &result)
|
||||
{
|
||||
@@ -56,10 +65,10 @@ struct compute_inverse_size4<Architecture::Target, float, MatrixType, ResultType
|
||||
|
||||
const float* data = matrix.data();
|
||||
const Index stride = matrix.innerStride();
|
||||
Packet4f _L1 = ploadt<Packet4f,MatrixAlignment>(data);
|
||||
Packet4f _L2 = ploadt<Packet4f,MatrixAlignment>(data + stride*4);
|
||||
Packet4f _L3 = ploadt<Packet4f,MatrixAlignment>(data + stride*8);
|
||||
Packet4f _L4 = ploadt<Packet4f,MatrixAlignment>(data + stride*12);
|
||||
Packet4f L1 = ploadt<Packet4f,MatrixAlignment>(data);
|
||||
Packet4f L2 = ploadt<Packet4f,MatrixAlignment>(data + stride*4);
|
||||
Packet4f L3 = ploadt<Packet4f,MatrixAlignment>(data + stride*8);
|
||||
Packet4f L4 = ploadt<Packet4f,MatrixAlignment>(data + stride*12);
|
||||
|
||||
// Four 2x2 sub-matrices of the input matrix
|
||||
// input = [[A, B],
|
||||
@@ -68,17 +77,17 @@ struct compute_inverse_size4<Architecture::Target, float, MatrixType, ResultType
|
||||
|
||||
if (!StorageOrdersMatch)
|
||||
{
|
||||
A = vec4f_unpacklo(_L1, _L2);
|
||||
B = vec4f_unpacklo(_L3, _L4);
|
||||
C = vec4f_unpackhi(_L1, _L2);
|
||||
D = vec4f_unpackhi(_L3, _L4);
|
||||
A = vec4f_unpacklo(L1, L2);
|
||||
B = vec4f_unpacklo(L3, L4);
|
||||
C = vec4f_unpackhi(L1, L2);
|
||||
D = vec4f_unpackhi(L3, L4);
|
||||
}
|
||||
else
|
||||
{
|
||||
A = vec4f_movelh(_L1, _L2);
|
||||
B = vec4f_movehl(_L2, _L1);
|
||||
C = vec4f_movelh(_L3, _L4);
|
||||
D = vec4f_movehl(_L4, _L3);
|
||||
A = vec4f_movelh(L1, L2);
|
||||
B = vec4f_movehl(L2, L1);
|
||||
C = vec4f_movelh(L3, L4);
|
||||
D = vec4f_movehl(L4, L3);
|
||||
}
|
||||
|
||||
Packet4f AB, DC;
|
||||
@@ -118,7 +127,7 @@ struct compute_inverse_size4<Architecture::Target, float, MatrixType, ResultType
|
||||
Packet4f det = vec4f_duplane(psub(padd(d1, d2), d), 0);
|
||||
|
||||
// reciprocal of the determinant of the input matrix, rd = 1/det
|
||||
Packet4f rd = pdiv(pset1<Packet4f>(1.0f), det);
|
||||
Packet4f rd = preciprocal(det);
|
||||
|
||||
// Four sub-matrices of the inverse
|
||||
Packet4f iA, iB, iC, iD;
|
||||
@@ -143,8 +152,8 @@ struct compute_inverse_size4<Architecture::Target, float, MatrixType, ResultType
|
||||
iC = psub(iC, pmul(vec4f_swizzle2(A, A, 1, 0, 3, 2), vec4f_swizzle2(DC, DC, 2, 1, 2, 1)));
|
||||
iC = psub(pmul(B, vec4f_duplane(dC, 0)), iC);
|
||||
|
||||
const float sign_mask[4] = {0.0f, numext::bit_cast<float>(0x80000000u), numext::bit_cast<float>(0x80000000u), 0.0f};
|
||||
const Packet4f p4f_sign_PNNP = ploadu<Packet4f>(sign_mask);
|
||||
EIGEN_ALIGN_MAX const float sign_mask[4] = {0.0f, -0.0f, -0.0f, 0.0f};
|
||||
const Packet4f p4f_sign_PNNP = pload<Packet4f>(sign_mask);
|
||||
rd = pxor(rd, p4f_sign_PNNP);
|
||||
iA = pmul(iA, rd);
|
||||
iB = pmul(iB, rd);
|
||||
@@ -173,9 +182,9 @@ struct compute_inverse_size4<Architecture::Target, double, MatrixType, ResultTyp
|
||||
ResultAlignment = traits<ResultType>::Alignment,
|
||||
StorageOrdersMatch = (MatrixType::Flags & RowMajorBit) == (ResultType::Flags & RowMajorBit)
|
||||
};
|
||||
typedef typename conditional<(MatrixType::Flags & LinearAccessBit),
|
||||
MatrixType const &,
|
||||
typename MatrixType::PlainObject>::type
|
||||
typedef std::conditional_t<(MatrixType::Flags & LinearAccessBit),
|
||||
MatrixType const &,
|
||||
typename MatrixType::PlainObject>
|
||||
ActualMatrixType;
|
||||
|
||||
static void run(const MatrixType &mat, ResultType &result)
|
||||
@@ -326,10 +335,10 @@ struct compute_inverse_size4<Architecture::Target, double, MatrixType, ResultTyp
|
||||
iC1 = psub(pmul(B1, dC), iC1);
|
||||
iC2 = psub(pmul(B2, dC), iC2);
|
||||
|
||||
const double sign_mask1[2] = {0.0, numext::bit_cast<double>(0x8000000000000000ull)};
|
||||
const double sign_mask2[2] = {numext::bit_cast<double>(0x8000000000000000ull), 0.0};
|
||||
const Packet2d sign_PN = ploadu<Packet2d>(sign_mask1);
|
||||
const Packet2d sign_NP = ploadu<Packet2d>(sign_mask2);
|
||||
EIGEN_ALIGN_MAX const double sign_mask1[2] = {0.0, -0.0};
|
||||
EIGEN_ALIGN_MAX const double sign_mask2[2] = {-0.0, 0.0};
|
||||
const Packet2d sign_PN = pload<Packet2d>(sign_mask1);
|
||||
const Packet2d sign_NP = pload<Packet2d>(sign_mask2);
|
||||
d1 = pxor(rd, sign_PN);
|
||||
d2 = pxor(rd, sign_NP);
|
||||
|
||||
@@ -348,4 +357,9 @@ struct compute_inverse_size4<Architecture::Target, double, MatrixType, ResultTyp
|
||||
#endif
|
||||
} // namespace internal
|
||||
} // namespace Eigen
|
||||
|
||||
#if EIGEN_COMP_GNUC_STRICT
|
||||
#pragma GCC pop_options
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user