Given that it is necessary to specify the number of loops in an external function. Is there a limit to the number of loops that an external function can have?
Many thanks
Phil
Loops in external functions
-
- Super Administrator
- Posts: 4838
- Joined: Wed Mar 05, 2003 3:10 am
Re: Loops in external functions
You don't specify the loops the function has, you specify how many subscript ranges it is going to be responsible for calculating. In C/C++ you can do anything you want to.
For example, if you have
x[sub] = SOMEFUNCTION_EG_COS(a[sub])
SOMEFUNCTION_EG_COS is computing COS, the function needs to be called for each element in the "SUB" subscript range.
Now if you have written an allocation function, you might want to allocate to all elements in "SUB" at the same time. You don't need to call the function once for each element in "SUB" as you want to allocate across all elements at the same time. This function would have 1 user managed loop.
allocation[sub] = SOME_ALLOC(DEMAND[sub], amount available)
SOME_ALLOC would only be called once, and in the function you would fill in all the values for "SUB".
If your function allocated to say store and region, your function might have 2 user managed loops. This would fill in the 2d table for [region,store] (the function would only get called once).
allocation[region,store] = SOME_ALLOC(DEMAND[region,store], amount available)
I hope this makes sense. It's kind of tricky to explain.
For example, if you have
x[sub] = SOMEFUNCTION_EG_COS(a[sub])
SOMEFUNCTION_EG_COS is computing COS, the function needs to be called for each element in the "SUB" subscript range.
Now if you have written an allocation function, you might want to allocate to all elements in "SUB" at the same time. You don't need to call the function once for each element in "SUB" as you want to allocate across all elements at the same time. This function would have 1 user managed loop.
allocation[sub] = SOME_ALLOC(DEMAND[sub], amount available)
SOME_ALLOC would only be called once, and in the function you would fill in all the values for "SUB".
If your function allocated to say store and region, your function might have 2 user managed loops. This would fill in the 2d table for [region,store] (the function would only get called once).
allocation[region,store] = SOME_ALLOC(DEMAND[region,store], amount available)
I hope this makes sense. It's kind of tricky to explain.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Loops in external functions
Got it.. That makes sense
Thanks
Phil
Thanks
Phil