12-01-2014 08:38 AM
12-02-2014 02:14 AM - edited 12-02-2014 02:18 AM
@dsavir wrote:
Hi,
I admit I've no idea what you're trying to do and why, but here is your code implemented using an in place structure. If the Center coordinate is given in 0 based indexing (so that in a 3x3 array, the center would be (1,1)) this gives the same result as your code. As I've no idea what parameters to put in this could be way off, but the in place structures used might give you an idea. Note that in the inner in place structure the split dimension is 1, and in the outer the split dimension is 0 (right click->split dimension).
Good luck,
Danielle
Thanks Dsavir. I tested your code and I could not get the correct result. By using the split function for IPE Structure, it actually takes all the remaining elements.
On the other hand, using the array subset function, we can take out a sub- array with specified length. The length is calculated using the "dist. from center". Also, I could see that you did not wire the "length calculated" to the split function.
I think it is possible to get the solution with two additional IPE structure inside the two structure you created. THis is to ensure the array portion has specified lenght. But, I think the performance and memory usage would be higher with this solution.
12-02-2014 02:15 AM
@ghighuphu wrote:
It can be enhanced certainly.
- avoid building case structures for easy operations. There is a trade off [time-wise] between building the case structure and calculating some extra values. Benchmarking needed.
- use the in-place structure as dsavir has suggested. I modified his, becuase it was not working for me, and I had to use a lot of "transposing 2D array". Again, benchmarking needed for your case.
Enhance readability by using proper representations (I32 vs DBL for indexes).
I think the distance from the center (DFC) should be redefined. It should be one less. Which elemenets are selected for 0 and 1, in your case? IMHO, DFC=0: a single element / no elements around, DFC=1: 3x3 elements,... You have DFC=2: 3x3 elements. DFC=0:??? I couldn't bare this so, I redefined it for me.
If you are keen on the best timing, you might want to benchmark the three suggestons archived and attached below. Let us know.
Cheers,
Sorry ghighuphu, I could not open your program. Please save it again in labview 2011 format. thank you 😃
12-02-2014 02:46 AM
Here you go, LV2010.
12-08-2014 07:34 PM
@ghighuphu wrote:
Here you go, LV2010.
Thanks a lot ghighuphu for three solutions you suggested. Sorry for the delay. I was on holiday recently.
I tested the code with an array of 1000x1000 elements and dist. from centre of 500.
Here are the performance result:
1) Using for loop : ~33ms
2) Using IPE Structure : ~48ms
3) Using Array subset/replace (ghighuphu): ~50ms
4) Using Array subset/replace (my version): ~40ms
Although the for loop gives the best performance, however, I opt to not using. Actually in my program, I have multiple arrays and all of them are using the same
portion of array location. So, by having the information on how to substract the array subset, it actually helps the operation to other arrays which are being executed sequentially. Hence, using for loop may not be the best way of doing it. Sorry, if you could not understand this. =P
I realised that the result for IPE structure is not correct. Since the timing for using IPE structure and usin "Replace array subset" are quite identical, I opt to use the latter since it provides better readability and allows the same portion to be used again in other operations.
I am also not sure why my version is faster than yours, but the use of max/min function to determine the centre of subarray is a great idea!
Thanks a lot for the effort. Really appreciate it.
12-08-2014 08:26 PM
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-09-2014 11:56 PM
@Hooovahh wrote:
I highly suggest posting the VI you used for your timing test. Many times people don't have rhe right settings for the code and will get incorrect results.
Please have a look at the attached image. All the timing test were done in the same method as illustrated. Please let me know if the way it is implemented is incorrect. thanks
12-10-2014 07:13 AM
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-10-2014 07:45 AM - edited 12-10-2014 07:48 AM
I'm gazing at your results and cannot believe it. Is the for-loop algorithm really the best for your large matrices? Are they sparse matrices (with a lot of NaN or zeros)? I coded the for-loop algorithm only to introduce some outsider for your timing experiment.
Can any Knight or Expert give any explanation for this? Why should a brute-force for-loop algorithm be better than the code with the IPE structure? And the code using IPE structure even worse than the code with subset replace? The latter should be optimised so no data copies are made.
Cheers,
12-10-2014 07:50 AM