mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
tutorial: extend casting section with set
This commit is contained in:
parent
cc6121b98d
commit
a040b7f15d
@ -190,13 +190,21 @@ v = 6 6 6
|
|||||||
|
|
||||||
\subsection TutorialCasting Casting
|
\subsection TutorialCasting Casting
|
||||||
|
|
||||||
In Eigen, any matrices of same size and same scalar type are all naturally compatible. The scalar type can be explicitely casted to another one using the template cast() function:
|
In Eigen, any matrices of same size and same scalar type are all naturally compatible. The scalar type can be explicitely casted to another one using the template MatrixBase::cast() function:
|
||||||
\code
|
\code
|
||||||
Matrix3d md(1,2,3);
|
Matrix3d md(1,2,3);
|
||||||
Matrix3f mf = md.cast<float>();
|
Matrix3f mf = md.cast<float>();
|
||||||
\endcode
|
\endcode
|
||||||
Note that casting to the same scalar type in an expression is free.
|
Note that casting to the same scalar type in an expression is free.
|
||||||
|
|
||||||
|
The sizes of a resizable destination matrix can be changed automatically using the Matrix::set() function:
|
||||||
|
\code
|
||||||
|
MatrixXf res(10,10);
|
||||||
|
Matrix3f a, b;
|
||||||
|
res = a + b; // does not work (no automatic resizing)
|
||||||
|
res.set(a+b); // OK
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
|
||||||
\subsection TutorialMap Map
|
\subsection TutorialMap Map
|
||||||
Any memory buffer can be mapped as an Eigen expression:
|
Any memory buffer can be mapped as an Eigen expression:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user