コード例 #1
0
ファイル: verify.c プロジェクト: spl/ivy
/*
 *  Permute the columns of PLA1 so that they match the order of PLA2
 *  Discard any columns of PLA1 which are not in PLA2
 *  Association is strictly by the names of the columns of the cover.
 */
void PLA_permute(pPLA PLA1, pPLA PLA2)
{
    register int i, j, *permute, npermute;
    register char *labi;
    char **label;

    /* determine which columns of PLA1 to save, and place these in the list
     * "permute"; the order in this list is the final output order
     */
    npermute = 0;
    permute = ALLOC(int, PLA2->F->sf_size);
    for(i = 0; i < PLA2->F->sf_size; i++) {
	labi = PLA2->label[i];
	for(j = 0; j < PLA1->F->sf_size; j++) {
	    if (strcmp(labi, PLA1->label[j]) == 0) {
		permute[npermute++] = j;
		break;
	    }
	}
    }

    /* permute columns */
    if (PLA1->F != NULL) {
	PLA1->F = sf_permute(PLA1->F, permute, npermute);
    }
    if (PLA1->R != NULL) {
	PLA1->R = sf_permute(PLA1->R, permute, npermute);
    }
    if (PLA1->D != NULL) {
	PLA1->D = sf_permute(PLA1->D, permute, npermute);
    }

    /* permute the labels */
    label = ALLOC(char *, cube.size);
    for(i = 0; i < npermute; i++) {
	label[i] = PLA1->label[permute[i]];
    }
    for(i = npermute; i < cube.size; i++) {
	label[i] = NULL;
    }
    FREE(PLA1->label);
    PLA1->label = label;

    FREE(permute);
}
コード例 #2
0
ファイル: verify.c プロジェクト: GtTmy/pyeda
///
//  Permute the columns of PLA1 so that they match the order of PLA2
//  Discard any columns of PLA1 which are not in PLA2
//  Association is strictly by the names of the columns of the cover.
//
void
PLA_permute(PLA_t *PLA1, PLA_t *PLA2)
{
    int i, j, *permute, npermute;
    char *labi;
    char **label;

    // determine which columns of PLA1 to save, and place these in the list
    // "permute"; the order in this list is the final output order
    npermute = 0;
    permute = ALLOC(int, PLA2->F->sf_size);
    for (i = 0; i < PLA2->F->sf_size; i++) {
        labi = PLA2->label[i];
        for (j = 0; j < PLA1->F->sf_size; j++) {
            if (strcmp(labi, PLA1->label[j]) == 0) {
                permute[npermute++] = j;
                break;
            }
        }
    }

    // permute columns
    if (PLA1->F != NULL)
        PLA1->F = sf_permute(PLA1->F, permute, npermute);
    if (PLA1->R != NULL)
        PLA1->R = sf_permute(PLA1->R, permute, npermute);
    if (PLA1->D != NULL)
        PLA1->D = sf_permute(PLA1->D, permute, npermute);

    // permute the labels
    label = ALLOC(char *, CUBE.size);
    for (i = 0; i < npermute; i++)
        label[i] = PLA1->label[permute[i]];
    for (i = npermute; i < CUBE.size; i++)
        label[i] = NULL;

    FREE(PLA1->label);
    PLA1->label = label;
    FREE(permute);
}