BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code


@paulmw wrote:

@JÞB wrote:

@altenbach wrote:

Well, to be fair, your code is not equivalent, because it omits the error handling. 😮


Nor does it remove all whitespace charactersSmiley Surprised missed that the first time myself



That will probably become a big bug for someone to discover in the future. "Why can't I insert a 32, it keeps chaning to 0!" (unless that is intended...)


That is not intended. It should properly handle any number of the range 1 - 100 (that's from a check outside this SubVI). Apparently this VI comes from a copy of another that does the same thing... only with a Uint32. Just take the unbundle and rebundle part near the end and expand those down to 4 indexes and more horizontal lines across.

 

As for the error handling. It happens again external to this subVI. "Just to be sure!"

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 1351 of 2,574
(10,905 Views)

@bsvare wrote:
That is not intended. It should properly handle any number of the range 1 - 100 (that's from a check outside this SubVI). Apparently this VI comes from a copy of another that does the same thing... only with a Uint32. Just take the unbundle and rebundle part near the end and expand those down to 4 indexes and more horizontal lines across.

 

As for the error handling. It happens again external to this subVI. "Just to be sure!"


- But the point of a subVI (as well as block diagram tidiness) is code packaging for re-use later, so you should not assume the the input conditions here will the same if this function is reused elswhere in the smae or a similar project. That is a VERY dangerous ASSumption to make Do not assume errors will always be handled exernally with this VI, there is probaly a very good reason for coding it like this even if there are no commments to explain it!

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 1352 of 2,574
(10,840 Views)

Manipulating some integer arrays.... (top of image) (seen here)

 

(An equivalent alternative is shown at the bottom of the image. The first three primitives replace the two FOR loops and trimmings!)

 

 

Message 1353 of 2,574
(10,723 Views)

Do some hex formatting....      (Seen here)

 

 

Message 1354 of 2,574
(10,665 Views)

Hmmm, this coercion dot is annoying here.
Luckily it's already CARred.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 1355 of 2,574
(10,642 Views)

@altenbach wrote:

Do some hex formatting....      (Seen here)

 

 


Also notice that the while loop will iterate two extra times (should be i+1 >= array size for the stop condition).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 1356 of 2,574
(10,596 Views)

@crossrulz wrote:
Also notice that the while loop will iterate two extra times (should be i+1 >= array size for the stop condition).

Yes, I did not worry about commenting on the loop code. Since the number of iterations is known before the loop starts, a FOR loop would be correcter anyway.

0 Kudos
Message 1357 of 2,574
(10,591 Views)

@ThiCop wrote:

Hmmm, this coercion dot is annoying here.
Luckily it's already CARred.


That coercion dot is a bit more than annoying.  If I remember correctly it blows up the [U8] into a [U64] or [I64].  This is one of those rare moments when a G implementation can outperform a primitive, albeit a botched primitive.

 

post-26690-0-20988700-1317667356.png

 

This is much faster than the primitive for [U8], simply by avoiding the wasteful coercion.  Not all red dots are created equal, this is one of the worst offenders.  At least the default conversion is not [CEXT].

Message 1358 of 2,574
(10,573 Views)

@Darin.K wrote:

@ThiCop wrote:

Hmmm, this coercion dot is annoying here.
Luckily it's already CARred.


That coercion dot is a bit more than annoying.  If I remember correctly it blows up the [U8] into a [U64] or [I64].  This is one of those rare moments when a G implementation can outperform a primitive, albeit a botched primitive.

 

post-26690-0-20988700-1317667356.png

 

This is much faster than the primitive for [U8], simply by avoiding the wasteful coercion.  Not all red dots are created equal, this is one of the worst offenders.  At least the default conversion is not [CEXT].


Like it!

 

I wonder if you couldn't eek a bit more performance autoindexing out (probably with 'Auto-Concatenating' turned on, LV2012+) and parallelizing? Ostensibly, the compiler could be able to handle the pre-allocation without all the explicit prims, since output size could be constrained through static analysis of that snippet.

0 Kudos
Message 1359 of 2,574
(10,564 Views)

@JackDunaway wrote:I wonder if you couldn't eek a bit more performance autoindexing out (probably with 'Auto-Concatenating' turned on, LV2012+) and parallelizing?

Come to think of it... i seem to recall conversations about performance characteristics of Auto-Concatenating closer approaching Build Array for each iteration rather than Auto-Indexing .... for this reason, may need to wait for LV2013 or beyond for the performance! 🙂

0 Kudos
Message 1360 of 2,574
(10,560 Views)