ConverterMatlabToNICE.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * @file ConverterMatlabToNICE.h
  3. * @author Alexander Freytag
  4. * @brief Several methods for converting Matlab data into NICE containers (Interface)
  5. * @date 15-01-2014 ( dd-mm-yyyy)
  6. */
  7. #ifndef _NICE_CONVERTERMATLABTONICEINCLUDE
  8. #define _NICE_CONVERTERMATLABTONICEINCLUDE
  9. // STL includes
  10. #include "mex.h"
  11. // NICE-core includes
  12. #include <core/vector/MatrixT.h>
  13. #include <core/vector/SparseVectorT.h>
  14. #include <core/vector/VectorT.h>
  15. namespace NICE {
  16. /**
  17. * @class ConverterMatlabToNICE
  18. * @author Alexander Freytag
  19. * @brief Several methods for converting Matlab data into NICE containers
  20. */
  21. class ConverterMatlabToNICE
  22. {
  23. protected:
  24. public:
  25. /**
  26. * @brief Default constructor
  27. **/
  28. ConverterMatlabToNICE();
  29. /**
  30. *@brief Default destructor
  31. **/
  32. ~ConverterMatlabToNICE();
  33. /**
  34. * @brief Convert a sparse matlab matrix into an std::vector of NICE::SparseVectors *
  35. * @TODO could be also converted into VVector!
  36. *
  37. * @param array_ptr Sparse MxD Matlab matrix
  38. * @return std::vector< NICE::SparseVector * >
  39. **/
  40. std::vector< const NICE::SparseVector * > convertSparseMatrixToNice( const mxArray *array_ptr ) const;
  41. /**
  42. * @brief Convert a sparse 1xD Matlab matrix into a SparseVector
  43. *
  44. * @param array_ptr Sparse 1xD Matlab matrix
  45. * @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.
  46. * @return NICE::SparseVector
  47. **/
  48. NICE::SparseVector convertSparseVectorToNice(
  49. const mxArray* array_ptr,
  50. const bool & b_adaptIndexMtoC = false
  51. ) const;
  52. /**
  53. * @brief Convert a MxD Matlab matrix into a NICE::Matrix
  54. *
  55. * @param matlabMatrix a matlab MxD matrix
  56. * @return NICE::Matrix
  57. **/
  58. NICE::Matrix convertDoubleMatrixToNice( const mxArray* matlabMatrix ) const;
  59. /**
  60. * @brief Convert a 1xD Matlab matrix into a NICE::Vector
  61. *
  62. * @param matlabMatrix a matlab 1xD matrix
  63. * @return NICE::Vector
  64. **/
  65. NICE::Vector convertDoubleVectorToNice( const mxArray* matlabMatrix ) const;
  66. /**
  67. * @brief Convert a Matlab char array into an std::string
  68. *
  69. * @param matlabString a matlab char array variable
  70. * @return std::string
  71. **/
  72. std::string convertMatlabToString( const mxArray *matlabString ) const;
  73. /**
  74. * @brief Convert a Matlab int32 variable into an std::int
  75. *
  76. * @param matlabInt32 a matlab int32 variable
  77. * @return int
  78. **/
  79. int convertMatlabToInt32( const mxArray *matlabInt32 ) const;
  80. /**
  81. * @brief Convert a Matlab double variable into an std::double
  82. *
  83. * @param matlabDouble a matlab double variable
  84. * @return double
  85. **/
  86. double convertMatlabToDouble( const mxArray *matlabDouble ) const;
  87. /**
  88. * @brief Convert a Matlab bool variable into an std::bool
  89. *
  90. * @param matlabBool a matlab bool variable
  91. * @return bool
  92. **/
  93. bool convertMatlabToBool( const mxArray *matlabBool ) const;
  94. };
  95. }
  96. #endif