ConverterMatlabToNICE.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. namespace MatlabConversion {
  17. /**
  18. * @author Alexander Freytag, Johannes Ruehle
  19. * @brief Several methods for converting Matlab data into NICE containers
  20. */
  21. /**
  22. * @brief Convert a sparse matlab matrix into an std::vector of NICE::SparseVectors *
  23. * @TODO could be also converted into VVector!
  24. *
  25. * @param array_ptr Sparse MxD Matlab matrix
  26. * @return std::vector< NICE::SparseVector * >
  27. **/
  28. std::vector< const NICE::SparseVector * > convertSparseMatrixToNice( const mxArray *array_ptr );
  29. /**
  30. * @brief Convert a sparse 1xD Matlab matrix into a SparseVector
  31. *
  32. * @param array_ptr Sparse 1xD Matlab matrix
  33. * @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.
  34. * @return NICE::SparseVector
  35. **/
  36. NICE::SparseVector convertSparseVectorToNice( const mxArray* array_ptr, const bool & b_adaptIndexMtoC = false );
  37. /**
  38. * @brief Convert a MxD Matlab matrix into a NICE::Matrix
  39. *
  40. * @param matlabMatrix a matlab MxD matrix
  41. * @return NICE::Matrix
  42. **/
  43. NICE::Matrix convertDoubleMatrixToNice( const mxArray* matlabMatrix );
  44. /**
  45. * @brief Convert a 1xD Matlab matrix into a NICE::Vector
  46. *
  47. * @param matlabMatrix a matlab 1xD matrix
  48. * @return NICE::Vector
  49. **/
  50. NICE::Vector convertDoubleVectorToNice( const mxArray* matlabMatrix );
  51. /**
  52. * @brief Convert a Matlab char array into an std::string
  53. *
  54. * @param matlabString a matlab char array variable
  55. * @return std::string
  56. **/
  57. std::string convertMatlabToString( const mxArray *matlabString );
  58. /**
  59. * @brief Convert a Matlab int32 scalar variable into an std::int
  60. *
  61. * @param matlabInt32 a matlab int32 variable
  62. * @return int
  63. **/
  64. int convertMatlabToInt32( const mxArray *matlabInt32 );
  65. /**
  66. * @brief Convert a Matlab double variable into an std::double
  67. *
  68. * @param matlabDouble a matlab double variable
  69. * @return double
  70. **/
  71. double convertMatlabToDouble( const mxArray *matlabDouble );
  72. /**
  73. * @brief Convert a Matlab bool variable into an std::bool
  74. *
  75. * @param matlabBool a matlab bool variable
  76. * @return bool
  77. **/
  78. bool convertMatlabToBool( const mxArray *matlabBool );
  79. } //ns MatlabConversion
  80. }
  81. #endif