comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: bits into bytes
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: bits into bytes [message #81031] Wed, 01 August 2012 20:19 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Wednesday, August 1, 2012 7:55:16 PM UTC-4, Heinz Stege wrote:
>
> processor. However the /PRESERVE_TYPE option of the TOTAL function
>
> should speed up the calculation.
>

Heinz,

Thanks for reminding me of the ISHFT() function and the /PRESERVE_TYPE keyword to TOTAL(). Actually, rather than use TOTAL(), I found the fastest method when dealing with millions of values is to use matrix multiply, as in the following example:

;Create an 8 x n byte array of random 0s and 1s. This will be compressed by a factor of 8 by storing ;each value in a bit rather than a byte

n = 1000000
x = byte(round(randomu(seed,8,n)))

yy = [128b,64b,32b,16b,8b,4b,2b,1b]
return, byte(yy#x)

The above code would be slightly faster if there were the equivalent of /PRESERVE_TYPE for matrix multiplication. Right now -- rather surprisingly, I think -- matrix multiplication of two byte arrays yields a long array. But the code is very fast anyway. --Wayne
[Message index]
 
Read Message
Read Message
Previous Topic: bits into bytes
Next Topic: imcontour no longer plotting in color

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:22:28 PDT 2025

Total time taken to generate the page: 0.96413 seconds