13 template<
typename MatrixType>
17 Scalar
zero =
static_cast<Scalar
>(0);
19 bool offDiagOK =
true;
20 for (
Index i = 0;
i < A.rows(); ++
i) {
22 offDiagOK = offDiagOK && (
A(
i,
j) ==
zero);
25 for (
Index i = 0;
i < A.rows(); ++
i) {
27 offDiagOK = offDiagOK && (
A(
i,
j) ==
zero);
31 bool diagOK = (A.diagonal().array() == 1).all();
32 return offDiagOK && diagOK;
36 template<
typename VectorType>
56 std::cout <<
v(
i) <<
" != " << ref <<
" ; relative error: " <<
std::abs((
v(
i)-ref)/ref) <<
" ; required precision: " << prec <<
" ; range: " << low <<
"," << high <<
" ; i: " <<
i <<
"\n";
63 template<
typename VectorType>
71 Scalar high = internal::random<Scalar>(-500,500);
72 Scalar low = (size == 1 ? high : internal::random<Scalar>(-500,500));
76 if(internal::random<float>(0.
f,1.
f)<0.05
f)
79 else if(size>2 && std::numeric_limits<RealScalar>::max_exponent10>0 && internal::random<float>(0.
f,1.
f)<0.1
f)
82 const Scalar
step = ((size == 1) ? 1 : (high-low)/(size-1));
86 m.setLinSpaced(size,low,high);
103 n(
i) = size==1 ? low : (low + ((high-low)*
Scalar(
i))/(size-1));
106 n(
i) = size==1 ? low : low +
Scalar((
double(high-low+1)*
double(
i))/
double(size));
110 m = VectorType::LinSpaced(size,low,high);
119 VERIFY(
m(m.size()-1) <= high );
120 VERIFY( (m.array() <= high).all() );
121 VERIFY( (m.array() >= low).all() );
124 VERIFY(
m(m.size()-1) >= low );
134 row_vector.setLinSpaced(size,low,high);
135 col_vector.setLinSpaced(size,low,high);
141 size_changer.setLinSpaced(size,low,high);
146 scalar.setLinSpaced(1,low,high);
148 VERIFY_IS_APPROX( ScalarMatrix::LinSpaced(1,low,high), ScalarMatrix::Constant(high) );
152 m.tail(size-1).setLinSpaced(low, high);
158 Index n0 = VectorType::SizeAtCompileTime==
Dynamic ? 0 : VectorType::SizeAtCompileTime;
159 low = internal::random<Scalar>();
160 m = VectorType::LinSpaced(n0,low,low-1);
163 if(VectorType::SizeAtCompileTime==
Dynamic)
169 m.setLinSpaced(n0,0,
Scalar(n0-1));
171 m.setLinSpaced(n0,low,low-1);
175 VERIFY_IS_APPROX(VectorType::LinSpaced(size,low,low),VectorType::Constant(size,low));
176 m.setLinSpaced(size,low,low);
183 if(VectorType::SizeAtCompileTime==
Dynamic)
186 for(
Index k=1; k<5; ++k)
189 for(
Index k=1; k<5; ++k)
196 template<
typename MatrixType>
207 s1 = internal::random<Scalar>();
211 A.setIdentity(rows, cols);
216 A = MatrixType::Constant(rows,cols,s1);
217 Index i = internal::random<Index>(0,rows-1);
218 Index j = internal::random<Index>(0,cols-1);
227 CALL_SUBTEST_2(
testMatrixType(MatrixXcf(internal::random<int>(1,300),internal::random<int>(1,300))) );
228 CALL_SUBTEST_3(
testMatrixType(MatrixXf(internal::random<int>(1,300),internal::random<int>(1,300))) );
231 CALL_SUBTEST_4(
testVectorType(VectorXd(internal::random<int>(1,30000))) );
234 CALL_SUBTEST_7(
testVectorType(VectorXf(internal::random<int>(1,30000))) );
240 CALL_SUBTEST_9(
testVectorType(VectorXi(internal::random<int>(1,10))) );
241 CALL_SUBTEST_9(
testVectorType(VectorXi(internal::random<int>(9,300))) );
245 #ifdef EIGEN_TEST_PART_6 250 #ifdef EIGEN_TEST_PART_9 254 ArrayXi a1(n), a2(n);
255 a1.setLinSpaced(n, 0, n-1);
256 for(
int i=0;
i<
n; ++
i)
262 #ifdef EIGEN_TEST_PART_10 264 VERIFY(( internal::has_nullary_operator<internal::scalar_constant_op<double> >::
value ));
265 VERIFY(( !internal::has_unary_operator<internal::scalar_constant_op<double> >::
value ));
266 VERIFY(( !internal::has_binary_operator<internal::scalar_constant_op<double> >::
value ));
267 VERIFY(( internal::functor_has_linear_access<internal::scalar_constant_op<double> >::
ret ));
269 VERIFY(( !internal::has_nullary_operator<internal::scalar_identity_op<double> >::
value ));
270 VERIFY(( !internal::has_unary_operator<internal::scalar_identity_op<double> >::
value ));
271 VERIFY(( internal::has_binary_operator<internal::scalar_identity_op<double> >::
value ));
272 VERIFY(( !internal::functor_has_linear_access<internal::scalar_identity_op<double> >::
ret ));
274 VERIFY(( !internal::has_nullary_operator<internal::linspaced_op<float,float> >::
value ));
275 VERIFY(( internal::has_unary_operator<internal::linspaced_op<float,float> >::
value ));
276 VERIFY(( !internal::has_binary_operator<internal::linspaced_op<float,float> >::
value ));
277 VERIFY(( internal::functor_has_linear_access<internal::linspaced_op<float,float> >::
ret ));
283 MatrixXf
A = MatrixXf::Random(3,3);
289 VectorXi
V = VectorXi::Random(3);
293 VERIFY(( internal::has_nullary_operator<internal::scalar_constant_op<float> >::
value ));
294 VERIFY(( !internal::has_unary_operator<internal::scalar_constant_op<float> >::
value ));
295 VERIFY(( !internal::has_binary_operator<internal::scalar_constant_op<float> >::
value ));
296 VERIFY(( internal::functor_has_linear_access<internal::scalar_constant_op<float> >::
ret ));
298 VERIFY(( !internal::has_nullary_operator<internal::linspaced_op<int,int> >::
value ));
299 VERIFY(( internal::has_unary_operator<internal::linspaced_op<int,int> >::
value ));
300 VERIFY(( !internal::has_binary_operator<internal::linspaced_op<int,int> >::
value ));
301 VERIFY(( internal::functor_has_linear_access<internal::linspaced_op<int,int> >::
ret ));
def step(data, isam, result, truth, currPoseIndex)
EIGEN_DONT_INLINE Scalar zero()
Rot2 R(Rot2::fromAngle(0.1))
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Matrix< SCALARA, Dynamic, Dynamic > A
void check_extremity_accuracy(const VectorType &v, const typename VectorType::Scalar &low, const typename VectorType::Scalar &high)
#define VERIFY_IS_APPROX(a, b)
#define VERIFY_IS_EQUAL(a, b)
bool equalsIdentity(const MatrixType &A)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
void testMatrixType(const MatrixType &m)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
Q R1(Eigen::AngleAxisd(1, Q_z_axis))
NumTraits< Scalar >::Real RealScalar
A matrix or vector expression mapping an existing expression.
#define CALL_SUBTEST(FUNC)
void reverse(const MatrixType &m)
Annotation indicating that a class derives from another given type.
Jet< T, N > pow(const Jet< T, N > &f, double g)
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
mxArray * scalar(mxClassID classid)
Q R2(Eigen::AngleAxisd(2, Vector3(0, 1, 0)))
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
void testVectorType(const VectorType &base)