4 struct isl_vec *isl_vec_alloc(struct isl_ctx *ctx, unsigned size)
8 vec = isl_alloc_type(ctx, struct isl_vec);
12 vec->block = isl_blk_alloc(ctx, size);
13 if (isl_blk_is_error(vec->block))
20 vec->el = vec->block.data;
24 isl_blk_free(ctx, vec->block);
28 struct isl_vec *isl_vec_copy(struct isl_vec *vec)
37 struct isl_vec *isl_vec_dup(struct isl_vec *vec)
43 vec2 = isl_vec_alloc(vec->ctx, vec->size);
44 isl_seq_cpy(vec2->el, vec->el, vec->size);
48 struct isl_vec *isl_vec_cow(struct isl_vec *vec)
57 vec2 = isl_vec_dup(vec);
62 void isl_vec_free(struct isl_vec *vec)
70 isl_ctx_deref(vec->ctx);
71 isl_blk_free(vec->ctx, vec->block);
75 void isl_vec_dump(struct isl_vec *vec, FILE *out, int indent)
80 fprintf(out, "%*snull vec\n", indent, "");
84 fprintf(out, "%*s[", indent, "");
85 for (i = 0; i < vec->size; ++i) {
88 isl_int_print(out, vec->el[i], 0);
93 void isl_vec_lcm(struct isl_vec *vec, isl_int *lcm)
95 isl_seq_lcm(vec->block.data, vec->size, lcm);
98 /* Given a rational vector, with the denominator in the first element
99 * of the vector, round up all coordinates.
101 struct isl_vec *isl_vec_ceil(struct isl_vec *vec)
103 vec = isl_vec_cow(vec);
107 isl_seq_cdiv_q(vec->el + 1, vec->el + 1, vec->el[0], vec->size - 1);
109 isl_int_set_si(vec->el[0], 1);
114 struct isl_vec *isl_vec_normalize(struct isl_vec *vec)
118 isl_seq_normalize(vec->ctx, vec->el, vec->size);