Optimizing For loop statement
- To: mathgroup at smc.vnet.net
- Subject: [mg129876] Optimizing For loop statement
- From: "tarpanelli at libero.it" <tarpanelli at libero.it>
- Date: Wed, 20 Feb 2013 22:27:29 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- Reply-to: "tarpanelli at libero.it" <tarpanelli at libero.it>
Hello, here below you can find a piece of Mathematica code: ... For[i=3,i<=n,i++, s=sigma[a,b,c] vol=ReplacePart[vol,{{i,1}->x[[i]],{i,2}->s}]; Clear[b]; b=Interpolation[vol]; ]; where sigma is a module which take as input parameters two scalars (a,c) and one interpolating function (b). What I need is to update the data (vol), on which the interpolating function is built, according to the new result of the module sigma which takes, itsself, the interpolating function as input parameter. I see that the For loop statement is really time-consuming, and I would like to know if it is possible to ptimize it. thanks a lot Paolo