Easy way to make Numarray Bool use 1 bit?

Discussion in 'Python' started by andrewfelch@gmail.com, Feb 7, 2006.

  1. Guest

    I need to be able to store thousands of one-million-length bit arrays.
    The first operations use the & operator. But eventually I must perform
    an inner product with a one-million-length integer array (summing at
    all the indices of the integer operand where the boolean operand has a
    "1").

    If I use the Boolean type, I end up using 1-byte, per needed bit, which
    is not efficient enough (only 1,000 arrays per gigabyte of memory).
    I'm limited by 32-bit windows to use only 2 GB total.

    Anybody know of a fast way to use only 125 kilobytes of memory per
    array and yet be able to inner product with an integer array quickly?
    Don't tell me I have to write C/C++ ! (ugh!)

    TIA,
    AndrewF
    , Feb 7, 2006
    #1
    1. Advertising

  2. Guest

    Ahh, I figured it out. The key is to set up the shapes so they
    broadcast like an outerproduct, but using bitwise_and as the operation
    and the second operand as the bit filter. So we temporarily expand
    each bit to a byte for numarray to be able to use it for dot products.
    If you use a temporary Boolean variable to store the bitwise_and ufunc
    output, the answer is automatically converted to boolean.

    Set up the shapes for an innerproduct-like operation to go from byte
    format back to bit compact Uint8 format. Go numarray!
    , Feb 7, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    1,752
    Timothy Bendfelt
    Jan 19, 2007
  2. Replies:
    0
    Views:
    250
  3. Replies:
    9
    Views:
    970
    Juha Nieminen
    Aug 22, 2007
  4. bark

    bit on bool

    bark, Aug 13, 2008, in forum: C++
    Replies:
    3
    Views:
    397
    James Kanze
    Aug 13, 2008
  5. Jeff.M
    Replies:
    6
    Views:
    172
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page