* Added generic unary operators (replace Opposite and Conjugate)

* functor templates are not template template parameter anymore
   (this allows to make templated functors !)
 * Main page: extented compiler discussion
 * A small hack to support gcc 3.4 and 4.0 (see the main page)
 * Fix a cast type issue in Cast
 * Various doxygen updates (mainly Cwise stuff and added doxygen groups
   in MatrixBase to split the huge memeber list, still not perfect though)
 * Updated Gael's email address
This commit is contained in:
Gael Guennebaud
2008-03-03 10:52:44 +00:00
parent ed20f64d68
commit 255689231d
16 changed files with 397 additions and 267 deletions

View File

@@ -29,8 +29,8 @@
namespace Eigen {
template<typename Scalar> struct AddIfNull {
static Scalar op(const Scalar a, const Scalar b) {return a<1e-3 ? b : a;}
struct AddIfNull {
template<typename Scalar> static Scalar op(const Scalar a, const Scalar b) {return a<=1e-3 ? b : a;}
};
template<typename MatrixType> void cwiseops(const MatrixType& m)
@@ -54,10 +54,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
v2 = VectorType::random(rows),
vzero = VectorType::zero(rows);
m2 = m2.cwise<AddIfNull>(mones);
//m2 = cwise<AddIfNull>(m2,mones);
std::cout << m2 << "\n";
m2 = m2.template cwise<AddIfNull>(mones);
VERIFY_IS_APPROX( mzero, m1-m1);
VERIFY_IS_APPROX( m2, m1+m2-m1);
@@ -72,12 +69,12 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
void EigenTest::testCwiseops()
{
for(int i = 0; i < 1/*m_repeat*/ ; i++) {
// cwiseops(Matrix<float, 1, 1>());
// cwiseops(Matrix4d());
// cwiseops(MatrixXcf(3, 3));
for(int i = 0; i < m_repeat ; i++) {
cwiseops(Matrix<float, 1, 1>());
cwiseops(Matrix4d());
cwiseops(MatrixXf(3, 3));
cwiseops(MatrixXi(8, 12));
// cwiseops(MatrixXcd(20, 20));
cwiseops(MatrixXd(20, 20));
}
}

View File

@@ -26,12 +26,38 @@
namespace Eigen {
// check minor separately in order to avoid the possible creation of a zero-sized
// array. Comes from a compilation error with gcc-3.4 or gcc-4 with -ansi -pedantic.
// Another solution would be to declare the array like this: T m_data[Size==0?1:Size]; in MatrixStorage
// but this is probably not bad to raise such an error at compile time...
template<typename Scalar, int _Rows, int _Cols> struct CheckMinor
{
typedef Matrix<Scalar, _Rows, _Cols> MatrixType;
CheckMinor(MatrixType& m1, int r1, int c1)
{
int rows = m1.rows();
int cols = m1.cols();
Matrix<Scalar, Dynamic, Dynamic> mi = m1.minor(0,0).eval();
VERIFY_IS_APPROX(mi, m1.block(1,1,rows-1,cols-1));
mi = m1.minor(r1,c1);
VERIFY_IS_APPROX(mi.transpose(), m1.transpose().minor(c1,r1));
//check operator(), both constant and non-constant, on minor()
m1.minor(r1,c1)(0,0) = m1.minor(0,0)(0,0);
}
};
template<typename Scalar> struct CheckMinor<Scalar,1,1>
{
typedef Matrix<Scalar, 1, 1> MatrixType;
CheckMinor(MatrixType&, int, int) {}
};
template<typename MatrixType> void submatrices(const MatrixType& m)
{
/* this test covers the following files:
Row.h Column.h Block.h Minor.h DiagonalCoeffs.h
*/
typedef typename MatrixType::Scalar Scalar;
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
typedef Matrix<Scalar, 1, MatrixType::Traits::ColsAtCompileTime> RowVectorType;
@@ -77,15 +103,7 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
m1.block(r1,c1,r2-r1+1,c2-c1+1)(r2-r1,c2-c1) = m2.block(0, 0, r2-r1+1,c2-c1+1)(0,0);
//check minor()
if(rows > 1 && cols > 1)
{
Matrix<Scalar, Dynamic, Dynamic> mi = m1.minor(0,0).eval();
VERIFY_IS_APPROX(mi, m1.block(1,1,rows-1,cols-1));
mi = m1.minor(r1,c1);
VERIFY_IS_APPROX(mi.transpose(), m1.transpose().minor(c1,r1));
//check operator(), both constant and non-constant, on minor()
m1.minor(r1,c1)(0,0) = m1.minor(0,0)(0,0);
}
CheckMinor<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::ColsAtCompileTime> checkminor(m1,r1,c1);
//check diagonal()
VERIFY_IS_APPROX(m1.diagonal(), m1.transpose().diagonal());