1 /* xbt_matrix_t management functions */
3 /* Copyright (c) 2006-2007, 2009-2010, 2013-2014. The SimGrid Team.
4 * All rights reserved. */
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. */
13 #include "xbt/function_types.h"
18 unsigned int lines, rows;
19 unsigned long elmsize;
22 void_f_pvoid_t free_f;
23 } s_xbt_matrix_t, *xbt_matrix_t;
26 /** @brief Retrieve the address of a cell (not its content)
28 #define xbt_matrix_get_ptr(mat,l,c) \
29 ((void*)&(mat)->data[(c)*(mat)->lines*(mat)->elmsize + (l)*(mat)->elmsize])
31 /** @brief Quick retrieval of scalar content
33 #define xbt_matrix_get_as(mat,l,c,type) *(type*)xbt_matrix_get_ptr(mat,l,c)
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);
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);
44 XBT_PUBLIC(void) xbt_matrix_dump(xbt_matrix_t matrix, const char *name, int coords, void_f_pvoid_t display_fun);
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);
51 #endif /* XBT_MATRIX_H */