p2m.m 585 B

1234567891011121314151617
  1. % Converts a python-wrapped Eigen Matrix to a Matlab matrix
  2. function [ M ] = p2m( P )
  3. if py.repr(py.type(P)) == '<class ''igl.eigen.MatrixXd''>'
  4. % Convert it to a python array first
  5. t = py.array.array('d',P);
  6. % Reshape it
  7. M = reshape(double(t),P.rows(),P.cols());
  8. elseif py.repr(py.type(P)) == '<class ''igl.eigen.MatrixXi''>'
  9. % Convert it to a python array first
  10. t = py.array.array('i',P);
  11. % Reshape it
  12. M = reshape(int32(t),P.rows(),P.cols());
  13. else
  14. error('Unsupported numerical type.');
  15. end
  16. end