1 /**-------------------------------------------------------------------**
3 **-------------------------------------------------------------------**
5 **-------------------------------------------------------------------**/
8 /******************************************************************************
9 * CLooG : the Chunky Loop Generator (experimental) *
10 ******************************************************************************
12 * Copyright (C) 2001-2005 Cedric Bastoul *
14 * This library is free software; you can redistribute it and/or *
15 * modify it under the terms of the GNU Lesser General Public *
16 * License as published by the Free Software Foundation; either *
17 * version 2.1 of the License, or (at your option) any later version. *
19 * This library is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Lesser General Public License for more details. *
24 * You should have received a copy of the GNU Lesser General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27 * Boston, MA 02110-1301 USA *
29 * CLooG, the Chunky Loop Generator *
30 * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr *
32 ******************************************************************************/
36 #include "../include/cloog/cloog.h"
40 * Allocate a CloogMatrix data structure with NbRows rows and NbColumns columns.
41 * All values are initialized to 0.
42 * This method returns a pointer to the data structure if successful or a NULL
45 CloogMatrix
*cloog_matrix_alloc(unsigned NbRows
, unsigned NbColumns
)
51 matrix
= (CloogMatrix
*)malloc(sizeof(CloogMatrix
));
56 matrix
->NbRows
= NbRows
;
57 matrix
->NbColumns
= NbColumns
;
59 if (!NbRows
|| !NbColumns
) {
61 matrix
->p_Init
= NULL
;
65 p
= (cloog_int_t
**)malloc(NbRows
* sizeof(cloog_int_t
*));
72 q
= (cloog_int_t
*)malloc(NbRows
* NbColumns
* sizeof(cloog_int_t
));
83 for (i
= 0; i
< NbRows
; i
++) {
85 for (j
= 0; j
< NbColumns
; j
++) {
86 cloog_int_init(*(q
+j
));
87 cloog_int_set_si(*(q
+j
), 0);
99 void cloog_matrix_free(CloogMatrix
* matrix
)
103 int size
= matrix
->NbRows
* matrix
->NbColumns
;
107 for (i
= 0; i
< size
; i
++)
108 cloog_int_clear(*p
++);
111 free(matrix
->p_Init
);
118 * cloog_matrix_print function:
119 * This function prints the content of a CloogMatrix structure (matrix) into a
120 * file (foo, possibly stdout).
122 void cloog_matrix_print(FILE* foo
, CloogMatrix
* m
)
127 fprintf(foo
, "(null)\n");
129 for (i
= 0; i
< m
->NbRows
; ++i
) {
130 for (j
= 0; j
< m
->NbColumns
; ++j
) {
131 cloog_int_print(foo
, m
->p
[i
][j
]);