ConverterMatlabToNICE.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifdef NICE_USELIB_MEX
  2. /**
  3. * @file ConverterMatlabToNICE.h
  4. * @author Alexander Freytag
  5. * @brief Several methods for converting Matlab data into NICE containers (Interface)
  6. * @date 15-01-2014 ( dd-mm-yyyy)
  7. */
  8. #ifndef _NICE_CONVERTERMATLABTONICEINCLUDE
  9. #define _NICE_CONVERTERMATLABTONICEINCLUDE
  10. // STL includes
  11. #include "mex.h"
  12. // NICE-core includes
  13. #include <core/vector/MatrixT.h>
  14. #include <core/vector/SparseVectorT.h>
  15. #include <core/vector/VectorT.h>
  16. namespace NICE {
  17. namespace MatlabConversion {
  18. /**
  19. * @author Alexander Freytag, Johannes Ruehle
  20. * @brief Several methods for converting Matlab data into NICE containers
  21. */
  22. /**
  23. * @brief Convert a sparse matlab matrix into an std::vector of NICE::SparseVectors *
  24. * @TODO could be also converted into VVector!
  25. *
  26. * @param array_ptr Sparse MxD Matlab matrix
  27. * @return std::vector< NICE::SparseVector * >
  28. **/
  29. std::vector< const NICE::SparseVector * > convertSparseMatrixToNice( const mxArray *array_ptr );
  30. /**
  31. * @brief Convert a sparse 1xD Matlab matrix into a SparseVector
  32. *
  33. * @param array_ptr Sparse 1xD Matlab matrix
  34. * @param b_adaptIndexMtoC if true, dim k will be inserted as k, not as k-1 (which would be the default for M->C). Defaults to false.
  35. * @return NICE::SparseVector
  36. **/
  37. NICE::SparseVector convertSparseVectorToNice( const mxArray* array_ptr, const bool & b_adaptIndexMtoC = false );
  38. /**
  39. * @brief Convert a MxD Matlab matrix into a NICE::Matrix
  40. *
  41. * @param matlabMatrix a matlab MxD matrix
  42. * @return NICE::Matrix
  43. **/
  44. NICE::Matrix convertDoubleMatrixToNice( const mxArray* matlabMatrix );
  45. /**
  46. * @brief Convert a 1xD Matlab matrix into a NICE::Vector
  47. *
  48. * @param matlabMatrix a matlab 1xD matrix
  49. * @return NICE::Vector
  50. **/
  51. NICE::Vector convertDoubleVectorToNice( const mxArray* matlabMatrix );
  52. /**
  53. * @brief Convert a Matlab char array into an std::string
  54. *
  55. * @param matlabString a matlab char array variable
  56. * @return std::string
  57. **/
  58. std::string convertMatlabToString( const mxArray *matlabString );
  59. /**
  60. * @brief Convert a Matlab int32 scalar variable into an std::int
  61. *
  62. * @param matlabInt32 a matlab int32 variable
  63. * @return int
  64. **/
  65. int convertMatlabToInt32( const mxArray *matlabInt32 );
  66. /**
  67. * @brief Convert a Matlab double variable into an std::double
  68. *
  69. * @param matlabDouble a matlab double variable
  70. * @return double
  71. **/
  72. double convertMatlabToDouble( const mxArray *matlabDouble );
  73. /**
  74. * @brief Convert a Matlab bool variable into an std::bool
  75. *
  76. * @param matlabBool a matlab bool variable
  77. * @return bool
  78. **/
  79. bool convertMatlabToBool( const mxArray *matlabBool );
  80. } //ns MatlabConversion
  81. }
  82. #endif
  83. #endif