in reply to Re^2: perl bit matrix transposition / weak typing problem
in thread perl bit matrix transposition / weak typing problem

I'm not sure what you are saying; does your original example work for you but is not fast enough?

I see you have return $out now, but I don't see you setting $out.

Update: I reread your original post and now see where you talk about trying to avoid the very kind of approach you present there. But I don't see where the trampling you describe comes into it. Do see BrowserUk's suggestion of using vec, which is perl's builtin way of dealing with data by bits without conversion.

Replies are listed 'Best First'.
Re^4: perl bit matrix transposition / weak typing problem
by infi (Acolyte) on Dec 13, 2004 at 13:16 UTC

    Well, $out is getting set by:

    for my $col (0..($BUFSIZE-1)) { $out[$newrow] |= (1 << $col) if ($in[7 - $col] >> $row & 1); } $newrow++;

    This is setting the actual bit in $out[$newrow] if the corresponding bit from the transposition source matrix is set.

    At any rate, BrowserUk's solution appears to be ideal and small, and exactly fits the requirements; the lack of thorough awareness of the vec() function made this difficult at best. In addition, it makes possible arbitrary matrix sizes, which solved another challenge I had thought of but didn't mention in the original post.

    Thanks,
    Jason