Speeding up Replacement Rules
- To: mathgroup at smc.vnet.net
- Subject: [mg24527] Speeding up Replacement Rules
- From: "Johannes Ludsteck" <ludsteck at zew.de>
- Date: Mon, 24 Jul 2000 03:04:08 -0400 (EDT)
- Organization: Zentr. f. Europ. Wirtschaftsforsch
- Sender: owner-wri-mathgroup at wolfram.com
Dear MathGroup Members, I use Mathematica to compute the hessian of a complicated function of a vector of about 50 variables. My problem with the job is that I need the mean of the hessian for about 50000 sets of vector values. Of course, it is simpe to compute a symbolic expression of the hessian in two steps: g=Map[D[f[args],#]&,args]; h=Map[D[g,#]&,args]; and to use this to compute the mean by defining a list of 500000 replacement rules, and to replace the stuff with (Plus@@(h/.rules))/50000; This works fine but very sloooooooow. Since I have to redo the computation of the mean some hundred times, I nead a drastic gain in speed. I think that the main reason for the poor performance of my strategy is that the replacement operation is slow. I think it should be possible to generate a Compiled function object which is much faster. Since I expect that this will require some time, I would like to know whether the increase in speed will compensate me for the pains of the implementation. Of course, if someone has Mathematica code which takes a vector valued function and generates a Compiled gradient or hessian function, I will accept it gratefully. The simple advice to compute the hessian by hand and to put this in a Compiled function is worthless for me, since I have to apply the mean hessian computation to a variety of different functions. Thank you, Johannes Ludsteck Johannes Ludsteck Centre for European Economic Research (ZEW) Department of Labour Economics, Human Resources and Social Policy Phone (+49)(0)621/1235-157 Fax (+49)(0)621/1235-225 P.O.Box 103443 D-68034 Mannheim GERMANY Email: ludsteck at zew.de