mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
rework Identity API: no longer restricted to square matrices
This commit is contained in:
@@ -43,7 +43,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::identity(rows),
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
|
||||
@@ -42,7 +42,7 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::identity(rows),
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
|
||||
@@ -46,7 +46,7 @@ template<typename MatrixType> void linearStructure(const MatrixType& m)
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::identity(rows),
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
|
||||
@@ -51,7 +51,7 @@ template<typename MatrixType> void miscMatrices(const MatrixType& m)
|
||||
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));
|
||||
VERIFY_IS_APPROX(square, MatrixType::identity(rows, rows));
|
||||
}
|
||||
|
||||
void EigenTest::testMiscMatrices()
|
||||
|
||||
@@ -46,7 +46,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::identity(rows),
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
@@ -83,7 +83,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m1, identity*m1);
|
||||
VERIFY_IS_APPROX(v1, identity*v1);
|
||||
// again, test operator() to check const-qualification
|
||||
VERIFY_IS_APPROX(MatrixType::identity(std::max(rows,cols))(r,c), static_cast<Scalar>(r==c));
|
||||
VERIFY_IS_APPROX(MatrixType::identity(rows, cols)(r,c), static_cast<Scalar>(r==c));
|
||||
}
|
||||
|
||||
void EigenTest::testProduct()
|
||||
|
||||
@@ -44,7 +44,7 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::identity(rows),
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
|
||||
Reference in New Issue
Block a user