1 /* xbt_matrix_t management functions */
3 /* Copyright (c) 2006 Martin Quinson. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "xbt/function_types.h"
17 unsigned int lines, rows;
18 unsigned long elmsize;
21 void_f_pvoid_t free_f;
22 } s_xbt_matrix_t, *xbt_matrix_t;
25 /** @brief Retrieve the address of a cell (not its content)
27 #define xbt_matrix_get_ptr(mat,l,c) \
28 ((void*)&(mat)->data[(c)*(mat)->lines*(mat)->elmsize + (l)*(mat)->elmsize])
30 /** @brief Quick retrieval of scalar content
32 #define xbt_matrix_get_as(mat,l,c,type) *(type*)xbt_matrix_get_ptr(mat,l,c)
34 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new(int lines, int rows,
35 const unsigned long elmsize,
36 void_f_pvoid_t const free_f);
37 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new_sub(xbt_matrix_t from,
40 pvoid_f_pvoid_t const cpy_f);
42 XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix);
43 XBT_PUBLIC(void) xbt_matrix_free_voidp(void *d);
45 XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest, xbt_matrix_t src,
48 unsigned int lpos_dst,
49 unsigned int rpos_dst,
50 unsigned int lpos_src,
51 unsigned int rpos_src,
52 pvoid_f_pvoid_t const cpy_f);
54 XBT_PUBLIC(void) xbt_matrix_dump(xbt_matrix_t matrix, const char *name,
55 int coords, void_f_pvoid_t display_fun);
56 XBT_PUBLIC(void) xbt_matrix_dump_display_double(void *d);
59 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_zeros(int lines, int rows);
60 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_id(int lines, int rows);
61 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_rand(int lines, int rows);
62 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_seq(int lines, int rows);
63 XBT_PUBLIC(int) xbt_matrix_double_is_seq(xbt_matrix_t mat);
64 XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_mult(xbt_matrix_t A,
66 XBT_PUBLIC(void) xbt_matrix_double_addmult(xbt_matrix_t A, xbt_matrix_t B,
67 /*OUT*/ xbt_matrix_t C);
69 #endif /* XBT_MATRIX_H */