namespace new in 2019.10
EigenIntegrationIntegration with Eigen.
Conversion of math types from and to the Eigen library.
Usage
This library depends on the Eigen library and is built if MAGNUM_WITH_EIGEN
is enabled when building Magnum Integration. To use this library with CMake, put FindMagnumIntegration.cmake into your modules/
directory, request the Eigen
component of the MagnumIntegration
package and link to the MagnumIntegration::Eigen
target:
find_package(MagnumIntegration REQUIRED Eigen) # ... target_link_libraries(your-app PRIVATE MagnumIntegration::Eigen)
Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-integration and eigen repositories and do the following before calling find_package()
. If you want to use system-installed Eigen, omit the first part and point CMAKE_PREFIX_PATH
to its installation dir if necessary.
set(EIGEN3_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/eigen) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/eigen/cmake) set(MAGNUM_WITH_EIGEN ON CACHE BOOL "" FORCE) add_subdirectory(magnum-integration EXCLUDE_FROM_ALL)
See also Downloading and building integration libraries and Integration library usage with CMake for more information.
Type conversion
The library provides built-in conversion between Eigen's types and Magnum's own types. For example, an Eigen::
#include <Magnum/EigenIntegration/Integration.h> … Eigen::Vector3f a{1.0f, 2.0f, 3.0f}; Vector3 b(a); auto c = Matrix4::rotation(35.0_degf, Vector3(a));
Or you can make a Containers::
#include <Magnum/EigenIntegration/DynamicMatrixIntegration.h> … Eigen::MatrixXd data = …; Containers::StridedArrayView2D<Double> view = EigenIntegration::arrayCast(data);
The integration routines are provided in the Magnum/
Functions
-
template<class T>auto arrayCast(const Containers::
StridedArrayView2D<T>& from) -> Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Unaligned, Eigen:: Stride<Eigen::Dynamic, Eigen::Dynamic>> new in Git master - Convert a Containers::
StridedArrayView2D to Eigen's dynamic matrix type. -
template<class T>auto arrayCast(const Containers::
StridedArrayView1D<T>& from) -> Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>, Eigen::Unaligned, Eigen::InnerStride<>> new in Git master - Convert a Containers::
StridedArrayView1D to Eigen's dynamic vector type. -
template<class Derived>auto arrayCast(const Eigen::DenseCoeffsBase<Derived, Eigen::DirectWriteAccessors>& from) -> std::
enable_if<..., Containers:: StridedArrayView1D<typename Derived:: Scalar>>::type new in Git master - Convert an Eigen expression to Containers::
StridedArrayView1D. -
template<class Derived>auto arrayCast(const Eigen::DenseCoeffsBase<Derived, Eigen::DirectWriteAccessors>& from) -> std::
enable_if<..., Containers:: StridedArrayView2D<typename Derived:: Scalar>>::type new in Git master - Convert an Eigen expression to Containers::
StridedArrayView2D. -
template<class Derived, int Direction>auto arrayCast(const Eigen::Reverse<Derived, Direction>& from) -> std::
enable_if<..., Containers:: StridedArrayView1D<typename Derived:: Scalar>>::type new in Git master - Convert an Eigen reverse expression to Containers::
StridedArrayView1D. -
template<class Derived, int Direction>auto arrayCast(const Eigen::Reverse<Derived, Direction>& from) -> std::
enable_if<..., Containers:: StridedArrayView2D<typename Derived:: Scalar>>::type new in Git master - Convert an Eigen reverse expression to Containers::
StridedArrayView2D. -
template<class To, class T>auto cast(const Math::
Quaternion<T>& from) -> To new in 2019.10 - Convert a Magnum type to Eigen type.
-
template<class To, std::auto cast(const Math::
size_t cols, std:: size_t rows, class T> RectangularMatrix<cols, rows, T>& from) -> To new in 2019.10 - Convert a Magnum type to Eigen type.
-
template<class To, std::auto cast(const Math::
size_t size> BitVector<size>& from) -> To new in 2019.10 -
template<class To, std::auto cast(const Math::
size_t size, class T> Vector<size, T>& from) -> To new in 2019.10
Function documentation
template<class T>
Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Unaligned, Eigen:: Stride<Eigen::Dynamic, Eigen::Dynamic>> Magnum:: EigenIntegration:: arrayCast(const Containers:: StridedArrayView2D<T>& from) new in Git master
Convert a Containers::
template<class T>
Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>, Eigen::Unaligned, Eigen::InnerStride<>> Magnum:: EigenIntegration:: arrayCast(const Containers:: StridedArrayView1D<T>& from) new in Git master
Convert a Containers::
Since for a one-dimensional Containers::
template<class Derived>
std:: enable_if<..., Containers:: StridedArrayView1D<typename Derived:: Scalar>>::type Magnum:: EigenIntegration:: arrayCast(const Eigen::DenseCoeffsBase<Derived, Eigen::DirectWriteAccessors>& from) new in Git master
Convert an Eigen expression to Containers::
If it is known at compile time that the Eigen expression has either one column or one row, then this function maps the Eigen expression to a Containers::
template<class Derived>
std:: enable_if<..., Containers:: StridedArrayView2D<typename Derived:: Scalar>>::type Magnum:: EigenIntegration:: arrayCast(const Eigen::DenseCoeffsBase<Derived, Eigen::DirectWriteAccessors>& from) new in Git master
Convert an Eigen expression to Containers::
Takes care of any Eigen expression that was not handled by the one-dimensional overload above.
template<class Derived, int Direction>
std:: enable_if<..., Containers:: StridedArrayView1D<typename Derived:: Scalar>>::type Magnum:: EigenIntegration:: arrayCast(const Eigen::Reverse<Derived, Direction>& from) new in Git master
Convert an Eigen reverse expression to Containers::
If it is known at compile time that the Eigen reverse expression has either one column or one row, then this function maps the Eigen reverse expression to a Containers::
template<class Derived, int Direction>
std:: enable_if<..., Containers:: StridedArrayView2D<typename Derived:: Scalar>>::type Magnum:: EigenIntegration:: arrayCast(const Eigen::Reverse<Derived, Direction>& from) new in Git master
Convert an Eigen reverse expression to Containers::
Takes care of any Eigen expression that was not handled by the one-dimensional overload above.
template<class To, class T>
To Magnum:: EigenIntegration:: cast(const Math:: Quaternion<T>& from) new in 2019.10
Convert a Magnum type to Eigen type.
Provided only for consistency with cast(const Math::
template<class To, std:: size_t cols, std:: size_t rows, class T>
To Magnum:: EigenIntegration:: cast(const Math:: RectangularMatrix<cols, rows, T>& from) new in 2019.10
Convert a Magnum type to Eigen type.
Due to the design of Eigen::
template<class To, std:: size_t size>
To Magnum:: EigenIntegration:: cast(const Math:: BitVector<size>& from) new in 2019.10
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class To, std:: size_t size, class T>
To Magnum:: EigenIntegration:: cast(const Math:: Vector<size, T>& from) new in 2019.10
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.