binary_library.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla
  7. // Public License v. 2.0. If a copy of the MPL was not distributed
  8. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. // This is a pure C header, no C++ here.
  10. // The functions declared here will be implemented in C++ but
  11. // we don't have to know, because thanks to the extern "C" syntax,
  12. // they will be compiled to C object code.
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. // just dummy empty structs to give different pointer types,
  18. // instead of using void* which would be type unsafe
  19. struct C_MatrixXd {};
  20. struct C_Map_MatrixXd {};
  21. // the C_MatrixXd class, wraps some of the functionality
  22. // of Eigen::MatrixXd.
  23. struct C_MatrixXd* MatrixXd_new(int rows, int cols);
  24. void MatrixXd_delete (struct C_MatrixXd *m);
  25. double* MatrixXd_data (struct C_MatrixXd *m);
  26. void MatrixXd_set_zero (struct C_MatrixXd *m);
  27. void MatrixXd_resize (struct C_MatrixXd *m, int rows, int cols);
  28. void MatrixXd_copy (struct C_MatrixXd *dst,
  29. const struct C_MatrixXd *src);
  30. void MatrixXd_copy_map (struct C_MatrixXd *dst,
  31. const struct C_Map_MatrixXd *src);
  32. void MatrixXd_set_coeff (struct C_MatrixXd *m,
  33. int i, int j, double coeff);
  34. double MatrixXd_get_coeff (const struct C_MatrixXd *m,
  35. int i, int j);
  36. void MatrixXd_print (const struct C_MatrixXd *m);
  37. void MatrixXd_add (const struct C_MatrixXd *m1,
  38. const struct C_MatrixXd *m2,
  39. struct C_MatrixXd *result);
  40. void MatrixXd_multiply (const struct C_MatrixXd *m1,
  41. const struct C_MatrixXd *m2,
  42. struct C_MatrixXd *result);
  43. // the C_Map_MatrixXd class, wraps some of the functionality
  44. // of Eigen::Map<MatrixXd>
  45. struct C_Map_MatrixXd* Map_MatrixXd_new(double *array, int rows, int cols);
  46. void Map_MatrixXd_delete (struct C_Map_MatrixXd *m);
  47. void Map_MatrixXd_set_zero (struct C_Map_MatrixXd *m);
  48. void Map_MatrixXd_copy (struct C_Map_MatrixXd *dst,
  49. const struct C_Map_MatrixXd *src);
  50. void Map_MatrixXd_copy_matrix(struct C_Map_MatrixXd *dst,
  51. const struct C_MatrixXd *src);
  52. void Map_MatrixXd_set_coeff (struct C_Map_MatrixXd *m,
  53. int i, int j, double coeff);
  54. double Map_MatrixXd_get_coeff (const struct C_Map_MatrixXd *m,
  55. int i, int j);
  56. void Map_MatrixXd_print (const struct C_Map_MatrixXd *m);
  57. void Map_MatrixXd_add (const struct C_Map_MatrixXd *m1,
  58. const struct C_Map_MatrixXd *m2,
  59. struct C_Map_MatrixXd *result);
  60. void Map_MatrixXd_multiply (const struct C_Map_MatrixXd *m1,
  61. const struct C_Map_MatrixXd *m2,
  62. struct C_Map_MatrixXd *result);
  63. #ifdef __cplusplus
  64. } // end extern "C"
  65. #endif