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