merge kaps
[libfirm] / ir / kaps / matrix.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   PBQP matrix.
23  * @date    02.10.2008
24  * @author  Sebastian Buchwald
25  * @version $Id$
26  */
27 #ifndef KAPS_MATRIX_H
28 #define KAPS_MATRIX_H
29
30 #include "matrix_t.h"
31
32 pbqp_matrix_t *pbqp_matrix_alloc(pbqp_t *pbqp, unsigned rows, unsigned cols);
33
34 /* Copy the given matrix. */
35 pbqp_matrix_t *pbqp_matrix_copy(pbqp_t *pbqp, pbqp_matrix_t *m);
36
37 pbqp_matrix_t *pbqp_matrix_copy_and_transpose(pbqp_t *pbqp, pbqp_matrix_t *m);
38
39 void pbqp_matrix_transpose(pbqp_t *pbqp, pbqp_matrix_t *mat);
40
41 /* sum += summand */
42 void pbqp_matrix_add(pbqp_matrix_t *sum, pbqp_matrix_t *summand);
43
44 void pbqp_matrix_set(pbqp_matrix_t *mat, unsigned row, unsigned col, num value);
45
46 num pbqp_matrix_get_col_min(pbqp_matrix_t *matrix, unsigned col_index, vector_t *flags);
47 num pbqp_matrix_get_row_min(pbqp_matrix_t *matrix, unsigned row_index, vector_t *flags);
48
49 unsigned pbqp_matrix_get_col_min_index(pbqp_matrix_t *matrix, unsigned col_index, vector_t *flags);
50 unsigned pbqp_matrix_get_row_min_index(pbqp_matrix_t *matrix, unsigned row_index, vector_t *flags);
51
52 void pbqp_matrix_set_col_value(pbqp_matrix_t *mat, unsigned col, num value);
53 void pbqp_matrix_set_row_value(pbqp_matrix_t *mat, unsigned row, num value);
54
55 void pbqp_matrix_sub_col_value(pbqp_matrix_t *matrix, unsigned col_index,
56                                vector_t *flags, num value);
57 void pbqp_matrix_sub_row_value(pbqp_matrix_t *matrix, unsigned row_index,
58                                vector_t *flags, num value);
59
60 int pbqp_matrix_is_zero(pbqp_matrix_t *mat, vector_t *src_vec, vector_t *tgt_vec);
61
62 void pbqp_matrix_add_to_all_cols(pbqp_matrix_t *mat, vector_t *vec);
63 void pbqp_matrix_add_to_all_rows(pbqp_matrix_t *mat, vector_t *vec);
64
65 #endif /* KAPS_MATRIX_H */