Another big refactoring change:

* add a new Eigen2Support module including Cwise, Flagged, and some other deprecated stuff
* add a few cwiseXxx functions
* adapt a few modules to use cwiseXxx instead of the .cwise() prefix
This commit is contained in:
Gael Guennebaud
2009-11-18 18:15:19 +01:00
parent 0529ecfe1b
commit e3d890bc5a
48 changed files with 634 additions and 408 deletions

View File

@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Array>

View File

@@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <functional>
#include <Eigen/Array>
@@ -60,9 +61,9 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
int r = ei_random<int>(0, rows-1),
c = ei_random<int>(0, cols-1);
Scalar s1 = ei_random<Scalar>();
// test Zero, Ones, Constant, and the set* variants
m3 = MatrixType::Constant(rows, cols, s1);
for (int j=0; j<cols; ++j)
@@ -84,7 +85,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
VERIFY_IS_APPROX(m4.setOnes(rows,cols), mones);
m4.fill(s1);
VERIFY_IS_APPROX(m4, m3);
VERIFY_IS_APPROX(v3.setConstant(rows, s1), VectorType::Constant(rows,s1));
VERIFY_IS_APPROX(v3.setZero(rows), vzero);
VERIFY_IS_APPROX(v3.setOnes(rows), vones);
@@ -107,7 +108,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
m3 = m1;
m3.cwise() *= m2;
VERIFY_IS_APPROX(m3, m1.cwise() * m2);
VERIFY_IS_APPROX(mones, m2.cwise()/m2);
if(NumTraits<Scalar>::HasFloatingPoint)
{
@@ -122,7 +123,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
VERIFY_IS_APPROX(m3.cwise().pow(-1), m3.cwise().inverse());
m3 = m1.cwise().abs();
VERIFY_IS_APPROX(m3.cwise().pow(RealScalar(0.5)), m3.cwise().sqrt());
// VERIFY_IS_APPROX(m1.cwise().tan(), m1.cwise().sin().cwise() / m1.cwise().cos());
VERIFY_IS_APPROX(mones, m1.cwise().sin().cwise().square() + m1.cwise().cos().cwise().square());
m3 = m1;
@@ -139,7 +140,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
VERIFY_IS_APPROX( m1.cwise().max(m2), m2.cwise().max(m1) );
VERIFY_IS_APPROX( m1.cwise().max(m1-mones), m1 );
VERIFY_IS_APPROX( m1.cwise().max(m1+mones), m1+mones );
VERIFY( (m1.cwise() == m1).all() );
VERIFY( (m1.cwise() != m2).any() );
VERIFY(!(m1.cwise() == (m1+mones)).any() );

View File

@@ -52,7 +52,7 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
// Regression test for issue #66
MatrixType z = MatrixType::Zero(rows,cols);
ComplexEigenSolver<MatrixType> eiz(z);
VERIFY((eiz.eigenvalues().cwise()==0).all());
VERIFY((eiz.eigenvalues().cwiseEqual(0)).all());
}
void test_eigensolver_complex()

View File

@@ -79,7 +79,7 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
// compare with eigen
VERIFY_IS_APPROX(_eval, eiSymm.eigenvalues());
VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymm.eigenvectors().cwise().abs());
VERIFY_IS_APPROX(_evec.cwiseAbs(), eiSymm.eigenvectors().cwiseAbs());
// generalized pb
Gsl::eigen_symm_gen(gSymmA, gSymmB, gEval, gEvec);
@@ -92,7 +92,7 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
// std::cerr << _eval.transpose() << "\n" << eiSymmGen.eigenvalues().transpose() << "\n\n";
// std::cerr << _evec.format(6) << "\n\n" << eiSymmGen.eigenvectors().format(6) << "\n\n\n";
VERIFY_IS_APPROX(_eval, eiSymmGen.eigenvalues());
VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymmGen.eigenvectors().cwise().abs());
VERIFY_IS_APPROX(_evec.cwiseAbs(), eiSymmGen.eigenvectors().cwiseAbs());
Gsl::free(gSymmA);
Gsl::free(gSymmB);

View File

@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>

View File

@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>

View File

@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>

View File

@@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>

View File

@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>

View File

@@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>

View File

@@ -23,6 +23,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>

View File

@@ -22,6 +22,7 @@
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
#define EIGEN2_SUPPORT
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>
@@ -109,7 +110,7 @@ template<typename Scalar, int Mode> void transformations(void)
t0.matrix().setZero();
t0 = Transform3::Identity();
VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
t0.linear() = q1.toRotationMatrix();
t1.setIdentity();
t1.linear() = q1.toRotationMatrix();
@@ -351,7 +352,7 @@ template<typename Scalar, int Mode> void transformations(void)
VERIFY_IS_APPROX(r2d1f.template cast<Scalar>(),r2d1);
Rotation2D<double> r2d1d = r2d1.template cast<double>();
VERIFY_IS_APPROX(r2d1d.template cast<Scalar>(),r2d1);
}
void test_geo_transformations()