diff options
author | Sven Verdoolaege <skimo@kotnet.org> | 2009-08-15 11:08:13 +0200 |
---|---|---|
committer | Sven Verdoolaege <skimo@kotnet.org> | 2009-08-28 19:42:19 +0200 |
commit | 3e2ab6e255665c1e7a2c34c9eb233b7696bf88fb (patch) | |
tree | e76b8a5a448241a5882c81d572f53b755bc2bb59 | |
parent | fe8b6ab12a6001b22c8fc11e9854623af4b306b5 (diff) | |
download | isl-3e2ab6e255665c1e7a2c34c9eb233b7696bf88fb.tar.gz isl-3e2ab6e255665c1e7a2c34c9eb233b7696bf88fb.tar.bz2 isl-3e2ab6e255665c1e7a2c34c9eb233b7696bf88fb.zip |
add isl_vec_mat_product
-rw-r--r-- | isl_mat.c | 28 | ||||
-rw-r--r-- | isl_mat.h | 1 |
2 files changed, 29 insertions, 0 deletions
@@ -236,6 +236,34 @@ error: return NULL; } +struct isl_vec *isl_vec_mat_product(struct isl_vec *vec, struct isl_mat *mat) +{ + int i, j; + struct isl_vec *prod; + + if (!mat || !vec) + goto error; + + isl_assert(ctx, mat->n_row == vec->size, goto error); + + prod = isl_vec_alloc(mat->ctx, mat->n_col); + if (!prod) + goto error; + + for (i = 0; i < prod->size; ++i) { + isl_int_set_si(prod->el[i], 0); + for (j = 0; j < vec->size; ++j) + isl_int_addmul(prod->el[i], vec->el[j], mat->row[j][i]); + } + isl_mat_free(mat); + isl_vec_free(vec); + return prod; +error: + isl_mat_free(mat); + isl_vec_free(vec); + return NULL; +} + struct isl_mat *isl_mat_aff_direct_sum(struct isl_mat *left, struct isl_mat *right) { @@ -53,6 +53,7 @@ struct isl_mat *isl_mat_swap_cols(struct isl_mat *mat, unsigned i, unsigned j); struct isl_mat *isl_mat_swap_rows(struct isl_mat *mat, unsigned i, unsigned j); struct isl_vec *isl_mat_vec_product(struct isl_mat *mat, struct isl_vec *vec); +struct isl_vec *isl_vec_mat_product(struct isl_vec *vec, struct isl_mat *mat); struct isl_mat *isl_mat_aff_direct_sum(struct isl_mat *left, struct isl_mat *right); struct isl_mat *isl_mat_left_hermite(struct isl_mat *M, |