ndarray
NumPy-friendly multidimensional arrays in C++
|
Functions that return an Eigen Map non-reference-counted view into an ndarray::Array. More...
Go to the source code of this file.
Functions | |
template<typename XprKind , typename T , int N, int C> | |
detail::SelectEigenMap< T, N, C, XprKind >::Type | ndarray::asEigen (Array< T, N, C > const &a) |
template<typename XprKind , typename T , int N, int C> | |
detail::SelectEigenMap< T, N, C, XprKind >::Type | ndarray::asEigen (ArrayRef< T, N, C > const &a) |
template<typename T , int N, int C> | |
detail::SelectEigenMap< T, N, C, Eigen::ArrayXpr >::Type | ndarray::asEigenArray (Array< T, N, C > const &a) |
template<typename T , int N, int C> | |
detail::SelectEigenMap< T, N, C, Eigen::ArrayXpr >::Type | ndarray::asEigenArray (ArrayRef< T, N, C > const &a) |
template<typename T , int N, int C> | |
detail::SelectEigenMap< T, N, C, Eigen::MatrixXpr >::Type | ndarray::asEigenMatrix (Array< T, N, C > const &a) |
template<typename T , int N, int C> | |
detail::SelectEigenMap< T, N, C, Eigen::MatrixXpr >::Type | ndarray::asEigenMatrix (ArrayRef< T, N, C > const &a) |
Functions that return an Eigen Map non-reference-counted view into an ndarray::Array.
detail::SelectEigenMap< T, N, C, XprKind >::Type ndarray::asEigen | ( | Array< T, N, C > const & | a | ) |
Use asEigenArray(array) or asEigen<Eigen::ArrayXpr>(array) to obtain an Eigen::Array-like view of an ndarray array. Use asEigenMatrix(array) or asEigen<Eigen::MatrixXpr>(array) to obtain an Eigen::Matrix-like view of an ndarray array. The returned view is an Eigen::Map whose memory is owned by the ndarray array.
Be careful when calling these functions on a temporary ndarray array, as you must keep the temporary alive until you are done with the returned Eigen::Map. For example the following will have undefined behavior:
auto eigenMap = asEigenMatrix(makeNdArray(...)); // at this point the temporary ndarray array is gone and eigenMap is broken processMatrix(eigenMap);
This version is safe:
processMatrix(asEigenMatrix(makeNdArray(...)));
This version is also safe and allows you to do additional processing of the Eigen map:
auto arr = makeNdArray(...); auto eigenMap = asEigenMatrix(arr); processMatrix(eigenMap); // ... do more with eigenMap