LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fastest conversion from DBL to U8 array

Solved!
Go to solution

Hi,

 

I have to convert a monster array of doubles to an array of bytes.

So first I have to convert (type cast) all the DBLs to array of bytes of 8 elements. The result byte array has a size of 8 x size of Double array.

 

This takes sooooo long... Is there a fast way to do it?

 

DBLtoU8.jpg

Message 1 of 7
(5,898 Views)
Solution
Accepted by topic author mitulatbati

Hi mitulatbati,

 

have you tried:

- to use pure G functions instead of formula node?

or, even better

- discard the whole FOR loop and directly typecast the DBL array to an U8 array?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(5,886 Views)

Hi,

  Instead of using array functions ,use split number vi..See the attachment..

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


Message 3 of 7
(5,879 Views)

Hi srikrishnaNF,

 

what are you doing there?

First you typecast to an array of U32 (I suppose), then split the U32 numbers in the loop to build a 4-element-U8-array, then autoindex those U8 arrays to form a bigger 2D array, then reshape that one to get the resulting 1D U8 array...

 

Why not directly typecast to U8 array?

 

I think I will post this thread to the RubeGoldberg-collection Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(5,873 Views)

Hi Gerd,

 

yes I have tried the pure X G function, but the speed is the same.

 

Typecasting a DBL array direct to a U8 array works fast!

 

MB

0 Kudos
Message 5 of 7
(5,860 Views)

Hi MB,

 

direct typecasting works fast because LV doesn't need to shuffle any data from one place to the other... Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 7
(5,837 Views)

GerdW wrote:

Hi MB,

 

direct typecasting works fast because LV doesn't need to shuffle any data from one place to the other... Smiley Wink


That is not really true. Typecast in LabVIEW always converts data into big endian form. For doubles this means inverting the byte order of every double but this is indeed still lighting fast in comparison to taking apart an array and copying it back into another array.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 7 of 7
(5,762 Views)