|
[Date Index]
[Thread Index]
[Author Index]
Re: A Mathematica implementation of SolvOpt
- To: mathgroup at smc.vnet.net
- Subject: [mg88633] Re: [mg88567] A Mathematica implementation of SolvOpt
- From: Carl Woll <carlw at wolfram.com>
- Date: Sat, 10 May 2008 06:53:59 -0400 (EDT)
- References: <200805090720.DAA16450@smc.vnet.net>
tommcd 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) to
>http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Shor_Optimization
>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 at
>http://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}
>];
>
>
Can't you just do:
deltax = Sign[g0] h1 ddx
or if you only want to rewrite a portion of the (already existing) delta
array:
deltax[[;;n]] = Sign[g0[[;;n]]] h1 ddx
Since Sign[0] is 0, you may want to consider using something like (2
UnitStep[g0] -1) instead.
Carl Woll
Wolfram Research
>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
>
>
Prev by Date:
Re: Display commands in a package
Next by Date:
EventHandler problem
Previous by thread:
A Mathematica implementation of SolvOpt
Next by thread:
Re: A Mathematica implementation of SolvOpt
|