01-27-2009 01:43 PM
I am trying to add two arrays together, it does not seem as if the arrays are broken up into more than one index. I have attached my code. If the array is broken up into indexes I would like to add each corresponding index, but I think the array is all in just one index and if so I was wondering how would I break it into indexes. Thanks
01-27-2009 01:59 PM
First I have to ask, why are you taking a 2-D array, converting it to a dynamic data type, and the converting it to a 1-D array? What is the meaning of th 1-D array vs. 2-D array?
01-27-2009 06:00 PM - edited 01-27-2009 06:02 PM
Since you are "transposing" and later work with 1D array, I assume you want to read the first column of the file.
Why do you need a sequence stacked 5 frames deep, local variables, 5 instances of the same boolean diagram constant and 5 path conststants of which some are identical??? 😮 None of this is needed!
All you need is probably something along the lines of the following picture, which probably does something similar to what you want. Still, we are probably still jumping through too many flaming hoops. Note that the execution order is uniquely defined by the wiring alone, no sequence needed! Can you take a step back and tell us what you are actually trying to achieve with all this? How many columns are in the file? Only one?
01-28-2009 10:40 AM
01-28-2009 12:03 PM - edited 01-28-2009 12:04 PM
Assuming I understood your question correctly heres a solution:
This will make an array of the sum of each column.
01-28-2009 12:13 PM
01-28-2009 12:17 PM
Ravens Fan wrote:
One step simpler, you can replace the inner for loop and shift register with an Add Array Elements function from the numeric palette.
There I go reinventing the wheel again, only bigger and clunkier
01-28-2009 12:20 PM - edited 01-28-2009 12:21 PM
(Cory, your inner FOR loop can be replaced by "add array elements", an atomic operation. :))
You definitely don't need to do disk IO for any of this. All you probably need to do is buit a 2D array at the loop boundary, transpose, and sum the slices in a loop, e.g. as follows.
Modify as needed. Let me know if anything is not clear.
01-28-2009 12:23 PM
altenbach wrote:(Cory, your inner FOR loop can be replaced by "add array elements", an atomic operation. :))
For some reason, once I start thinking about something, I automatically start coding without checking if there is a function that already does the desired task. That would probably be a good thing to start doing.
01-28-2009 12:28 PM
Cory K wrote:For some reason, once I start thinking about something, I automatically start coding without checking if there is a function that already does the desired task. That would probably be a good thing to start doing.
Oh, I know how that works! 😄
At least you found a nice "in-place" solution. Some would have added things via value property nodes. 😮