Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A new datacontainer: the matrix
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 24 May 2006 09:56:55 +0000 (09:56 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 24 May 2006 09:56:55 +0000 (09:56 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2289 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/xbt/matrix.h [new file with mode: 0644]

diff --git a/include/xbt/matrix.h b/include/xbt/matrix.h
new file mode 100644 (file)
index 0000000..d5b67a6
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Id$ */
+
+/* xbt_matrix_t management functions                                        */
+
+/* Copyright (c) 2006 Martin Quinson. All rights reserved.                  */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef XBT_MATRIX_H
+#define XBT_MATRIX_H
+
+#include "xbt/misc.h"
+#include "xbt/function_types.h"
+
+SG_BEGIN_DECL()
+
+typedef struct {
+  unsigned int lines, rows;
+  unsigned long elmsize;
+
+  char *data;
+  void_f_pvoid_t *free_f;
+} s_xbt_matrix_t, *xbt_matrix_t;
+
+
+  /** @brief Retrieve the address of a cell (not its content)
+   *  @hideinitializer */
+#define xbt_matrix_get_ptr(mat,l,c) \
+  ((void*)&(mat)->data[(c)*(mat)->lines*(mat)->elmsize + (l)*(mat)->elmsize])
+
+  /** @brief Quick retrieval of scalar content
+   *  @hideinitializer */
+#define xbt_matrix_get_as(mat,l,c,type) *(type*)xbt_matrix_getp(mat,l,c) 
+
+xbt_matrix_t xbt_matrix_new(int lines, int rows, 
+                           const unsigned long elmsize,
+                           void_f_pvoid_t * const free_f);
+void xbt_matrix_free(xbt_matrix_t matrix);
+void xbt_matrix_free_voidp(void *d);
+
+void xbt_matrix_dump(xbt_matrix_t matrix, const char *name,
+                    void_f_pvoid_t display_fun);
+
+SG_END_DECL()
+
+
+#endif /* XBT_MATRIX_H */