1 /* xbt_matrix_t management functions */
3 /* Copyright (c) 2006, 2007, 2009, 2010. 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,
36 const unsigned long elmsize,
37 void_f_pvoid_t const free_f);
38 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new_sub(xbt_matrix_t from,
41 pvoid_f_pvoid_t const cpy_f);
43 XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix);
44 XBT_PUBLIC(void) xbt_matrix_free_voidp(void *d);
46 XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest,
50 unsigned int lpos_dst,
51 unsigned int rpos_dst,
52 unsigned int lpos_src,
53 unsigned int rpos_src,
54 pvoid_f_pvoid_t const cpy_f);
56 XBT_PUBLIC(void) xbt_matrix_dump(xbt_matrix_t matrix, const char *name,
57 int coords, void_f_pvoid_t display_fun);
58 XBT_PUBLIC(void) xbt_matrix_dump_display_double(void *d);
61 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_zeros(int lines, int rows);
62 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_id(int lines, int rows);
63 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_rand(int lines, int rows);
64 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_seq(int lines, int rows);
65 XBT_PUBLIC(int) xbt_matrix_double_is_seq(xbt_matrix_t mat);
66 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_mult(xbt_matrix_t A,
68 XBT_PUBLIC(void) xbt_matrix_double_addmult(xbt_matrix_t A, xbt_matrix_t B,
69 /*OUT*/ xbt_matrix_t C);
71 #endif /* XBT_MATRIX_H */