prepare_lhs.cpp 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #include "prepare_lhs.h"
  2. #include <algorithm>
  3. template <typename DerivedV>
  4. IGL_INLINE void igl::prepare_lhs_double(
  5. const Eigen::PlainObjectBase<DerivedV> & V,
  6. mxArray *plhs[])
  7. {
  8. using namespace std;
  9. plhs[0] = mxCreateDoubleMatrix(V.rows(),V.cols(), mxREAL);
  10. double * Vp = mxGetPr(plhs[0]);
  11. copy(&V.data()[0],&V.data()[0]+V.size(),Vp);
  12. }
  13. template <typename DerivedV>
  14. IGL_INLINE void igl::prepare_lhs_index(
  15. const Eigen::PlainObjectBase<DerivedV> & V,
  16. mxArray *plhs[])
  17. {
  18. // Treat indices as reals
  19. const auto Vd = (V.template cast<double>().array()+1).eval();
  20. return prepare_lhs_double(Vd,plhs);
  21. }
  22. #ifndef IGL_HEADER_ONLY
  23. template void igl::prepare_lhs_index<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
  24. template void igl::prepare_lhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
  25. template void igl::prepare_lhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, mxArray_tag**);
  26. #endif