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

Home » Public Forums » archive » Re: Coding for speed help needed
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: Coding for speed help needed [message #9060 is a reply to message #9054] Thu, 29 May 1997 00:00 Go to previous message
wmc is currently offline  wmc
Messages: 117
Registered: February 1995
Senior Member
In article r3r@gazette.bcm.tmc.edu, pford@bcm.tmc.edu (Patrick V. Ford) writes:
> I need a FAST method of decoding a series of bytes to floats. The byte pattern encodes a range of numbers
> from MIN to MAX. I am attempting to code this as an call_external routine in C, but it is buggy and has not worked yet. The
> basic C routine looks this:
>
>
...cuts...
> kappa = (byte[0] << 24) | (byte[1] << 16) | (byte[2] << 8) | byte[3];
> /* Note: endian is irrelvant to the algorithm */
>
> range = *max - *min;
> *result = range/((float)ULONG_MAX) * (float)kappa + *min;
>
> What I would like to do, is do this in IDL where the result would go into A,
> where
>
> A = fltarr(64,64)
>
> and the byte array is
>
> B = bytarr(64*64*4)
>

so why not:

i=indgen(64*64)*4
a=b(i)*2l^24+b(i+1)*2l^16+b(i+2)*2l^8+b(i+3)
a=a*kappa+min ; or some other scaling

its possible you might prefer your shifts to the 2l^24 etc -
I don't know which is faster.

> with a minumum of for loops.

is none few enough? ;-)

- William

---
William M Connolley | wmc@bas.ac.uk | http://www.nbs.ac.uk/public/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
[Message index]
 
Read Message
Read Message
Previous Topic: Re: colors in IDL
Next Topic: Phil's Having a Bad Day...

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

Current Time: Sun Nov 30 15:13:29 PST 2025

Total time taken to generate the page: 0.54800 seconds