2010-01-06 20:56:04 +08:00
namespace Eigen {
/** \page Eigen2ToEigen3 Porting from Eigen2 to Eigen3
The goals of this page is to enumerate the API changes between Eigen2 and Eigen3,
and to help porting an application from Eigen2 to Eigen3.
\b Table \b of \b contents
2010-01-07 00:35:22 +08:00
- \ref CompatibilitySupport
2010-04-23 06:27:13 +08:00
- \ref VectorBlocks
- \ref TriangularViews
- \ref TriangularSolveInPlace
- \ref Using
2010-01-07 00:35:22 +08:00
- \ref CoefficientWiseOperations
2010-04-23 02:11:18 +08:00
- \ref Corners
2010-01-07 00:35:22 +08:00
- \ref LazyVsNoalias
2010-01-06 20:56:04 +08:00
\section CompatibilitySupport Eigen2 compatibility support
2010-04-23 06:27:13 +08:00
In order to ease the switch from Eigen2 to Eigen3, Eigen3 features a compatibility mode which can be enabled by defining the EIGEN2_SUPPORT preprocessor token \b before including any Eigen header (typically it should be set in your project options).
2010-01-06 20:56:04 +08:00
2010-04-23 06:27:13 +08:00
\section VectorBlocks Vector blocks
2010-01-06 20:56:04 +08:00
<table>
2010-04-23 06:27:13 +08:00
<tr><td>Eigen 2</td><td>Eigen 3</td></tr>
2010-01-07 00:35:22 +08:00
<tr><td>\code
2010-04-23 06:27:13 +08:00
vector.start(length)
vector.start<length>()
vector.end(length)
vector.end<length>()
2010-01-07 00:35:22 +08:00
\endcode</td><td>\code
2010-04-23 06:27:13 +08:00
vector.head(length)
vector.head<length>()
vector.tail(length)
vector.tail<length>()
\endcode</td></tr>
</table>
\section Corners Matrix Corners
<table>
<tr><td>Eigen 2</td><td>Eigen 3</td></tr>
<tr><td>\code
matrix.corner(TopLeft,r,c)
matrix.corner(TopRight,r,c)
matrix.corner(BottomLeft,r,c)
matrix.corner(BottomRight,r,c)
matrix.corner<r,c>(TopLeft)
matrix.corner<r,c>(TopRight)
matrix.corner<r,c>(BottomLeft)
matrix.corner<r,c>(BottomRight)
\endcode</td><td>\code
matrix.topLeftCorner(r,c)
matrix.topRightCorner(r,c)
matrix.bottomLeftCorner(r,c)
matrix.bottomRightCorner(r,c)
matrix.topLeftCorner<r,c>()
matrix.topRightCorner<r,c>()
matrix.bottomLeftCorner<r,c>()
matrix.bottomRightCorner<r,c>()
\endcode</td>
</tr>
</table>
Notice that Eigen3 also provides these new convenience methods: topRows(), bottomRows(), leftCols(), rightCols(). See in class DenseBase.
\section TriangularViews Triangular views
TODO: fill this section
\section TriangularSolveInPlace Triangular in-place solving
<table>
<tr><td>Eigen 2</td><td>Eigen 3</td></tr>
<tr><td>\code A.triangularSolveInPlace<XXX>(X);\endcode</td><td>\code A.triangularView<XXX>().solveInPlace(X);\endcode</td></tr>
2010-01-08 04:15:32 +08:00
<tr><td colspan="3"></td></tr>
<tr><td>\code
UpperTriangular
LowerTriangular
UnitUpperTriangular
UnitLowerTriangular
StrictlyUpperTriangular
StrictlyLowerTriangular
\endcode</td><td>\code
Upper
Lower
UnitUpper
UnitLower
StrictlyUpper
StrictlyLower
\endcode</td>
2010-04-23 06:27:13 +08:00
</tr>
2010-01-06 20:56:04 +08:00
</table>
2010-04-23 06:27:13 +08:00
\section Using The USING_PART_OF_NAMESPACE_EIGEN macro
The USING_PART_OF_NAMESPACE_EIGEN macro has been removed. In Eigen 3, just do:
\code
using namespace Eigen;
\endcode
2010-01-06 20:56:04 +08:00
\section CoefficientWiseOperations Coefficient wise operations
2010-01-10 02:54:31 +08:00
In Eigen2, coefficient wise operations which have no proper mathematical definition (as a coefficient wise product)
were achieved using the .cwise() prefix, e.g.:
2010-01-07 00:43:11 +08:00
\code a.cwise() * b \endcode
2010-01-10 02:54:31 +08:00
In Eigen3 this .cwise() prefix has been superseded by a new kind of matrix type called
2010-01-06 20:56:04 +08:00
Array for which all operations are performed coefficient wise. You can easily view a matrix as an array and vice versa using
the MatrixBase::array() and ArrayBase::matrix() functions respectively. Here is an example:
\code
Vector4f a, b, c;
c = a.array() * b.array();
\endcode
Note that the .array() function is not at all a synonym of the deprecated .cwise() prefix.
While the .cwise() prefix changed the behavior of the following operator, the array() function performs
2010-01-10 02:54:31 +08:00
a permanent conversion to the array world. Therefore, for binary operations such as the coefficient wise product,
2010-01-06 20:56:04 +08:00
both sides must be converted to an \em array as in the above example. On the other hand, when you
2010-01-10 02:54:31 +08:00
concatenate multiple coefficient wise operations you only have to do the conversion once, e.g.:
2010-01-06 20:56:04 +08:00
\code
Vector4f a, b, c;
c = a.array().abs().pow(3) * b.array().abs().sin();
\endcode
With Eigen2 you would have written:
\code
c = (a.cwise().abs().cwise().pow(3)).cwise() * (b.cwise().abs().cwise().sin());
\endcode
2010-02-10 21:08:47 +08:00
\section LazyVsNoalias Lazy evaluation and noalias
2010-01-06 20:56:04 +08:00
2010-02-10 21:08:47 +08:00
In Eigen all operations are performed in a lazy fashion except the matrix products which are always evaluated into a temporary by default.
2010-01-06 20:56:04 +08:00
In Eigen2, lazy evaluation could be enforced by tagging a product using the .lazy() function. However, in complex expressions it was not
2010-01-10 02:54:31 +08:00
easy to determine where to put the lazy() function. In Eigen3, the lazy() feature has been superseded by the MatrixBase::noalias() function
2010-01-06 20:56:04 +08:00
which can be used on the left hand side of an assignment when no aliasing can occur. Here is an example:
\code
MatrixXf a, b, c;
...
c.noalias() += 2 * a.transpose() * b;
\endcode
2010-02-10 21:08:47 +08:00
However, the noalias mechanism does not cover all the features of the old .lazy(). Indeed, in some extremely rare cases,
it might be useful to explicit request for a lay product, i.e., for a product which will be evaluated one coefficient at once, on request,
just like any other expressions. To this end you can use the MatrixBase::lazyProduct() function, however we strongly discourage you to
use it unless you are sure of what you are doing, i.e., you have rigourosly measured a speed improvement.
2010-01-06 20:56:04 +08:00
*/
}