mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
More Index related stuff.
This commit is contained in:
@@ -50,8 +50,8 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
|
||||
Scalar x = ei_random<Scalar>();
|
||||
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
Index r = ei_random<Index>(0, rows-1),
|
||||
c = ei_random<Index>(0, cols-1);
|
||||
|
||||
m1.coeffRef(r,c) = x;
|
||||
VERIFY_IS_APPROX(x, m1.coeff(r,c));
|
||||
|
||||
@@ -60,8 +60,8 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
vones = VectorType::Ones(rows),
|
||||
v3(rows);
|
||||
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
Index r = ei_random<Index>(0, rows-1),
|
||||
c = ei_random<Index>(0, cols-1);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ template<typename MatrixType> void determinant(const MatrixType& m)
|
||||
/* this test covers the following files:
|
||||
Determinant.h
|
||||
*/
|
||||
int size = m.rows();
|
||||
typedef typename MatrixType::Index Index;
|
||||
Index size = m.rows();
|
||||
|
||||
MatrixType m1(size, size), m2(size, size);
|
||||
m1.setRandom();
|
||||
@@ -41,10 +42,10 @@ template<typename MatrixType> void determinant(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(MatrixType::Identity(size, size).determinant(), Scalar(1));
|
||||
VERIFY_IS_APPROX((m1*m2).eval().determinant(), m1.determinant() * m2.determinant());
|
||||
if(size==1) return;
|
||||
int i = ei_random<int>(0, size-1);
|
||||
int j;
|
||||
Index i = ei_random<Index>(0, size-1);
|
||||
Index j;
|
||||
do {
|
||||
j = ei_random<int>(0, size-1);
|
||||
j = ei_random<Index>(0, size-1);
|
||||
} while(j==i);
|
||||
m2 = m1;
|
||||
m2.row(i).swap(m2.row(j));
|
||||
|
||||
@@ -66,8 +66,8 @@ template<typename MatrixType> void diagonalmatrices(const MatrixType& m)
|
||||
sq_m1.transpose() = ldm1;
|
||||
VERIFY_IS_APPROX(sq_m1, ldm1.toDenseMatrix());
|
||||
|
||||
int i = ei_random<int>(0, rows-1);
|
||||
int j = ei_random<int>(0, cols-1);
|
||||
Index i = ei_random<Index>(0, rows-1);
|
||||
Index j = ei_random<Index>(0, cols-1);
|
||||
|
||||
VERIFY_IS_APPROX( ((ldm1 * m1)(i,j)) , ldm1.diagonal()(i) * m1(i,j) );
|
||||
VERIFY_IS_APPROX( ((ldm1 * (m1+m2))(i,j)) , ldm1.diagonal()(i) * (m1+m2)(i,j) );
|
||||
|
||||
@@ -35,8 +35,8 @@ template<typename BoxType> void alignedbox(const BoxType& _box)
|
||||
/* this test covers the following files:
|
||||
AlignedBox.h
|
||||
*/
|
||||
|
||||
const int dim = _box.dim();
|
||||
typedef typename BoxType::Index Index;
|
||||
const Index dim = _box.dim();
|
||||
typedef typename BoxType::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
|
||||
|
||||
@@ -33,8 +33,8 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
|
||||
/* this test covers the following files:
|
||||
Hyperplane.h
|
||||
*/
|
||||
|
||||
const int dim = _plane.dim();
|
||||
typedef typename HyperplaneType::Index Index;
|
||||
const Index dim = _plane.dim();
|
||||
typedef typename HyperplaneType::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime, 1> VectorType;
|
||||
|
||||
@@ -33,8 +33,8 @@ template<typename LineType> void parametrizedline(const LineType& _line)
|
||||
/* this test covers the following files:
|
||||
ParametrizedLine.h
|
||||
*/
|
||||
|
||||
const int dim = _line.dim();
|
||||
typedef typename LineType::Index Index;
|
||||
const Index dim = _line.dim();
|
||||
typedef typename LineType::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime, 1> VectorType;
|
||||
|
||||
@@ -45,8 +45,8 @@ template<typename MatrixType> void linearStructure(const MatrixType& m)
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
while (ei_abs(s1)<1e-3) s1 = ei_random<Scalar>();
|
||||
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
Index r = ei_random<Index>(0, rows-1),
|
||||
c = ei_random<Index>(0, cols-1);
|
||||
|
||||
VERIFY_IS_APPROX(-(-m1), m1);
|
||||
VERIFY_IS_APPROX(m1+m1, 2*m1);
|
||||
|
||||
@@ -82,9 +82,10 @@ template<typename MatrixType> void map_class_matrix(const MatrixType& m)
|
||||
|
||||
template<typename VectorType> void map_static_methods(const VectorType& m)
|
||||
{
|
||||
typedef typename VectorType::Index Index;
|
||||
typedef typename VectorType::Scalar Scalar;
|
||||
|
||||
int size = m.size();
|
||||
Index size = m.size();
|
||||
|
||||
// test Map.h
|
||||
Scalar* array1 = ei_aligned_new<Scalar>(size);
|
||||
|
||||
@@ -26,13 +26,14 @@
|
||||
|
||||
template<typename VectorType> void map_class_vector(const VectorType& m)
|
||||
{
|
||||
typedef typename VectorType::Index Index;
|
||||
typedef typename VectorType::Scalar Scalar;
|
||||
|
||||
int size = m.size();
|
||||
Index size = m.size();
|
||||
|
||||
VectorType v = VectorType::Random(size);
|
||||
|
||||
int arraysize = 3*size;
|
||||
Index arraysize = 3*size;
|
||||
|
||||
Scalar* array = ei_aligned_new<Scalar>(arraysize);
|
||||
|
||||
@@ -68,7 +69,7 @@ template<typename MatrixType> void map_class_matrix(const MatrixType& _m)
|
||||
|
||||
MatrixType m = MatrixType::Random(rows,cols);
|
||||
|
||||
int arraysize = 2*(rows+4)*(cols+4);
|
||||
Index arraysize = 2*(rows+4)*(cols+4);
|
||||
|
||||
Scalar* array = ei_aligned_new<Scalar>(arraysize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user