2010-01-06 20:56:04 +08:00
namespace Eigen {
/** \page Eigen2ToEigen3 Porting from Eigen2 to Eigen3
2010-10-20 21:43:16 +08:00
This page lists the most important API changes between Eigen2 and Eigen3,
and gives tips to help porting your application from Eigen2 to Eigen3.
2010-01-06 20:56:04 +08:00
Big changes in Eigen documentation:
- Organize the documentation into "chapters".
- Each chapter include many documentation pages, reference pages organized as modules, and a quick reference page.
- The "Chapters" tree is created using the defgroup/ingroup mechanism, even for the documentation pages (i.e., .dox files for which I added an \eigenManualPage macro that we can switch between \page or \defgroup ).
- Add a "General topics" entry for all pages that do not fit well in the previous "chapters".
- The highlevel struture is managed by a new eigendoxy_layout.xml file.
- remove the "index" and quite useless pages (namespace list, class hierarchy, member list, file list, etc.)
- add the javascript search-engine.
- add the "treeview" panel.
- remove \tableofcontents (replace them by a custom \eigenAutoToc macro to be able to easily re-enable if needed).
- add javascript to automatically generate a TOC from the h1/h2 tags of the current page, and put the TOC in the left side panel.
- overload various javascript function generated by doxygen to:
- remove the root of the treeview
- remove links to section/subsection from the treeview
- automatically expand the "Chapters" section
- automatically expand the current section
- adjust the height of the treeview to take into account the TOC
- always use the default .css file, eigendoxy.css now only includes our modifications
- use Doxyfile to specify our logo
- remove cross references to unsupported modules (temporarily)
2013-01-05 23:37:11 +08:00
\eigenAutoToc
2010-01-06 20:56:04 +08:00
\section CompatibilitySupport Eigen2 compatibility support
2014-07-01 22:58:11 +08:00
Up to version 3.2 %Eigen provides <a href="http://eigen.tuxfamily.org/dox/Eigen2SupportModes.html">Eigen2 support modes</a>. These are removed now, because they were barely used anymore and became hard to maintain after internal re-designs.
You can still use them by first <a href="http://eigen.tuxfamily.org/dox/Eigen2ToEigen3.html">porting your code to Eigen 3.2</a>.
2010-01-06 20:56:04 +08:00
2010-10-29 21:00:35 +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
2011-02-10 23:55:22 +08:00
\section ComplexDot Dot products over complex numbers
This is the single trickiest change between Eigen 2 and Eigen 3. It only affects code using \c std::complex numbers as scalar type.
Eigen 2's dot product was linear in the first variable. Eigen 3's dot product is linear in the second variable. In other words, the Eigen 2 code \code x.dot(y) \endcode is equivalent to the Eigen 3 code \code y.dot(x) \endcode In yet other words, dot products are complex-conjugated in Eigen 3 compared to Eigen 2. The switch to the new convention was commanded by common usage, especially with the notation \f$ x^Ty \f$ for dot products of column-vectors.
2010-04-23 06:27:13 +08:00
\section VectorBlocks Vector blocks
2010-01-06 20:56:04 +08:00
2010-10-19 17:40:49 +08:00
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th></th>
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
2010-10-19 17:40:49 +08:00
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th></th>
2010-04-23 06:27:13 +08:00
<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.
2010-06-25 21:32:01 +08:00
\section CoefficientWiseOperations Coefficient wise operations
2010-04-23 06:27:13 +08:00
2010-06-25 21:32:01 +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.:
\code a.cwise() * b \endcode
In Eigen3 this .cwise() prefix has been superseded by a new kind of matrix type called
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
a permanent conversion to the array world. Therefore, for binary operations such as the coefficient wise product,
both sides must be converted to an \em array as in the above example. On the other hand, when you
concatenate multiple coefficient wise operations you only have to do the conversion once, e.g.:
\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-04-23 06:27:13 +08:00
2010-06-25 21:32:01 +08:00
\section PartAndExtract Triangular and self-adjoint matrices
2010-04-23 06:27:13 +08:00
2010-06-25 21:32:01 +08:00
In Eigen 2 you had to play with the part, extract, and marked functions to deal with triangular and selfadjoint matrices. In Eigen 3, all these functions have been removed in favor of the concept of \em views:
2010-04-23 06:27:13 +08:00
2010-10-19 17:40:49 +08:00
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th></tr>
2010-06-25 21:32:01 +08:00
<tr><td>\code
A.part<UpperTriangular>();
A.part<StrictlyLowerTriangular>(); \endcode</td>
<td>\code
A.triangularView<Upper>()
A.triangularView<StrictlyLower>()\endcode</td></tr>
<tr><td>\code
A.extract<UpperTriangular>();
A.extract<StrictlyLowerTriangular>();\endcode</td>
<td>\code
A.triangularView<Upper>()
A.triangularView<StrictlyLower>()\endcode</td></tr>
<tr><td>\code
A.marked<UpperTriangular>();
A.marked<StrictlyLowerTriangular>();\endcode</td>
<td>\code
A.triangularView<Upper>()
A.triangularView<StrictlyLower>()\endcode</td></tr>
<tr><td colspan="2"></td></tr>
<tr><td>\code
A.part<SelfAdfjoint|UpperTriangular>();
A.extract<SelfAdfjoint|LowerTriangular>();\endcode</td>
<td>\code
A.selfadjointView<Upper>()
A.selfadjointView<Lower>()\endcode</td></tr>
<tr><td colspan="2"></td></tr>
2010-01-08 04:15:32 +08:00
<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-06-25 21:32:01 +08:00
\sa class TriangularView, class SelfAdjointView
\section TriangularSolveInPlace Triangular in-place solving
2010-10-19 17:40:49 +08:00
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th></tr>
2010-06-25 21:32:01 +08:00
<tr><td>\code A.triangularSolveInPlace<XxxTriangular>(Y);\endcode</td><td>\code A.triangularView<Xxx>().solveInPlace(Y);\endcode</td></tr>
</table>
2010-10-15 20:48:44 +08:00
\section Decompositions Matrix decompositions
Some of Eigen 2's matrix decompositions have been renamed in Eigen 3, while some others have been removed and are replaced by other decompositions in Eigen 3.
2010-10-19 17:40:49 +08:00
<table class="manual">
2010-10-15 20:48:44 +08:00
<tr>
2010-10-19 17:40:49 +08:00
<th>Eigen 2</th>
<th>Eigen 3</th>
<th>Notes</th>
2010-10-15 20:48:44 +08:00
</tr>
<tr>
<td>LU</td>
<td>FullPivLU</td>
2010-10-19 17:40:49 +08:00
<td class="alt">See also the new PartialPivLU, it's much faster</td>
2010-10-15 20:48:44 +08:00
</tr>
<tr>
<td>QR</td>
<td>HouseholderQR</td>
2010-10-19 17:40:49 +08:00
<td class="alt">See also the new ColPivHouseholderQR, it's more reliable</td>
2010-10-15 20:48:44 +08:00
</tr>
<tr>
<td>SVD</td>
<td>JacobiSVD</td>
2010-10-19 17:40:49 +08:00
<td class="alt">We currently don't have a bidiagonalizing SVD; of course this is planned.</td>
2010-10-15 20:48:44 +08:00
</tr>
<tr>
<td>EigenSolver and friends</td>
<td>\code #include<Eigen/Eigenvalues> \endcode </td>
2010-10-19 17:40:49 +08:00
<td class="alt">Moved to separate module</td>
2010-10-15 20:48:44 +08:00
</tr>
2010-10-18 19:23:48 +08:00
</table>
2010-10-15 20:48:44 +08:00
2010-06-25 21:32:01 +08:00
\section LinearSolvers Linear solvers
2010-10-19 17:40:49 +08:00
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th><th>Notes</th></tr>
2010-06-25 21:32:01 +08:00
<tr><td>\code A.lu();\endcode</td>
<td>\code A.fullPivLu();\endcode</td>
2010-10-19 17:40:49 +08:00
<td class="alt">Now A.lu() returns a PartialPivLU</td></tr>
2010-06-25 21:32:01 +08:00
<tr><td>\code A.lu().solve(B,&X);\endcode</td>
<td>\code X = A.lu().solve(B);
X = A.fullPivLu().solve(B);\endcode</td>
2010-10-19 17:40:49 +08:00
<td class="alt">The returned by value is fully optimized</td></tr>
2010-06-25 21:32:01 +08:00
<tr><td>\code A.llt().solve(B,&X);\endcode</td>
<td>\code X = A.llt().solve(B);
X = A.selfadjointView<Lower>.llt().solve(B);
X = A.selfadjointView<Upper>.llt().solve(B);\endcode</td>
2010-10-19 17:40:49 +08:00
<td class="alt">The returned by value is fully optimized and \n
2010-06-25 21:32:01 +08:00
the selfadjointView API allows you to select the \n
triangular part to work on (default is lower part)</td></tr>
<tr><td>\code A.llt().solveInPlace(B);\endcode</td>
<td>\code B = A.llt().solve(B);
B = A.selfadjointView<Lower>.llt().solve(B);
B = A.selfadjointView<Upper>.llt().solve(B);\endcode</td>
2010-10-19 17:40:49 +08:00
<td class="alt">In place solving</td></tr>
2010-06-25 21:32:01 +08:00
<tr><td>\code A.ldlt().solve(B,&X);\endcode</td>
<td>\code X = A.ldlt().solve(B);
X = A.selfadjointView<Lower>.ldlt().solve(B);
X = A.selfadjointView<Upper>.ldlt().solve(B);\endcode</td>
2010-10-19 17:40:49 +08:00
<td class="alt">The returned by value is fully optimized and \n
2010-06-25 21:32:01 +08:00
the selfadjointView API allows you to select the \n
triangular part to work on</td></tr>
</table>
2011-02-10 23:55:22 +08:00
\section GeometryModule Changes in the Geometry module
The Geometry module is the one that changed the most. If you rely heavily on it, it's probably a good idea to use the \ref Eigen2SupportModes "Eigen 2 support modes" to perform your migration.
2010-10-29 21:00:35 +08:00
\section Transform The Transform class
2010-04-23 06:27:13 +08:00
2011-02-11 01:58:37 +08:00
In Eigen 2, the Transform class didn't really know whether it was a projective or affine transformation. In Eigen 3, it takes a new \a Mode template parameter, which indicates whether it's \a Projective or \a Affine transform. There is no default value.
2010-10-29 21:00:35 +08:00
The Transform3f (etc) typedefs are no more. In Eigen 3, the Transform typedefs explicitly refer to the \a Projective and \a Affine modes:
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th><th>Notes</th></tr>
<tr>
<td> Transform3f </td>
<td> Affine3f or Projective3f </td>
<td> Of course 3f is just an example here </td>
</tr>
</table>
2010-04-23 06:27:13 +08:00
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
2010-10-15 20:48:44 +08:00
\section AlignMacros Alignment-related macros
The EIGEN_ALIGN_128 macro has been renamed to EIGEN_ALIGN16. Don't be surprised, it's just that we switched to counting in bytes ;-)
The EIGEN_DONT_ALIGN option still exists in Eigen 3, but it has a new cousin: EIGEN_DONT_ALIGN_STATICALLY. It allows to get rid of all static alignment issues while keeping alignment of dynamic-size heap-allocated arrays, thus keeping vectorization for dynamic-size objects.
\section AlignedMap Aligned Map objects
A common issue with Eigen 2 was that when mapping an array with Map, there was no way to tell Eigen that your array was aligned. There was a ForceAligned option but it didn't mean that; it was just confusing and has been removed.
2011-05-04 00:08:14 +08:00
New in Eigen3 is the #Aligned option. See the documentation of class Map. Use it like this:
2010-10-15 20:48:44 +08:00
\code
Map<Vector4f, Aligned> myMappedVector(some_aligned_array);
\endcode
2011-02-10 23:55:22 +08:00
There also are related convenience static methods, which actually are the preferred way as they take care of such things as constness:
2010-10-15 20:48:44 +08:00
\code
result = Vector4f::MapAligned(some_aligned_array);
\endcode
2011-03-04 23:24:41 +08:00
\section StdContainers STL Containers
2013-07-02 21:08:12 +08:00
In Eigen2, <tt>#include<Eigen/StdVector></tt> tweaked std::vector to automatically align elements. The problem was that that was quite invasive. In Eigen3, we only override standard behavior if you use Eigen::aligned_allocator<T> as your allocator type. So for example, if you use std::vector<Matrix4f>, you need to do the following change (note that aligned_allocator is under namespace Eigen):
2011-03-04 23:24:41 +08:00
<table class="manual">
<tr><th>Eigen 2</th><th>Eigen 3</th></tr>
<tr>
<td> \code std::vector<Matrix4f> \endcode </td>
<td> \code std::vector<Matrix4f, aligned_allocator<Matrix4f> > \endcode </td>
</tr>
</table>
2010-12-03 17:54:16 +08:00
\section eiPrefix Internal ei_ prefix
2010-12-03 18:22:35 +08:00
In Eigen2, global internal functions and structures were prefixed by \c ei_. In Eigen3, they all have been moved into the more explicit \c internal namespace. So, e.g., \c ei_sqrt(x) now becomes \c internal::sqrt(x). Of course it is not recommended to rely on Eigen's internal features.
2010-12-03 17:54:16 +08:00
2010-01-06 20:56:04 +08:00
*/
}