BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Biggest problem I have is that getting the class name (or even a class ID) from a (Generic) reference is (relatively) slow.

 

Pretty sure I exhausted all options. For instance, getting the type data and a LUT isn't faster (and could be much slower if the type data is large).

 

The only up side is that the simplest solution (the property node) isn't slower then all other solutions. But I still would like it to be faster.

 

I might try to store the class ID with the reference (it's in a class) to avoid getting the class ID more then once, but it's a lot of work, adds complexity. And it might do nothing. I guess a PoP is the way to go.

0 Kudos
Message 2531 of 2,635
(2,849 Views)

@raphschru wrote:

raphschru_1-1686446731114.png

 


Don't you need shift register for the error line in the while loop?

0 Kudos
Message 2532 of 2,635
(2,815 Views)

No because in this mechanism, an error means "this case failed, try the next one". A shift register would propagate the error to the next iteration and cause an infinite loop. The last (Default) case does nothing and ensures the loop is exited after unsuccessfully trying every case.

 

Additionally, I voluntarily took the blue property node out of the error cluster because the object might not have a label, which should not cause an error.

Message 2533 of 2,635
(2,811 Views)

Ways to create a unit circle in complex datatype (seen here )

 

(also, xy graphs understand complex, so converting RE/IM to a X/Y bundle is not even necessary)

 

 

altenbach_1-1688052429296.png

Message 2534 of 2,635
(2,649 Views)

@altenbach wrote:

Ways to create a unit circle in complex datatype (seen here )

 

(also, xy graphs understand complex, so converting RE/IM to a X/Y bundle is not even necessary)

 

 

altenbach_1-1688052429296.png


Oh but what a pretty implementation of [e^i*pi+1=0]  


"Should be" isn't "Is" -Jay
Message 2535 of 2,635
(2,607 Views)

So, if you have a race conditions due to blatant overuse of local variables, one "solution" would be to wrap a two iteration FOR loop around the entire code so the local variable no longer has a stale value the second time around. 😄 (seen here and also see my comments)

 

altenbach_0-1689457215572.png

0 Kudos
Message 2536 of 2,635
(2,272 Views)

@altenbach wrote:

...  and also see my comments

 

 

"I won't look at pages peppered with advertisements."


I agree, but I just tried something for the first time, didn't know it existed.  On his linked site (web magazine) I switched on MS Edge's "Immersive Reader" and it's a complete night and day difference.  Gave it a thumbs up.

Message 2537 of 2,635
(2,211 Views)

Occasionally, even NI produces Rube-Goldberg code!

 

Granted, this code is probably 30+ years old and lot of things have changed since then.

Maybe this was perfectly good code back then, 😄

 

So, for entertainment, let's have a look inside Draw rectangle. Note that there is some suspicious orange parts and the division by two is done twice in parallel (I am sure the compiler will simplify it!). So what does this inflating excursion from 2 bytes (I16) to 8 bytes(DBL) and back to 2 bytes(I16) actually do?? Scratches head while staring at it!!!!

 

altenbach_0-1692388530907.png

 

 

The nice thing is that I16 is small enough so we can easily test the entire domain (-32768 .. 32767) of the function and It turns out that the result is either 0 or 1, and it is 1 for all even inputs and 0 for all odd inputs. (Red code below)

 

I am sure there is a simpler way, right? 

 

Here's one possibility (green). I am sure there are other, equally simple solutions:

 

altenbach_1-1692388844256.png

 

 

Message 2538 of 2,635
(1,998 Views)

Increment by one and then AND 1 would do the same. It's probably only nanoseconds difference if you do an increment or an integer complement if any at all.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2539 of 2,635
(1,994 Views)

wiebeCARYA_0-1692605981637.png

 

This would be faster than both the not and the add on the variable input.

 

The not on the constant will be constant folded...

Message 2540 of 2,635
(1,888 Views)