LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need a more gentle way to coerce numeric arrays

Solved!
Go to solution

I wrote a set of VIs to manipulate, plot, and save data in a four-dimensional array.  The array can be extremely large, so I used the numeric type U16, which was sufficient to describe all my data at the time.  Now, I also need to handle floating point numbers (SGL is good enough) in smaller 4D arrays.  I could change my VIs to handle SGL, and they would coerce the U16, but that would double the size of the array and limit its ultimate size, which was the point of using U16 in the first place.

 

Is there any simple way to allow a VI to handle two different numeric types without actually coercing?

 

(FYI, my VIs include various array functions, in-place element structures, data value references, TDMS functions, and a functional global variable to pass the array between parallel loops.)

 

Thanks.

0 Kudos
Message 1 of 5
(2,234 Views)

It's hard to give specific advice without knowing the exact data structure you need, particular since you say you need a 4-D array.

 

But you could try looking at a cluster that contains multiple arrays,  or an array of clusters.  A cluster will allow you to have different datatypes grouped together.

0 Kudos
Message 2 of 5
(2,230 Views)

In case it helps make my issue clearer, I've attached two of the VIs I would need to generalize to handle U16 or SGL 4D array.  I haven't attached sub-VIs, but hopefully you can at least get an impression.

 

I think I recall an idea called "overloading" from C++, where a single subroutine could accept different versions of its inputs.  That's what I'm hoping for here.

 

(Note: I have some comments and questions included inside these VIs, but those were added a long time ago and don't pertain to my present question).

Download All
0 Kudos
Message 3 of 5
(2,219 Views)
Solution
Accepted by topic author bracker

 


@bracker wrote:

 

Is there any simple way to allow a VI to handle two different numeric types without actually coercing?

 


Yes and no, what you do is create a Polymorphic VI, It's a common interface which can call different sub-vi's depending on the inputs. In this case you'll make a new sub-vi with SGL as input and output and when you drop and wire the polymorphic VI it'll adapt/select to the wires attached.

 

If the only thing you need to do with the sub-vi is change data type it should be very fast and easy, and the result in the main code is beautiful.

 

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 5
(2,199 Views)

Thanks, that is exactly what I need.

0 Kudos
Message 5 of 5
(2,192 Views)