# Tag Info

6

In general, it looks like you need to separate the process of execution and monitoring. The only general way I see to do this is to make your function an object (a pair of functions sharing a mutable state), so that one function would execute the code, while the other would report the internal state to the user. Here is one possibility: obj = ...

3

The problem is that the Do loop is computed before being passed to Monitor. Use HoldAll (or HoldFirst) with Function to achieve your desired goal: Options[heavyFunction] = {monitor -> True}; heavyFunction[x_, OptionsPattern[]] := Module[{n}, Function[code, If[OptionValue@monitor, Monitor[code, n], code], HoldAll]@ Do[Pause[0.1], {n, 10}]]

1

You could use two alternative definitions of your heavyFunction instead of trying to pack all definitions into one. The first definition (monitored) will be used when the option monitor -> True is included in the call; the second definition (not monitored) applies to calls to this function without options. Clear[heavyFunction] heavyFunction[x_, monitor ...

4

Does this fit your needs? Scan[ SetOptions[#, CellGroupingRules -> None] &, Cells[] ]

5

Below are a bunch, although they seem to be a compilation of options for many or all plotting functions, including (mainly) 3D functions. As @belisarius remarked in a comment, using ?NumericQ is the standard way to prevent symbolic analysis, if indeed Plot is doing such. Use something like nf[x_?NumericQ] := f[x]; Plot[f[x], {x, a, b}] Without a ...

4

If you want to do the Unprotect thing, take care to restrict your mod to the specific case: Unprotect[Dot]; Dot[a_List, b_List] /; Dimensions[a][[1]] == 1 && Dimensions[a] == Reverse@Dimensions[b] := Total@Thread@Times[First@a, First/@b] Protect[Dot]; x = {{1, 2, 3}}; y = {{4}, {5}, {6}}; Row[ { MatrixForm[x] MatrixForm[y], " = ...

7

Mathematica uses the SUNDIALS/CVODES libraries. I would recommend the following paper and the references therein. Quoting from the introduction, The forward sensitivity module in CVODES implements the simultaneous corrector method, as well as two flavors of staggered corrector methods. Its adjoint sensitivity module provides a combination of ...

1

As MarcoB pointed out, Evaluate-In-Place Ctrl+Shift+Enter on ColorSetter[] gives an input object that when clicked brings up the menu color palette. However, if you're putting this inside a plot (or PasteButton) you must use a dynamic function. For putting it in plots use PlotStyle -> DynamicSetting[ColorSetter[]]. Thanks, MarcoB.

3

Many built-in functions use a Method option, and suboptions are given within that option, nested, rather than flat as in your examples. The value of Method is extracted and processed, e.g. with ChartingConstructMethod and ChartingparseMethod, then used as needed. I suggest that you do something similar. Simplistically: Options[f] = {method -> {"a", ...

6

You can do this by moving method from an option to a parameter and explicitly listing the options in OptionsPattern. With this approach Options is not used. ClearAll[f] f[x_, method : "a", OptionsPattern[{depth -> 5}]] := {x, method, OptionValue[depth]} f[x_, method : "b", OptionsPattern[{totTime -> 10}]] := {x, method, OptionValue[totTime]} ...

Top 50 recent answers are included