Re: A Mathematica implementation of SolvOpt
- To: mathgroup at smc.vnet.net
- Subject: [mg88610] Re: A Mathematica implementation of SolvOpt
- From: tommcd <TCMcDermott at gmail.com>
- Date: Fri, 9 May 2008 07:17:42 -0400 (EDT)
- References: <g00uq4$gi1$1@smc.vnet.net>
it's probably obvious but the Fortran equivalent should of course have been Where(g0 >= 0.0) deltax = h1*ddx ElseWhere deltax = -h1*ddx End Where On May 9, 8:34 am, tommcd <TCMcDerm... at gmail.com> wrote: > Hi, > I recently uploaded a Mathematica implementation of SolvOpt > (an implementation of Shor's r algorithm for the minimization of > nonlinear, possibly non-smooth objective functions) tohttp://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageNam... > The main package is SolvOpt.m, with shorTest.m and the notebook > SolvOptTest.nb being for demonstration purposes. > The original (Fortran, C, and other) implementations and documentation > are available athttp://www.uni-graz.at/imawww/kuntsevich/solvopt/ > > As this is my 1st mathematica package (I've only ever used notebooks > interactively before) I'd > appreciate any suggestions or constructive criticism, especially with > regard to efficiency and style. > > For example I'd like a more efficient and elegant way to express > Do[ > deltax[[j]] = If[ g0[[j]] >= 0.0, h1*ddx, -h1*ddx] > , {j,n} > ]; > > which in Fortran 95 can be written very clearly as > > Where(g0 >= 0.0) > g0 = h1*ddx > ElseWhere > g0 = -h1*ddx > End Where > > where g0 can be any array of up to 7 dimensions, & any number of array > assignments > can appear in each section (not just the one shown here), moreover the > 'Where' can itself > be nested inside another where etc.. For now a construct which works > for the 1D list above > and avoids the do loop would be fine, though if there is a general > method for masked array assignments in Mathematica I love to hear > about it. > > Regards, > > Tom