Re: Replace array row in a loop
Mihai Costache [EMAIL PROTECTED] wrote: long explanation snipped It's all very nice, except it takes 20 minutes (Pentium III 800MHz Win2K LV7.1)! I then replace the FOR loop with a formula node and inside that a workmate of mine writes the corresponding C code to do exactly the same job. Now it takes 10 seconds! Is LabVIEW really worthwhile, or do we all need to go back to basics and learn C? Can you provide a VI somewhere where you show what you are doing? Your explanation is a little difficult to imagine (not your fault as such things are hard to describe at any rate) but I'm sure there are possibilities to actually do that perfectly fast in LabVIEW only, possibly beating even the formula node. The problem is not that LabVIEW is so bad, but rather that it takes so much work from you in such situations that you don't worry about optimal algorithmes in the first place and when you do, it is sometimes hard to see the optimal solution. Rolf Kalbermatter CIT Engineering Nederland BVtel: +31 (070) 415 9190 Treubstraat 7H fax: +31 (070) 415 9191 2288 EG Rijswijkhttp://www.citengineering.com Netherlands mailto:[EMAIL PROTECTED]
RE: Replace array row in a loop
I'm not sure why, but that feedback node slows things down tremendously. When I use a regular shift register, it is very fast. I performed the simple test of initializing a 256,000x4 element 2D array of SGL with NaN and then replacing the first 93,000 rows with {0,1,2,3}. What's with the feedback node? - Dan
RE: Replace array row in a loop
Yes Rolf, there is indeed a way of doing it perfectly fast in LabVIEW and even beating the formula node: I just right-clicked on the feedback node and said replace with shift register. Now, if you blink, you miss it! The mistery deepens! I will send you and the others that have volunteered to help me (Michael Avaliotis, Paul Brown) a vi containing the loop, perhaps you can spot what am I doing wrong. Many thanks, Mihai -Original Message- From: Rolf Kalbermatter [mailto:[EMAIL PROTECTED] Sent: Friday, 11 June 2004 7:37 a.m. To: 'Mihai Costache' Cc: Info LabVIEW (E-mail) Subject: Re: Replace array row in a loop Mihai Costache [EMAIL PROTECTED] wrote: long explanation snipped It's all very nice, except it takes 20 minutes (Pentium III 800MHz Win2K LV7.1)! I then replace the FOR loop with a formula node and inside that a workmate of mine writes the corresponding C code to do exactly the same job. Now it takes 10 seconds! Is LabVIEW really worthwhile, or do we all need to go back to basics and learn C? Can you provide a VI somewhere where you show what you are doing? Your explanation is a little difficult to imagine (not your fault as such things are hard to describe at any rate) but I'm sure there are possibilities to actually do that perfectly fast in LabVIEW only, possibly beating even the formula node. Rolf Kalbermatter CIT Engineering Nederland BVtel: +31 (070) 415 9190 Treubstraat 7H fax: +31 (070) 415 9191 2288 EG Rijswijk http://www.citengineering.com Netherlands mailto:[EMAIL PROTECTED]
Replace array row in a loop
I am processing the data coming out of a laser scanner. I set the scanner for let's say 512 lines x 500 points/line, so I should get the coordinates of 256,000 points. For reasons known only to my laser scanner, the number of points actually returned is much smaller, for instance approx. 93,000 on my latest attempt, and the data is returned to me without place holders for the missing points. However, for the data to be useful to my overall application, I do need to reconstruct the 256,000 points array with NaN's as place holders. Somehow I was able to figure out the exact sequence and location of the valid 93,000 points (you don't really want to know the details of that algorithm), so then what I do is: -initialise a SGL 2D array of 256,000 rows x 4 columns, where the first column is the laser scan index (0 for the first 512 rows, 1 for the next 512 rows and so on), and the remaining 3 columns are NaN's for the x,y,z coordinates of the points. - then, inside a FOR loop, 93,000 times I replace one row at a time with the appropriate coordinates as returned by the scanner. I have to do it one row at a time as the points are missing in totally random order. Of course I use a shift register (or feed-back node to be trendy) and the Replace Array Subset function. It's all very nice, except it takes 20 minutes (Pentium III 800MHz Win2K LV7.1)! I then replace the FOR loop with a formula node and inside that a workmate of mine writes the corresponding C code to do exactly the same job. Now it takes 10 seconds! Is LabVIEW really worthwhile, or do we all need to go back to basics and learn C? Mihai Costache Senior Research Development Engineer Industrial Research Ltd. Brooke House 24 Balfour Rd., Parnell PO Box 2225 Auckland, New Zealand DDI: +64 - 9 - 920 3645 Fax: +64 - 9 - 920 3106 www.irl.cri.nz Men stumble over the truth from time to time, but most pick themselves up and hurry off as if nothing happened. Sir Winston Churchill (1874-1965)
RE: Replace array row in a loop
-Original Message- From: Bruce Ammons [mailto:[EMAIL PROTECTED] Sent: Thursday, 10 June 2004 3:58 p.m. To: 'Mihai Costache' Subject: RE: Replace array row in a loop By any chance, would it be faster if you swapped rows and columns in your 2D array? I always get confused which one is a small block of memory and which one is spread out. Nope! Perhaps doing the replace as three individual values instead of a row? You can resize the replace elements icon to include three single values. This might eliminate some kind of memory reallocation that may be occurring. Nope! Perhaps storing three arrays and replacing one value in each? Simple test: initialise a shift register in a FOR loop with a 256,000 elements SGL array, replace one at a time the first 93,000 and check how long it takes. Answer: long! You shouldn't need a column for the index, since this is fixed. It is just the integer value of the index / 512. True. Perhaps use a 3D array 500x512x3??? Nope! I suspect some of these ideas are really bad, but it is difficult to tell until they are tested. I appreciate your ideas, unfortunatelly they are not able to overcome LabVIEW's obvious inherent shortcomings. Bruce Mihai
RE: Replace array row in a loop
Well, I assume you have a loop within a loop? You iterate 93000 times for every row in your 256000 array? 23billion iterations, yes, this would be slow. Even on my 2.2GHz Pentium4 it takes 2-3 minutes. The proper way is to just iterate once through your data and determine where to plug it into your blank array. Here is one approach (there are others of course) that I came up with that might help you. I don't know what your criteria is for determining good data and where it belongs, this is up to you. This method took about 3secs. http://lavausergroup.org/labviewimages/reconstruct_data.gif Michael Aivaliotis http://forums.lavausergroup.org http://mmwis.com snip what I do is: -initialise a SGL 2D array of 256,000 rows x 4 columns, where the first column is the laser scan index (0 for the first 512 rows, 1 for the next 512 rows and so on), and the remaining 3 columns are NaN's for the x,y,z coordinates of the points. - then, inside a FOR loop, 93,000 times I replace one row at a time with the appropriate coordinates as returned by the scanner. I have to do it one row at a time as the points are missing in totally random order. Of course I use a shift register (or feed-back node to be trendy) and the Replace Array Subset function. It's all very nice, except it takes 20 minutes (Pentium III 800MHz Win2K LV7.1)! I then replace the FOR loop with a formula node and inside that a workmate of mine writes the corresponding C code to do exactly the same job. Now it takes 10 seconds! Is LabVIEW really worthwhile, or do we all need to go back to basics and learn C?
RE: Replace array row in a loop
I wonder if we're talking about the same thing here. I performed the test you indicate below and in addition created a 4 column array and replaced all 256,000 rows. It only took 165ms on my computer. Granted I have a faster computer but how long does it take on yours? Also, what version of LabVIEW are you using? Michael Aivaliotis http://forums.lavausergroup.org http://mmwis.com Simple test: initialise a shift register in a FOR loop with a 256,000 elements SGL array, replace one at a time the first 93,000 and check how long it takes. Answer: long!