*/
#include <isl_ctx_private.h>
-#include <isl/dim.h>
+#include <isl/space.h>
#include <isl/seq.h>
#include <isl_mat_private.h>
#include "isl_map_private.h"
-#include <isl_dim_private.h>
+#include <isl_space_private.h>
+
+isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat)
+{
+ return mat ? mat->ctx : NULL;
+}
struct isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
unsigned n_row, unsigned n_col)
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;
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;
if (!bset)
goto error;
} else if (mat->n_col < mat->n_row) {
- bset->dim = isl_dim_cow(bset->dim);
+ bset->dim = isl_space_cow(bset->dim);
if (!bset->dim)
goto error;
bset->dim->n_out -= mat->n_row - mat->n_col;
goto error;
}
if (mat->n_col != mat->n_row) {
- set->dim = isl_dim_cow(set->dim);
+ set->dim = isl_space_cow(set->dim);
if (!set->dim)
goto error;
set->dim->n_out += mat->n_col;
return NULL;
}
-void isl_mat_dump(struct isl_mat *mat, FILE *out, int indent)
+void isl_mat_print_internal(__isl_keep isl_mat *mat, FILE *out, int indent)
{
int i, j;
}
}
+void isl_mat_dump(__isl_keep isl_mat *mat)
+{
+ isl_mat_print_internal(mat, stderr, 0);
+}
+
struct isl_mat *isl_mat_drop_cols(struct isl_mat *mat, unsigned col, unsigned n)
{
int r;
{
int i;
+ if (isl_int_is_one(m))
+ return mat;
+
+ mat = isl_mat_cow(mat);
if (!mat)
return NULL;
return mat;
}
+__isl_give isl_mat *isl_mat_scale_down_row(__isl_take isl_mat *mat, int row,
+ isl_int m)
+{
+ if (isl_int_is_one(m))
+ return mat;
+
+ mat = isl_mat_cow(mat);
+ if (!mat)
+ return NULL;
+
+ isl_seq_scale_down(mat->row[row], mat->row[row], m, mat->n_col);
+
+ return mat;
+}
+
__isl_give isl_mat *isl_mat_normalize(__isl_take isl_mat *mat)
{
isl_int gcd;
return mat;
}
+__isl_give isl_mat *isl_mat_normalize_row(__isl_take isl_mat *mat, int row)
+{
+ mat = isl_mat_cow(mat);
+ if (!mat)
+ return NULL;
+
+ isl_seq_normalize(mat->ctx, mat->row[row], mat->n_col);
+
+ return mat;
+}
+
/* Number of initial non-zero columns.
*/
int isl_mat_initial_non_zero_cols(__isl_keep isl_mat *mat)