mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
907fba9ea9 | ||
|
|
7e0b7b1f25 | ||
|
|
5ac00624ed | ||
|
|
c0a0d2d181 | ||
|
|
ec39a39cb6 | ||
|
|
ccc6731f86 | ||
|
|
b09bb50aeb | ||
|
|
c7b8de77c0 | ||
|
|
c44bbabdcc | ||
|
|
468863f3a0 | ||
|
|
81f36b0e21 | ||
|
|
c196a49f67 |
@@ -7,7 +7,7 @@ set(INCLUDE_INSTALL_DIR
|
||||
"The directory where we install the header files"
|
||||
FORCE)
|
||||
|
||||
set(EIGEN_VERSION_NUMBER "2.0.14")
|
||||
set(EIGEN_VERSION_NUMBER "2.0.15")
|
||||
set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER}")
|
||||
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||
|
||||
@@ -139,7 +139,7 @@ inline bool MatrixBase<Derived>::any() const
|
||||
template<typename Derived>
|
||||
inline int MatrixBase<Derived>::count() const
|
||||
{
|
||||
return this->cast<bool>().cast<int>().sum();
|
||||
return this->cast<bool>().template cast<int>().sum();
|
||||
}
|
||||
|
||||
#endif // EIGEN_ALLANDANY_H
|
||||
|
||||
@@ -132,11 +132,12 @@ void LLT<MatrixType>::compute(const MatrixType& a)
|
||||
m_isInitialized = true;
|
||||
return;
|
||||
}
|
||||
m_matrix.col(0).end(size-1) = a.row(0).end(size-1).adjoint() / ei_real(m_matrix.coeff(0,0));
|
||||
if(ei_real(m_matrix.coeff(0,0))>0)
|
||||
m_matrix.col(0).end(size-1) = a.row(0).end(size-1).adjoint() / ei_real(m_matrix.coeff(0,0));
|
||||
for (int j = 1; j < size; ++j)
|
||||
{
|
||||
x = ei_real(a.coeff(j,j)) - m_matrix.row(j).start(j).squaredNorm();
|
||||
if (x < cutoff)
|
||||
if (x <= cutoff)
|
||||
{
|
||||
m_isPositiveDefinite = false;
|
||||
continue;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Eigen
|
||||
{
|
||||
|
||||
#define EIGEN_INSTANTIATE_PRODUCT(TYPE) \
|
||||
template static void ei_cache_friendly_product<TYPE>( \
|
||||
template void ei_cache_friendly_product<TYPE>( \
|
||||
int _rows, int _cols, int depth, \
|
||||
bool _lhsRowMajor, const TYPE* _lhs, int _lhsStride, \
|
||||
bool _rhsRowMajor, const TYPE* _rhs, int _rhsStride, \
|
||||
|
||||
@@ -35,16 +35,6 @@ template<typename T> inline T ei_random_amplitude()
|
||||
else return static_cast<T>(10);
|
||||
}
|
||||
|
||||
template<typename T> inline T ei_hypot(T x, T y)
|
||||
{
|
||||
T _x = ei_abs(x);
|
||||
T _y = ei_abs(y);
|
||||
T p = std::max(_x, _y);
|
||||
T q = std::min(_x, _y);
|
||||
T qp = q/p;
|
||||
return p * ei_sqrt(T(1) + qp*qp);
|
||||
}
|
||||
|
||||
/**************
|
||||
*** int ***
|
||||
**************/
|
||||
@@ -292,4 +282,14 @@ inline bool ei_isApproxOrLessThan(long double a, long double b, long double prec
|
||||
return a <= b || ei_isApprox(a, b, prec);
|
||||
}
|
||||
|
||||
template<typename T> inline T ei_hypot(T x, T y)
|
||||
{
|
||||
T _x = ei_abs(x);
|
||||
T _y = ei_abs(y);
|
||||
T p = std::max(_x, _y);
|
||||
T q = std::min(_x, _y);
|
||||
T qp = q/p;
|
||||
return p * ei_sqrt(T(1) + qp*qp);
|
||||
}
|
||||
|
||||
#endif // EIGEN_MATHFUNCTIONS_H
|
||||
|
||||
@@ -614,7 +614,7 @@ struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCo
|
||||
else
|
||||
{
|
||||
_res = ei_aligned_stack_new(Scalar, res.size());
|
||||
Map<Matrix<Scalar,DestDerived::SizeAtCompileTime,1,ColMajor> >(_res, res.size()) = res;
|
||||
Map<Matrix<Scalar,1,DestDerived::SizeAtCompileTime,ColMajor> >(_res, res.size()) = res;
|
||||
}
|
||||
ei_cache_friendly_product_colmajor_times_vector(res.size(),
|
||||
&product.rhs().const_cast_derived().coeffRef(0,0), product.rhs().stride(),
|
||||
@@ -622,7 +622,7 @@ struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCo
|
||||
|
||||
if (!EvalToRes)
|
||||
{
|
||||
res = Map<Matrix<Scalar,DestDerived::SizeAtCompileTime,1,ColMajor> >(_res, res.size());
|
||||
res = Map<Matrix<Scalar,1,DestDerived::SizeAtCompileTime,ColMajor> >(_res, res.size());
|
||||
ei_aligned_stack_delete(Scalar, _res, res.size());
|
||||
}
|
||||
}
|
||||
@@ -677,7 +677,7 @@ struct ei_cache_friendly_product_selector<ProductType,1,LhsOrder,LhsAccess,RhsCo
|
||||
else
|
||||
{
|
||||
_lhs = ei_aligned_stack_new(Scalar, product.lhs().size());
|
||||
Map<Matrix<Scalar,Lhs::SizeAtCompileTime,1,ColMajor> >(_lhs, product.lhs().size()) = product.lhs();
|
||||
Map<Matrix<Scalar,1,Lhs::SizeAtCompileTime,ColMajor> >(_lhs, product.lhs().size()) = product.lhs();
|
||||
}
|
||||
ei_cache_friendly_product_rowmajor_times_vector(&product.rhs().const_cast_derived().coeffRef(0,0), product.rhs().stride(),
|
||||
_lhs, product.lhs().size(), res);
|
||||
|
||||
@@ -35,7 +35,7 @@ template<typename Lhs, typename Rhs,
|
||||
? UpperTriangular
|
||||
: -1,
|
||||
int StorageOrder = ei_is_part<Lhs>::value ? -1 // this is to solve ambiguous specializations
|
||||
: int(Lhs::Flags) & (RowMajorBit|SparseBit)
|
||||
: int(Lhs::Flags) & int(RowMajorBit|SparseBit)
|
||||
>
|
||||
struct ei_solve_triangular_selector;
|
||||
|
||||
|
||||
@@ -114,13 +114,13 @@ template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const __m128&
|
||||
template<> EIGEN_STRONG_INLINE void ei_pstoreu<double>(double* to, const __m128d& from) { _mm_storeu_pd(to, from); }
|
||||
template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const __m128i& from) { _mm_storeu_si128(reinterpret_cast<__m128i*>(to), from); }
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1500) && defined(_WIN64)
|
||||
#if defined(_MSC_VER) && (_MSC_VER <= 1500) && defined(_WIN64) && !defined(__INTEL_COMPILER)
|
||||
// The temporary variable fixes an internal compilation error.
|
||||
// Direct of the struct members fixed bug #62.
|
||||
template<> EIGEN_STRONG_INLINE float ei_pfirst<__m128>(const __m128& a) { return a.m128_f32[0]; }
|
||||
template<> EIGEN_STRONG_INLINE double ei_pfirst<__m128d>(const __m128d& a) { return a.m128d_f64[0]; }
|
||||
template<> EIGEN_STRONG_INLINE int ei_pfirst<__m128i>(const __m128i& a) { int x = _mm_cvtsi128_si32(a); return x; }
|
||||
#elif defined(_MSC_VER) && (_MSC_VER <= 1500)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER <= 1500) && !defined(__INTEL_COMPILER)
|
||||
// The temporary variable fixes an internal compilation error.
|
||||
template<> EIGEN_STRONG_INLINE float ei_pfirst<__m128>(const __m128& a) { float x = _mm_cvtss_f32(a); return x; }
|
||||
template<> EIGEN_STRONG_INLINE double ei_pfirst<__m128d>(const __m128d& a) { double x = _mm_cvtsd_f64(a); return x; }
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#define EIGEN_WORLD_VERSION 2
|
||||
#define EIGEN_MAJOR_VERSION 0
|
||||
#define EIGEN_MINOR_VERSION 14
|
||||
#define EIGEN_MINOR_VERSION 15
|
||||
|
||||
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
|
||||
(EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
|
||||
|
||||
@@ -188,7 +188,8 @@ template<> inline void ei_conditional_aligned_free<false>(void *ptr)
|
||||
template<typename T> inline void ei_destruct_elements_of_array(T *ptr, std::size_t size)
|
||||
{
|
||||
// always destruct an array starting from the end.
|
||||
while(size) ptr[--size].~T();
|
||||
if(ptr)
|
||||
while(size) ptr[--size].~T();
|
||||
}
|
||||
|
||||
/** \internal delete objects constructed with ei_aligned_new
|
||||
|
||||
@@ -515,9 +515,10 @@ bool LU<MatrixType>::solve(
|
||||
if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c, m_precision))
|
||||
return false;
|
||||
}
|
||||
m_lu.corner(TopLeft, m_rank, m_rank)
|
||||
.template marked<UpperTriangular>()
|
||||
.solveTriangularInPlace(c.corner(TopLeft, m_rank, c.cols()));
|
||||
if(m_rank>0)
|
||||
m_lu.corner(TopLeft, m_rank, m_rank)
|
||||
.template marked<UpperTriangular>()
|
||||
.solveTriangularInPlace(c.corner(TopLeft, m_rank, c.cols()));
|
||||
|
||||
// Step 4
|
||||
result->resize(m_lu.cols(), b.cols());
|
||||
|
||||
@@ -270,12 +270,18 @@ bool QR<MatrixType>::solve(
|
||||
ei_assert(m_isInitialized && "QR is not initialized.");
|
||||
const int rows = m_qr.rows();
|
||||
ei_assert(b.rows() == rows);
|
||||
result->resize(rows, b.cols());
|
||||
// enforce the computation of the rank
|
||||
rank();
|
||||
|
||||
result->resize(m_qr.cols(), b.cols());
|
||||
|
||||
// TODO(keir): There is almost certainly a faster way to multiply by
|
||||
// Q^T without explicitly forming matrixQ(). Investigate.
|
||||
*result = matrixQ().transpose()*b;
|
||||
|
||||
|
||||
if(m_rank==0)
|
||||
return result->isZero();
|
||||
|
||||
if(!isSurjective())
|
||||
{
|
||||
// is result is in the image of R ?
|
||||
|
||||
@@ -124,4 +124,8 @@ void test_cholesky()
|
||||
CALL_SUBTEST( cholesky(MatrixXf(17,17)) );
|
||||
CALL_SUBTEST( cholesky(MatrixXd(33,33)) );
|
||||
}
|
||||
|
||||
MatrixXf m = MatrixXf::Zero(10,10);
|
||||
VectorXf b = VectorXf::Zero(10);
|
||||
VERIFY(!m.llt().isPositiveDefinite());
|
||||
}
|
||||
|
||||
@@ -132,4 +132,10 @@ void test_lu()
|
||||
CALL_SUBTEST( lu_invertible<MatrixXcf>() );
|
||||
CALL_SUBTEST( lu_invertible<MatrixXcd>() );
|
||||
}
|
||||
|
||||
MatrixXf m = MatrixXf::Zero(10,10);
|
||||
VectorXf b = VectorXf::Zero(10);
|
||||
VectorXf x = VectorXf::Random(10);
|
||||
VERIFY(m.lu().solve(b,&x));
|
||||
VERIFY(x.isZero());
|
||||
}
|
||||
|
||||
@@ -48,4 +48,11 @@ void test_product_large()
|
||||
MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a;
|
||||
VERIFY_IS_APPROX((a = a * b), (c * b).eval());
|
||||
}
|
||||
|
||||
{
|
||||
MatrixXf mat1(10,10); mat1.setRandom();
|
||||
MatrixXf mat2(32,10); mat2.setRandom();
|
||||
MatrixXf result = mat1.row(2)*mat2.transpose();
|
||||
VERIFY_IS_APPROX(result, (mat1.row(2)*mat2.transpose()).eval());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,4 +75,11 @@ void test_qr()
|
||||
mat << 1, 1, 1, 2, 2, 2, 1, 2, 3;
|
||||
VERIFY(!mat.qr().isFullRank());
|
||||
}
|
||||
{
|
||||
MatrixXf m = MatrixXf::Zero(10,10);
|
||||
VectorXf b = VectorXf::Zero(10);
|
||||
VectorXf x = VectorXf::Random(10);
|
||||
VERIFY(m.qr().solve(b,&x));
|
||||
VERIFY(x.isZero());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user