LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Array Functions

Solved!
Go to solution

Hi all,

 

I have a 2D array that is formed of 1D arrays of data stacked together. I'd like to perform some functions (just basic math really) on each 1D array.

I know I can use indexing into a for loop to do this one array at a time, but I was wondering if there was a way of doing the same maths on each row of a 2D array (a 1D array) simultaneously?

 

As an extra, if this is possible, is it doable for an unknown size 2D array (with reasonable size limits)?

0 Kudos
Message 1 of 9
(2,872 Views)
Solution
Accepted by topic author KieranW

Hi KieranW,

 

For loops support iteration parallelism: right click on the loop edge and the option should be in the pop-up menu.  When enabled, you get an additional terminal on the loop as shown here.  I've never used this feature so can't really comment on any possible pitfalls but I'm sure other contributors can weigh in as necessary.

 

Parallel Loop.png

 

Andy

Message 2 of 9
(2,860 Views)

Hi Kieran,

 

a way of doing the same maths on each row of a 2D array (a 1D array) simultaneously?

Due to polymorphism you can apply basic math on the whole 2D array - no need to index by rows…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 9
(2,848 Views)

Ah this is great - exactly what I'm looking for thank you.

0 Kudos
Message 4 of 9
(2,833 Views)

In principle this would work but the maths includes summing each 1D array and dividing it by its sum so trying to do this using arrays would just hurt my head...

0 Kudos
Message 5 of 9
(2,832 Views)

@KieranW wrote:

In principle this would work but the maths includes summing each 1D array and dividing it by its sum so trying to do this using arrays would just hurt my head...


That's a very easy calculation: It's 1.

Or do you mean to divide the sum of each array with the total of all?

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(2,820 Views)

Is this what you are looking for? You can also add in the parallel looping suggested up above and it should all work as desired

0 Kudos
Message 7 of 9
(2,816 Views)

This is the basic principle yes but as I said in the original post I was familiar with using indexing and for loops. It was the parallel processing suggested above I was after.

0 Kudos
Message 8 of 9
(2,807 Views)

It's not the maths I'm struggling with. It was literally just the parallelism solved in the first response to this post. I was giving the summing of a 1D array as an example of why I needed to split the original 2D array into the constituent 1D arrays.

0 Kudos
Message 9 of 9
(2,804 Views)