add isl_mat_diag
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 20 Sep 2011 13:58:11 +0000 (15:58 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 22 Sep 2011 11:12:52 +0000 (13:12 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_mat.c
isl_mat_private.h

index e64beae..02e10b6 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -281,7 +281,7 @@ error:
        return NULL;
 }
 
-struct isl_mat *isl_mat_identity(struct isl_ctx *ctx, unsigned n_row)
+__isl_give isl_mat *isl_mat_diag(isl_ctx *ctx, unsigned n_row, isl_int d)
 {
        int i;
        struct isl_mat *mat;
@@ -291,13 +291,20 @@ struct isl_mat *isl_mat_identity(struct isl_ctx *ctx, unsigned n_row)
                return NULL;
        for (i = 0; i < n_row; ++i) {
                isl_seq_clr(mat->row[i], i);
-               isl_int_set_si(mat->row[i][i], 1);
+               isl_int_set(mat->row[i][i], d);
                isl_seq_clr(mat->row[i]+i+1, n_row-(i+1));
        }
 
        return mat;
 }
 
+__isl_give isl_mat *isl_mat_identity(isl_ctx *ctx, unsigned n_row)
+{
+       if (!ctx)
+               return NULL;
+       return isl_mat_diag(ctx, n_row, ctx->one);
+}
+
 struct isl_vec *isl_mat_vec_product(struct isl_mat *mat, struct isl_vec *vec)
 {
        int i;
index 5ba4990..f27f29a 100644 (file)
@@ -27,3 +27,4 @@ void isl_mat_sub_copy(struct isl_ctx *ctx, isl_int **dst, isl_int **src,
        unsigned n_row, unsigned dst_col, unsigned src_col, unsigned n_col);
 void isl_mat_sub_neg(struct isl_ctx *ctx, isl_int **dst, isl_int **src,
        unsigned n_row, unsigned dst_col, unsigned src_col, unsigned n_col);
+__isl_give isl_mat *isl_mat_diag(isl_ctx *ctx, unsigned n_row, isl_int d);