Expose mju_sparse2dense to public API.

PiperOrigin-RevId: 688985153
Change-Id: I9559f1d47363d0afada80c86abdc729cd1910b63
This commit is contained in:
Yuval Tassa
2024-10-23 09:00:33 -07:00
committed by Copybara-Service
parent b598d79b3f
commit e14aebfd16
9 changed files with 103 additions and 2 deletions
+19
View File
@@ -1021,6 +1021,25 @@ PYBIND11_MODULE(_functions, pymodule) {
});
Def<traits::mju_transformSpatial>(pymodule);
// Sparse math
DEF_WITH_OMITTED_PY_ARGS(traits::mju_sparse2dense, "nr", "nc")(
pymodule,
[](Eigen::Ref<EigenArrayXX> res,
Eigen::Ref<const EigenVectorX> mat,
Eigen::Ref<const EigenVectorI> rownnz,
Eigen::Ref<const EigenVectorI> rowadr,
Eigen::Ref<const EigenVectorI> colind) {
if (res.rows() != rownnz.size()) {
throw py::type_error("#rows in res should equal size of rownnz");
}
if (res.rows() != rowadr.size()) {
throw py::type_error("#rows in res should equal size of rowadr");
}
return ::mju_sparse2dense(res.data(), mat.data(), res.rows(),
res.cols(), rownnz.data(), rowadr.data(),
colind.data());
});
// Quaternions
Def<traits::mju_rotVecQuat>(pymodule);
Def<traits::mju_negQuat>(pymodule);