BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

So we have a 1D array of U8 that we need to recast as little endian U16 array.

 

The worst way (top of image) takes 15 minutes to execute for 3M elements (!!!) AND produces

incorrect and meaningless results due to the fact that leading zeroes in binary are dropped and x0000 later removed with string operations..

 

Here's the wrong way (top of image)

  1. Convert the U8 array to DBL, increasing the memory footprint 8x. (significant for a size=2950000 array!)
  2. double the array again by branching (hopefully the compiler will only make one copy)..
  3. Autoindex one instance at a FOR loop boundary and convert to a binary formatted string
  4. Index element i+1 from the other instance and also convert to a binary formatted string.
  5. if [i] is even, concatenate the two string in little-endian order, else output an empty string
  6. scan the resulting binary formatted string to an I32 number and autoindex at the loop boundary
  7. flatten the I32 array to a string and use "replace all" to eliminate the extra empty strings (makes no sense!)
  8. Do some more meningless juggling 
  9. cast it all back to I32

We have a complete lack of understanding of datatypes and of the distinction between formatted strings vs flattened strings.

 

 

A quick, and probably correct (!), alternative is shown at the bottom of the image (10).

 

 

(Adapted from this post)

Message Edited by altenbach on 08-30-2008 10:48 AM
Message 311 of 2,608
(14,580 Views)

Manipulate some arrays

 

 

 

 

(Found HERE

Message 312 of 2,608
(14,506 Views)

What are you complaining about?   That's a beautifull piece of art!    You have to admire the craftmanship!  Smiley Tongue

 

Message 313 of 2,608
(14,487 Views)

 

From here

Message 314 of 2,608
(14,455 Views)

To do some simple scaling af an array with two elements, we could either do:

  1. the "array-to-cluster-unbundle-bundle-cluster-to-array dance" around a formula node or
  2. A few easy array operations

Your pick! 😄

 

Of course for clarity we would place all formula statement on a single line and resize the formula not so most of it is hidden. (See original code).

Thi\us we we will never notice that we accidentally multiply instead of substract.

(guessing here, but if the second statement is really  "D=(C*0.8996)*26.667;", why would we need the brackets?)

 

 

(also adapted from the same as above)

Message Edited by altenbach on 09-05-2008 08:33 AM
Message 315 of 2,608
(14,441 Views)

Anthony de Vries wrote:

What are you complaining about?   That's a beautifull piece of art!    You have to admire the craftmanship!  Smiley Tongue


LOL, but I also want to see the upgrade after he adapts the code to 128 channels. 😄

 

In my alternative, the only thing you need to change is a single diagram constant. 🙂

(...or, if the array of scaling constants is correctly sized, just take it's array size instead and the entire code scales automatically)

Message 316 of 2,608
(14,428 Views)

Something SMercurio noticed... 

 

A typical Rube...  not that it is easy to figure out how to simplify.. 😉

 

from: http://forums.ni.com/ni/board/message?board.id=170&thread.id=354222

 

 

 

Message 317 of 2,608
(14,374 Views)

There's so much white space on the block diagram that it should all be used... or NOT!!

 

 Here's the thread.

Message 318 of 2,608
(14,315 Views)
..............and what about the frontpanel Smiley Tongue
Message 319 of 2,608
(14,288 Views)

K C wrote:
..............and what about the frontpanel Smiley Tongue

"Grey space"? 😄

Message 320 of 2,608
(14,284 Views)