mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-11-27 06:30:28 +08:00
Avoid I
as an identifier, since it may clash with the C-header complex.h
This commit is contained in:
parent
ec8a387972
commit
934b8a1304
@ -10,11 +10,11 @@
|
||||
#include "sparse_solver.h"
|
||||
#include <Eigen/IterativeLinearSolvers>
|
||||
|
||||
template<typename T, typename I> void test_bicgstab_T()
|
||||
template<typename T, typename I_> void test_bicgstab_T()
|
||||
{
|
||||
BiCGSTAB<SparseMatrix<T,0,I>, DiagonalPreconditioner<T> > bicgstab_colmajor_diag;
|
||||
BiCGSTAB<SparseMatrix<T,0,I>, IdentityPreconditioner > bicgstab_colmajor_I;
|
||||
BiCGSTAB<SparseMatrix<T,0,I>, IncompleteLUT<T,I> > bicgstab_colmajor_ilut;
|
||||
BiCGSTAB<SparseMatrix<T,0,I_>, DiagonalPreconditioner<T> > bicgstab_colmajor_diag;
|
||||
BiCGSTAB<SparseMatrix<T,0,I_>, IdentityPreconditioner > bicgstab_colmajor_I;
|
||||
BiCGSTAB<SparseMatrix<T,0,I_>, IncompleteLUT<T,I_> > bicgstab_colmajor_ilut;
|
||||
//BiCGSTAB<SparseMatrix<T>, SSORPreconditioner<T> > bicgstab_colmajor_ssor;
|
||||
|
||||
bicgstab_colmajor_diag.setTolerance(NumTraits<T>::epsilon()*4);
|
||||
|
@ -66,6 +66,7 @@
|
||||
#undef isnan
|
||||
#undef isinf
|
||||
#undef isfinite
|
||||
#undef I
|
||||
|
||||
#include <boost/multiprecision/cpp_dec_float.hpp>
|
||||
#include <boost/multiprecision/number.hpp>
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include "sparse_solver.h"
|
||||
#include <Eigen/IterativeLinearSolvers>
|
||||
|
||||
template<typename T, typename I> void test_conjugate_gradient_T()
|
||||
template<typename T, typename I_> void test_conjugate_gradient_T()
|
||||
{
|
||||
typedef SparseMatrix<T,0,I> SparseMatrixType;
|
||||
typedef SparseMatrix<T,0,I_> SparseMatrixType;
|
||||
ConjugateGradient<SparseMatrixType, Lower > cg_colmajor_lower_diag;
|
||||
ConjugateGradient<SparseMatrixType, Upper > cg_colmajor_upper_diag;
|
||||
ConjugateGradient<SparseMatrixType, Lower|Upper> cg_colmajor_loup_diag;
|
||||
|
@ -12,14 +12,14 @@
|
||||
#include <Eigen/IterativeLinearSolvers>
|
||||
#include <unsupported/Eigen/IterativeSolvers>
|
||||
|
||||
template<typename T, typename I> void test_incomplete_cholesky_T()
|
||||
template<typename T, typename I_> void test_incomplete_cholesky_T()
|
||||
{
|
||||
typedef SparseMatrix<T,0,I> SparseMatrixType;
|
||||
ConjugateGradient<SparseMatrixType, Lower, IncompleteCholesky<T, Lower, AMDOrdering<I> > > cg_illt_lower_amd;
|
||||
ConjugateGradient<SparseMatrixType, Lower, IncompleteCholesky<T, Lower, NaturalOrdering<I> > > cg_illt_lower_nat;
|
||||
ConjugateGradient<SparseMatrixType, Upper, IncompleteCholesky<T, Upper, AMDOrdering<I> > > cg_illt_upper_amd;
|
||||
ConjugateGradient<SparseMatrixType, Upper, IncompleteCholesky<T, Upper, NaturalOrdering<I> > > cg_illt_upper_nat;
|
||||
ConjugateGradient<SparseMatrixType, Upper|Lower, IncompleteCholesky<T, Lower, AMDOrdering<I> > > cg_illt_uplo_amd;
|
||||
typedef SparseMatrix<T,0,I_> SparseMatrixType;
|
||||
ConjugateGradient<SparseMatrixType, Lower, IncompleteCholesky<T, Lower, AMDOrdering<I_> > > cg_illt_lower_amd;
|
||||
ConjugateGradient<SparseMatrixType, Lower, IncompleteCholesky<T, Lower, NaturalOrdering<I_> > > cg_illt_lower_nat;
|
||||
ConjugateGradient<SparseMatrixType, Upper, IncompleteCholesky<T, Upper, AMDOrdering<I_> > > cg_illt_upper_amd;
|
||||
ConjugateGradient<SparseMatrixType, Upper, IncompleteCholesky<T, Upper, NaturalOrdering<I_> > > cg_illt_upper_nat;
|
||||
ConjugateGradient<SparseMatrixType, Upper|Lower, IncompleteCholesky<T, Lower, AMDOrdering<I_> > > cg_illt_uplo_amd;
|
||||
|
||||
|
||||
CALL_SUBTEST( check_sparse_spd_solving(cg_illt_lower_amd) );
|
||||
|
@ -335,8 +335,8 @@ void check_indexed_view()
|
||||
VERIFY_IS_APPROX( A(B.RowsAtCompileTime, 1), A(4,1) );
|
||||
VERIFY_IS_APPROX( A(B.RowsAtCompileTime-1, B.ColsAtCompileTime-1), A(3,3) );
|
||||
VERIFY_IS_APPROX( A(B.RowsAtCompileTime, B.ColsAtCompileTime), A(4,4) );
|
||||
const Index I = 3, J = 4;
|
||||
VERIFY_IS_APPROX( A(I,J), A(3,4) );
|
||||
const Index I_ = 3, J_ = 4;
|
||||
VERIFY_IS_APPROX( A(I_,J_), A(3,4) );
|
||||
}
|
||||
|
||||
// check extended block API
|
||||
|
@ -97,6 +97,8 @@
|
||||
#define FORBIDDEN_IDENTIFIER (this_identifier_is_forbidden_to_avoid_clashes) this_identifier_is_forbidden_to_avoid_clashes
|
||||
// B0 is defined in POSIX header termios.h
|
||||
#define B0 FORBIDDEN_IDENTIFIER
|
||||
// `I` may be defined by complex.h:
|
||||
#define I FORBIDDEN_IDENTIFIER
|
||||
|
||||
// Unit tests calling Eigen's blas library must preserve the default blocking size
|
||||
// to avoid troubles.
|
||||
|
@ -9,17 +9,17 @@
|
||||
|
||||
#include "sparse_solver.h"
|
||||
|
||||
template<typename T, typename I> void test_simplicial_cholesky_T()
|
||||
template<typename T, typename I_> void test_simplicial_cholesky_T()
|
||||
{
|
||||
typedef SparseMatrix<T,0,I> SparseMatrixType;
|
||||
typedef SparseMatrix<T,0,I_> SparseMatrixType;
|
||||
SimplicialCholesky<SparseMatrixType, Lower> chol_colmajor_lower_amd;
|
||||
SimplicialCholesky<SparseMatrixType, Upper> chol_colmajor_upper_amd;
|
||||
SimplicialLLT< SparseMatrixType, Lower> llt_colmajor_lower_amd;
|
||||
SimplicialLLT< SparseMatrixType, Upper> llt_colmajor_upper_amd;
|
||||
SimplicialLDLT< SparseMatrixType, Lower> ldlt_colmajor_lower_amd;
|
||||
SimplicialLDLT< SparseMatrixType, Upper> ldlt_colmajor_upper_amd;
|
||||
SimplicialLDLT< SparseMatrixType, Lower, NaturalOrdering<I> > ldlt_colmajor_lower_nat;
|
||||
SimplicialLDLT< SparseMatrixType, Upper, NaturalOrdering<I> > ldlt_colmajor_upper_nat;
|
||||
SimplicialLDLT< SparseMatrixType, Lower, NaturalOrdering<I_> > ldlt_colmajor_lower_nat;
|
||||
SimplicialLDLT< SparseMatrixType, Upper, NaturalOrdering<I_> > ldlt_colmajor_upper_nat;
|
||||
|
||||
check_sparse_spd_solving(chol_colmajor_lower_amd);
|
||||
check_sparse_spd_solving(chol_colmajor_upper_amd);
|
||||
|
@ -47,9 +47,9 @@ namespace internal {
|
||||
*/
|
||||
|
||||
|
||||
template<std::size_t I, class T> constexpr inline T& array_get(std::vector<T>& a) { return a[I]; }
|
||||
template<std::size_t I, class T> constexpr inline T&& array_get(std::vector<T>&& a) { return a[I]; }
|
||||
template<std::size_t I, class T> constexpr inline T const& array_get(std::vector<T> const& a) { return a[I]; }
|
||||
template<std::size_t I_, class T> constexpr inline T& array_get(std::vector<T>& a) { return a[I_]; }
|
||||
template<std::size_t I_, class T> constexpr inline T&& array_get(std::vector<T>&& a) { return a[I_]; }
|
||||
template<std::size_t I_, class T> constexpr inline T const& array_get(std::vector<T> const& a) { return a[I_]; }
|
||||
|
||||
/* Suppose you have a template of the form
|
||||
* template<typename T> struct X;
|
||||
|
@ -197,13 +197,13 @@ EIGEN_DEVICE_FUNC bool operator==(const array<T,N>& lhs, const array<T,N>& rhs)
|
||||
|
||||
|
||||
namespace internal {
|
||||
template<std::size_t I, class T, std::size_t N>
|
||||
template<std::size_t I_, class T, std::size_t N>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& array_get(array<T,N>& a) {
|
||||
return a[I];
|
||||
return a[I_];
|
||||
}
|
||||
template<std::size_t I, class T, std::size_t N>
|
||||
template<std::size_t I_, class T, std::size_t N>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& array_get(const array<T,N>& a) {
|
||||
return a[I];
|
||||
return a[I_];
|
||||
}
|
||||
|
||||
template<class T, std::size_t N> struct array_size<array<T,N> > {
|
||||
@ -240,16 +240,16 @@ namespace internal {
|
||||
* this may not be constexpr
|
||||
*/
|
||||
#if defined(__GLIBCXX__) && __GLIBCXX__ < 20120322
|
||||
#define STD_GET_ARR_HACK a._M_instance[I]
|
||||
#define STD_GET_ARR_HACK a._M_instance[I_]
|
||||
#elif defined(_LIBCPP_VERSION)
|
||||
#define STD_GET_ARR_HACK a.__elems_[I]
|
||||
#define STD_GET_ARR_HACK a.__elems_[I_]
|
||||
#else
|
||||
#define STD_GET_ARR_HACK std::template get<I, T, N>(a)
|
||||
#define STD_GET_ARR_HACK std::template get<I_, T, N>(a)
|
||||
#endif
|
||||
|
||||
template<std::size_t I, class T, std::size_t N> constexpr inline T& array_get(std::array<T,N>& a) { return (T&) STD_GET_ARR_HACK; }
|
||||
template<std::size_t I, class T, std::size_t N> constexpr inline T&& array_get(std::array<T,N>&& a) { return (T&&) STD_GET_ARR_HACK; }
|
||||
template<std::size_t I, class T, std::size_t N> constexpr inline T const& array_get(std::array<T,N> const& a) { return (T const&) STD_GET_ARR_HACK; }
|
||||
template<std::size_t I_, class T, std::size_t N> constexpr inline T& array_get(std::array<T,N>& a) { return (T&) STD_GET_ARR_HACK; }
|
||||
template<std::size_t I_, class T, std::size_t N> constexpr inline T&& array_get(std::array<T,N>&& a) { return (T&&) STD_GET_ARR_HACK; }
|
||||
template<std::size_t I_, class T, std::size_t N> constexpr inline T const& array_get(std::array<T,N> const& a) { return (T const&) STD_GET_ARR_HACK; }
|
||||
|
||||
#undef STD_GET_ARR_HACK
|
||||
|
||||
|
@ -166,13 +166,13 @@ array<t, n> repeat(t v) {
|
||||
return array;
|
||||
}
|
||||
|
||||
template<std::size_t I, class Head, class Tail>
|
||||
template<std::size_t I_, class Head, class Tail>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename Head::type array_get(type_list<Head, Tail>&) {
|
||||
return get<I, type_list<Head, Tail> >::value;
|
||||
return get<I_, type_list<Head, Tail> >::value;
|
||||
}
|
||||
template<std::size_t I, class Head, class Tail>
|
||||
template<std::size_t I_, class Head, class Tail>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename Head::type array_get(const type_list<Head, Tail>&) {
|
||||
return get<I, type_list<Head, Tail> >::value;
|
||||
return get<I_, type_list<Head, Tail> >::value;
|
||||
}
|
||||
|
||||
template <class NList>
|
||||
@ -200,13 +200,13 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const std::vector<t>& a) {
|
||||
}
|
||||
|
||||
|
||||
template<std::size_t I, class T>
|
||||
template<std::size_t I_, class T>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& array_get(std::vector<T>& a) {
|
||||
return a[I];
|
||||
return a[I_];
|
||||
}
|
||||
template<std::size_t I, class T>
|
||||
template<std::size_t I_, class T>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& array_get(const std::vector<T>& a) {
|
||||
return a[I];
|
||||
return a[I_];
|
||||
}
|
||||
|
||||
struct sum_op {
|
||||
|
@ -177,9 +177,9 @@ namespace Eigen
|
||||
// I, J, K are the pivot indexes permutation for the rotation matrix, that match this Euler system.
|
||||
// They are used in this class converters.
|
||||
// They are always different from each other, and their possible values are: 0, 1, or 2.
|
||||
I = AlphaAxisAbs - 1,
|
||||
J = (AlphaAxisAbs - 1 + 1 + IsOdd)%3,
|
||||
K = (AlphaAxisAbs - 1 + 2 - IsOdd)%3
|
||||
I_ = AlphaAxisAbs - 1,
|
||||
J_ = (AlphaAxisAbs - 1 + 1 + IsOdd)%3,
|
||||
K_ = (AlphaAxisAbs - 1 + 2 - IsOdd)%3
|
||||
;
|
||||
|
||||
// TODO: Get @mat parameter in form that avoids double evaluation.
|
||||
@ -194,24 +194,24 @@ namespace Eigen
|
||||
const Scalar plusMinus = IsEven? 1 : -1;
|
||||
const Scalar minusPlus = IsOdd? 1 : -1;
|
||||
|
||||
const Scalar Rsum = sqrt((mat(I,I) * mat(I,I) + mat(I,J) * mat(I,J) + mat(J,K) * mat(J,K) + mat(K,K) * mat(K,K))/2);
|
||||
res[1] = atan2(plusMinus * mat(I,K), Rsum);
|
||||
const Scalar Rsum = sqrt((mat(I_,I_) * mat(I_,I_) + mat(I_,J_) * mat(I_,J_) + mat(J_,K_) * mat(J_,K_) + mat(K_,K_) * mat(K_,K_))/2);
|
||||
res[1] = atan2(plusMinus * mat(I_,K_), Rsum);
|
||||
|
||||
// There is a singularity when cos(beta) == 0
|
||||
if(Rsum > 4 * NumTraits<Scalar>::epsilon()) {// cos(beta) != 0
|
||||
res[0] = atan2(minusPlus * mat(J, K), mat(K, K));
|
||||
res[2] = atan2(minusPlus * mat(I, J), mat(I, I));
|
||||
res[0] = atan2(minusPlus * mat(J_, K_), mat(K_, K_));
|
||||
res[2] = atan2(minusPlus * mat(I_, J_), mat(I_, I_));
|
||||
}
|
||||
else if(plusMinus * mat(I, K) > 0) {// cos(beta) == 0 and sin(beta) == 1
|
||||
Scalar spos = mat(J, I) + plusMinus * mat(K, J); // 2*sin(alpha + plusMinus * gamma
|
||||
Scalar cpos = mat(J, J) + minusPlus * mat(K, I); // 2*cos(alpha + plusMinus * gamma)
|
||||
else if(plusMinus * mat(I_, K_) > 0) {// cos(beta) == 0 and sin(beta) == 1
|
||||
Scalar spos = mat(J_, I_) + plusMinus * mat(K_, J_); // 2*sin(alpha + plusMinus * gamma
|
||||
Scalar cpos = mat(J_, J_) + minusPlus * mat(K_, I_); // 2*cos(alpha + plusMinus * gamma)
|
||||
Scalar alphaPlusMinusGamma = atan2(spos, cpos);
|
||||
res[0] = alphaPlusMinusGamma;
|
||||
res[2] = 0;
|
||||
}
|
||||
else {// cos(beta) == 0 and sin(beta) == -1
|
||||
Scalar sneg = plusMinus * (mat(K, J) + minusPlus * mat(J, I)); // 2*sin(alpha + minusPlus*gamma)
|
||||
Scalar cneg = mat(J, J) + plusMinus * mat(K, I); // 2*cos(alpha + minusPlus*gamma)
|
||||
Scalar sneg = plusMinus * (mat(K_, J_) + minusPlus * mat(J_, I_)); // 2*sin(alpha + minusPlus*gamma)
|
||||
Scalar cneg = mat(J_, J_) + plusMinus * mat(K_, I_); // 2*cos(alpha + minusPlus*gamma)
|
||||
Scalar alphaMinusPlusBeta = atan2(sneg, cneg);
|
||||
res[0] = alphaMinusPlusBeta;
|
||||
res[2] = 0;
|
||||
@ -230,24 +230,24 @@ namespace Eigen
|
||||
const Scalar plusMinus = IsEven? 1 : -1;
|
||||
const Scalar minusPlus = IsOdd? 1 : -1;
|
||||
|
||||
const Scalar Rsum = sqrt((mat(I, J) * mat(I, J) + mat(I, K) * mat(I, K) + mat(J, I) * mat(J, I) + mat(K, I) * mat(K, I)) / 2);
|
||||
const Scalar Rsum = sqrt((mat(I_, J_) * mat(I_, J_) + mat(I_, K_) * mat(I_, K_) + mat(J_, I_) * mat(J_, I_) + mat(K_, I_) * mat(K_, I_)) / 2);
|
||||
|
||||
res[1] = atan2(Rsum, mat(I, I));
|
||||
res[1] = atan2(Rsum, mat(I_, I_));
|
||||
|
||||
// There is a singularity when sin(beta) == 0
|
||||
if(Rsum > 4 * NumTraits<Scalar>::epsilon()) {// sin(beta) != 0
|
||||
res[0] = atan2(mat(J, I), minusPlus * mat(K, I));
|
||||
res[2] = atan2(mat(I, J), plusMinus * mat(I, K));
|
||||
res[0] = atan2(mat(J_, I_), minusPlus * mat(K_, I_));
|
||||
res[2] = atan2(mat(I_, J_), plusMinus * mat(I_, K_));
|
||||
}
|
||||
else if(mat(I, I) > 0) {// sin(beta) == 0 and cos(beta) == 1
|
||||
Scalar spos = plusMinus * mat(K, J) + minusPlus * mat(J, K); // 2*sin(alpha + gamma)
|
||||
Scalar cpos = mat(J, J) + mat(K, K); // 2*cos(alpha + gamma)
|
||||
else if(mat(I_, I_) > 0) {// sin(beta) == 0 and cos(beta) == 1
|
||||
Scalar spos = plusMinus * mat(K_, J_) + minusPlus * mat(J_, K_); // 2*sin(alpha + gamma)
|
||||
Scalar cpos = mat(J_, J_) + mat(K_, K_); // 2*cos(alpha + gamma)
|
||||
res[0] = atan2(spos, cpos);
|
||||
res[2] = 0;
|
||||
}
|
||||
else {// sin(beta) == 0 and cos(beta) == -1
|
||||
Scalar sneg = plusMinus * mat(K, J) + plusMinus * mat(J, K); // 2*sin(alpha - gamma)
|
||||
Scalar cneg = mat(J, J) - mat(K, K); // 2*cos(alpha - gamma)
|
||||
Scalar sneg = plusMinus * mat(K_, J_) + plusMinus * mat(J_, K_); // 2*sin(alpha - gamma)
|
||||
Scalar cneg = mat(J_, J_) - mat(K_, K_); // 2*cos(alpha - gamma)
|
||||
res[0] = atan2(sneg, cneg);
|
||||
res[2] = 0;
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ void verify_euler(const EulerAngles<Scalar, EulerSystem>& e)
|
||||
}
|
||||
}
|
||||
|
||||
const Vector3 I = EulerAnglesType::AlphaAxisVector();
|
||||
const Vector3 J = EulerAnglesType::BetaAxisVector();
|
||||
const Vector3 K = EulerAnglesType::GammaAxisVector();
|
||||
const Vector3 I_ = EulerAnglesType::AlphaAxisVector();
|
||||
const Vector3 J_ = EulerAnglesType::BetaAxisVector();
|
||||
const Vector3 K_ = EulerAnglesType::GammaAxisVector();
|
||||
|
||||
// Is approx checks
|
||||
VERIFY(e.isApprox(e));
|
||||
@ -97,7 +97,7 @@ void verify_euler(const EulerAngles<Scalar, EulerSystem>& e)
|
||||
VERIFY_APPROXED_RANGE(betaRangeStart, ebis.beta(), betaRangeEnd);
|
||||
VERIFY_APPROXED_RANGE(-PI, ebis.gamma(), PI);
|
||||
|
||||
const Matrix3 mbis(AngleAxisType(ebis.alpha(), I) * AngleAxisType(ebis.beta(), J) * AngleAxisType(ebis.gamma(), K));
|
||||
const Matrix3 mbis(AngleAxisType(ebis.alpha(), I_) * AngleAxisType(ebis.beta(), J_) * AngleAxisType(ebis.gamma(), K_));
|
||||
VERIFY_IS_APPROX(Scalar(mbis.determinant()), ONE);
|
||||
VERIFY_IS_APPROX(mbis, ebis.toRotationMatrix());
|
||||
/*std::cout << "===================\n" <<
|
||||
|
Loading…
Reference in New Issue
Block a user