38 namespace eigen_converter {
47 template <
class Derived>
49 typedef typename Derived::Scalar
Scalar;
50 core::Dtype dtype = core::Dtype::FromType<Scalar>();
51 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
52 matrix_row_major = matrix;
53 return core::Tensor(matrix_row_major.data(), {matrix.rows(), matrix.cols()},
62 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
70 Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
78 Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
126 const std::vector<Eigen::Vector3d> &values,
140 const std::vector<Eigen::Vector2d> &values,
154 const std::vector<Eigen::Vector2i> &values,
167 const std::vector<Eigen::Vector3i> &values,
core::Tensor EigenMatrixToTensor(const Eigen::MatrixBase< Derived > &matrix)
Converts a eigen matrix of shape (M, N) with alignment A and type T to a tensor.
Definition: EigenConverter.h:48
std::vector< Eigen::Vector2i > TensorToEigenVector2iVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2i>. An exception will be thrown if the...
Definition: EigenConverter.cpp:179
core::Tensor EigenVector3iVectorToTensor(const std::vector< Eigen::Vector3i > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector3i to a (N, 3) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:198
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXd(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXd of same shape. Regardless of the tensor dtype, the output will be converted to double.
Definition: EigenConverter.cpp:86
core::Tensor EigenVector2iVectorToTensor(const std::vector< Eigen::Vector2i > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector2i to a (N, 2) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:204
Definition: PinholeCameraIntrinsic.cpp:35
Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXi(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXi of same shape. Regardless of the tensor dtype, the output will be converted to int.
Definition: EigenConverter.cpp:96
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXf(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXf of same shape. Regardless of the tensor dtype, the output will be converted to float.
Definition: EigenConverter.cpp:91
core::Tensor EigenVector2dVectorToTensor(const std::vector< Eigen::Vector2d > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector2d to a (N, 2) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:191
std::vector< Eigen::Vector2d > TensorToEigenVector2dVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2d>. An exception will be thrown if the...
Definition: EigenConverter.cpp:164
core::Tensor EigenVector3dVectorToTensor(const std::vector< Eigen::Vector3d > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector3d to a (N, 3) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:184
std::vector< Eigen::Vector3i > TensorToEigenVector3iVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3i>. An exception will be thrown if the...
Definition: EigenConverter.cpp:174
std::vector< Eigen::Vector3d > TensorToEigenVector3dVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3d>. An exception will be thrown if the...
Definition: EigenConverter.cpp:169