mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
* Merge Extract and Part to the Part expression.
Renamed "MatrixBase::extract() const" to "MatrixBase::part() const" * Renamed static functions identity, zero, ones, random with an upper case first letter: Identity, Zero, Ones and Random.
This commit is contained in:
@@ -35,18 +35,18 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
v3 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
v3 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>(),
|
||||
s2 = ei_random<Scalar>();
|
||||
|
||||
@@ -37,16 +37,16 @@ template<typename MatrixType> void scalarAdd(const MatrixType& m)
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>(),
|
||||
s2 = ei_random<Scalar>();
|
||||
|
||||
VERIFY_IS_APPROX(m1.cwise() + s1, s1 + m1.cwise());
|
||||
VERIFY_IS_APPROX(m1.cwise() + s1, MatrixType::constant(rows,cols,s1) + m1);
|
||||
VERIFY_IS_APPROX((m1*Scalar(2)).cwise() - s2, (m1+m1) - MatrixType::constant(rows,cols,s2) );
|
||||
VERIFY_IS_APPROX(m1.cwise() + s1, MatrixType::Constant(rows,cols,s1) + m1);
|
||||
VERIFY_IS_APPROX((m1*Scalar(2)).cwise() - s2, (m1+m1) - MatrixType::Constant(rows,cols,s2) );
|
||||
m3 = m1;
|
||||
m3.cwise() += s2;
|
||||
VERIFY_IS_APPROX(m3, m1.cwise() + s2);
|
||||
@@ -71,8 +71,8 @@ template<typename MatrixType> void comparisons(const MatrixType& m)
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols);
|
||||
|
||||
VERIFY(((m1.cwise() + Scalar(1)).cwise() > m1).all());
|
||||
|
||||
@@ -34,17 +34,17 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
|
||||
// this test relies a lot on Random.h, and there's not much more that we can do
|
||||
// to test it, hence I consider that we will have tested Random.h
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
@@ -68,7 +68,7 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
// hence has no _write() method, the corresponding MatrixBase method (here zero())
|
||||
// should return a const-qualified object so that it is the const-qualified
|
||||
// operator() that gets called, which in turn calls _read().
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::zero(rows,cols)(r,c), static_cast<Scalar>(1));
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows,cols)(r,c), static_cast<Scalar>(1));
|
||||
|
||||
// now test copying a row-vector into a (column-)vector and conversely.
|
||||
square.col(r) = square.row(r).eval();
|
||||
|
||||
@@ -38,8 +38,8 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> SquareMatrixType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
|
||||
MatrixType a = MatrixType::random(rows,cols);
|
||||
VectorType b = VectorType::random(rows);
|
||||
MatrixType a = MatrixType::Random(rows,cols);
|
||||
VectorType b = VectorType::Random(rows);
|
||||
SquareMatrixType covMat = a * a.adjoint();
|
||||
|
||||
CholeskyWithoutSquareRoot<SquareMatrixType> cholnosqrt(covMat);
|
||||
|
||||
@@ -35,7 +35,7 @@ void test_commainitializer()
|
||||
|
||||
double data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
|
||||
m3 = Matrix3d::random();
|
||||
m3 = Matrix3d::Random();
|
||||
m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
|
||||
VERIFY_IS_APPROX(m3, (Matrix<double,3,3,RowMajorBit>::map(data)) );
|
||||
|
||||
@@ -43,14 +43,14 @@ void test_commainitializer()
|
||||
vec[0] << 1, 4, 7;
|
||||
vec[1] << 2, 5, 8;
|
||||
vec[2] << 3, 6, 9;
|
||||
m3 = Matrix3d::random();
|
||||
m3 = Matrix3d::Random();
|
||||
m3 << vec[0], vec[1], vec[2];
|
||||
VERIFY_IS_APPROX(m3, (Matrix<double,3,3,RowMajorBit>::map(data)) );
|
||||
|
||||
vec[0] << 1, 2, 3;
|
||||
vec[1] << 4, 5, 6;
|
||||
vec[2] << 7, 8, 9;
|
||||
m3 = Matrix3d::random();
|
||||
m3 = Matrix3d::Random();
|
||||
m3 << vec[0].transpose(),
|
||||
4, 5, 6,
|
||||
vec[2].transpose();
|
||||
|
||||
@@ -42,18 +42,18 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mones = MatrixType::ones(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
mones = MatrixType::Ones(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
m2 = m2.template binaryExpr<AddIfNull<Scalar> >(mones);
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
|
||||
|
||||
typedef typename std::complex<typename NumTraits<typename MatrixType::Scalar>::Real> Complex;
|
||||
|
||||
MatrixType a = MatrixType::random(rows,cols);
|
||||
MatrixType a = MatrixType::Random(rows,cols);
|
||||
MatrixType symmA = a.adjoint() * a;
|
||||
|
||||
SelfAdjointEigenSolver<MatrixType> eiSymm(symmA);
|
||||
VERIFY_IS_APPROX(symmA * eiSymm.eigenvectors(), (eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal().eval()));
|
||||
|
||||
// generalized eigen problem Ax = lBx
|
||||
MatrixType b = MatrixType::random(rows,cols);
|
||||
MatrixType b = MatrixType::Random(rows,cols);
|
||||
MatrixType symmB = b.adjoint() * b;
|
||||
eiSymm.compute(symmA,symmB);
|
||||
VERIFY_IS_APPROX(symmA * eiSymm.eigenvectors(), symmB * (eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal().eval()));
|
||||
|
||||
@@ -42,9 +42,9 @@ template<typename Scalar> void geometry(void)
|
||||
typedef AngleAxis<Scalar> AngleAxis;
|
||||
|
||||
Quaternion q1, q2;
|
||||
Vector3 v0 = Vector3::random(),
|
||||
v1 = Vector3::random(),
|
||||
v2 = Vector3::random();
|
||||
Vector3 v0 = Vector3::Random(),
|
||||
v1 = Vector3::Random(),
|
||||
v2 = Vector3::Random();
|
||||
Matrix3 matrot1;
|
||||
|
||||
Scalar a = ei_random<Scalar>(-M_PI, M_PI);
|
||||
@@ -116,7 +116,7 @@ template<typename Scalar> void geometry(void)
|
||||
t1.setIdentity();
|
||||
t1.affine() = q1.toRotationMatrix();
|
||||
|
||||
v0 << 50, 2, 1;//= Vector3::random().cwiseProduct(Vector3(10,2,0.5));
|
||||
v0 << 50, 2, 1;//= Vector3::Random().cwiseProduct(Vector3(10,2,0.5));
|
||||
t0.scale(v0);
|
||||
t1.prescale(v0);
|
||||
|
||||
@@ -140,8 +140,8 @@ template<typename Scalar> void geometry(void)
|
||||
|
||||
// 2D transformation
|
||||
Transform2 t20, t21;
|
||||
Vector2 v20 = Vector2::random();
|
||||
Vector2 v21 = Vector2::random();
|
||||
Vector2 v20 = Vector2::Random();
|
||||
Vector2 v21 = Vector2::Random();
|
||||
t21.setIdentity();
|
||||
t21.affine() = Rotation2D<Scalar>(a).toRotationMatrix();
|
||||
VERIFY_IS_APPROX(t20.fromPositionOrientationScale(v20,a,v21).matrix(),
|
||||
|
||||
@@ -36,10 +36,10 @@ template<typename MatrixType> void inverse(const MatrixType& m)
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = MatrixType::identity(rows, rows);
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
identity = MatrixType::Identity(rows, rows);
|
||||
|
||||
m2 = m1.inverse();
|
||||
VERIFY_IS_APPROX(m1, m2.inverse() );
|
||||
|
||||
@@ -38,17 +38,17 @@ template<typename MatrixType> void linearStructure(const MatrixType& m)
|
||||
|
||||
// this test relies a lot on Random.h, and there's not much more that we can do
|
||||
// to test it, hence I consider that we will have tested Random.h
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ template<typename VectorType> void tmap(const VectorType& m)
|
||||
// test Map.h
|
||||
Scalar* array1 = ei_aligned_malloc<Scalar>(size);
|
||||
Scalar* array2 = ei_aligned_malloc<Scalar>(size);
|
||||
Map<VectorType, Aligned>(array1, size) = VectorType::random(size);
|
||||
Map<VectorType, Aligned>(array1, size) = VectorType::Random(size);
|
||||
Map<VectorType>(array2, size) = Map<VectorType>(array1, size);
|
||||
VectorType ma1 = Map<VectorType>(array1, size);
|
||||
VectorType ma2 = Map<VectorType, Aligned>(array2, size);
|
||||
|
||||
@@ -37,18 +37,18 @@ template<typename MatrixType> void miscMatrices(const MatrixType& m)
|
||||
int cols = m.cols();
|
||||
|
||||
int r = ei_random<int>(0, rows-1), r2 = ei_random<int>(0, rows-1), c = ei_random<int>(0, cols-1);
|
||||
VERIFY_IS_APPROX(MatrixType::ones(rows,cols)(r,c), static_cast<Scalar>(1));
|
||||
MatrixType m1 = MatrixType::ones(rows,cols);
|
||||
VERIFY_IS_APPROX(MatrixType::Ones(rows,cols)(r,c), static_cast<Scalar>(1));
|
||||
MatrixType m1 = MatrixType::Ones(rows,cols);
|
||||
VERIFY_IS_APPROX(m1(r,c), static_cast<Scalar>(1));
|
||||
VectorType v1 = VectorType::random(rows);
|
||||
VectorType v1 = VectorType::Random(rows);
|
||||
v1[0];
|
||||
Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
square = v1.asDiagonal();
|
||||
if(r==r2) VERIFY_IS_APPROX(square(r,r2), v1[r]);
|
||||
else VERIFY_IS_MUCH_SMALLER_THAN(square(r,r2), static_cast<Scalar>(1));
|
||||
square = MatrixType::zero(rows, rows);
|
||||
square.diagonal() = VectorType::ones(rows);
|
||||
VERIFY_IS_APPROX(square, MatrixType::identity(rows, rows));
|
||||
square = MatrixType::Zero(rows, rows);
|
||||
square.diagonal() = VectorType::Ones(rows);
|
||||
VERIFY_IS_APPROX(square, MatrixType::Identity(rows, rows));
|
||||
}
|
||||
|
||||
void test_miscmatrices()
|
||||
|
||||
@@ -56,17 +56,17 @@ template<typename MatrixType> void nomalloc(const MatrixType& m)
|
||||
|
||||
// this test relies a lot on Random.h, and there's not much more that we can do
|
||||
// to test it, hence I consider that we will have tested Random.h
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
@@ -82,7 +82,7 @@ template<typename MatrixType> void nomalloc(const MatrixType& m)
|
||||
void test_nomalloc()
|
||||
{
|
||||
// check that our operator new is indeed called:
|
||||
VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::random(3,3));
|
||||
VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::Random(3,3));
|
||||
CALL_SUBTEST( nomalloc(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( nomalloc(Matrix4d()) );
|
||||
}
|
||||
|
||||
@@ -54,21 +54,21 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
|
||||
// this test relies a lot on Random.h, and there's not much more that we can do
|
||||
// to test it, hence I consider that we will have tested Random.h
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols);
|
||||
mzero = MatrixType::Zero(rows, cols);
|
||||
RowSquareMatrixType
|
||||
identity = RowSquareMatrixType::identity(rows, rows),
|
||||
square = RowSquareMatrixType::random(rows, rows),
|
||||
res = RowSquareMatrixType::random(rows, rows);
|
||||
identity = RowSquareMatrixType::Identity(rows, rows),
|
||||
square = RowSquareMatrixType::Random(rows, rows),
|
||||
res = RowSquareMatrixType::Random(rows, rows);
|
||||
ColSquareMatrixType
|
||||
square2 = ColSquareMatrixType::random(cols, cols),
|
||||
res2 = ColSquareMatrixType::random(cols, cols);
|
||||
RowVectorType v1 = RowVectorType::random(rows),
|
||||
v2 = RowVectorType::random(rows),
|
||||
vzero = RowVectorType::zero(rows);
|
||||
ColVectorType vc2 = ColVectorType::random(cols), vcres;
|
||||
square2 = ColSquareMatrixType::Random(cols, cols),
|
||||
res2 = ColSquareMatrixType::Random(cols, cols);
|
||||
RowVectorType v1 = RowVectorType::Random(rows),
|
||||
v2 = RowVectorType::Random(rows),
|
||||
vzero = RowVectorType::Zero(rows);
|
||||
ColVectorType vc2 = ColVectorType::Random(cols), vcres;
|
||||
OtherMajorMatrixType tm1 = m1;
|
||||
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
@@ -99,7 +99,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(v1, identity*v1);
|
||||
VERIFY_IS_APPROX(v1.transpose(), v1.transpose() * identity);
|
||||
// again, test operator() to check const-qualification
|
||||
VERIFY_IS_APPROX(MatrixType::identity(rows, cols)(r,c), static_cast<Scalar>(r==c));
|
||||
VERIFY_IS_APPROX(MatrixType::Identity(rows, cols)(r,c), static_cast<Scalar>(r==c));
|
||||
|
||||
if (rows!=cols)
|
||||
VERIFY_RAISES_ASSERT(m3 = m1*m1);
|
||||
|
||||
@@ -37,10 +37,10 @@ template<typename MatrixType> void qr(const MatrixType& m)
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> SquareMatrixType;
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
|
||||
|
||||
MatrixType a = MatrixType::random(rows,cols);
|
||||
MatrixType a = MatrixType::Random(rows,cols);
|
||||
QR<MatrixType> qrOfA(a);
|
||||
VERIFY_IS_APPROX(a, qrOfA.matrixQ() * qrOfA.matrixR());
|
||||
VERIFY_IS_NOT_APPROX(a+MatrixType::identity(rows, cols), qrOfA.matrixQ() * qrOfA.matrixR());
|
||||
VERIFY_IS_NOT_APPROX(a+MatrixType::Identity(rows, cols), qrOfA.matrixQ() * qrOfA.matrixR());
|
||||
|
||||
SquareMatrixType b = a.adjoint() * a;
|
||||
|
||||
@@ -52,7 +52,7 @@ template<typename MatrixType> void qr(const MatrixType& m)
|
||||
HessenbergDecomposition<SquareMatrixType> hess(b);
|
||||
VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
|
||||
VERIFY_IS_APPROX(tridiag.matrixT(), hess.matrixH());
|
||||
b = SquareMatrixType::random(cols,cols);
|
||||
b = SquareMatrixType::Random(cols,cols);
|
||||
hess.compute(b);
|
||||
VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
|
||||
}
|
||||
|
||||
@@ -62,18 +62,18 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
v3 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
v3 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
|
||||
@@ -32,23 +32,23 @@ template<typename MatrixType> void triangular(const MatrixType& m)
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
MatrixType m1 = MatrixType::random(rows, cols),
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
r1(rows, cols),
|
||||
r2(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mones = MatrixType::ones(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
mones = MatrixType::Ones(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
::Identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
::Random(rows, rows);
|
||||
VectorType v1 = VectorType::Random(rows),
|
||||
v2 = VectorType::Random(rows),
|
||||
vzero = VectorType::Zero(rows);
|
||||
|
||||
MatrixType m1up = m1.template extract<Eigen::Upper>();
|
||||
MatrixType m2up = m2.template extract<Eigen::Upper>();
|
||||
MatrixType m1up = m1.template part<Eigen::Upper>();
|
||||
MatrixType m2up = m2.template part<Eigen::Upper>();
|
||||
|
||||
if (rows*cols>1)
|
||||
{
|
||||
@@ -70,18 +70,18 @@ template<typename MatrixType> void triangular(const MatrixType& m)
|
||||
m1.setZero();
|
||||
m1.template part<Eigen::Upper>() = (m2.transpose() * m2).lazy();
|
||||
m3 = m2.transpose() * m2;
|
||||
VERIFY_IS_APPROX(m3.template extract<Eigen::Lower>().transpose(), m1);
|
||||
VERIFY_IS_APPROX(m3.template part<Eigen::Lower>().transpose(), m1);
|
||||
|
||||
// test overloaded operator=
|
||||
m1.setZero();
|
||||
m1.template part<Eigen::Lower>() = (m2.transpose() * m2).lazy();
|
||||
VERIFY_IS_APPROX(m3.template extract<Eigen::Lower>(), m1);
|
||||
VERIFY_IS_APPROX(m3.template part<Eigen::Lower>(), m1);
|
||||
|
||||
// test back and forward subsitution
|
||||
m1 = MatrixType::random(rows, cols);
|
||||
VERIFY_IS_APPROX(m1.template extract<Eigen::Upper>() * (m1.template extract<Eigen::Upper>().inverseProduct(m2)), m2);
|
||||
VERIFY_IS_APPROX(m1.template extract<Eigen::Lower>() * (m1.template extract<Eigen::Lower>().inverseProduct(m2)), m2);
|
||||
VERIFY((m1.template extract<Eigen::Upper>() * m2.template extract<Eigen::Upper>()).isUpper());
|
||||
m1 = MatrixType::Random(rows, cols);
|
||||
VERIFY_IS_APPROX(m1.template part<Eigen::Upper>() * (m1.template part<Eigen::Upper>().inverseProduct(m2)), m2);
|
||||
VERIFY_IS_APPROX(m1.template part<Eigen::Lower>() * (m1.template part<Eigen::Lower>().inverseProduct(m2)), m2);
|
||||
VERIFY((m1.template part<Eigen::Upper>() * m2.template part<Eigen::Upper>()).isUpper());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user