Skip to content

Instantly share code, notes, and snippets.

View ajasja's full-sized avatar

Ajasja Ljubetič ajasja

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ajasja
ajasja / gist:2627215
Created May 7, 2012 10:51
NelderMeadMinimize`Dump`CompiledNelderMead
(* Produces compiled code for the Nelder-Mead algorithm with the objective function inlined. *)
(* The objective function takes the form F[parametersToOptimize..,constantParameters] *)
NelderMeadMinimize`Dump`CompiledNelderMead[
objectiveFunction_Function | objectiveFunction_CompiledFunction, vars : {__Symbol}, const: {__Symbol},
opts : OptionsPattern[NelderMeadMinimize`Dump`CompiledNelderMead]
] :=
NelderMeadMinimize`Dump`CompiledNelderMead[
objectiveFunction, vars, const
opts
] =
(*Original implementation*)
MakeInPeriodicCellOrig =
Compile[{x, cellwidth},
First@Sort[{x, x - cellwidth, x + cellwidth},
Abs[#1] < Abs[#2] &], {{Sort[_], _Real}},
CompilationOptions -> {"ExpressionOptimization" -> True,
"InlineCompiledFunctions" -> True,
"InlineExternalDefinitions" -> True},
RuntimeAttributes -> {Listable},
"RuntimeOptions" -> "Speed"