I have the following two procedures that I'd like to call in a loop:
proc intg1(x); retp((x .* dlnm(x,mu,sigma))); endp; proc intg2(x); retp((x .* dlnm(x,mu,sigma))); endp;
To do that, I have found this additional procedure :
nms = &intg1 | &intg2 ; proc intgh(x,h); local intg; intg = nms[h]; local intg:proc; retp(intg(x)); endp;
which should return intgh(x) whenever intg(x,h) is called inside the loop "for h=(1, 2, 1)". The problem is that I use intg with the command intquad1, which does not allow me to specify the argument of intg (x,h).
Any idea on how I could alternatively index the intg procedures inside the loop?
The current version of GAUSS (starting with version 16), is able to pass additional arbitrary arguments to the integration and optimization procedures. Here is a simple example:
scl = 1; limits = 1|0; intquad1(&scaleSin, limits, scl); proc (1) = scaleSin(x, scl); retp(sin(x) .* scl); endp;
This should resolve your problem unless, the extra variable, 'h' in your case, changes during a single call to intquad. If the variable is changed during the call to intquad, then you would have to make 'h' a global variable. In this case, 'h' would not be passed into your procedure, it would just be referenced, for example:
scl = 1; limits = 1|0; intquad1(&scaleSin, limits); //Using global 'scl' proc (1) = scaleSin(x); retp(sin(x) .* scl); endp;