<commit_before>/*
 * Copyright 2008-2009 Katholieke Universiteit Leuven
 *
 * Use of this software is governed by the GNU LGPLv2.1 license
 *
 * Written by <NAME>, K.U.Leuven, Departement
 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
 */

#include <assert.h>
#include <string.h>
#include <isl/set.h>
#include "isl_tab.h"
#include "isl_map_private.h"
#include "isl_sample.h"
#include "isl_scan.h"
#include <isl/seq.h>
#include <isl/ilp.h>
#include <isl_point_private.h>

/* The input of this program is the same as that of the "example" program
 * from the PipLib distribution, except that the "big parameter column"
 * should always be -1.
 *
 * Context constraints in PolyLib format
 * -1
 * Problem constraints in PolyLib format
 * Optional list of options
 *
 * The options are
 *	Maximize	compute maximum instead of minimum
 *	Rational	compute rational optimum instead of integer optimum
 *	Urs_parms	don't assume parameters are non-negative
 *	Urs_unknowns	don't assume unknowns are non-negative
 */

struct options {
	struct isl_options	*isl;
	unsigned		 verify;
};

struct isl_arg options_arg[] = {
ISL_ARG_CHILD(struct options, isl, "isl", isl_options_arg, "isl options")
ISL_ARG_BOOL(struct options, verify, 'T', "verify", 0, NULL)
ISL_ARG_END
};

ISL_ARG_DEF(options, struct options, options_arg)

static __isl_give isl_basic_set *set_bounds(__isl_take isl_basic_set *bset)
{
	unsigned nparam;
	int i, r;
	isl_point *pt, *pt2;
	isl_basic_set *box;

	nparam = isl_basic_set_dim(bset, isl_dim_param);
	r = nparam >= 8 ? 4 : nparam >= 5 ? 6 : 30;

	pt = isl_basic_set_sample_point(isl_basic_set_copy(bset));
	pt2 = isl_point_copy(pt);

	for (i = 0; i < nparam; ++i) {
		pt = isl_point_add_ui(pt, isl_dim_param, i, r);
		pt2 = isl_point_sub_ui(pt2, isl_dim_param, i, r);
	}

	box = isl_basic_set_box_from_points(pt, pt2);

	return isl_basic_set_intersect(bset, box);
}

static struct isl_basic_set *to_parameter_domain(struct isl_basic_set *context)
{
	struct isl_dim *param_dim;
	struct isl_basic_set *model;

	param_dim = isl_dim_set_alloc(context->ctx,
					isl_basic_set_n_dim(context), 0);
	model = isl_basic_set_empty(param_dim);
	context = isl_basic_set_from_underlying_set(context, model);

	return context;
}

isl_basic_set *plug_in_parameters(isl_basic_set *bset, struct isl_vec *params)
{
	int i;

	for (i = 0; i < params->size - 1; ++i)
		bset = isl_basic_set_fix(bset,
					 isl_dim_param, i, params->el[1 + i]);

	bset = isl_basic_set_remove_dims(bset,
					 isl_dim_param, 0, params->size - 1);

	isl_vec_free(params);

	return bset;
}

isl_set *set_plug_in_parameters(isl_set *set, struct isl_vec *params)
{
	int i;

	for (i = 0; i < params->size - 1; ++i)
		set = isl_set_fix(set, isl_dim_param, i, params->el[1 + i]);
<commit_msg>isl_pip: preserve names of parameters in input context<commit_after>/*
 * Copyright 2008-2009 <NAME>
 *
 * Use of this software is governed by the GNU LGPLv2.1 license
 *
 * Written by <NAME>, K.U.Leuven, Departement
 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
 */

#include <assert.h>
#include <string.h>
#include <isl/set.h>
#include "isl_tab.h"
#include "isl_map_private.h"
#include "isl_sample.h"
#include "isl_scan.h"
#include <isl/seq.h>
#include <isl/ilp.h>
#include <isl_point_private.h>

/* The input of this program is the same as that of the "example" program
 * from the PipLib distribution, except that the "big parameter column"
 * should always be -1.
 *
 * Context constraints in PolyLib format
 * -1
 * Problem constraints in PolyLib format
 * Optional list of options
 *
 * The options are
 *	Maximize	compute maximum instead of minimum
 *	Rational	compute rational optimum instead of integer optimum
 *	Urs_parms	don't assume parameters are non-negative
 *	Urs_unknowns	don't assume unknowns are non-negative
 */

struct options {
	struct isl_options	*isl;
	unsigned		 verify;
};

struct isl_arg options_arg[] = {
ISL_ARG_CHILD(struct options, isl, "isl", isl_options_arg, "isl options")
ISL_ARG_BOOL(struct options, verify, 'T', "verify", 0, NULL)
ISL_ARG_END
};

ISL_ARG_DEF(options, struct options, options_arg)

static __isl_give isl_basic_set *set_bounds(__isl_take isl_basic_set *bset)
{
	unsigned nparam;
	int i, r;
	isl_point *pt, *pt2;
	isl_basic_set *box;

	nparam = isl_basic_set_dim(bset, isl_dim_param);
	r = nparam >= 8 ? 4 : nparam >= 5 ? 6 : 30;

	pt = isl_basic_set_sample_point(isl_basic_set_copy(bset));
	pt2 = isl_point_copy(pt);

	for (i = 0; i < nparam; ++i) {
		pt = isl_point_add_ui(pt, isl_dim_param, i, r);
		pt2 = isl_point_sub_ui(pt2, isl_dim_param, i, r);
	}

	box = isl_basic_set_box_from_points(pt, pt2);

	return isl_basic_set_intersect(bset, box);
}

static struct isl_basic_set *to_parameter_domain(struct isl_basic_set *context)
{
	return isl_basic_set_move_dims(context, isl_dim_param, 0, isl_dim_set, 0,
				       isl_basic_set_dim(context, isl_dim_set));
}

isl_basic_set *plug_in_parameters(isl_basic_set *bset, struct isl_vec *params)
{
	int i;

	for (i = 0; i < params->size - 1; ++i)
		bset = isl_basic_set_fix(bset,
					 isl_dim_param, i, params->el[1 + i]);

	bset = isl_basic_set_remove_dims(bset,
					 isl_dim_param, 0, params->size - 1);

	isl_vec_free(params);

	return bset;
}

isl_set *set_plug_in_parameters(isl_set *set, struct isl_vec *params)
{
	int i;

	for (i = 0; i < params->size - 1; ++i)
		set = isl_set_fix(set, isl_dim_param, i, params->el[1 + i]);

{'fraction_non_alphanumeric': 0.1136238279095422, 'fraction_numerical': 0.015260158117300974, 'mean_word_length': 4.787234042553192, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3963492', 'n_tokens_mistral': 2251, 'n_tokens_neox': 2124, 'n_words': 548}