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 (at) 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 10 // This is a pure C header, no C++ here. 11 // The functions declared here will be implemented in C++ but 12 // we don't have to know, because thanks to the extern "C" syntax, 13 // they will be compiled to C object code. 14 15 #ifdef __cplusplus 16 extern "C" 17 { 18 #endif 19 20 // just dummy empty structs to give different pointer types, 21 // instead of using void* which would be type unsafe 22 struct C_MatrixXd {}; 23 struct C_Map_MatrixXd {}; 24 25 // the C_MatrixXd class, wraps some of the functionality 26 // of Eigen::MatrixXd. 27 struct C_MatrixXd* MatrixXd_new(int rows, int cols); 28 void MatrixXd_delete (struct C_MatrixXd *m); 29 double* MatrixXd_data (struct C_MatrixXd *m); 30 void MatrixXd_set_zero (struct C_MatrixXd *m); 31 void MatrixXd_resize (struct C_MatrixXd *m, int rows, int cols); 32 void MatrixXd_copy (struct C_MatrixXd *dst, 33 const struct C_MatrixXd *src); 34 void MatrixXd_copy_map (struct C_MatrixXd *dst, 35 const struct C_Map_MatrixXd *src); 36 void MatrixXd_set_coeff (struct C_MatrixXd *m, 37 int i, int j, double coeff); 38 double MatrixXd_get_coeff (const struct C_MatrixXd *m, 39 int i, int j); 40 void MatrixXd_print (const struct C_MatrixXd *m); 41 void MatrixXd_add (const struct C_MatrixXd *m1, 42 const struct C_MatrixXd *m2, 43 struct C_MatrixXd *result); 44 void MatrixXd_multiply (const struct C_MatrixXd *m1, 45 const struct C_MatrixXd *m2, 46 struct C_MatrixXd *result); 47 48 // the C_Map_MatrixXd class, wraps some of the functionality 49 // of Eigen::Map<MatrixXd> 50 struct C_Map_MatrixXd* Map_MatrixXd_new(double *array, int rows, int cols); 51 void Map_MatrixXd_delete (struct C_Map_MatrixXd *m); 52 void Map_MatrixXd_set_zero (struct C_Map_MatrixXd *m); 53 void Map_MatrixXd_copy (struct C_Map_MatrixXd *dst, 54 const struct C_Map_MatrixXd *src); 55 void Map_MatrixXd_copy_matrix(struct C_Map_MatrixXd *dst, 56 const struct C_MatrixXd *src); 57 void Map_MatrixXd_set_coeff (struct C_Map_MatrixXd *m, 58 int i, int j, double coeff); 59 double Map_MatrixXd_get_coeff (const struct C_Map_MatrixXd *m, 60 int i, int j); 61 void Map_MatrixXd_print (const struct C_Map_MatrixXd *m); 62 void Map_MatrixXd_add (const struct C_Map_MatrixXd *m1, 63 const struct C_Map_MatrixXd *m2, 64 struct C_Map_MatrixXd *result); 65 void Map_MatrixXd_multiply (const struct C_Map_MatrixXd *m1, 66 const struct C_Map_MatrixXd *m2, 67 struct C_Map_MatrixXd *result); 68 69 #ifdef __cplusplus 70 } // end extern "C" 71 #endif