07-14-2016 06:01 AM
Hello,
I would like to build an N dimensional array without using for loops one inside the others N times because I would like to have the number of dimensions variables, so I don't want to change the code by adding or removing for loops everytime I change the number of dimensions. I would like to start let's say with 7 dimensions 10x10x10x10x10x15x20.
Thanks,
Zied
Solved! Go to Solution.
07-14-2016 06:22 AM
Did you try to use the Initialize array function?
07-14-2016 06:24 AM
Yout can't. Whatever you do programmatically has to have the same datatype on its output wire. So you can create a 1-D array and have it pass its data down the line, then later create a 7-D array. The 7-D array wire is a different datatype and would break all downstream code.
The only thing you can do is create a 7D array, and if you actually want it to be a 2D array, make the other 5 dimensions only 1 element wide.
07-14-2016 06:32 AM
Hello,
You can easily fill an n dimension array using Initialize Array VI, however the number of dimensions remain non-variable. Still it is more simple and flexible, than working with loops. Donwside is, you can't create arrays based on some logic, it just fills the whole with the same element. Replacing some elements one by one can be done with the Replace Array Subset VI, but replacing all I'm afraid still requires n embedded for loops.
Regards,
Adam
07-14-2016 06:42 AM
Thank you guys,
Actually, I need to fill the tables with variable number and not to just initilise it.It is doable with few dimensions but if I need 50 or 100 dimensions then it will be very tiring and I have to change the number of dimensions each time I change the diemsion of the function I have.
Cheers.
Zied
07-14-2016 06:49 AM
If you need that many dimensions, then you may want to reconsider how you structure you data. What is the real world meaning of 50-100 dimensions? Why is that number so variable?
The most number of dimensions I've ever needed was 4. and I could possibly see expanding that to 5. But other than this one particular project, I've only ever needed 3 or less.
07-14-2016 06:54 AM
Hi,
I am trying to calculate f(x1,x2...,xn) of the Ackley function that can be of any dimensions.
http://www.sfu.ca/~ssurjano/ackley.html
I am trying to calculte xi for a grid of 10 or customisable for each dimension.
Thanks,
Zied
07-14-2016 06:56 AM
I am with RavensFan, in any of the application I worked I never wanted to have more than 2 dimensions. In one case I used 3 dimensions which also ended up as 2d after restructuing the data.
07-14-2016 07:24 AM
I don't think your computer can handle a 50 dimension array.
Think about. Suppose each dimension was 10 elements, the smallest dimension of your 7D array you gave in the original post. A 50-D array is 10^50. That is a heck of a lot of zeroes. If each value in the array was only a byte, you don't have enough memory in your PC to hold it all.
Let's say it was only 2 elements in each dimension. Then you are talking 2^50 bytes. 1.12 x 10^15 bytes. . Which is 1125 Terabtyes.
07-14-2016 08:05 AM
Hi again, Maybe I will not try to use this function with 50 dimensions after your warning of memory but still need to try it with 7 to 15 dimensions.
Thanks,
Zied