projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
It does not make any sense to remove AM, which loads a non-GP value to fix register...
[libfirm]
/
ir
/
adt
/
gaussseidel.c
diff --git
a/ir/adt/gaussseidel.c
b/ir/adt/gaussseidel.c
index
5b5aca5
..
51f215f
100644
(file)
--- a/
ir/adt/gaussseidel.c
+++ b/
ir/adt/gaussseidel.c
@@
-43,7
+43,7
@@
struct _gs_matrix_t {
static INLINE void alloc_cols(row_col_t *row, int c_cols) {
assert(c_cols > row->c_cols);
row->c_cols = c_cols;
static INLINE void alloc_cols(row_col_t *row, int c_cols) {
assert(c_cols > row->c_cols);
row->c_cols = c_cols;
- row->cols =
xrealloc(row->cols, c_cols * sizeof(*row->cols)
);
+ row->cols =
XREALLOC(row->cols, col_val_t, c_cols
);
}
static INLINE void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_init) {
}
static INLINE void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_init) {
@@
-51,7
+51,7
@@
static INLINE void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_
assert(c_rows > m->c_rows);
m->c_rows = c_rows;
assert(c_rows > m->c_rows);
m->c_rows = c_rows;
- m->rows =
xrealloc(m->rows, c_rows * sizeof(*m->rows)
);
+ m->rows =
XREALLOC(m->rows, row_col_t, c_rows
);
for (i = begin_init; i < c_rows; ++i) {
m->rows[i].c_cols = 0;
for (i = begin_init; i < c_rows; ++i) {
m->rows[i].c_cols = 0;
@@
-64,8
+64,7
@@
static INLINE void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_
}
gs_matrix_t *gs_new_matrix(int n_init_rows, int n_init_cols) {
}
gs_matrix_t *gs_new_matrix(int n_init_rows, int n_init_cols) {
- gs_matrix_t *res = xmalloc(sizeof(*res));
- memset(res, 0, sizeof(*res));
+ gs_matrix_t *res = XMALLOCZ(gs_matrix_t);
if (n_init_rows < 16)
n_init_rows = 16;
res->initial_col_increase = n_init_cols;
if (n_init_rows < 16)
n_init_rows = 16;
res->initial_col_increase = n_init_cols;
@@
-117,7
+116,7
@@
void gs_matrix_trim_row_capacities(gs_matrix_t *m) {
if (the_row->c_cols) {
the_row->c_cols = the_row->n_cols;
if (the_row->c_cols)
if (the_row->c_cols) {
the_row->c_cols = the_row->n_cols;
if (the_row->c_cols)
- the_row->cols =
xrealloc(the_row->cols, the_row->c_cols * sizeof(*the_row->cols)
);
+ the_row->cols =
XREALLOC(the_row->cols, col_val_t, the_row->c_cols
);
else
xfree(the_row->cols);
}
else
xfree(the_row->cols);
}
@@
-145,7
+144,7
@@
void gs_matrix_set(gs_matrix_t *m, int row, int col, double val) {
int min, max, c, i;
if (row >= m->c_rows) {
int min, max, c, i;
if (row >= m->c_rows) {
- int new_c_rows =
ROW_INCREASE_FACTOR * row
;
+ int new_c_rows =
(int)(ROW_INCREASE_FACTOR * row)
;
alloc_rows(m, new_c_rows, m->initial_col_increase, m->c_rows);
}
alloc_rows(m, new_c_rows, m->initial_col_increase, m->c_rows);
}
@@
-203,10
+202,13
@@
void gs_matrix_set(gs_matrix_t *m, int row, int col, double val) {
}
double gs_matrix_get(const gs_matrix_t *m, int row, int col) {
}
double gs_matrix_get(const gs_matrix_t *m, int row, int col) {
+ row_col_t *the_row;
int c;
int c;
+
if (row >= m->c_rows)
return 0.0;
if (row >= m->c_rows)
return 0.0;
- row_col_t *the_row = &m->rows[row];
+
+ the_row = &m->rows[row];
if (row == col)
return the_row->diag != 0.0 ? 1.0 / the_row->diag : 0.0;
if (row == col)
return the_row->diag != 0.0 ? 1.0 / the_row->diag : 0.0;
@@
-278,13
+280,14
@@
void gs_matrix_export(const gs_matrix_t *m, double *nw, int size)
void gs_matrix_dump(const gs_matrix_t *m, int a, int b, FILE *out) {
int effective_rows = MIN(a, m->c_rows);
int r, c, i;
void gs_matrix_dump(const gs_matrix_t *m, int a, int b, FILE *out) {
int effective_rows = MIN(a, m->c_rows);
int r, c, i;
- double *elems =
xmalloc(b * sizeof(*elems)
);
+ double *elems =
XMALLOCN(double, b
);
// The rows which have some content
for (r=0; r < effective_rows; ++r) {
// The rows which have some content
for (r=0; r < effective_rows; ++r) {
+ row_col_t *row = &m->rows[r];
+
memset(elems, 0, b * sizeof(*elems));
memset(elems, 0, b * sizeof(*elems));
- row_col_t *row = &m->rows[r];
for (c = 0; c < row->n_cols; ++c) {
int col_idx = row->cols[c].col_idx;
elems[col_idx] = row->cols[c].v;
for (c = 0; c < row->n_cols; ++c) {
int col_idx = row->cols[c].col_idx;
elems[col_idx] = row->cols[c].v;