- many updates after Cwise change

- fix compilation in product.cpp with std::complex
- fix bug in MatrixBase::operator!=
This commit is contained in:
Benoit Jacob
2008-07-08 07:56:01 +00:00
parent f5791eeb70
commit 6f09d3a67d
21 changed files with 40 additions and 56 deletions

View File

@@ -4,11 +4,11 @@ o /** \mainpage Eigen
This is the API documentation for Eigen.
Most of the API is available as methods in MatrixBase, so this is a good starting point for browsing. Also have a look at Matrix, as a few methods and the matrix constructors are there.
Most of the API is available as methods in MatrixBase, so this is a good starting point for browsing. Also have a look at Matrix, as a few methods and the matrix constructors are there. Other notable classes for the Eigen API are Cwise, which contains the methods for doing certain coefficient-wise operations, and Part.
For a first contact with Eigen, it is enough to look at Matrix and MatrixBase. In fact, except for advanced use, the only class that you'll have to explicitly name in your program, i.e. of which you'll explicitly contruct objects, is Matrix. For instance, vectors are handled as a special case of Matrix with one column.
For a first contact with Eigen, it is enough to look at Matrix, MatrixBase, and Cwise. In fact, except for advanced use, the only class that you'll have to explicitly name in your program, i.e. of which you'll explicitly contruct objects, is Matrix. For instance, vectors are handled as a special case of Matrix with one column. Typedefs are provided, e.g. Vector2f is a typedef for Matrix<float, 2, 1>.
The many other classes are typically return types for MatrixBase methods.
Most of the other classes are just return types for MatrixBase methods.
*/

View File

@@ -22,7 +22,7 @@ struct unroll_echelon
unroll_echelon<Derived, Step-1>::run(m);
int rowOfBiggest, colOfBiggest;
m.template corner<CornerRows, CornerCols>(BottomRight)
.cwiseAbs()
.cwise().abs()
.maxCoeff(&rowOfBiggest, &colOfBiggest);
m.row(k).swap(m.row(k+rowOfBiggest));
m.col(k).swap(m.col(k+colOfBiggest));
@@ -54,7 +54,7 @@ struct unroll_echelon<Derived, Dynamic>
int rowOfBiggest, colOfBiggest;
int cornerRows = m.rows()-k, cornerCols = m.cols()-k;
m.corner(BottomRight, cornerRows, cornerCols)
.cwiseAbs()
.cwise().abs()
.maxCoeff(&rowOfBiggest, &colOfBiggest);
m.row(k).swap(m.row(k+rowOfBiggest));
m.col(k).swap(m.col(k+colOfBiggest));

View File

@@ -7,12 +7,11 @@ using namespace std;
template<typename Scalar> struct MakeComplexOp EIGEN_EMPTY_STRUCT {
typedef complex<Scalar> result_type;
complex<Scalar> operator()(const Scalar& a, const Scalar& b) const { return complex<Scalar>(a,b); }
enum { Cost = 0 };
};
int main(int, char**)
{
Matrix4d m1 = Matrix4d::random(), m2 = Matrix4d::random();
cout << m1.cwise(m2, MakeComplexOp<double>()) << endl;
cout << m1.binaryExpr(m2, MakeComplexOp<double>()) << endl;
return 0;
}

View File

@@ -9,12 +9,11 @@ struct CwiseClampOp {
CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {}
const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); }
Scalar m_inf, m_sup;
enum { Cost = Eigen::ConditionalJumpCost + Eigen::NumTraits<Scalar>::AddCost };
};
int main(int, char**)
{
Matrix4d m1 = Matrix4d::random();
cout << m1 << endl << "becomes: " << endl << m1.cwise(CwiseClampOp<double>(-0.5,0.5)) << endl;
cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl;
return 0;
}

View File

@@ -1,5 +0,0 @@
int data[4] = {1,3,0,2};
cout << Matrix2i::map(data) << endl;
Matrix2i::map(data) *= 2;
cout << "The data is now:" << endl;
for(int i = 0; i < 4; i++) cout << data[i] << endl;

View File

@@ -1,5 +0,0 @@
int data[4] = {1,3,0,2};
cout << VectorXi::map(data, 4) << endl;
VectorXi::map(data, 4) *= 2;
cout << "The data is now:" << endl;
for(int i = 0; i < 4; i++) cout << data[i] << endl;

View File

@@ -1,5 +0,0 @@
int data[4] = {1,3,0,2};
cout << MatrixXi::map(data, 2, 2) << endl;
MatrixXi::map(data, 2, 2) *= 2;
cout << "The data is now:" << endl;
for(int i = 0; i < 4; i++) cout << data[i] << endl;