Exemplo n.º 1
0
void
dotest(int nrows, int ncols, int *xys)
{
    BITMAT *inp = bitmat(nrows, ncols);
    BITMAT *exp = bitmat(ncols, nrows);

    for (; *xys >= 0; xys += 2) {
        bitmat_set(inp, xys[0] % nrows, xys[1] % ncols, 1);
        bitmat_set(exp, xys[1] % ncols, xys[0] % nrows, 1);
    }

    puts("---- inp"); prbm(inp);
    puts("---- exp"); prbm(exp);

    BITMAT *act = bitmat_trans(inp);
    int rc = bitmat_cmp(act, exp);
    ok(!rc, "trans %d x %d", nrows, ncols);
    if (rc) {
        puts("actual:");
        prbm(act);
    }

    bitmat_destroy(inp);
    bitmat_destroy(exp);
    bitmat_destroy(act);
}
Exemplo n.º 2
0
BITMAT*
naive_trans(BITMAT const*bmp)
{
    unsigned i, j;
    BITMAT *ret = bitmat(bmp->ncols, bmp->nrows);
    for (i = 0; i < bmp->nrows; ++i)
        for (j = 0; j < bmp->ncols; ++j)
            bitmat_set(ret, j, i, bitmat_get(bmp, i, j));
    return ret;
}