LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parametic test loops

Solved!
Go to solution
The problem here is that you went from 2601 iterations to 183920 iterations using a build array.  This function will make you re-allocate memory every iteration to account for the new array size.  Try to use Initialize array, then replace array elements within your loop.  This will require a bit more code to determine the indexes to replace, but cutting out the memory allocation should considerably speed this up.
Brian A.
National Instruments
Applications Engineer
Message 11 of 21
(1,474 Views)
Solution
Accepted by topic author ShotSimon

ShotSimon wrote:

I must be doing something wrong.  I went and added another loop to create another parametric parameter ~150,000 x 4 parameters.


Allocating the output array once and doing things "in place" is the right thing to do. Keeping track of the insert point is trivial.

 

Try this:

Message Edited by altenbach on 10-03-2008 09:05 AM
Message Edited by altenbach on 10-03-2008 09:07 AM
Download All
Message 12 of 21
(1,470 Views)

My solution was very close but I was still missing the index shift register on the inner loop?  I guess I still don't understand why I can't use the index on the inner most loop as the row indexSmiley Mad

 

Thank you for saving me some time figuring this out.  -SS



0 Kudos
Message 13 of 21
(1,464 Views)

I get it now, every index choice rolls from 0 to N.  So we need an index that only changes once per every four loops!  Excellent little solution.

When you get a chance could you explain how you can do things entirely inside the loops?  That is remove the four initialization loops? 

 

-SS



0 Kudos
Message 14 of 21
(1,463 Views)

ShotSimon wrote:

When you get a chance could you explain how you can do things entirely inside the loops?


I am currently on vacation in a hotel room in the middle of nowhere. I'm not sure how much time I'll have in the next few days. 🙂

 

(I agree, there is way too much duplicate code, still.)

0 Kudos
Message 15 of 21
(1,455 Views)

ShotSimon wrote:

When you get a chance could you explain how you can do things entirely inside the loops?  That is remove the four initialization loops? 


Well, it's quite simple.

 

  • You would just calculate the array elements on the fly inside each of the stacked loops (see option 1).
  • If you don't want to use the shift regsiters, you can just built it in autoidenxing output tunnels and reshape later (see option 2)
  • You could even get away with a single FOR loop if you do some fancy math (see option 3, also attached).
  • There are many other possibilities

 

Note that these three solutions probably differ somewhat in performance, but it's probably not worth worrying about it unless you need gigantic arrays. Can you guess which one is best? 🙂

 

Message Edited by altenbach on 10-05-2008 09:44 AM
Download All
Message 16 of 21
(1,423 Views)

Oh, btw, you should really change the display format of your controls. It is very annoying to have it display 0 digits of precision, but have the increment set at 0.25. This means that 75% of all presses on the increment/decrement buttons have no visible effect, but still change the data.

 

(I have not changed this in my versions above.)

Message 17 of 21
(1,408 Views)

Altenbach,

 

That solution is really amazing.  I didn't realize my increment was set the way it was, sorry about that.  I timed the code and I believe you improved the timing by a factor of three with the third version.  -SS 



0 Kudos
Message 18 of 21
(1,395 Views)

Altenbach,

 

OK this solution is very good for another reason.  If I want to add other parameters, it's simply a matter of increasing the size of the Index and Build Array Functions and adding another Quotient & Remainder Function.  This is much easier then adding in FOR loops and such. 

 

I'm still curious how I could make this routine such that if the user added more parameters on the input array it would simple accomidate this and create the corresponding parametric outputs.  It seems so close the way it's written.

 

Sorry I realize I might be driving you nuts, so forgive me in advanceSmiley Tongue  -SS



0 Kudos
Message 19 of 21
(1,393 Views)

ShotSimon wrote:

I'm still curious how I could make this routine such that if the user added more parameters on the input array it would simple accomidate this and create the corresponding parametric outputs.  It seems so close the way it's written.


Anything repetitive can probably be written using an autoindexig FOR loop. 😄

 

In this particular case the only problem is that we need to reverse the array for the inner loop, but that's probably not such a big deal.

 

(If you don't reverse, you simply get the solution sorted differently, that might be OK too. Try it!)

 

Here's a quick draft. Makes sense?

 

 

This code is getting more compact with each version... 😉

 

Message Edited by altenbach on 10-06-2008 08:39 AM
Download All
0 Kudos
Message 20 of 21
(1,376 Views)