Daily bump.
[official-gcc.git] / gcc / lambda-trans.c
blobba1449977ea0dddf5163bee1bdbd8cd584e8a826
1 /* Lambda matrix transformations.
2 Copyright (C) 2003, 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
3 Contributed by Daniel Berlin <dberlin@dberlin.org>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree-flow.h"
25 #include "lambda.h"
27 /* Allocate a new transformation matrix. */
29 lambda_trans_matrix
30 lambda_trans_matrix_new (int colsize, int rowsize,
31 struct obstack * lambda_obstack)
33 lambda_trans_matrix ret;
35 ret = (lambda_trans_matrix)
36 obstack_alloc (lambda_obstack, sizeof (struct lambda_trans_matrix_s));
37 LTM_MATRIX (ret) = lambda_matrix_new (rowsize, colsize, lambda_obstack);
38 LTM_ROWSIZE (ret) = rowsize;
39 LTM_COLSIZE (ret) = colsize;
40 LTM_DENOMINATOR (ret) = 1;
41 return ret;
44 /* Return true if MAT is an identity matrix. */
46 bool
47 lambda_trans_matrix_id_p (lambda_trans_matrix mat)
49 if (LTM_ROWSIZE (mat) != LTM_COLSIZE (mat))
50 return false;
51 return lambda_matrix_id_p (LTM_MATRIX (mat), LTM_ROWSIZE (mat));
55 /* Compute the inverse of the transformation matrix MAT. */
57 lambda_trans_matrix
58 lambda_trans_matrix_inverse (lambda_trans_matrix mat,
59 struct obstack * lambda_obstack)
61 lambda_trans_matrix inverse;
62 int determinant;
64 inverse = lambda_trans_matrix_new (LTM_ROWSIZE (mat), LTM_COLSIZE (mat),
65 lambda_obstack);
66 determinant = lambda_matrix_inverse (LTM_MATRIX (mat), LTM_MATRIX (inverse),
67 LTM_ROWSIZE (mat), lambda_obstack);
68 LTM_DENOMINATOR (inverse) = determinant;
69 return inverse;
73 /* Print out a transformation matrix. */
75 void
76 print_lambda_trans_matrix (FILE *outfile, lambda_trans_matrix mat)
78 print_lambda_matrix (outfile, LTM_MATRIX (mat), LTM_ROWSIZE (mat),
79 LTM_COLSIZE (mat));