# Tag Info

## Hot answers tagged kernel

25

Maybe this ? ClearAll["Global*"]

22

What was saved was the content of sol, which happens to contain the solution to your equation (you explicitly set it to that), and therefore is certainly sufficient for your plot. Saving Kernel state however would involve saving things like the random seed, so the following would give the same output twice (using a hypothetical function SaveKernelState and ...

21

You can select which kernel is used by your notebook from the menu item Evaluation -> Notebook's Kernel. By default you will probably only have one kernel called Local available. If your Mathematica license allows for it (typically licenses allow for two simultaneous kernels on a machine), you can add new kernels by selecting the Evaluation -> Kernel ...

20

In the days when computers were slower, and the kernel took a long time to start up (in wall time), a little package was made to help with cleaning up without having to restart the kernel. This package is still included with Mathematica, and is found in AddOns\ExtraPackages\Utilities\CleanSlate.m (within the Mathematica installation directory). It is more ...

19

Since one may not always accurately predict when MemoryContrained is needed, I recommend setting up a watch-dog task. Belisarius described how to do this here in answer to my question. I will reproduce it below as answers that are merely links are discouraged. In Mathematica 8 you could start a memory watchdog, something along the lines of: ...

18

As people have figured out in the comments, this was a quite deliberate decision on our part. One which I can take a significant amount of credit/responsibility/blame for. First a little bit about the extra kernel. The kernel is enabled using a password which causes it to run in Wolfram Player mode. It runs using the same binary as the regular kernel, ...

17

There is an easy way to keep your data in the notebook itself and NOT to save them in external file - using Compress. As @Leonid says here and I already mentioned this before in this answer for similar case with Interpolation function. Start from some output you need: sol = NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, u[t, 0] == Sin[t], ...

17

You need to daemonize your script: nohup math -script test.txt 0<&- &>/dev/null & Now this will run as a background process with no output captured. If your script does indeed produce output, just replace /dev/null with the filename. In order to daemonize something you need to disconnect all the automatically connected streams (stdin, ...

15

Here is the method I outlined. I'll illustrate on a small example where we split matrix into top and bottom halves. In[794]:= SeedRandom[1111]; halfsize = 3; mat = RandomInteger[{-4, 4}, {2*halfsize, 10}] Out[796]= {{-3, -1, 3, -3, 3, 3, 3, 3, 4, 2}, {3, 3, -3, 0, 0, 1, -2, -4, 0, -1}, {-3, 4, 3, 0, -2, 4, 3, -2, -2, -2}, {2, 2, 4, 0, -4, 4, -1, -4, ...

15

To access the errors, you need to invoke the Front End directly from the kernel. In effect, you end up telling the kernel to tell the FE to tell the kernel to do something, so that the FE can report any errors it finds. The method I use is SetAttributes[getFrontEndErrors, HoldAll]; getFrontEndErrors[gexpr_] := Module[{nb}, ...

14

In addition to Mr.Wizard's answer. In many cases it is very practical to stop the evaluation when the actual amount of free physical memory in your system becomes less than specified threshold. You can get the amount of free physical memory very efficiently via NETLink call to GlobalMemoryStatusEx function of kernel32.dll (which is available both under 32 ...

14

I use a shortcut key Ctrl+Q for Quit[], allowing rapid clearing of all sessions variables. Here is how you can add this to Mathematica: You will be editing KeyEventTranslations.tr. This is an important system file so be careful. Start by copying the file you are going to edit from the $InstallationDirectory to$UserBaseDirectory in the same tree. This ...

14

There is a setting in Mathematica that controls whether it can access the internet. Go to Preferences -> Internet Connectivity and uncheck "Allow the Wolfram System to access the Internet". Disabling this will disable some features that depend on internet access, such as Wolfram|Alpha queries. This setting can also be controlled by the $AllowInternet ... 14 This can be relatively easily done using extremely useful$FrontEnd option "ClearEvaluationQueueOnKernelQuit" introduced by Chris Degnen. Usage Print @ $SessionID quitAndEvaluate[ Print @$SessionID ] 25183094379509806957 25183094575602627552 quitAndEvaluate[] will restart kernel without aby additional tasks. It may be useful if you want ...

12

The option to save a variable, a value, in a notebook, that I find simple and deserves a chance is to store them in the notebook's tagging rules. You can compress it if you want, or you can autoload it through an initialization cell or through the NotebookDynamicExpression too. The core is this: r = RandomReal[{-1, 1}, 1000000]; ...

12

This message is issued by Function itself. To see this, try Function[Module[{slot = 1}, Slot[slot]]] If Function has named formal parameters, the message goes away: Function[x, Module[{slot = 1}, Slot[slot]]] So to fix this first we need to find out where is the argument passed to ParallelEvaluate wrapped by Function. Fortunately the parallel tools ...

11

Try this out: Lets say you have a variable called kernelA in one notebook using Kernel A. Then: CurrentValue[$FrontEndSession, {TaggingRules, "KernelA"}] = kernelA In your other notebook, running Kernel B just evaluate variableFromOthernotebook = CurrentValue[$FrontEndSession, {TaggingRules, "KernelA"}] Edit An alternative that might be faster ...

11

Yes, the Mathematica application on Mac OS contains a few external binaries, which are mostly used for importing and exporting. These files have suffix .exe: $find "/Applications/Mathematica 8.app" -name '*.exe'|wc -l 49 But even though .exe is a prefix common for Windows executables, it doesn’t mean that it can’t be used for other things. In fact, Mac OS ... 10 You can make use of either TimeConstrained or MemoryConstrained to terminate evaluation when it runs out of time or memory respectively. For example, if you have a function that has a reasonable memory footprint, but takes time to evaluate, you can abort evaluation after a certain amount of time (in seconds) has elapsed, as: ... 10 You can put your calculation inside TimeConstrained. However in your case, probably the better idea is to restrict the used memory. That's done with MemoryConstrained. If you don't want to figure out the available memory yourself, see here for how to do it automatically. For example this terminates a calculation if the calculation needs more than 1 GB of ... 10 I would not classify this as a bug. The behaviour of a Slot expression that is not directly contained within a Function expression is not defined by the documentation, and is unreliable in practice. Consider the following two functions: f[x_] := x + 100 g[x_] := x + # &[100] They appear to be essentially equivalent, but it just so happens that the ... 10 You can use GNU screen to make a sort of persistent terminal that allows you to resume work wherever you left off. Take a look at the many tutorials available. It's not completely clear from your question whether the better solution is this, or nohup (see Stefan's answer). Use nohup if your workflow is non-interactive: log in, start a batch job that ... 10 You cannot Quit kernel while evaluation is still running: the Quit[] command will be placed in the queue and executed only after finishing of evaluation of all the previous inputs. In contrast, Evaluation>>Quit Kernel will quit the kernel immediately even if it is still running. UPDATE As Kuba notice in the comments, via "Preemptive" link it is ... 9 Since graphics can no longer be exported without access to a front end, even with remote connections you have to have X11 installed and working on your local machine. Therefore, the first thing you should do is: go to the web site http://xquartz.macosforge.org/landing/ and download the latest version of X11 appropriate for your OS X version. After installing ... 9 Here is a very simple example of how to use MathLink for this sort of communication. I will use normal code blocks for kernel A and quoted code blocks for kernel B. You must evaluate these in the order shown. link = LinkCreate["a uniquely named link"]; link = LinkConnect["a uniquely named link"]; LinkActivate[link]; MathLinkAddSharingLink[link]; ... 9 I have the following commands in my init.m file, which can be found in$UserBaseDirectory/Kernel/init.m. eraseAll := ClearAll[Evaluate[$Context<>"*"]]; eraseAll::usage="eraseAll clears all values, definitions, attributes, messages and defaults associated with symbols in the current context" removeAll := Remove[Evaluate[$Context<>"*"]]; ...

9

In addition to assigning to In, the Mathematica main loop assigns the input to InString before it is parsed as an expression. You can then retrieve InString[1] and parse the result with ToExpression, wrapping it in Defer to prevent it from evaluating immediately: In[5]:= ToExpression[InString[1], StandardForm, Defer] Out[5]= Round[SessionTime[]] You can ...

9

To give references to the first part of your question: The best description about the main evaluation loop I have ever read can be found in (as already stated in the comments) Power Programming with Mathematica: The Kernel by David Wagner. A free pdf version of this book can be downloaded here. Therein, he refers to the tutorial Mathematica Internals: A ...

9

Updated This happens because your DynamicModule returns a dynamic object of which x is passed on to the front-end before the scheduled task starts, so the front-end-x cannot be modified anymore by any process (more details at the end). The problem can be further simplified. This works: RemoveScheduledTask@ScheduledTasks[]; DynamicModule[{x = 0}, ...

8

As J.M. pointed out, this can be achieved by using an init.m file. init.m files are loaded on startup. The documentation can be found here. To load the VectorAnalysis package on each startup, you can write the init file using Export. The snippet below will append a Needs["VectorAnalysis`"] to the kernel init.m file: initFileName = ...

Only top voted, non community-wiki answers of a minimum length are eligible