big change: MatrixBase only takes one template parameter "Derived", the

template parameter "Scalar" is removed. This is achieved by introducting a
template <typename Derived> struct Scalar to achieve a forward-declaration of
the Scalar typedefs.
This commit is contained in:
Benoit Jacob
2008-03-10 17:23:11 +00:00
parent 9d9d81ad71
commit 01572b9f54
40 changed files with 434 additions and 369 deletions

View File

@@ -71,7 +71,7 @@ The To-do wiki for Eigen is here: <a href="http://techbase.kde.org/index.php?tit
Eigen is standard C++98 and so should theoretically be compatible with any compliant compiler. Of course, in practice, things might be slightly different. At least, Eigen is known to compile with any version of GCC from 3.3 to 4.3 as well as with recent versions of ICC.
Eigen is well tested with recent versions of GCC and ICC. Both GCC 4.2 and ICC gives very good performance. ICC might provide even better performance when the auto-vectorization makes sense. For some reason the performance is not so great with GCC 4.1.
Eigen is well tested with recent versions of GCC and ICC. Both GCC 4.2 and ICC give very good performance. ICC might provide even better performance when the auto-vectorization makes sense. For some reason the performance is not so great with GCC 4.1.
For best performance, we recommend the following compilation flags:
<ul>

View File

@@ -2,16 +2,16 @@
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
template<typename Derived>
Eigen::Block<Derived>
topLeftCorner(MatrixBase<Scalar, Derived>& m, int rows, int cols)
topLeftCorner(MatrixBase<Derived>& m, int rows, int cols)
{
return Eigen::Block<Derived>(m.asArg(), 0, 0, rows, cols);
}
template<typename Scalar, typename Derived>
template<typename Derived>
const Eigen::Block<Derived>
topLeftCorner(const MatrixBase<Scalar, Derived>& m, int rows, int cols)
topLeftCorner(const MatrixBase<Derived>& m, int rows, int cols)
{
return Eigen::Block<Derived>(m.asArg(), 0, 0, rows, cols);
}

View File

@@ -2,14 +2,17 @@
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
template<typename Derived>
const Eigen::CwiseUnaryOp<
Eigen::ScalarCastOp<typename Eigen::NumTraits<Scalar>::FloatingPoint>,
Derived
Eigen::ScalarCastOp<
typename Eigen::NumTraits< typename Eigen::Scalar<Derived>::Type >::FloatingPoint
>, Derived
>
castToFloatingPoint(const MatrixBase<Scalar, Derived>& m)
castToFloatingPoint(const MatrixBase<Derived>& m)
{
return m.template cast<typename Eigen::NumTraits<Scalar>::FloatingPoint>();
return m.template cast<typename Eigen::NumTraits<
typename Eigen::Scalar<Derived>::Type>::FloatingPoint
>();
}
int main(int, char**)

View File

@@ -2,16 +2,16 @@
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
template<typename Derived>
Eigen::Column<Derived>
firstColumn(MatrixBase<Scalar, Derived>& m)
firstColumn(MatrixBase<Derived>& m)
{
return Eigen::Column<Derived>(m.asArg(), 0);
}
template<typename Scalar, typename Derived>
template<typename Derived>
const Eigen::Column<Derived>
firstColumn(const MatrixBase<Scalar, Derived>& m)
firstColumn(const MatrixBase<Derived>& m)
{
return Eigen::Column<Derived>(m.asArg(), 0);
}

View File

@@ -9,9 +9,9 @@ struct CwiseMinOp EIGEN_EMPTY_STRUCT {
};
// define a custom binary operator between two matrices
template<typename Scalar, typename Derived1, typename Derived2>
template<typename Derived1, typename Derived2>
const Eigen::CwiseBinaryOp<CwiseMinOp, Derived1, Derived2>
cwiseMin(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
cwiseMin(const MatrixBase<Derived1> &mat1, const MatrixBase<Derived2> &mat2)
{
return Eigen::CwiseBinaryOp<CwiseMinOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
}

View File

@@ -13,6 +13,6 @@ struct CwiseClampOp EIGEN_EMPTY_STRUCT {
int main(int, char**)
{
Matrix4d m1 = Matrix4d::random();
cout << m1.cwise(CwiseClampOp<Matrix4d::Scalar>(-0.5,0.5)) << endl;
cout << m1.cwise(CwiseClampOp<double>(-0.5,0.5)) << endl;
return 0;
}

View File

@@ -2,9 +2,9 @@
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
template<typename Derived>
const Eigen::Eval<Eigen::Transpose<Derived> >
evaluatedTranspose(const MatrixBase<Scalar, Derived>& m)
evaluatedTranspose(const MatrixBase<Derived>& m)
{
return m.transpose().eval();
}

View File

@@ -2,16 +2,16 @@
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
template<typename Derived>
Eigen::Block<Derived, 2, 2>
topLeft2x2Corner(MatrixBase<Scalar, Derived>& m)
topLeft2x2Corner(MatrixBase<Derived>& m)
{
return Eigen::Block<Derived, 2, 2>(m.asArg(), 0, 0);
}
template<typename Scalar, typename Derived>
template<typename Derived>
const Eigen::Block<Derived, 2, 2>
topLeft2x2Corner(const MatrixBase<Scalar, Derived>& m)
topLeft2x2Corner(const MatrixBase<Derived>& m)
{
return Eigen::Block<Derived, 2, 2>(m.asArg(), 0, 0);
}

View File

@@ -2,16 +2,16 @@
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
template<typename Derived>
Eigen::Row<Derived>
firstRow(MatrixBase<Scalar, Derived>& m)
firstRow(MatrixBase<Derived>& m)
{
return Eigen::Row<Derived>(m.asArg(), 0);
}
template<typename Scalar, typename Derived>
template<typename Derived>
const Eigen::Row<Derived>
firstRow(const MatrixBase<Scalar, Derived>& m)
firstRow(const MatrixBase<Derived>& m)
{
return Eigen::Row<Derived>(m.asArg(), 0);
}