Exemple #1
0
/* Get upper bound for the pos^th variable if it's a (single) constant: return 
 * 0 if not constant,  1 otherwise */
int pluto_constraints_get_const_ub(const PlutoConstraints *cnst, int pos, 
        int *ub)
{
    int i, retval;

    PlutoConstraints *cst = pluto_constraints_dup(cnst);

    pluto_constraints_project_out_single(cst, 0, pos);
    pluto_constraints_project_out_single(cst, 1, cst->ncols-2);
    //pluto_constraints_project_out_single_isl(cst, 0, pos);
    //pluto_constraints_project_out_single_isl(cst, 1, cst->ncols-2);

    retval = 0;
    *ub = INT_MAX;
    for (i=0; i<cst->nrows; i++) {
        if (cst->is_eq[i]) {
            *ub = cst->val[i][cst->ncols-1];
            retval = 1;
            break;
        }
        if (!cst->is_eq[i] && cst->val[i][0] <= -1) {
            *ub = PLMIN(*ub,cst->val[i][cst->ncols-1]);
            retval = 1;
        }
    }
    pluto_constraints_free(cst);

    if (retval && cnst->next != NULL) {
        int next_ub;
        retval = pluto_constraints_get_const_ub(cnst->next, pos, &next_ub);
        if (*ub != next_ub)  retval = 0;
    }

    return retval;
}
Exemple #2
0
/* Converts matrix to row-echelon form in-place */
PlutoMatrix *pluto_matrix_to_row_echelon(PlutoMatrix *mat)
{
    int i, j, k, r, _lcm, factor1;

    r=0;
    for (i=0; i< PLMIN(mat->ncols,mat->nrows); i++)  {
        //pluto_matrix_print(stdout, sched);
        if (mat->val[r][i] == 0) {
            for (k=r+1; k<mat->nrows; k++) {
                if (mat->val[k][i] != 0) break;
            }
            if (k<mat->nrows)    {
                pluto_matrix_interchange_rows(mat, r, k);
            }
        }
        if (mat->val[r][i] != 0) {
            for (k=r+1; k<mat->nrows; k++) {
                if (mat->val[k][i] == 0) continue;
                _lcm = lcm(mat->val[k][i], mat->val[r][i]);
                factor1 = _lcm/mat->val[k][i];
                for (j=i; j<mat->ncols; j++) {
                    mat->val[k][j] = mat->val[k][j]*factor1
                        - mat->val[r][j]*(_lcm/mat->val[r][i]);
                }
            }
            r++;
        }
    }

    return mat;
}