Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Easy way to make Numarray Bool use 1 bit?

Thread Tools

Easy way to make Numarray Bool use 1 bit?
Posts: n/a
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

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!)


Reply With Quote
Posts: n/a
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!

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
datetime - easy way to make it use local timezone? Python 0 02-21-2007 06:36 PM
how to make bool class with custom output? C++ 3 04-02-2006 09:16 AM
Easy way to make .WMV file portable billybooger Computer Support 1 10-29-2005 05:19 PM
numarray - use of fromfunction Alex Hunsley Python 0 07-04-2004 09:33 PM
Easiest way to *add a column* to a 2d matrix/array in numarray??? Christian Seberino Python 4 04-27-2004 08:08 PM