isl_map_private.h \
isl_map_piplib.h \
isl_mat.c \
+ isl_mat_private.h \
isl_morph.c \
isl_morph.h \
isl_name.c \
__isl_give isl_union_map *isl_union_map_lexmax(
__isl_take isl_union_map *umap);
+=head2 Matrices
+
+Matrices can be created, copied and freed using the following functions.
+
+ #include <isl_mat.h>
+ __isl_give isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
+ unsigned n_row, unsigned n_col);
+ __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
+ void isl_mat_free(__isl_take isl_mat *mat);
+
+Note that the elements of a newly created matrix may have arbitrary values.
+The elements can be changed and inspected using the following functions.
+
+ int isl_mat_rows(__isl_keep isl_mat *mat);
+ int isl_mat_cols(__isl_keep isl_mat *mat);
+ int isl_mat_get_element(__isl_keep isl_mat *mat,
+ int row, int col, isl_int *v);
+ __isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,
+ int row, int col, isl_int v);
+
+C<isl_mat_get_element> will return a negative value if anything went wrong.
+In that case, the value of C<*v> is undefined.
+
+The following function can be used to compute the (right) inverse
+of a matrix, i.e., a matrix such that the product of the original
+and the inverse (in that order) is a multiple of the identity matrix.
+The input matrix is assumed to be of full row-rank.
+
+ __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
+
+The following function can be used to compute the (right) kernel
+(or null space) of a matrix, i.e., a matrix such that the product of
+the original and the kernel (in that order) is the zero matrix.
+
+ __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
+
=head2 Points
Points are elements of a set. They can be used to construct
extern "C" {
#endif
-struct isl_mat {
- int ref;
-
- struct isl_ctx *ctx;
-
-#define ISL_MAT_BORROWED (1 << 0)
- unsigned flags;
-
- unsigned n_row;
- unsigned n_col;
-
- isl_int **row;
-
- /* actual size of the rows in memory; n_col <= max_col */
- unsigned max_col;
-
- struct isl_blk block;
-};
+struct isl_mat;
typedef struct isl_mat isl_mat;
-struct isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
+__isl_give isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
unsigned n_row, unsigned n_col);
struct isl_mat *isl_mat_dup(struct isl_mat *mat);
struct isl_mat *isl_mat_extend(struct isl_mat *mat,
unsigned n_row, unsigned n_col);
struct isl_mat *isl_mat_identity(struct isl_ctx *ctx, unsigned n_row);
-struct isl_mat *isl_mat_copy(struct isl_mat *mat);
+__isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
struct isl_mat *isl_mat_cow(struct isl_mat *mat);
-void isl_mat_free(struct isl_mat *mat);
+void isl_mat_free(__isl_take isl_mat *mat);
+
+int isl_mat_rows(__isl_keep isl_mat *mat);
+int isl_mat_cols(__isl_keep isl_mat *mat);
+int isl_mat_get_element(__isl_keep isl_mat *mat, int row, int col, isl_int *v);
+__isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,
+ int row, int col, isl_int v);
struct isl_mat *isl_mat_sub_alloc(struct isl_ctx *ctx, isl_int **row,
unsigned first_row, unsigned n_row, unsigned first_col, unsigned n_col);
struct isl_mat *right);
struct isl_mat *isl_mat_product(struct isl_mat *left, struct isl_mat *right);
struct isl_mat *isl_mat_transpose(struct isl_mat *mat);
-struct isl_mat *isl_mat_right_inverse(struct isl_mat *mat);
-struct isl_mat *isl_mat_right_kernel(struct isl_mat *mat);
+__isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
+__isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
__isl_give isl_mat *isl_mat_normalize(__isl_take isl_mat *mat);
#include "isl_equalities.h"
#include "isl_sample.h"
#include "isl_tab.h"
+#include <isl_mat_private.h>
struct isl_basic_map *isl_basic_map_implicit_equalities(
struct isl_basic_map *bmap)
#define ISL_BASIS_REDUCTION_H
#include "isl_set.h"
-#include "isl_mat.h"
+#include <isl_mat_private.h>
#include "isl_tab.h"
#if defined(__cplusplus)
#include "isl_map_private.h"
#include "isl_seq.h"
#include "isl_tab.h"
+#include <isl_mat_private.h>
#define STATUS_ERROR -1
#define STATUS_REDUNDANT 1
#include "isl_lp.h"
#include "isl_map.h"
#include "isl_map_private.h"
-#include "isl_mat.h"
+#include <isl_mat_private.h>
#include "isl_set.h"
#include "isl_seq.h"
#include "isl_equalities.h"
* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*/
-#include "isl_mat.h"
+#include <isl_mat_private.h>
#include "isl_seq.h"
#include "isl_map_private.h"
#include "isl_equalities.h"
#include <isl_factorization.h>
#include <isl_dim_private.h>
+#include <isl_mat_private.h>
static __isl_give isl_factorizer *isl_factorizer_alloc(
__isl_take isl_morph *morph, int n_group)
#include <isl_map_private.h>
#include <isl_lp.h>
#include <isl_seq.h>
+#include <isl_mat_private.h>
static __isl_give isl_qpolynomial_fold *qpolynomial_fold_alloc(
enum isl_fold type, __isl_take isl_dim *dim, int n)
#include "isl_obj.h"
#include "isl_polynomial_private.h"
#include <isl_union_map.h>
+#include <isl_mat_private.h>
struct variable {
char *name;
#include "isl_sample.h"
#include "isl_tab.h"
#include "isl_vec.h"
+#include <isl_mat_private.h>
/* Maps dst positions to src positions */
struct isl_dim_map {
#include "isl_seq.h"
#include "isl_tab.h"
#include <isl_dim_private.h>
+#include <isl_mat_private.h>
static void swap_equality(struct isl_basic_map *bmap, int a, int b)
{
#include "isl_dim.h"
#include "isl_seq.h"
-#include "isl_mat.h"
+#include <isl_mat_private.h>
#include "isl_map_private.h"
#include <isl_dim_private.h>
free(mat);
}
+int isl_mat_rows(__isl_keep isl_mat *mat)
+{
+ return mat ? mat->n_row : -1;
+}
+
+int isl_mat_cols(__isl_keep isl_mat *mat)
+{
+ return mat ? mat->n_col : -1;
+}
+
+int isl_mat_get_element(__isl_keep isl_mat *mat, int row, int col, isl_int *v)
+{
+ if (!mat)
+ return -1;
+ if (row < 0 || row >= mat->n_row)
+ isl_die(mat->ctx, isl_error_invalid, "row out of range",
+ return -1);
+ if (col < 0 || col >= mat->n_col)
+ isl_die(mat->ctx, isl_error_invalid, "column out of range",
+ return -1);
+ isl_int_set(*v, mat->row[row][col]);
+ return 0;
+}
+
+__isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,
+ int row, int col, isl_int v)
+{
+ mat = isl_mat_cow(mat);
+ if (!mat)
+ return NULL;
+ if (row < 0 || row >= mat->n_row)
+ isl_die(mat->ctx, isl_error_invalid, "row out of range",
+ goto error);
+ if (col < 0 || col >= mat->n_col)
+ isl_die(mat->ctx, isl_error_invalid, "column out of range",
+ goto error);
+ isl_int_set(mat->row[row][col], v);
+ return mat;
+error:
+ isl_mat_free(mat);
+ return NULL;
+}
+
struct isl_mat *isl_mat_identity(struct isl_ctx *ctx, unsigned n_row)
{
int i;
--- /dev/null
+#include <isl_mat.h>
+
+struct isl_mat {
+ int ref;
+
+ struct isl_ctx *ctx;
+
+#define ISL_MAT_BORROWED (1 << 0)
+ unsigned flags;
+
+ unsigned n_row;
+ unsigned n_col;
+
+ isl_int **row;
+
+ /* actual size of the rows in memory; n_col <= max_col */
+ unsigned max_col;
+
+ struct isl_blk block;
+};
#include <isl_morph.h>
#include <isl_seq.h>
#include <isl_map_private.h>
+#include <isl_mat_private.h>
#include <isl_dim_private.h>
#include <isl_equalities.h>
#include <isl_printer_private.h>
#include <isl_dim_private.h>
#include <isl_map_private.h>
+#include <isl_mat_private.h>
#include <isl_union_map.h>
static const char *s_to[2] = { " -> ", " \\to " };
#include <isl_point_private.h>
#include <isl_dim_private.h>
#include <isl_map_private.h>
+#include <isl_mat_private.h>
static unsigned pos(__isl_keep isl_dim *dim, enum isl_dim_type type)
{
* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*/
-#include "isl_mat.h"
+#include <isl_mat_private.h>
#include "isl_map_private.h"
#include "isl_tab.h"
#include "isl_seq.h"
#include "isl_seq.h"
#include "isl_tab.h"
#include "isl_sample.h"
+#include <isl_mat_private.h>
/*
* The implementation of parametric integer linear programming in this file
#include <isl_dim_private.h>
#include <isl_lp.h>
#include <isl_union_map.h>
+#include <isl_mat_private.h>
int isl_map_is_transitively_closed(__isl_keep isl_map *map)
{
#include <isl_dim_private.h>
#include <isl_morph.h>
#include <isl_vertices_private.h>
+#include <isl_mat_private.h>
#define SELECTED 1
#define DESELECTED -1
#include "isl_equalities.h"
#include "isl_seq.h"
#include "isl_scan.h"
+#include <isl_mat_private.h>
/* The input of this program is the same as that of the "polytope_scan"
* program from the barvinok distribution.