Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to fix the windows build (+clang-format)
[simgrid.git] / include / xbt / matrix.h
1 /* xbt_matrix_t management functions                                        */
2
3 /* Copyright (c) 2006-2007, 2009-2010, 2013-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef XBT_MATRIX_H
10 #define XBT_MATRIX_H
11
12 #include "xbt/misc.h"
13 #include "xbt/function_types.h"
14
15 SG_BEGIN_DECL()
16
17 typedef struct {
18   unsigned int lines, rows;
19   unsigned long elmsize;
20
21   char *data;
22   void_f_pvoid_t free_f;
23 } s_xbt_matrix_t, *xbt_matrix_t;
24
25
26   /** @brief Retrieve the address of a cell (not its content)
27    *  @hideinitializer */
28 #define xbt_matrix_get_ptr(mat,l,c) \
29   ((void*)&(mat)->data[(c)*(mat)->lines*(mat)->elmsize + (l)*(mat)->elmsize])
30
31   /** @brief Quick retrieval of scalar content
32    *  @hideinitializer */
33 #define xbt_matrix_get_as(mat,l,c,type) *(type*)xbt_matrix_get_ptr(mat,l,c)
34
35 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new(int lines, int rows, const unsigned long elmsize, void_f_pvoid_t const free_f);
36 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new_sub(xbt_matrix_t from, int lsize, int rsize, int lpos, int rpos,
37                                             pvoid_f_pvoid_t const cpy_f);
38 XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix);
39
40 XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest, xbt_matrix_t src, unsigned int lsize, unsigned int rsize,
41                                         unsigned int lpos_dst, unsigned int rpos_dst, unsigned int lpos_src,
42                                         unsigned int rpos_src, pvoid_f_pvoid_t const cpy_f);
43
44 XBT_PUBLIC(void) xbt_matrix_dump(xbt_matrix_t matrix, const char *name, int coords, void_f_pvoid_t display_fun);
45
46 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_zeros(int lines, int rows);
47 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_id(int lines, int rows);
48 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_seq(int lines, int rows);
49 XBT_PUBLIC(void) xbt_matrix_double_addmult(xbt_matrix_t A, xbt_matrix_t B, /*OUT*/ xbt_matrix_t C);
50 SG_END_DECL()
51 #endif                          /* XBT_MATRIX_H */