├── Makefile.linux ├── Makefile.osx ├── Makefile.win ├── Pythonika.c ├── Pythonika.h ├── Pythonika.nb ├── Pythonika.tm └── README /Makefile.linux: -------------------------------------------------------------------------------- 1 | 2 | # Set the paths according to your MathLink Developer Kit location. 3 | # (The paths should not contain whitespaces) 4 | 5 | MATHEMATICA_INSTALL_DIR = /usr/local/Wolfram/Mathematica/7.0 6 | MLINKDIR = ${MATHEMATICA_INSTALL_DIR}/SystemFiles/Links/MathLink/DeveloperKit 7 | 8 | SYS = Linux 9 | CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions 10 | 11 | INCDIR = ${CADDSDIR} 12 | LIBDIR = ${CADDSDIR} 13 | 14 | MPREP = "${CADDSDIR}/mprep" 15 | MCC = "${CADDSDIR}/mcc" 16 | 17 | # Modify the following for Python versions other than 2.6 18 | PYTHON_VERSION_MAJOR = 2 19 | PYTHON_VERSION_MINOR = 6 20 | 21 | 22 | # Path to the Python includes (modify according to Python version) 23 | # 24 | PYTHONINC = /usr/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/ 25 | 26 | 27 | PYTHONIKA = Pythonika 28 | INCLUDES = -I${INCDIR} -I${PYTHONINC} 29 | 30 | # libstdc++ and librt are, apparently, needed for correct compilation under Linux 31 | # with libMLi3 statically linked 32 | # 33 | LIBS = -L${LIBDIR} ${LIBDIR}/libML32i3.a -lstdc++ -lrt -lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 34 | 35 | 36 | all : Pythonika 37 | 38 | Pythonika: ${PYTHONIKA}.o ${PYTHONIKA}tm.o 39 | ${CC} ${INCLUDES} ${PYTHONIKA}.o ${PYTHONIKA}tm.o ${LIBS} -o ${PYTHONIKA} 40 | 41 | ${PYTHONIKA}tm.o: ${PYTHONIKA}.tm 42 | ${MPREP} ${PYTHONIKA}.tm -o ${PYTHONIKA}tm.c 43 | ${CC} -c ${PYTHONIKA}tm.c ${INCLUDES} 44 | 45 | ${PYTHONIKA}.o: ${PYTHONIKA}.c 46 | ${CC} -c ${PYTHONIKA}.c ${INCLUDES} 47 | 48 | clean : 49 | rm -f ${PYTHONIKA}tm.* ${PYTHONIKA}.o ${PYTHONIKA} 50 | -------------------------------------------------------------------------------- /Makefile.osx: -------------------------------------------------------------------------------- 1 | 2 | # Set the paths according to your MathLink Developer Kit location. 3 | # (The paths should not contain whitespaces) 4 | 5 | #MLINKDIR = ./mathematica/AddOns/MathLink/DeveloperKit 6 | MLINKDIR = /Applications/Mathematica.app/Contents/SystemFiles/Links/MathLink/DeveloperKit 7 | 8 | #SYS = MacOSX-x86 9 | SYS = MacOSX-x86-64 10 | CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions 11 | 12 | INCDIR = ${CADDSDIR} 13 | LIBDIR = ${CADDSDIR} 14 | 15 | # Modify the following for Python versions other than 2.6 16 | PYTHON_VERSION_MAJOR = 2 17 | PYTHON_VERSION_MINOR = 7 18 | 19 | 20 | 21 | # Depending on your version of OSX the Python framework might be in /Library 22 | # instead of /System/Library (default for later OSX versions) 23 | 24 | PYTHONFRAMEWORKDIR= /usr/local/Cellar/python/2.7.11/Frameworks 25 | PYTHONINC = ${PYTHONFRAMEWORKDIR}/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 26 | 27 | # PYTHONFRAMEWORKDIR = /System/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 28 | # PYTHONINC = /System/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 29 | 30 | # For some older OSX systems: 31 | # 32 | #PYTHONFRAMEWORKDIR = /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 33 | #PYTHONINC = /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 34 | 35 | 36 | # For macports' Python 37 | # 38 | #PYTHONFRAMEWORKDIR = /opt/local/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 39 | #PYTHONINC = /opt/local/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} 40 | 41 | 42 | 43 | 44 | 45 | OPTS = -DPYTHON${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} 46 | 47 | PYTHONIKA = Pythonika 48 | INCLUDES = -I${INCDIR} -I${PYTHONINC} 49 | LIBS = -L${LIBDIR} -lMLi4 -F${PYTHONFRAMEWORKDIR} -framework Python -framework CoreFoundation 50 | MPREP = "${CADDSDIR}/mprep" 51 | MCC = "${CADDSDIR}/mcc" 52 | 53 | 54 | all : Pythonika 55 | 56 | 57 | Pythonika: ${PYTHONIKA}.o ${PYTHONIKA}tm.o 58 | ${CXX} ${INCLUDES} ${PYTHONIKA}.o ${PYTHONIKA}tm.o ${LIBS} -o ${PYTHONIKA} 59 | 60 | 61 | ${PYTHONIKA}tm.o: ${PYTHONIKA}.tm 62 | ${MPREP} ${PYTHONIKA}.tm -o ${PYTHONIKA}tm.c 63 | ${CXX} -c ${PYTHONIKA}tm.c ${INCLUDES} 64 | 65 | ${PYTHONIKA}.o: ${PYTHONIKA}.c 66 | ${CXX} ${OPTS} -c ${PYTHONIKA}.c ${INCLUDES} 67 | 68 | clean : 69 | rm -f ${PYTHONIKA}tm.* ${PYTHONIKA}.o ${PYTHONIKA} 70 | -------------------------------------------------------------------------------- /Makefile.win: -------------------------------------------------------------------------------- 1 | 2 | # Path of the MathLink directory. Modify it to point to the location 3 | # containing the 'bin' and 'include' locations. 4 | # 5 | # Note: "CL" seems not to like paths containing whitespace therefore 6 | # it's probably a good idea to copy the folder containing them to the 7 | # Pythonika directory. 8 | # 9 | #MATHLINKDIR = mldev32 10 | #MATHLINKDIR = DeveloperKit\Windows\CompilerAdditions\mldev32\ 11 | MATHLINKDIR = c:\progra~1\Wolfra~1\Mathematica\7.0\SystemFiles\Links\MathLink\DeveloperKit\Windows\CompilerAdditions\mldev32\ 12 | 13 | 14 | # Modify the following for Python versions other than 2.7 15 | PYTHONVERSION = 27 16 | 17 | # Path to the Python installation 18 | # 19 | PYTHONDIR = c:\python$(PYTHONVERSION) 20 | 21 | # Filename of the Python library, change according to version. 22 | # 23 | PYTHONLIB = python$(PYTHONVERSION).lib 24 | 25 | # Set according to the your Python version 26 | PYTHONDEF = PYTHON$(PYTHONVERSION) 27 | 28 | 29 | CFLAGS = /c /DWIN32 /D_WINDOWS /D$(PYTHONDEF) /W3 /Z7 /Ot 30 | LINKFLAGS = /SUBSYSTEM:CONSOLE /PDB:NONE /INCREMENTAL:no kernel32.lib user32.lib gdi32.lib 31 | 32 | 33 | INCLUDES = /I$(PYTHONDIR)\include /I$(MATHLINKDIR)\include 34 | MPREP = $(MATHLINKDIR)\bin\mprep.exe 35 | LIBS = $(PYTHONDIR)\libs\$(PYTHONLIB) $(MATHLINKDIR)\lib\ml32i3m.lib 36 | 37 | all: 38 | "$(MPREP)" Pythonika.tm -o Pythonikatm.c 39 | CL Pythonika.c Pythonikatm.c $(INCLUDES) $(CFLAGS) 40 | LINK Pythonika.obj Pythonikatm.obj /OUT:Pythonika.exe $(LIBS) $(LINKFLAGS) 41 | 42 | 43 | clean: 44 | del *.obj Pythonikatm.c Pythonika.exe -------------------------------------------------------------------------------- /Pythonika.c: -------------------------------------------------------------------------------- 1 | /* 2 | Pythonika 1.0 - Python Interpreter Interface for Mathematica. 3 | 4 | Copyright (c) 2005-2010 Ero Carrera 5 | 6 | All rights reserved. 7 | 8 | */ 9 | 10 | #include "Pythonika.h" 11 | #include "mathlink.h" 12 | 13 | 14 | // Python code run at initialization time to 15 | // set instances of a class to capture the 16 | // stdin and stdout generated by the Python 17 | // code. 18 | 19 | const char *interpreter_initialization_code = \ 20 | "import sys\n" 21 | "class Capture:\n" 22 | " def __init__(self):\n" 23 | " self.data = ''\n" 24 | " def write(self, str):\n" 25 | " self.data += str\n" 26 | "stdout = sys.stdout\n" 27 | "stderr = sys.stderr\n" 28 | "capture_stdout = Capture()\n" 29 | "capture_stderr = Capture()\n" 30 | "sys.stdout = capture_stdout\n" 31 | "sys.stderr = capture_stderr\n"; 32 | 33 | 34 | InterpreterState *interpreter_state; 35 | 36 | #define MAX_LIST_LEVELS_MSG "Maximum level of 2048 nested lists reached." 37 | #define MAX_LIST_LEVELS 2048 38 | static PyObject *List[MAX_LIST_LEVELS]; 39 | static int list_level = -1; 40 | 41 | 42 | int main(int argc, char **argv) 43 | { 44 | 45 | init_interpreter(); 46 | 47 | return MLMain(argc, argv); 48 | 49 | shutdown_interpreter(); 50 | } 51 | 52 | 53 | void PyInteger(char const*name, long value) 54 | { 55 | PyObject *obj; 56 | 57 | obj = PyLong_FromLong(value); 58 | 59 | if(list_level>=0 && List[list_level]) { 60 | PyList_Append(List[list_level], obj); 61 | Py_DECREF(obj); 62 | return; 63 | } 64 | 65 | PyObject_SetAttrString(interpreter_state->main_module, name, obj); 66 | Py_DECREF(obj); 67 | } 68 | 69 | 70 | void PyReal(char const*name, double value) 71 | { 72 | PyObject *obj; 73 | 74 | obj = PyFloat_FromDouble(value); 75 | 76 | if(list_level>=0 && List[list_level]) { 77 | PyList_Append(List[list_level], obj); 78 | Py_DECREF(obj); 79 | return; 80 | } 81 | 82 | PyObject_SetAttrString(interpreter_state->main_module, name, obj); 83 | Py_DECREF(obj); 84 | } 85 | 86 | 87 | void PyComplex(char const*name, double value, double value2) 88 | { 89 | PyObject *obj; 90 | 91 | obj = PyComplex_FromDoubles(value, value2); 92 | 93 | if(list_level>=0 && List[list_level]) { 94 | PyList_Append(List[list_level], obj); 95 | Py_DECREF(obj); 96 | return; 97 | } 98 | 99 | PyObject_SetAttrString(interpreter_state->main_module, name, obj); 100 | Py_DECREF(obj); 101 | } 102 | 103 | 104 | void PyUnicodeString(const char *name, const unsigned short *value, int len) 105 | { 106 | PyObject *obj; 107 | 108 | 109 | obj = PyUnicode_FromUnicode((unsigned short *)value, len); 110 | 111 | if(list_level>=0 && List[list_level]) { 112 | PyList_Append(List[list_level], obj); 113 | Py_DECREF(obj); 114 | return; 115 | } 116 | 117 | PyObject_SetAttrString( interpreter_state->main_module, name, obj); 118 | Py_DECREF(obj); 119 | } 120 | 121 | 122 | void PyString(char const*name, int *value, long len) 123 | { 124 | long idx; 125 | char *buffer; 126 | PyObject *obj; 127 | 128 | 129 | buffer = (char *)malloc(len); 130 | if(!buffer) { 131 | MLPutString(stdlink, "Pythonika: Can't allocate memory for string."); 132 | return; 133 | } 134 | 135 | for(idx=0; idx=0 && List[list_level]) { 143 | PyList_Append(List[list_level], obj); 144 | Py_DECREF(obj); 145 | MLPutSymbol(stdlink, "Null"); 146 | return; 147 | } 148 | 149 | PyObject_SetAttrString( interpreter_state->main_module, name, obj); 150 | Py_DECREF(obj); 151 | 152 | MLPutSymbol(stdlink, "Null"); 153 | } 154 | 155 | 156 | void PySymbol(char const*name, char const*value) 157 | { 158 | PyObject *obj; 159 | 160 | if(!strncmp(value, "Null", 4)) 161 | obj = Py_None; 162 | else if(!strncmp(value, "True", 4)) 163 | obj = Py_True; 164 | else if(!strncmp(value, "False", 5)) 165 | obj = Py_False; 166 | 167 | if(list_level>=0 && List[list_level]) { 168 | PyList_Append(List[list_level], obj); 169 | return; 170 | } 171 | 172 | PyObject_SetAttrString( interpreter_state->main_module, name, obj); 173 | } 174 | 175 | 176 | void PyOpenList(char const*name) 177 | { 178 | PyObject *list; 179 | 180 | if(list_level+1==MAX_LIST_LEVELS) { 181 | MLPutString(stdlink, MAX_LIST_LEVELS_MSG); 182 | return; 183 | } 184 | 185 | list = PyList_New(0); 186 | 187 | // If a list exists, embed this list inside 188 | if(list_level>=0 && List[list_level]) 189 | PyList_Append(List[list_level], list); 190 | 191 | // Otherwise just add a new one using the given name 192 | else 193 | PyObject_SetAttrString(interpreter_state->main_module, name, list); 194 | 195 | List[++list_level] = list; 196 | 197 | Py_DECREF(list); 198 | MLPutSymbol(stdlink, "Null"); 199 | } 200 | 201 | 202 | void PyCloseList(void) 203 | { 204 | List[list_level--] = NULL; 205 | } 206 | 207 | 208 | // Attempt to execute the input typed by the user. 209 | 210 | #define MATHEMATICA_NEWLINE_TOKEN "\\012" 211 | #define NEWLINE_TOKEN " \n" 212 | 213 | void clean_input(char const*input) 214 | { 215 | int i, length; 216 | 217 | length = strlen(input); 218 | 219 | for(i=0; i+4<=length; i++) 220 | if(!memcmp( (void *)(input+i), (void *)MATHEMATICA_NEWLINE_TOKEN, 4 )) 221 | memcpy((void *)(input+i), NEWLINE_TOKEN, 4); 222 | } 223 | 224 | 225 | void Py(char const*input) { 226 | PyObject *code_obj; 227 | 228 | clean_input(input); 229 | 230 | // Compile the user input as an expression. 231 | code_obj = Py_CompileString(input, "User Input", Py_eval_input); 232 | 233 | if(code_obj) { 234 | 235 | // If the compilation was successful, the resulting code 236 | // object is evaluated. 237 | DEBUG("execute_input: evaluating eval_input") 238 | 239 | mat_eval_compiled_code(code_obj, Py_eval_input); 240 | Py_DECREF(code_obj); 241 | 242 | return; 243 | 244 | } else { 245 | 246 | DEBUG("execute_input: evaluating file_input") 247 | 248 | // If the compilation did not succeed probably the 249 | // code was not an expression. Subsequently it will now 250 | // be compiled as a statement or group of statements. 251 | // The error is therefore cleared. If it triggers again 252 | // after this compilation then there will be a syntax 253 | // or other kind or error in the user's input. 254 | PyErr_Clear(); 255 | 256 | code_obj = Py_CompileString(input, "User Input", Py_file_input); 257 | if(code_obj) { 258 | mat_eval_compiled_code(code_obj, Py_file_input); 259 | Py_DECREF(code_obj); 260 | 261 | return; 262 | } 263 | } 264 | 265 | handle_error(); 266 | return; 267 | } 268 | 269 | 270 | // Read and output any data which Python code 271 | // might have written to stdout or stderr. 272 | 273 | void process_std(PyObject *source) 274 | { 275 | PyObject *std_data; 276 | char *std_str; 277 | Py_ssize_t length; 278 | 279 | DEBUG("process_std: getting data") 280 | std_data = PyObject_GetAttrString(source, "data"); 281 | DEBUG("process_std: getting string from data") 282 | PyString_AsStringAndSize(std_data, &std_str, &length); 283 | 284 | if(length>0) { 285 | DEBUG("process_std: showing string") 286 | MLPutString(stdlink, std_str); 287 | Py_DECREF(std_data); 288 | 289 | PyObject_SetAttrString(source, "data", PyString_FromString("")); 290 | 291 | return; 292 | } 293 | MLPutSymbol(stdlink, "Null"); 294 | } 295 | 296 | 297 | void flush_std(PyObject *source) 298 | { 299 | PyObject *std_data; 300 | char *std_str; 301 | 302 | std_data = PyObject_GetAttrString(source, "data"); 303 | std_str = PyString_AsString(std_data); 304 | 305 | if(strlen(std_str)>0) { 306 | Py_DECREF(std_data); 307 | PyObject_SetAttrString(source, "data", PyString_FromString("")); 308 | return; 309 | } 310 | } 311 | 312 | 313 | // Handle errors in the input. If the error is a syntax 314 | // error it might be due to incomplete input. That's 315 | // checked for and if so, more input is requested. 316 | 317 | void handle_error(void) 318 | { 319 | // The error information is written to stdout. 320 | PyErr_Print(); 321 | 322 | process_std(interpreter_state->capture_stderr); 323 | flush_std(interpreter_state->capture_stdout); 324 | 325 | return; 326 | } 327 | 328 | 329 | void mat_process_iterable_object(PyObject *obj, char *error_msg) 330 | { 331 | Py_ssize_t length; 332 | PyObject *iterator, *item; 333 | 334 | length = PyObject_Length(obj); 335 | 336 | MLPutFunction(stdlink, "List", 1); 337 | MLPutFunction(stdlink, "Sequence", length); 338 | 339 | iterator = PyObject_GetIter(obj); 340 | 341 | if(iterator==NULL) { 342 | MLPutString(stdlink, error_msg); 343 | return; 344 | } 345 | 346 | while(item = PyIter_Next(iterator)) { 347 | python_to_mathematica_object(item); 348 | Py_DECREF(item); 349 | } 350 | 351 | Py_DECREF(iterator); 352 | 353 | return; 354 | } 355 | 356 | 357 | void python_to_mathematica_object(PyObject *obj) 358 | { 359 | if(PyBool_Check(obj)) { 360 | if(obj==Py_True) 361 | MLPutSymbol(stdlink, "True"); 362 | else 363 | MLPutSymbol(stdlink, "False"); 364 | return; 365 | } 366 | if(PyInt_Check(obj)) { 367 | MLPutLongInteger(stdlink, PyInt_AsLong(obj)); 368 | return; 369 | } 370 | if(PyLong_Check(obj)) { 371 | Py_ssize_t length; 372 | char *str, *mat_expr; 373 | PyObject *long_as_str; 374 | 375 | long_as_str = PyObject_CallMethod(obj, (char *)"__str__", NULL); 376 | PyString_AsStringAndSize(long_as_str, &str, &length); 377 | 378 | MLPutFunction(stdlink, "ToExpression", 1); 379 | MLPutString(stdlink, str); 380 | 381 | Py_DECREF(long_as_str); 382 | return; 383 | } 384 | if(obj==Py_None) { 385 | MLPutSymbol(stdlink, "Null"); 386 | return; 387 | } 388 | if(PyFloat_Check(obj)) { 389 | MLPutDouble(stdlink, (double)PyFloat_AsDouble(obj)); 390 | return; 391 | } 392 | if(PyComplex_Check(obj)) { 393 | MLPutFunction(stdlink, "Complex", 2); 394 | MLPutDouble(stdlink, (double)PyComplex_RealAsDouble(obj)); 395 | MLPutDouble(stdlink, (double)PyComplex_ImagAsDouble(obj)); 396 | return; 397 | } 398 | if(PyString_Check(obj)) { 399 | char *str; 400 | Py_ssize_t length; 401 | 402 | PyString_AsStringAndSize(obj, &str, &length); 403 | 404 | MLPutByteString(stdlink, (unsigned char *)str, length); 405 | return; 406 | } 407 | 408 | if(PyUnicode_Check(obj)) { 409 | MLPutUCS2String(stdlink, 410 | PyUnicode_AsUnicode(obj), 411 | PyUnicode_GetSize(obj) ); 412 | return; 413 | } 414 | if(PyTuple_Check(obj)) { 415 | 416 | mat_process_iterable_object(obj, (char *)"Can't get iterator for 'tuple'"); 417 | 418 | return; 419 | } 420 | if(PyList_Check(obj)) { 421 | 422 | mat_process_iterable_object(obj, (char *)"Can't get iterator for 'list'"); 423 | 424 | return; 425 | } 426 | if(PyObject_TypeCheck(obj, &PySet_Type)) { 427 | 428 | mat_process_iterable_object(obj, (char *)"Can't get iterator for 'set'"); 429 | 430 | return; 431 | } 432 | 433 | if(PyDict_Check(obj)) { 434 | PyObject *items; 435 | 436 | items = PyDict_Items(obj); 437 | python_to_mathematica_object(items); 438 | Py_DECREF(items); 439 | 440 | return; 441 | } 442 | 443 | // This should ideally print info, like type of the object, that 444 | // can't be converted. 445 | MLPutString(stdlink, "Object type can't be converted!"); 446 | } 447 | 448 | 449 | 450 | // Evaluate a compiled "code object" 451 | 452 | void mat_eval_compiled_code(PyObject *code_obj, int parse_mode) 453 | { 454 | PyObject *code_executed; 455 | 456 | DEBUG("eval_code: running PyEval_EvalCode") 457 | 458 | // Evaluate the code. 459 | code_executed = (PyObject *)PyEval_EvalCode( 460 | (PyCodeObject *)code_obj, 461 | interpreter_state->main_dict, 462 | interpreter_state->main_dict); 463 | 464 | if(!code_executed) { 465 | DEBUG("eval_code: PyEval_EvalCode failed") 466 | handle_error(); 467 | return; 468 | } 469 | DEBUG("eval_code: code executed") 470 | 471 | DEBUG("eval_code: showing output") 472 | 473 | if(parse_mode==Py_eval_input) { 474 | 475 | // If the mode is Py_eval_input and the code evaluated 476 | // successfully, an expression has been executed and the 477 | // resulting value is the returned Python object. 478 | // The interpreter will output a string representation of 479 | // the object. 480 | DEBUG("eval_code: showing repr") 481 | 482 | python_to_mathematica_object(code_executed); 483 | 484 | // Mathematica can only receive in one stream (no separate way of 485 | // feeding stderr/stdour messages). If an object is returned, then 486 | // any text printed, which would be otherwise returned as a string, 487 | // is discarded. 488 | flush_std(interpreter_state->capture_stdout); 489 | 490 | // Free unneeded object. 491 | Py_DECREF(code_executed); 492 | return; 493 | 494 | } else { 495 | 496 | // Otherwise, the code evaluated was one or more statements 497 | // which do not return a value, if any output has been 498 | // produced, it will be available in the Capture instance 499 | // The output is shown by the interpreter. 500 | 501 | DEBUG("eval_code: showing stdout") 502 | process_std(interpreter_state->capture_stdout); 503 | return; 504 | } 505 | 506 | 507 | MLPutSymbol(stdlink, "Null"); 508 | 509 | return; 510 | } 511 | 512 | 513 | 514 | void init_interpreter(void) 515 | { 516 | PyObject *code_executed; 517 | 518 | #ifdef READLINE 519 | rl_initialize(); 520 | (char*(*)(const char*, int))rl_completion_entry_function = (char*(*)(const char*, int))rl_python_completion_function; 521 | #endif 522 | 523 | Py_Initialize(); 524 | 525 | interpreter_state = (InterpreterState *)malloc(sizeof(InterpreterState)); 526 | 527 | // Get the main dictionary 528 | interpreter_state->main_module = PyImport_AddModule("__main__"); 529 | interpreter_state->main_dict = PyModule_GetDict( 530 | interpreter_state->main_module); 531 | 532 | code_executed = PyRun_String( 533 | interpreter_initialization_code, Py_file_input, 534 | interpreter_state->main_dict, NULL); 535 | interpreter_state->capture_stdout = PyMapping_GetItemString( 536 | interpreter_state->main_dict, (char *)"capture_stdout"); 537 | interpreter_state->capture_stderr = PyMapping_GetItemString( 538 | interpreter_state->main_dict, (char *)"capture_stderr"); 539 | 540 | Py_DECREF(code_executed); 541 | 542 | return; 543 | } 544 | 545 | 546 | void shutdown_interpreter(void) 547 | { 548 | Py_DECREF(interpreter_state->capture_stdout); 549 | Py_DECREF(interpreter_state->capture_stderr); 550 | 551 | #ifdef READLINE 552 | Py_DECREF(interpreter_state->__builtins__); 553 | 554 | free_array_of_strings(builtins); 555 | free_array_of_strings(keywords); 556 | #endif 557 | 558 | Py_Finalize(); 559 | } 560 | -------------------------------------------------------------------------------- /Pythonika.h: -------------------------------------------------------------------------------- 1 | /* 2 | Pythonika 1.0 - Python Interpreter Interface for Mathematica. 3 | 4 | Copyright (c) 2005-2010 Ero Carrera 5 | 6 | All rights reserved. 7 | 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | /* 19 | #define DEBUG(x) { \ 20 | FILE *fd; \ 21 | fd = fopen("/path/to/log/file.log", "at+");\ 22 | fputs(x, fd); \ 23 | fputs("\n", fd); \ 24 | fclose(fd);} 25 | */ 26 | #define DEBUG(x) {} 27 | 28 | 29 | // Structure holding the objects dealing 30 | // with a interactive interpreter instance. 31 | 32 | typedef struct interpreter_state { 33 | PyObject *main_module; 34 | PyObject *main_dict; 35 | PyObject *capture_stdout; 36 | PyObject *capture_stderr; 37 | PyObject *__builtins__; 38 | } InterpreterState; 39 | 40 | void init_interpreter(void); 41 | void shutdown_interpreter(void); 42 | void handle_error(void); 43 | void mat_eval_compiled_code(PyObject *code_obj, int parse_mode); 44 | void mat_eval_compiled_code_silent(PyObject *code_obj, int parse_mode); 45 | void mat_process_iterable_object(PyObject *obj, char *error_msg); 46 | void python_to_mathematica_object(PyObject *obj); 47 | void Pythonika(char *input); 48 | -------------------------------------------------------------------------------- /Pythonika.nb: -------------------------------------------------------------------------------- 1 | (* Content-type: application/mathematica *) 2 | 3 | (*** Wolfram Notebook File ***) 4 | (* http://www.wolfram.com/nb *) 5 | 6 | (* CreatedBy='Mathematica 7.0' *) 7 | 8 | (*CacheID: 234*) 9 | (* Internal cache information: 10 | NotebookFileLineBreakTest 11 | NotebookFileLineBreakTest 12 | NotebookDataPosition[ 145, 7] 13 | NotebookDataLength[ 75351, 1776] 14 | NotebookOptionsPosition[ 6790, 311] 15 | NotebookOutlinePosition[ 73058, 1699] 16 | CellTagsIndexPosition[ 73015, 1696] 17 | WindowFrame->Normal*) 18 | 19 | (* Beginning of Notebook Content *) 20 | Notebook[{ 21 | Cell["Pythonika", "Title"], 22 | 23 | Cell["Loading", "Subtitle"], 24 | 25 | Cell[CellGroupData[{ 26 | 27 | Cell[TextData[{ 28 | StyleBox["Pythonika", 29 | FontSlant->"Italic"], 30 | " loading." 31 | }], "Text"], 32 | 33 | Cell[BoxData[{ 34 | RowBox[{ 35 | RowBox[{"app", "=", "\"\\""}], ";"}], "\n", 36 | RowBox[{ 37 | RowBox[{"app", " ", "=", " ", "\"\\""}], 38 | ";"}], "\[IndentingNewLine]", 39 | RowBox[{ 40 | RowBox[{"Install", "[", "app", "]"}], ";"}]}], "Input"], 41 | 42 | Cell["Check whether it's alive.", "Text"], 43 | 44 | Cell[BoxData[ 45 | RowBox[{"Links", "[", "app", "]"}]], "Input"], 46 | 47 | Cell["Unload.", "Text"], 48 | 49 | Cell[BoxData[ 50 | RowBox[{ 51 | RowBox[{"Uninstall", "[", 52 | RowBox[{ 53 | RowBox[{"Links", "[", "app", "]"}], "[", 54 | RowBox[{"[", "1", "]"}], "]"}], "]"}], ";"}]], "Input"] 55 | }, Open ]], 56 | 57 | Cell["Usage", "Subtitle"], 58 | 59 | Cell[CellGroupData[{ 60 | 61 | Cell[TextData[{ 62 | "Basic examples. (notice that all objects are returned as the corresponding \ 63 | ones in ", 64 | StyleBox["Mathematica", 65 | FontSlant->"Italic"], 66 | " )" 67 | }], "Text"], 68 | 69 | Cell[BoxData[ 70 | RowBox[{"Py", "[", "\"\\"", "]"}]], "Input"], 71 | 72 | Cell["Py[\"1+1\"]", "Input"] 73 | }, Open ]], 74 | 75 | Cell["Py[\"1+2j\"]", "Input"], 76 | 77 | Cell[CellGroupData[{ 78 | 79 | Cell[TextData[{ 80 | "Arbitrarily long integers, Python's ", 81 | StyleBox["long", 82 | FontWeight->"Bold", 83 | FontSlant->"Italic"], 84 | "'s, are properly dealt with." 85 | }], "Text"], 86 | 87 | Cell["Py[\"2**128\"]", "Input"] 88 | }, Open ]], 89 | 90 | Cell[TextData[{ 91 | "Passing ", 92 | StyleBox["Mathematica's ", 93 | FontSlant->"Italic"], 94 | "objects to Python" 95 | }], "Subtitle"], 96 | 97 | Cell[TextData[{ 98 | "Pythonika provides with ", 99 | StyleBox["Mathematica", 100 | FontSlant->"Italic"], 101 | " functions to convert from the most basic types into their equivalent in ", 102 | StyleBox["Python", 103 | FontSlant->"Italic"], 104 | ". Beware that symbolic ", 105 | StyleBox["Mathematica", 106 | FontSlant->"Italic"], 107 | " expressions may need to be wrapped around ", 108 | StyleBox["N[expr]", 109 | FontWeight->"Bold", 110 | FontSlant->"Italic"], 111 | " in order to turn them into a numerical value that can be converted into ", 112 | StyleBox["Python.\n", 113 | FontSlant->"Italic"], 114 | "The functions take the name of the Python object receiving the data (does \ 115 | not need to exist beforehand) and the value to pass." 116 | }], "Text"], 117 | 118 | Cell[CellGroupData[{ 119 | 120 | Cell["Passsing a complex number.", "Text"], 121 | 122 | Cell["PyComplex[\"my_complex\", 2+3/2\[ImaginaryI]]", "Input"], 123 | 124 | Cell["Py[\"(my_complex, my_complex.real, my_complex.imag)\"]", "Input"] 125 | }, Open ]], 126 | 127 | Cell[CellGroupData[{ 128 | 129 | Cell["Passing a real number.", "Text"], 130 | 131 | Cell["PyReal[\"my_real\", N[\[Pi]/4]]", "Input"], 132 | 133 | Cell["Py[\"(my_real, my_real**2)\"]", "Input"] 134 | }, Open ]], 135 | 136 | Cell[CellGroupData[{ 137 | 138 | Cell["Passing a list.", "Text"], 139 | 140 | Cell["ToPy[\"my_list\", {1,2,3,4}]", "Input"], 141 | 142 | Cell["Py[\"my_list\"]", "Input"] 143 | }, Open ]], 144 | 145 | Cell[CellGroupData[{ 146 | 147 | Cell[TextData[{ 148 | "In order to make it all simpler, the ", 149 | StyleBox["ToPy", 150 | FontWeight->"Bold", 151 | FontSlant->"Italic"], 152 | " function will detect the data type passed and convert it accordingly. \ 153 | Therefore ", 154 | StyleBox["ToPy", 155 | FontWeight->"Bold", 156 | FontSlant->"Italic"], 157 | " is the ", 158 | StyleBox["only", 159 | FontWeight->"Bold"], 160 | " method needed to pass data to ", 161 | StyleBox["Python", 162 | FontSlant->"Italic"], 163 | "." 164 | }], "Text"], 165 | 166 | Cell["ToPy[\"my_generic\", 1/2+2\[ImaginaryI]]", "Input"], 167 | 168 | Cell["Py[\"my_generic\"]", "Input"], 169 | 170 | Cell["ToPy[ \"my_generic2\", N[{2+3\[ImaginaryI], Sqrt[2]}] ]", "Input"], 171 | 172 | Cell["Py[\"my_generic2\"]", "Input"] 173 | }, Open ]], 174 | 175 | Cell[CellGroupData[{ 176 | 177 | Cell[TextData[{ 178 | "Pythonika can be fed multiline code using ", 179 | StyleBox["Mathematica's \"\\<\" ", 180 | FontSlant->"Italic"], 181 | "and", 182 | StyleBox[" \"\\>\" ", 183 | FontSlant->"Italic"], 184 | "in order to preserve the line breaks." 185 | }], "Text"], 186 | 187 | Cell["\<\ 188 | Py[\"\\< 189 | square_roots = list() 190 | for i in range(10): 191 | square_roots.append(i**.5) 192 | print square_roots[-1] 193 | \\>\"]\ 194 | \>", "Input"] 195 | }, Open ]], 196 | 197 | Cell[CellGroupData[{ 198 | 199 | Cell["Retrieve a variable's contents.", "Text"], 200 | 201 | Cell["SquareRoots = Py[\"square_roots\"]", "Input"] 202 | }, Open ]], 203 | 204 | Cell[CellGroupData[{ 205 | 206 | Cell[TextData[{ 207 | "Pythonika can do any iterable object. (This examples work only with ", 208 | StyleBox["Python 2.4 & 2.5", 209 | FontWeight->"Bold"], 210 | ", because of the generators", 211 | ")" 212 | }], "Text"], 213 | 214 | Cell["Sets", "Text"], 215 | 216 | Cell["Py[\"set(x**2 for x in range(10))\"]", "Input"], 217 | 218 | Cell["Lists", "Text"], 219 | 220 | Cell["Py[\"list(x**2 for x in (2,3,5,7,11,13,17))\"]", "Input"], 221 | 222 | Cell["Dictionaries", "Text"], 223 | 224 | Cell["Py[\"dict((x, x**2) for x in (2,3,5,7,11,13,17))\"]", "Input"] 225 | }, Open ]], 226 | 227 | Cell[TextData[{ 228 | "This examples work only with ", 229 | StyleBox["Python 2.5", 230 | FontWeight->"Bold"], 231 | ", because of the generators" 232 | }], "Text"], 233 | 234 | Cell["Py[\"any(x>5 for x in range(10))\"]", "Input"], 235 | 236 | Cell[TextData[{ 237 | "Defining ", 238 | StyleBox["Mathematica", 239 | FontSlant->"Italic"], 240 | " functions in ", 241 | StyleBox["Python", 242 | FontSlant->"Italic"] 243 | }], "Subtitle"], 244 | 245 | Cell[CellGroupData[{ 246 | 247 | Cell["This function expects a list as argument.", "Text"], 248 | 249 | Cell[BoxData[ 250 | RowBox[{ 251 | RowBox[{"funcOne", "=", 252 | RowBox[{ 253 | "PyFunction", "[", "\"\\"", 254 | "]"}]}], ";"}]], "Input"], 255 | 256 | Cell["\<\ 257 | This expects a complex, long or integer. (or anything where the power \ 258 | operator is defined)\ 259 | \>", "Text"], 260 | 261 | Cell[BoxData[ 262 | RowBox[{ 263 | RowBox[{"funcTwo", "=", 264 | RowBox[{"PyFunction", "[", "\"\\"", "]"}]}], 265 | ";"}]], "Input"], 266 | 267 | Cell[CellGroupData[{ 268 | 269 | Cell["Evaluate them", "Text"], 270 | 271 | Cell[BoxData[{ 272 | RowBox[{"funcOne", "[", 273 | RowBox[{ 274 | RowBox[{"2", "+", 275 | RowBox[{"3", "\[ImaginaryI]"}]}], ",", "3"}], 276 | "]"}], "\[IndentingNewLine]", 277 | RowBox[{"funcOne", "[", 278 | RowBox[{"{", 279 | RowBox[{ 280 | RowBox[{"2", "+", 281 | RowBox[{"3", "\[ImaginaryI]"}]}], ",", "3"}], "}"}], 282 | "]"}], "\[IndentingNewLine]", 283 | RowBox[{"funcTwo", "[", 284 | RowBox[{"2", "+", 285 | RowBox[{"3", "\[ImaginaryI]"}]}], "]"}]}], "Input"] 286 | }, Open ]] 287 | }, Open ]], 288 | 289 | Cell[CellGroupData[{ 290 | 291 | Cell["\<\ 292 | Define a class with a power operator which raises the value used to \ 293 | initialize an instance to the given exponent and returns the result modulo 7.\ 294 | \ 295 | \>", "Text"], 296 | 297 | Cell["\<\ 298 | Py[\"\\< 299 | class NN: 300 | def __init__(self, v): 301 | self.v = v 302 | def __pow__(self, exp): 303 | return (self.v**exp)%7 304 | 305 | print NN(2)**4 306 | \\>\"]\ 307 | \>", "Input"], 308 | 309 | Cell["Py[\"NN(3)**4\"]", "Input"] 310 | }, Open ]] 311 | }, 312 | CellGrouping->Manual, 313 | WindowSize->{596, 686}, 314 | WindowMargins->{{245, Automatic}, {Automatic, 11}}, 315 | PrintingCopies->1, 316 | PrintingPageRange->{1, Automatic}, 317 | ShowSelection->True, 318 | CellLabelAutoDelete->True, 319 | FrontEndVersion->"10.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (October 16, \ 320 | 2013)", 321 | StyleDefinitions->Notebook[{ 322 | Cell[ 323 | CellGroupData[{ 324 | Cell["Style Definitions", "Title"], 325 | Cell[ 326 | "Modify the definitions below to change the default appearance of all \ 327 | cells in a given style. Make modifications to any definition using commands \ 328 | in the Format menu.", "Text"], 329 | Cell[ 330 | CellGroupData[{ 331 | Cell["Style Environment Names", "Section"], 332 | Cell[ 333 | StyleData[All, "Working"], PageWidth -> WindowWidth, ScriptMinSize -> 334 | 9], 335 | Cell[ 336 | StyleData[All, "Presentation"], PageWidth -> WindowWidth, 337 | ScriptMinSize -> 12, FontSize -> 16], 338 | Cell[ 339 | StyleData[All, "SlideShow"], PageWidth -> WindowWidth, 340 | ScrollingOptions -> { 341 | "PagewiseDisplay" -> True, "VerticalScrollRange" -> Fit}, 342 | ShowCellBracket -> False, ScriptMinSize -> 9], 343 | Cell[ 344 | StyleData[All, "Condensed"], PageWidth -> WindowWidth, 345 | CellBracketOptions -> {"Margins" -> {1, 1}, "Widths" -> {0, 5}}, 346 | ScriptMinSize -> 8, FontSize -> 11], 347 | Cell[ 348 | StyleData[All, "Printout"], PageWidth -> PaperWidth, ScriptMinSize -> 349 | 7, FontSize -> 10, 350 | PrivateFontOptions -> {"FontType" -> "Outline"}]}, Open]], 351 | Cell[ 352 | CellGroupData[{ 353 | Cell["Notebook Options", "Section"], 354 | Cell[ 355 | "The options defined for the style below will be used at the \ 356 | Notebook level.", "Text"], 357 | Cell[ 358 | StyleData["Notebook"], PageHeaders -> {{ 359 | Cell[ 360 | TextData[{ 361 | CounterBox["Page"]}], "PageNumber"], None, 362 | Cell[ 363 | TextData[{ 364 | ValueBox["FileName"]}], "Header"]}, { 365 | Cell[ 366 | TextData[{ 367 | ValueBox["FileName"]}], "Header"], None, 368 | Cell[ 369 | TextData[{ 370 | CounterBox["Page"]}], "PageNumber"]}}, 371 | PageHeaderLines -> {True, True}, 372 | PrintingOptions -> { 373 | "FacingPages" -> True, "FirstPageHeader" -> False}, 374 | CellFrameLabelMargins -> 6, StyleMenuListing -> None]}, Open]], 375 | Cell[ 376 | CellGroupData[{ 377 | Cell["Styles for Headings", "Section"], 378 | Cell[ 379 | CellGroupData[{ 380 | Cell[ 381 | StyleData["Title"], ShowCellBracket -> False, 382 | CellMargins -> {{0, 0}, {0, 0}}, PageBreakBelow -> False, 383 | InputAutoReplacements -> {"TeX" -> StyleBox[ 384 | RowBox[{"T", 385 | AdjustmentBox[ 386 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 387 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 388 | RowBox[{"L", 389 | StyleBox[ 390 | AdjustmentBox[ 391 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 392 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 393 | AdjustmentBox[ 394 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 395 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 396 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 397 | "gridMathematica" -> FormBox[ 398 | RowBox[{"grid", 399 | AdjustmentBox[ 400 | StyleBox["Mathematica", FontSlant -> "Italic"], 401 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 402 | "webMathematica" -> FormBox[ 403 | RowBox[{"web", 404 | AdjustmentBox[ 405 | StyleBox["Mathematica", FontSlant -> "Italic"], 406 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 407 | Inherited}, LineSpacing -> {1, 11}, CounterIncrements -> 408 | "Title", 409 | CounterAssignments -> {{"Section", 0}, {"Equation", 0}, { 410 | "Figure", 0}, {"Subtitle", 0}, {"Subsubtitle", 0}}, FontSize -> 411 | 34, FontColor -> GrayLevel[1], Background -> 412 | RGBColor[0.300008, 0.600015, 0.800015]], 413 | Cell[ 414 | StyleData["Title", "Presentation"], 415 | CellMargins -> {{0, 0}, {0, 0}}, 416 | CellFrameMargins -> {{12, 10}, {24, 24}}, LineSpacing -> {1, 0}, 417 | FontSize -> 46], 418 | Cell[ 419 | StyleData["Title", "Condensed"], CellMargins -> {{0, 0}, {0, 0}}, 420 | FontSize -> 20], 421 | Cell[ 422 | StyleData["Title", "Printout"], CellMargins -> {{0, 0}, {0, 0}}, 423 | FontSize -> 24, FontTracking -> "Plain", Background -> 424 | GrayLevel[0]]}, Closed]], 425 | Cell[ 426 | CellGroupData[{ 427 | Cell[ 428 | StyleData["Subtitle"], ShowCellBracket -> False, 429 | CellMargins -> {{0, 0}, {0, 0}}, PageBreakBelow -> False, 430 | InputAutoReplacements -> {"TeX" -> StyleBox[ 431 | RowBox[{"T", 432 | AdjustmentBox[ 433 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 434 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 435 | RowBox[{"L", 436 | StyleBox[ 437 | AdjustmentBox[ 438 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 439 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 440 | AdjustmentBox[ 441 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 442 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 443 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 444 | "gridMathematica" -> FormBox[ 445 | RowBox[{"grid", 446 | AdjustmentBox[ 447 | StyleBox["Mathematica", FontSlant -> "Italic"], 448 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 449 | "webMathematica" -> FormBox[ 450 | RowBox[{"web", 451 | AdjustmentBox[ 452 | StyleBox["Mathematica", FontSlant -> "Italic"], 453 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 454 | Inherited}, LineSpacing -> {1, 3}, ParagraphIndent -> -96, 455 | CounterIncrements -> "Subtitle", 456 | CounterAssignments -> {{"Section", 0}, {"Equation", 0}, { 457 | "Figure", 0}, {"Subsubtitle", 0}}, FontFamily -> "Helvetica", 458 | FontSize -> 18, FontColor -> GrayLevel[1], Background -> 459 | RGBColor[0.700008, 0.900008, 0.700008]], 460 | Cell[ 461 | StyleData["Subtitle", "Presentation"], 462 | CellMargins -> {{0, 0}, {4, 0}}, 463 | CellFrameMargins -> {{12, 10}, {12, 8}}, LineSpacing -> {1, 6}, 464 | ParagraphIndent -> -157, FontSize -> 28], 465 | Cell[ 466 | StyleData["Subtitle", "Condensed"], 467 | CellMargins -> {{0, 0}, {0, 0}}, ParagraphIndent -> -78, 468 | FontSize -> 14], 469 | Cell[ 470 | StyleData["Subtitle", "Printout"], 471 | CellMargins -> {{0, 0}, {0, 0}}, ParagraphIndent -> -85, 472 | FontSize -> 16, Background -> GrayLevel[0.6]]}, Closed]], 473 | Cell[ 474 | CellGroupData[{ 475 | Cell[ 476 | StyleData["Subsubtitle"], ShowCellBracket -> False, 477 | CellMargins -> {{10, 4}, {30, 10}}, PageBreakBelow -> False, 478 | InputAutoReplacements -> {"TeX" -> StyleBox[ 479 | RowBox[{"T", 480 | AdjustmentBox[ 481 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 482 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 483 | RowBox[{"L", 484 | StyleBox[ 485 | AdjustmentBox[ 486 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 487 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 488 | AdjustmentBox[ 489 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 490 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 491 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 492 | "gridMathematica" -> FormBox[ 493 | RowBox[{"grid", 494 | AdjustmentBox[ 495 | StyleBox["Mathematica", FontSlant -> "Italic"], 496 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 497 | "webMathematica" -> FormBox[ 498 | RowBox[{"web", 499 | AdjustmentBox[ 500 | StyleBox["Mathematica", FontSlant -> "Italic"], 501 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 502 | Inherited}, CounterIncrements -> "Subsubtitle", 503 | CounterAssignments -> {{"Section", 0}, {"Equation", 0}, { 504 | "Figure", 0}}, FontFamily -> "Helvetica", FontSize -> 14, 505 | FontSlant -> "Italic"], 506 | Cell[ 507 | StyleData["Subsubtitle", "Presentation"], 508 | CellMargins -> {{15, 10}, {50, 10}}, LineSpacing -> {1, 0}, 509 | FontSize -> 22], 510 | Cell[ 511 | StyleData["Subsubtitle", "Condensed"], 512 | CellMargins -> {{8, 10}, {12, 8}}, FontSize -> 12], 513 | Cell[ 514 | StyleData["Subsubtitle", "Printout"], 515 | CellMargins -> {{9, 10}, {50, 10}}, FontSize -> 14]}, Closed]], 516 | Cell[ 517 | CellGroupData[{ 518 | Cell[ 519 | StyleData["Section"], CellFrame -> {{6, 0}, {0, 1}}, CellDingbat -> 520 | None, CellMargins -> {{12, Inherited}, {4, 24}}, 521 | CellGroupingRules -> {"SectionGrouping", 30}, PageBreakBelow -> 522 | False, CellFrameMargins -> 6, 523 | InputAutoReplacements -> {"TeX" -> StyleBox[ 524 | RowBox[{"T", 525 | AdjustmentBox[ 526 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 527 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 528 | RowBox[{"L", 529 | StyleBox[ 530 | AdjustmentBox[ 531 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 532 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 533 | AdjustmentBox[ 534 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 535 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 536 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 537 | "gridMathematica" -> FormBox[ 538 | RowBox[{"grid", 539 | AdjustmentBox[ 540 | StyleBox["Mathematica", FontSlant -> "Italic"], 541 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 542 | "webMathematica" -> FormBox[ 543 | RowBox[{"web", 544 | AdjustmentBox[ 545 | StyleBox["Mathematica", FontSlant -> "Italic"], 546 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 547 | Inherited}, LineSpacing -> {1, 7}, CounterIncrements -> 548 | "Section", 549 | CounterAssignments -> {{"Subsection", 0}, {"Subsubsection", 0}}, 550 | FontFamily -> "Helvetica", FontSize -> 16, FontWeight -> "Bold", 551 | FontColor -> RGBColor[0.571389, 0.19675, 0.570504]], 552 | Cell[ 553 | StyleData["Section", "Presentation"], 554 | CellFrame -> {{8, 0}, {0, 2}}, 555 | CellMargins -> {{15, 10}, {14, 32}}, 556 | CellFrameMargins -> {{8, 10}, {10, 14}}, LineSpacing -> {1, 2}, 557 | FontSize -> 24, FontTracking -> "Condensed"], 558 | Cell[ 559 | StyleData["Section", "Condensed"], 560 | CellMargins -> {{8, Inherited}, {2, 12}}, FontSize -> 12], 561 | Cell[ 562 | StyleData["Section", "Printout"], 563 | CellMargins -> {{9, 0}, {2, 50}}, FontSize -> 14, FontTracking -> 564 | "Plain", FontColor -> GrayLevel[0]]}, Closed]], 565 | Cell[ 566 | CellGroupData[{ 567 | Cell[ 568 | StyleData["Subsection"], 569 | CellMargins -> {{12, Inherited}, {8, 20}}, 570 | CellGroupingRules -> {"SectionGrouping", 40}, PageBreakBelow -> 571 | False, InputAutoReplacements -> {"TeX" -> StyleBox[ 572 | RowBox[{"T", 573 | AdjustmentBox[ 574 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 575 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 576 | RowBox[{"L", 577 | StyleBox[ 578 | AdjustmentBox[ 579 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 580 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 581 | AdjustmentBox[ 582 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 583 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 584 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 585 | "gridMathematica" -> FormBox[ 586 | RowBox[{"grid", 587 | AdjustmentBox[ 588 | StyleBox["Mathematica", FontSlant -> "Italic"], 589 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 590 | "webMathematica" -> FormBox[ 591 | RowBox[{"web", 592 | AdjustmentBox[ 593 | StyleBox["Mathematica", FontSlant -> "Italic"], 594 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 595 | Inherited}, LineSpacing -> {1, 7}, CounterIncrements -> 596 | "Subsection", CounterAssignments -> {{"Subsubsection", 0}}, 597 | FontFamily -> "Helvetica", FontSize -> 13, FontWeight -> "Bold"], 598 | Cell[ 599 | StyleData["Subsection", "Presentation"], 600 | CellMargins -> {{15, 10}, {12, 32}}, LineSpacing -> {1, 0}, 601 | FontSize -> 22], 602 | Cell[ 603 | StyleData["Subsection", "Condensed"], 604 | CellMargins -> {{8, Inherited}, {2, 12}}, FontSize -> 12], 605 | Cell[ 606 | StyleData["Subsection", "Printout"], 607 | CellMargins -> {{9, 0}, {4, 40}}, FontSize -> 12]}, Closed]], 608 | Cell[ 609 | CellGroupData[{ 610 | Cell[ 611 | StyleData["Subsubsection"], CellDingbat -> "\[FilledSquare]", 612 | CellMargins -> {{25, Inherited}, {8, 12}}, 613 | CellGroupingRules -> {"SectionGrouping", 50}, PageBreakBelow -> 614 | False, InputAutoReplacements -> {"TeX" -> StyleBox[ 615 | RowBox[{"T", 616 | AdjustmentBox[ 617 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 618 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 619 | RowBox[{"L", 620 | StyleBox[ 621 | AdjustmentBox[ 622 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 623 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 624 | AdjustmentBox[ 625 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 626 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 627 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 628 | "gridMathematica" -> FormBox[ 629 | RowBox[{"grid", 630 | AdjustmentBox[ 631 | StyleBox["Mathematica", FontSlant -> "Italic"], 632 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 633 | "webMathematica" -> FormBox[ 634 | RowBox[{"web", 635 | AdjustmentBox[ 636 | StyleBox["Mathematica", FontSlant -> "Italic"], 637 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 638 | Inherited}, LineSpacing -> {1, 9}, CounterIncrements -> 639 | "Subsubsection", FontFamily -> "Times", FontSize -> 13, 640 | FontWeight -> "Bold"], 641 | Cell[ 642 | StyleData["Subsubsection", "Presentation"], 643 | CellMargins -> {{34, 10}, {18, 28}}, LineSpacing -> {1, 0}, 644 | FontSize -> 18], 645 | Cell[ 646 | StyleData["Subsubsection", "Condensed"], 647 | CellMargins -> {{22, Inherited}, {2, 12}}, FontSize -> 10], 648 | Cell[ 649 | StyleData["Subsubsection", "Printout"], 650 | CellMargins -> {{21, 0}, {4, 20}}, FontSize -> 11]}, Closed]]}, 651 | Open]], 652 | Cell[ 653 | CellGroupData[{ 654 | Cell["Styles for Body Text", "Section"], 655 | Cell[ 656 | CellGroupData[{ 657 | Cell[ 658 | StyleData["Text"], CellMargins -> {{60, 10}, {7, 7}}, 659 | InputAutoReplacements -> {"TeX" -> StyleBox[ 660 | RowBox[{"T", 661 | AdjustmentBox[ 662 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 663 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 664 | RowBox[{"L", 665 | StyleBox[ 666 | AdjustmentBox[ 667 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 668 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 669 | AdjustmentBox[ 670 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 671 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 672 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 673 | "gridMathematica" -> FormBox[ 674 | RowBox[{"grid", 675 | AdjustmentBox[ 676 | StyleBox["Mathematica", FontSlant -> "Italic"], 677 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 678 | "webMathematica" -> FormBox[ 679 | RowBox[{"web", 680 | AdjustmentBox[ 681 | StyleBox["Mathematica", FontSlant -> "Italic"], 682 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 683 | Inherited}, LineSpacing -> {1, 3}, CounterIncrements -> "Text", 684 | FontSize -> 14, 685 | PrivateFontOptions -> {"FontType" -> "Outline"}], 686 | Cell[ 687 | StyleData["Text", "Presentation"], 688 | CellMargins -> {{15, 10}, {8, 10}}, LineSpacing -> {1, 5}, 689 | ParagraphSpacing -> {0, 12}, FontSize -> 18], 690 | Cell[ 691 | StyleData["Text", "Condensed"], CellMargins -> {{8, 10}, {4, 4}}, 692 | LineSpacing -> {1, 1}, ParagraphSpacing -> {0, 4}], 693 | Cell[ 694 | StyleData["Text", "Printout"], CellMargins -> {{9, 0}, {4, 4}}, 695 | Hyphenation -> True, ParagraphSpacing -> {0, 6}]}, Open]], 696 | Cell[ 697 | CellGroupData[{ 698 | Cell[ 699 | StyleData["SmallText"], CellMargins -> {{12, 10}, {5, 5}}, 700 | InputAutoReplacements -> {"TeX" -> StyleBox[ 701 | RowBox[{"T", 702 | AdjustmentBox[ 703 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 704 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 705 | RowBox[{"L", 706 | StyleBox[ 707 | AdjustmentBox[ 708 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 709 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 710 | AdjustmentBox[ 711 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 712 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 713 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 714 | "gridMathematica" -> FormBox[ 715 | RowBox[{"grid", 716 | AdjustmentBox[ 717 | StyleBox["Mathematica", FontSlant -> "Italic"], 718 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 719 | "webMathematica" -> FormBox[ 720 | RowBox[{"web", 721 | AdjustmentBox[ 722 | StyleBox["Mathematica", FontSlant -> "Italic"], 723 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 724 | Inherited}, LineSpacing -> {1, 3}, ParagraphSpacing -> {0, 6}, 725 | CounterIncrements -> "SmallText", FontFamily -> "Helvetica", 726 | FontSize -> 9], 727 | Cell[ 728 | StyleData["SmallText", "Presentation"], 729 | CellMargins -> {{15, 10}, {8, 10}}, LineSpacing -> {1, 5}, 730 | FontSize -> 14], 731 | Cell[ 732 | StyleData["SmallText", "Condensed"], 733 | CellMargins -> {{8, 10}, {2, 2}}, LineSpacing -> {1, 2}, 734 | FontSize -> 9], 735 | Cell[ 736 | StyleData["SmallText", "Printout"], 737 | CellMargins -> {{9, 0}, {4, 4}}, Hyphenation -> True, FontSize -> 738 | 7]}, Closed]]}, Open]], 739 | Cell[ 740 | CellGroupData[{ 741 | Cell["Inline Formatting", "Section"], 742 | Cell[ 743 | "These styles are for modifying individual words or letters in a \ 744 | cell exclusive of the cell tag.", "Text"], 745 | Cell[ 746 | StyleData["RM"], StyleMenuListing -> None, FontWeight -> "Plain", 747 | FontSlant -> "Plain"], 748 | Cell[ 749 | StyleData["BF"], StyleMenuListing -> None, FontWeight -> "Bold"], 750 | Cell[ 751 | StyleData["IT"], StyleMenuListing -> None, FontSlant -> "Italic"], 752 | Cell[ 753 | StyleData["TR"], StyleMenuListing -> None, FontFamily -> "Times", 754 | FontWeight -> "Plain", FontSlant -> "Plain"], 755 | Cell[ 756 | StyleData["TI"], StyleMenuListing -> None, FontFamily -> "Times", 757 | FontWeight -> "Plain", FontSlant -> "Italic"], 758 | Cell[ 759 | StyleData["TB"], StyleMenuListing -> None, FontFamily -> "Times", 760 | FontWeight -> "Bold", FontSlant -> "Plain"], 761 | Cell[ 762 | StyleData["TBI"], StyleMenuListing -> None, FontFamily -> "Times", 763 | FontWeight -> "Bold", FontSlant -> "Italic"], 764 | Cell[ 765 | StyleData["MR"], "TwoByteSyntaxCharacterAutoReplacement" -> True, 766 | HyphenationOptions -> {"HyphenationCharacter" -> "\[Continuation]"}, 767 | StyleMenuListing -> None, FontFamily -> "Courier", FontWeight -> 768 | "Plain", FontSlant -> "Plain"], 769 | Cell[ 770 | StyleData["MO"], "TwoByteSyntaxCharacterAutoReplacement" -> True, 771 | HyphenationOptions -> {"HyphenationCharacter" -> "\[Continuation]"}, 772 | StyleMenuListing -> None, FontFamily -> "Courier", FontWeight -> 773 | "Plain", FontSlant -> "Italic"], 774 | Cell[ 775 | StyleData["MB"], "TwoByteSyntaxCharacterAutoReplacement" -> True, 776 | HyphenationOptions -> {"HyphenationCharacter" -> "\[Continuation]"}, 777 | StyleMenuListing -> None, FontFamily -> "Courier", FontWeight -> 778 | "Bold", FontSlant -> "Plain"], 779 | Cell[ 780 | StyleData["MBO"], "TwoByteSyntaxCharacterAutoReplacement" -> True, 781 | HyphenationOptions -> {"HyphenationCharacter" -> "\[Continuation]"}, 782 | StyleMenuListing -> None, FontFamily -> "Courier", FontWeight -> 783 | "Bold", FontSlant -> "Italic"], 784 | Cell[ 785 | StyleData["SR"], StyleMenuListing -> None, FontFamily -> 786 | "Helvetica", FontWeight -> "Plain", FontSlant -> "Plain"], 787 | Cell[ 788 | StyleData["SO"], StyleMenuListing -> None, FontFamily -> 789 | "Helvetica", FontWeight -> "Plain", FontSlant -> "Italic"], 790 | Cell[ 791 | StyleData["SB"], StyleMenuListing -> None, FontFamily -> 792 | "Helvetica", FontWeight -> "Bold", FontSlant -> "Plain"], 793 | Cell[ 794 | StyleData["SBO"], StyleMenuListing -> None, FontFamily -> 795 | "Helvetica", FontWeight -> "Bold", FontSlant -> "Italic"], 796 | Cell[ 797 | CellGroupData[{ 798 | Cell[ 799 | StyleData["SO10"], StyleMenuListing -> None, FontFamily -> 800 | "Helvetica", FontSize -> 10, FontWeight -> "Plain", FontSlant -> 801 | "Italic"], 802 | Cell[ 803 | StyleData["SO10", "Printout"], StyleMenuListing -> None, 804 | FontFamily -> "Helvetica", FontSize -> 7, FontWeight -> "Plain", 805 | FontSlant -> "Italic"]}, Closed]], 806 | Cell[ 807 | CellGroupData[{ 808 | Cell[ 809 | StyleData["Inert"], StyleMenuListing -> None, Background -> 810 | RGBColor[0.870588, 0.905882, 0.972549]], 811 | Cell[ 812 | StyleData["Inert", "Printout"], StyleMenuListing -> None, 813 | Background -> GrayLevel[1]]}, Closed]]}, Closed]], 814 | Cell[ 815 | CellGroupData[{ 816 | Cell["Styles for Input/Output", "Section"], 817 | Cell[ 818 | "The cells in this section define styles used for input and output \ 819 | to the kernel. Be careful when modifying, renaming, or removing these \ 820 | styles, because the front end associates special meanings with these style \ 821 | names.", "Text"], 822 | Cell[ 823 | CellGroupData[{ 824 | Cell[ 825 | StyleData["Input"], CellFrame -> 1, 826 | CellMargins -> {{52, 10}, {8, 8}}, Evaluatable -> True, 827 | CellGroupingRules -> "InputGrouping", CellHorizontalScrolling -> 828 | True, PageBreakWithin -> False, GroupPageBreakWithin -> False, 829 | CellLabelMargins -> {{5, Inherited}, {Inherited, Inherited}}, 830 | DefaultFormatType -> DefaultInputFormatType, 831 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 832 | HyphenationOptions -> { 833 | "HyphenationCharacter" -> "\[Continuation]"}, LanguageCategory -> 834 | "Formula", FormatType -> InputForm, ShowStringCharacters -> True, 835 | NumberMarks -> True, 836 | LinebreakAdjustments -> {0.85, 2, 10, 0, 1}, CounterIncrements -> 837 | "Input", FontFamily -> "Times", FontSize -> 12, FontWeight -> 838 | "Plain", PrivateFontOptions -> {"FontType" -> "Outline"}, 839 | Background -> RGBColor[1, 0.800015, 0.6]], 840 | Cell[ 841 | StyleData["Input", "Presentation"], 842 | CellFrame -> {{5, 0}, {0, 0}}, 843 | CellMargins -> {{74, 10}, {8, 10}}, 844 | CellFrameMargins -> {{10, 10}, {14, 14}}, LineSpacing -> {1, 0}, 845 | FontSize -> 18], 846 | Cell[ 847 | StyleData["Input", "Condensed"], 848 | CellMargins -> {{40, Inherited}, {1, 4}}], 849 | Cell[ 850 | StyleData["Input", "Printout"], CellMargins -> {{44, 0}, {2, 6}}, 851 | Background -> GrayLevel[0.900008]]}, Closed]], 852 | Cell[ 853 | CellGroupData[{ 854 | Cell[ 855 | StyleData["InlineInput"], Evaluatable -> True, CellGroupingRules -> 856 | "InputGrouping", CellHorizontalScrolling -> True, 857 | PageBreakWithin -> False, GroupPageBreakWithin -> False, 858 | DefaultFormatType -> DefaultInputFormatType, 859 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 860 | HyphenationOptions -> { 861 | "HyphenationCharacter" -> "\[Continuation]"}, 862 | AutoItalicWords -> {}, FormatType -> InputForm, 863 | ShowStringCharacters -> True, NumberMarks -> True, 864 | CounterIncrements -> "Input", FontWeight -> "Bold", 865 | PrivateFontOptions -> {"FontType" -> "Outline"}], 866 | Cell[ 867 | StyleData["InlineInput", "Presentation"], FontSize -> 18], 868 | Cell[ 869 | StyleData["InlineInput", "Condensed"]], 870 | Cell[ 871 | StyleData["InlineInput", "Printout"], FontSize -> 10]}, Closed]], 872 | Cell[ 873 | CellGroupData[{ 874 | Cell[ 875 | StyleData["Output"], CellFrame -> 1, 876 | CellMargins -> {{52, 10}, {8, 8}}, CellEditDuplicate -> True, 877 | CellGroupingRules -> "OutputGrouping", CellHorizontalScrolling -> 878 | True, PageBreakWithin -> False, GroupPageBreakWithin -> False, 879 | GeneratedCell -> True, CellAutoOverwrite -> True, 880 | CellLabelMargins -> {{3, Inherited}, {Inherited, Inherited}}, 881 | DefaultFormatType -> DefaultOutputFormatType, 882 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 883 | HyphenationOptions -> { 884 | "HyphenationCharacter" -> "\[Continuation]"}, LanguageCategory -> 885 | "Formula", FormatType -> InputForm, CounterIncrements -> 886 | "Output", PrivateFontOptions -> {"FontType" -> "Outline"}, 887 | Background -> GrayLevel[0.900008]], 888 | Cell[ 889 | StyleData["Output", "Presentation"], 890 | CellFrame -> {{5, 0}, {0, 0}}, 891 | CellMargins -> {{74, 10}, {12, 5}}, 892 | CellFrameMargins -> {{10, 10}, {14, 14}}, LineSpacing -> {1, 0}, 893 | FontSize -> 18], 894 | Cell[ 895 | StyleData["Output", "Condensed"], 896 | CellMargins -> {{40, Inherited}, {4, 1}}], 897 | Cell[ 898 | StyleData["Output", "Printout"], 899 | CellMargins -> {{44, 0}, {6, 2}}, Background -> 900 | GrayLevel[0.900008]]}, Closed]], 901 | Cell[ 902 | CellGroupData[{ 903 | Cell[ 904 | StyleData["Message"], 905 | CellMargins -> {{62, Inherited}, {Inherited, Inherited}}, 906 | CellGroupingRules -> "OutputGrouping", PageBreakWithin -> False, 907 | GroupPageBreakWithin -> False, GeneratedCell -> True, 908 | CellAutoOverwrite -> True, ShowCellLabel -> False, 909 | DefaultFormatType -> DefaultOutputFormatType, 910 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 911 | HyphenationOptions -> { 912 | "HyphenationCharacter" -> "\[Continuation]"}, FormatType -> 913 | InputForm, CounterIncrements -> "Message", StyleMenuListing -> 914 | None, FontColor -> RGBColor[1, 0, 0]], 915 | Cell[ 916 | StyleData["Message", "Presentation"], 917 | CellMargins -> {{86, 20}, {10, 10}}, LineSpacing -> {1, 0}, 918 | FontSize -> 18], 919 | Cell[ 920 | StyleData["Message", "Condensed"], 921 | CellMargins -> {{50, Inherited}, {Inherited, Inherited}}], 922 | Cell[ 923 | StyleData["Message", "Printout"], 924 | CellMargins -> {{54, Inherited}, {Inherited, Inherited}}, 925 | FontColor -> GrayLevel[0]]}, Closed]], 926 | Cell[ 927 | CellGroupData[{ 928 | Cell[ 929 | StyleData["Print"], 930 | CellMargins -> {{62, Inherited}, {Inherited, Inherited}}, 931 | CellGroupingRules -> "OutputGrouping", CellHorizontalScrolling -> 932 | True, PageBreakWithin -> False, GroupPageBreakWithin -> False, 933 | GeneratedCell -> True, CellAutoOverwrite -> True, ShowCellLabel -> 934 | False, DefaultFormatType -> DefaultOutputFormatType, 935 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 936 | HyphenationOptions -> { 937 | "HyphenationCharacter" -> "\[Continuation]"}, FormatType -> 938 | InputForm, CounterIncrements -> "Print", StyleMenuListing -> 939 | None], 940 | Cell[ 941 | StyleData["Print", "Presentation"], 942 | CellMargins -> {{86, 20}, {4, 4}}, LineSpacing -> {1, 0}, 943 | FontSize -> 18], 944 | Cell[ 945 | StyleData["Print", "Condensed"], 946 | CellMargins -> {{50, Inherited}, {Inherited, Inherited}}], 947 | Cell[ 948 | StyleData["Print", "Printout"], 949 | CellMargins -> {{54, Inherited}, {Inherited, Inherited}}]}, 950 | Closed]], 951 | Cell[ 952 | CellGroupData[{ 953 | Cell[ 954 | StyleData["Graphics"], 955 | CellMargins -> {{62, Inherited}, {Inherited, Inherited}}, 956 | CellGroupingRules -> "GraphicsGrouping", CellHorizontalScrolling -> 957 | True, PageBreakWithin -> False, GeneratedCell -> True, 958 | CellAutoOverwrite -> True, ShowCellLabel -> False, 959 | DefaultFormatType -> DefaultOutputFormatType, FormatType -> 960 | InputForm, CounterIncrements -> "Graphics", StyleMenuListing -> 961 | None], 962 | Cell[ 963 | StyleData["Graphics", "Presentation"], 964 | CellMargins -> {{86, 20}, {8, 8}}, FontSize -> 18], 965 | Cell[ 966 | StyleData["Graphics", "Condensed"], 967 | CellMargins -> {{52, Inherited}, {Inherited, Inherited}}, 968 | ImageSize -> {175, 175}], 969 | Cell[ 970 | StyleData["Graphics", "Printout"], 971 | CellMargins -> {{54, Inherited}, {Inherited, Inherited}}, 972 | ImageSize -> {250, 250}]}, Closed]], 973 | Cell[ 974 | CellGroupData[{ 975 | Cell[ 976 | StyleData["CellLabel"], StyleMenuListing -> None, FontFamily -> 977 | "Helvetica", FontSize -> 11, FontWeight -> "Bold", FontColor -> 978 | RGBColor[0.571389, 0.19675, 0.570504]], 979 | Cell[ 980 | StyleData["CellLabel", "Presentation"], FontSize -> 12], 981 | Cell[ 982 | StyleData["CellLabel", "Condensed"], FontSize -> 8], 983 | Cell[ 984 | StyleData["CellLabel", "Printout"], FontSize -> 8, FontColor -> 985 | GrayLevel[0]]}, Closed]]}, Open]], 986 | Cell[ 987 | CellGroupData[{ 988 | Cell["Unique Styles", "Section"], 989 | Cell[ 990 | CellGroupData[{ 991 | Cell[ 992 | StyleData["Author"], ShowCellBracket -> False, 993 | CellMargins -> {{10, 4}, {2, 10}}, LineSpacing -> {1, 5}, 994 | FontSize -> 16, FontSlant -> "Italic"], 995 | Cell[ 996 | StyleData["Author", "Presentation"], 997 | CellMargins -> {{15, 10}, {4, 16}}, LineSpacing -> {1, 5}, 998 | ParagraphSpacing -> {0, 12}, FontSize -> 24], 999 | Cell[ 1000 | StyleData["Author", "Condensed"], 1001 | CellMargins -> {{8, 10}, {1, 4}}, LineSpacing -> {1, 1}, 1002 | ParagraphSpacing -> {0, 4}, FontSize -> 12], 1003 | Cell[ 1004 | StyleData["Author", "Printout"], 1005 | CellMargins -> {{9, 0}, {4, 12}}, ParagraphSpacing -> {0, 6}, 1006 | FontSize -> 14]}, Closed]], 1007 | Cell[ 1008 | CellGroupData[{ 1009 | Cell[ 1010 | StyleData["Copyright"], ShowCellBracket -> False, 1011 | CellMargins -> {{10, 10}, {40, 2}}, FontFamily -> "Helvetica", 1012 | FontSize -> 9], 1013 | Cell[ 1014 | StyleData["Copyright", "Presentation"], 1015 | CellMargins -> {{15, 10}, {50, 4}}, LineSpacing -> {1, 5}, 1016 | FontSize -> 14], 1017 | Cell[ 1018 | StyleData["Copyright", "Condensed"], 1019 | CellMargins -> {{8, 10}, {12, 1}}, LineSpacing -> {1, 2}, 1020 | FontSize -> 9], 1021 | Cell[ 1022 | StyleData["Copyright", "Printout"], 1023 | CellMargins -> {{9, 0}, {72, 4}}, FontSize -> 7]}, Closed]], 1024 | Cell[ 1025 | CellGroupData[{ 1026 | Cell[ 1027 | StyleData["Example"], CellMargins -> {{12, 10}, {5, 12}}, 1028 | LineSpacing -> {1, 3}, ParagraphSpacing -> {0, 12}, 1029 | CounterIncrements -> "Example", FontFamily -> "Times", 1030 | FontWeight -> "Bold"], 1031 | Cell[ 1032 | StyleData["Example", "Presentation"], 1033 | CellMargins -> {{18, 10}, {8, 20}}, LineSpacing -> {1, 5}, 1034 | ParagraphSpacing -> {0, 12}, FontSize -> 18], 1035 | Cell[ 1036 | StyleData["Example", "Condensed"], 1037 | CellMargins -> {{8, 10}, {4, 8}}, LineSpacing -> {1, 1}, 1038 | ParagraphSpacing -> {0, 4}], 1039 | Cell[ 1040 | StyleData["Example", "Printout"], 1041 | CellMargins -> {{9, 0}, {4, 10}}, ParagraphSpacing -> {0, 6}]}, 1042 | Closed]], 1043 | Cell[ 1044 | CellGroupData[{ 1045 | Cell[ 1046 | StyleData["Definition"], CellFrame -> {{3, 0}, {0, 0}}, 1047 | CellMargins -> {{52, 10}, {8, 8}}, PageBreakWithin -> False, 1048 | GroupPageBreakWithin -> False, 1049 | CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 1050 | ShowStringCharacters -> True, CounterIncrements -> "Definition", 1051 | FontFamily -> "Helvetica", FontWeight -> "Bold", FontColor -> 1052 | GrayLevel[1], Background -> RGBColor[0.2, 0.700008, 0.700008]], 1053 | Cell[ 1054 | StyleData["Definition", "Presentation"], 1055 | CellFrame -> {{5, 0}, {0, 0}}, 1056 | CellMargins -> {{74, 10}, {8, 12}}, 1057 | CellFrameMargins -> {{10, 10}, {14, 14}}, LineSpacing -> {1, 0}, 1058 | FontSize -> 18], 1059 | Cell[ 1060 | StyleData["Definition", "Condensed"], 1061 | CellMargins -> {{40, 10}, {1, 4}}], 1062 | Cell[ 1063 | StyleData["Definition", "Printout"], 1064 | CellMargins -> {{44, 0}, {2, 6}}, Hyphenation -> True, 1065 | Background -> GrayLevel[0.6]]}, Closed]], 1066 | Cell[ 1067 | CellGroupData[{ 1068 | Cell[ 1069 | StyleData["Theorem"], CellFrame -> {{3, 0}, {0, 0}}, 1070 | CellMargins -> {{52, 10}, {8, 8}}, PageBreakWithin -> False, 1071 | GroupPageBreakWithin -> False, 1072 | CellLabelMargins -> {{23, Inherited}, {Inherited, Inherited}}, 1073 | ShowStringCharacters -> True, CounterIncrements -> "Theorem", 1074 | FontFamily -> "Helvetica", FontWeight -> "Bold", FontColor -> 1075 | GrayLevel[1], Background -> RGBColor[0.408011, 0.440726, 0.8]], 1076 | Cell[ 1077 | StyleData["Theorem", "Presentation"], 1078 | CellFrame -> {{5, 0}, {0, 0}}, 1079 | CellMargins -> {{74, 10}, {8, 12}}, 1080 | CellFrameMargins -> {{10, 10}, {14, 14}}, LineSpacing -> {1, 0}, 1081 | FontSize -> 18], 1082 | Cell[ 1083 | StyleData["Theorem", "Condensed"], 1084 | CellMargins -> {{40, 10}, {1, 4}}], 1085 | Cell[ 1086 | StyleData["Theorem", "Printout"], 1087 | CellMargins -> {{44, 0}, {2, 6}}, Hyphenation -> True, 1088 | Background -> GrayLevel[0.4]]}, Closed]], 1089 | Cell[ 1090 | CellGroupData[{ 1091 | Cell[ 1092 | StyleData["ExerciseMain"], CellFrame -> {{6, 0}, {0, 1}}, 1093 | CellMargins -> {{12, Inherited}, {4, 20}}, 1094 | CellGroupingRules -> {"SectionGrouping", 30}, PageBreakBelow -> 1095 | False, CellFrameColor -> RGBColor[0.571389, 0.19675, 0.570504], 1096 | LineSpacing -> {1, 7}, CounterIncrements -> "Subsection", 1097 | CounterAssignments -> {{"Subsubsection", 0}}, FontFamily -> 1098 | "Helvetica", FontSize -> 16, FontWeight -> "Bold", FontColor -> 1099 | RGBColor[0.571389, 0.19675, 0.570504]], 1100 | Cell[ 1101 | StyleData["ExerciseMain", "Presentation"], 1102 | CellFrame -> {{8, 0}, {0, 2}}, 1103 | CellMargins -> {{18, 10}, {12, 32}}, 1104 | CellFrameMargins -> {{10, 10}, {14, 14}}, LineSpacing -> {1, 2}, 1105 | FontSize -> 24, FontTracking -> "Condensed"], 1106 | Cell[ 1107 | StyleData["ExerciseMain", "Condensed"], 1108 | CellMargins -> {{8, Inherited}, {2, 12}}, FontSize -> 12], 1109 | Cell[ 1110 | StyleData["ExerciseMain", "Printout"], 1111 | CellMargins -> {{9, 0}, {2, 50}}, CellFrameColor -> 1112 | GrayLevel[0.500008], FontSize -> 14, FontTracking -> "Plain", 1113 | FontColor -> GrayLevel[0]]}, Closed]], 1114 | Cell[ 1115 | CellGroupData[{ 1116 | Cell[ 1117 | StyleData["Exercise"], CellDingbat -> "\[FilledDownTriangle]", 1118 | CellMargins -> {{23, Inherited}, {4, 18}}, 1119 | CellGroupingRules -> {"SectionGrouping", 50}, PageBreakBelow -> 1120 | False, LineSpacing -> {1, 7}, CounterIncrements -> 1121 | "Subsubsection", FontFamily -> "Times", FontSize -> 13, 1122 | FontWeight -> "Bold", FontColor -> 1123 | RGBColor[0.571389, 0.19675, 0.570504]], 1124 | Cell[ 1125 | StyleData["Exercise", "Presentation"], 1126 | CellMargins -> {{28, 10}, {10, 34}}, LineSpacing -> {1, 0}, 1127 | FontSize -> 22], 1128 | Cell[ 1129 | StyleData["Exercise", "Condensed"], 1130 | CellMargins -> {{17, Inherited}, {2, 12}}, FontSize -> 10], 1131 | Cell[ 1132 | StyleData["Exercise", "Printout"], 1133 | CellFrame -> {{0, 0}, {0.5, 0}}, CellDingbat -> None, 1134 | CellMargins -> {{9, 0}, {6, 20}}, Hyphenation -> True, FontSize -> 1135 | 11, FontColor -> GrayLevel[0]]}, Closed]], 1136 | Cell[ 1137 | CellGroupData[{ 1138 | Cell[ 1139 | StyleData["ExerciseText"], CellMargins -> {{62, 10}, {5, 5}}, 1140 | LineSpacing -> {1, 3}, ParagraphSpacing -> {0, 8}, 1141 | CounterIncrements -> "ExerciseText", FontFamily -> "Times"], 1142 | Cell[ 1143 | StyleData["ExerciseText", "Presentation"], 1144 | CellMargins -> {{100, 10}, {8, 8}}, LineSpacing -> {1, 5}, 1145 | ParagraphSpacing -> {0, 12}, FontSize -> 18], 1146 | Cell[ 1147 | StyleData["ExerciseText", "Condensed"], 1148 | CellMargins -> {{52, 10}, {2, 2}}, LineSpacing -> {1, 1}, 1149 | ParagraphSpacing -> {0, 4}], 1150 | Cell[ 1151 | StyleData["ExerciseText", "Printout"], 1152 | CellMargins -> {{54, 0}, {4, 4}}, Hyphenation -> True, 1153 | ParagraphSpacing -> {0, 6}]}, Closed]]}, Open]], 1154 | Cell[ 1155 | CellGroupData[{ 1156 | Cell["Formulas and Programming", "Section"], 1157 | Cell[ 1158 | CellGroupData[{ 1159 | Cell[ 1160 | StyleData["DisplayFormula"], CellMargins -> {{62, 10}, {2, 10}}, 1161 | CellHorizontalScrolling -> True, DefaultFormatType -> 1162 | DefaultInputFormatType, "TwoByteSyntaxCharacterAutoReplacement" -> 1163 | True, HyphenationOptions -> { 1164 | "HyphenationCharacter" -> "\[Continuation]"}, LanguageCategory -> 1165 | "Formula", ScriptLevel -> 0, SingleLetterItalics -> True, 1166 | UnderoverscriptBoxOptions -> {LimitsPositioning -> True}], 1167 | Cell[ 1168 | StyleData["DisplayFormula", "Presentation"], 1169 | CellMargins -> {{100, 10}, {8, 16}}, FontSize -> 18], 1170 | Cell[ 1171 | StyleData["DisplayFormula", "Condensed"], 1172 | CellMargins -> {{52, 10}, {2, 10}}, FontSize -> 10], 1173 | Cell[ 1174 | StyleData["DisplayFormula", "Printout"], 1175 | CellMargins -> {{54, 10}, {2, 10}}, FontSize -> 10]}, Closed]], 1176 | Cell[ 1177 | CellGroupData[{ 1178 | Cell[ 1179 | StyleData["ChemicalFormula"], CellMargins -> {{62, 10}, {2, 10}}, 1180 | DefaultFormatType -> DefaultInputFormatType, 1181 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 1182 | HyphenationOptions -> { 1183 | "HyphenationCharacter" -> "\[Continuation]"}, LanguageCategory -> 1184 | "Formula", AutoSpacing -> False, 1185 | ScriptBaselineShifts -> {0.6, Automatic}, ScriptLevel -> 1, 1186 | SingleLetterItalics -> False, ZeroWidthTimes -> True], 1187 | Cell[ 1188 | StyleData["ChemicalFormula", "Presentation"], 1189 | CellMargins -> {{100, 10}, {8, 12}}, FontSize -> 18], 1190 | Cell[ 1191 | StyleData["ChemicalFormula", "Condensed"], 1192 | CellMargins -> {{52, 10}, {2, 10}}, FontSize -> 10], 1193 | Cell[ 1194 | StyleData["ChemicalFormula", "Printout"], 1195 | CellMargins -> {{54, 10}, {2, 10}}, FontSize -> 10]}, Closed]], 1196 | Cell[ 1197 | CellGroupData[{ 1198 | Cell[ 1199 | StyleData["Program"], CellMargins -> {{12, 10}, {Inherited, 6}}, 1200 | Hyphenation -> False, LanguageCategory -> "Formula", FontFamily -> 1201 | "Courier"], 1202 | Cell[ 1203 | StyleData["Program", "Presentation"], 1204 | CellMargins -> {{20, 30}, {4, 4}}, FontSize -> 18], 1205 | Cell[ 1206 | StyleData["Program", "Condensed"], 1207 | CellMargins -> {{8, 10}, {Inherited, 4}}, FontSize -> 9.5], 1208 | Cell[ 1209 | StyleData["Program", "Printout"], 1210 | CellMargins -> {{9, 0}, {Inherited, 4}}, FontSize -> 9.5]}, 1211 | Closed]]}, Open]], 1212 | Cell[ 1213 | CellGroupData[{ 1214 | Cell["Styles for Automatic Numbering", "Section"], 1215 | Cell[ 1216 | "The following styles are useful for numbered equations, figures, \ 1217 | etc. They automatically give the cell a FrameLabel containing a reference to \ 1218 | a particular counter, and also increment that counter.", "Text"], 1219 | Cell[ 1220 | CellGroupData[{ 1221 | Cell[ 1222 | StyleData["NumberedEquation"], 1223 | CellMargins -> {{62, 10}, {Inherited, Inherited}}, 1224 | CellFrameLabels -> {{None, 1225 | Cell[ 1226 | TextData[{"(", 1227 | CounterBox["NumberedEquation"], ")"}]]}, {None, None}}, 1228 | DefaultFormatType -> DefaultInputFormatType, 1229 | "TwoByteSyntaxCharacterAutoReplacement" -> True, 1230 | HyphenationOptions -> { 1231 | "HyphenationCharacter" -> "\[Continuation]"}, CounterIncrements -> 1232 | "NumberedEquation", FormatTypeAutoConvert -> False], 1233 | Cell[ 1234 | StyleData["NumberedEquation", "Presentation"], 1235 | CellMargins -> {{100, 10}, {6, 8}}, FontSize -> 18], 1236 | Cell[ 1237 | StyleData["NumberedEquation", "Condensed"], 1238 | CellMargins -> {{52, 10}, {Inherited, Inherited}}], 1239 | Cell[ 1240 | StyleData["NumberedEquation", "Printout"], 1241 | CellMargins -> {{54, 0}, {Inherited, Inherited}}]}, Closed]], 1242 | Cell[ 1243 | CellGroupData[{ 1244 | Cell[ 1245 | StyleData["NumberedFigure"], 1246 | CellMargins -> {{62, 145}, {Inherited, Inherited}}, 1247 | CellFrameLabels -> {{None, None}, { 1248 | Cell[ 1249 | TextData[{"Figure ", 1250 | CounterBox["NumberedFigure"]}]], None}}, CounterIncrements -> 1251 | "NumberedFigure", 1252 | ImageMargins -> {{43, Inherited}, {Inherited, 0}}, 1253 | FormatTypeAutoConvert -> False], 1254 | Cell[ 1255 | StyleData["NumberedFigure", "Presentation"], 1256 | CellMargins -> {{100, 145}, {8, 6}}, FontSize -> 18], 1257 | Cell[ 1258 | StyleData["NumberedFigure", "Condensed"]], 1259 | Cell[ 1260 | StyleData["NumberedFigure", "Printout"]]}, Closed]], 1261 | Cell[ 1262 | CellGroupData[{ 1263 | Cell[ 1264 | StyleData["NumberedTable"], 1265 | CellMargins -> {{62, 145}, {Inherited, Inherited}}, 1266 | CellFrameLabels -> {{None, None}, { 1267 | Cell[ 1268 | TextData[{"Table ", 1269 | CounterBox["NumberedTable"]}]], None}}, TextAlignment -> 1270 | Center, CounterIncrements -> "NumberedTable", 1271 | FormatTypeAutoConvert -> False], 1272 | Cell[ 1273 | StyleData["NumberedTable", "Presentation"], 1274 | CellMargins -> {{100, 145}, {8, 8}}, FontSize -> 18], 1275 | Cell[ 1276 | StyleData["NumberedTable", "Condensed"]], 1277 | Cell[ 1278 | StyleData["NumberedTable", "Printout"]]}, Closed]]}, Open]], 1279 | Cell[ 1280 | CellGroupData[{ 1281 | Cell["Styles for Headers and Footers", "Section"], 1282 | Cell[ 1283 | StyleData["Header"], CellMargins -> {{0, 0}, {4, 1}}, 1284 | StyleMenuListing -> None, FontFamily -> "Helvetica", FontSize -> 9, 1285 | FontSlant -> "Italic"], 1286 | Cell[ 1287 | StyleData["Footer"], CellMargins -> {{0, 0}, {0, 4}}, 1288 | StyleMenuListing -> None, FontFamily -> "Helvetica", FontSize -> 6], 1289 | Cell[ 1290 | StyleData["PageNumber"], CellMargins -> {{0, 0}, {4, 1}}, 1291 | StyleMenuListing -> None, FontFamily -> "Helvetica", FontSize -> 9, 1292 | FontWeight -> "Bold"]}, Open]], 1293 | Cell[ 1294 | CellGroupData[{ 1295 | Cell["Hyperlink Styles", "Section"], 1296 | Cell[ 1297 | "The cells below define styles useful for making hypertext \ 1298 | ButtonBoxes. The \"Hyperlink\" style is for links within the same Notebook, \ 1299 | or between Notebooks.", "Text"], 1300 | Cell[ 1301 | CellGroupData[{ 1302 | Cell[ 1303 | StyleData["Hyperlink"], StyleMenuListing -> None, 1304 | ButtonStyleMenuListing -> Automatic, FontColor -> 1305 | RGBColor[0.269993, 0.308507, 0.6], 1306 | ButtonBoxOptions -> { 1307 | Active -> True, Appearance -> {Automatic, None}, 1308 | ButtonFunction :> (FrontEndExecute[{ 1309 | FrontEnd`NotebookLocate[#2]}]& ), ButtonNote -> 1310 | ButtonData}], 1311 | Cell[ 1312 | StyleData["Hyperlink", "Presentation"], FontSize -> 16], 1313 | Cell[ 1314 | StyleData["Hyperlink", "Condensed"], FontSize -> 11], 1315 | Cell[ 1316 | StyleData["Hyperlink", "SlideShow"]], 1317 | Cell[ 1318 | StyleData["Hyperlink", "Printout"], FontSize -> 10, 1319 | FontVariations -> {"Underline" -> False}, FontColor -> 1320 | GrayLevel[0]]}, Closed]], 1321 | Cell[ 1322 | "The following styles are for linking automatically to the on-line \ 1323 | help system.", "Text"], 1324 | Cell[ 1325 | CellGroupData[{ 1326 | Cell[ 1327 | StyleData["MainBookLink"], StyleMenuListing -> None, 1328 | ButtonStyleMenuListing -> Automatic, FontColor -> 1329 | RGBColor[0.269993, 0.308507, 0.6], 1330 | ButtonBoxOptions -> { 1331 | Active -> True, Appearance -> {Automatic, None}, 1332 | ButtonFunction :> (FrontEndExecute[{ 1333 | FrontEnd`HelpBrowserLookup["MainBook", #]}]& )}], 1334 | Cell[ 1335 | StyleData["MainBookLink", "Presentation"], FontSize -> 16], 1336 | Cell[ 1337 | StyleData["MainBookLink", "Condensed"], FontSize -> 11], 1338 | Cell[ 1339 | StyleData["MainBookLink", "SlideShow"]], 1340 | Cell[ 1341 | StyleData["MainBookLink", "Printout"], FontSize -> 10, 1342 | FontVariations -> {"Underline" -> False}, FontColor -> 1343 | GrayLevel[0]]}, Closed]], 1344 | Cell[ 1345 | CellGroupData[{ 1346 | Cell[ 1347 | StyleData["AddOnsLink"], StyleMenuListing -> None, 1348 | ButtonStyleMenuListing -> Automatic, FontFamily -> "Courier", 1349 | FontColor -> RGBColor[0.269993, 0.308507, 0.6], 1350 | ButtonBoxOptions -> { 1351 | Active -> True, Appearance -> {Automatic, None}, 1352 | ButtonFunction :> (FrontEndExecute[{ 1353 | FrontEnd`HelpBrowserLookup["AddOns", #]}]& )}], 1354 | Cell[ 1355 | StyleData["AddOnsLink", "Presentation"], FontSize -> 16], 1356 | Cell[ 1357 | StyleData["AddOnsLink", "Condensed"], FontSize -> 11], 1358 | Cell[ 1359 | StyleData["AddOnsLink", "SlideShow"]], 1360 | Cell[ 1361 | StyleData["AddOnsLink", "Printout"], FontSize -> 10, 1362 | FontVariations -> {"Underline" -> False}, FontColor -> 1363 | GrayLevel[0]]}, Closed]], 1364 | Cell[ 1365 | CellGroupData[{ 1366 | Cell[ 1367 | StyleData["RefGuideLink"], StyleMenuListing -> None, 1368 | ButtonStyleMenuListing -> Automatic, FontFamily -> "Courier", 1369 | FontColor -> RGBColor[0.269993, 0.308507, 0.6], 1370 | ButtonBoxOptions -> { 1371 | Active -> True, Appearance -> {Automatic, None}, 1372 | ButtonFunction :> (FrontEndExecute[{ 1373 | FrontEnd`HelpBrowserLookup["RefGuide", #]}]& )}], 1374 | Cell[ 1375 | StyleData["RefGuideLink", "Presentation"], FontSize -> 16], 1376 | Cell[ 1377 | StyleData["RefGuideLink", "Condensed"], FontSize -> 11], 1378 | Cell[ 1379 | StyleData["RefGuideLink", "SlideShow"]], 1380 | Cell[ 1381 | StyleData["RefGuideLink", "Printout"], FontSize -> 10, 1382 | FontVariations -> {"Underline" -> False}, FontColor -> 1383 | GrayLevel[0]]}, Closed]], 1384 | Cell[ 1385 | CellGroupData[{ 1386 | Cell[ 1387 | StyleData["RefGuideLinkText"], StyleMenuListing -> None, 1388 | ButtonStyleMenuListing -> Automatic, FontColor -> 1389 | RGBColor[0.269993, 0.308507, 0.6], 1390 | ButtonBoxOptions -> { 1391 | Active -> True, Appearance -> {Automatic, None}, 1392 | ButtonFunction :> (FrontEndExecute[{ 1393 | FrontEnd`HelpBrowserLookup["RefGuide", #]}]& )}], 1394 | Cell[ 1395 | StyleData["RefGuideLinkText", "Presentation"], FontSize -> 16], 1396 | Cell[ 1397 | StyleData["RefGuideLinkText", "Condensed"], FontSize -> 11], 1398 | Cell[ 1399 | StyleData["RefGuideLinkText", "SlideShow"]], 1400 | Cell[ 1401 | StyleData["RefGuideLinkText", "Printout"], FontSize -> 10, 1402 | FontVariations -> {"Underline" -> False}, FontColor -> 1403 | GrayLevel[0]]}, Closed]], 1404 | Cell[ 1405 | CellGroupData[{ 1406 | Cell[ 1407 | StyleData["GettingStartedLink"], StyleMenuListing -> None, 1408 | ButtonStyleMenuListing -> Automatic, FontColor -> 1409 | RGBColor[0.269993, 0.308507, 0.6], 1410 | ButtonBoxOptions -> { 1411 | Active -> True, Appearance -> {Automatic, None}, 1412 | ButtonFunction :> (FrontEndExecute[{ 1413 | FrontEnd`HelpBrowserLookup["GettingStarted", #]}]& )}], 1414 | Cell[ 1415 | StyleData["GettingStartedLink", "Presentation"], FontSize -> 16], 1416 | Cell[ 1417 | StyleData["GettingStartedLink", "Condensed"], FontSize -> 11], 1418 | Cell[ 1419 | StyleData["GettingStartedLink", "SlideShow"]], 1420 | Cell[ 1421 | StyleData["GettingStartedLink", "Printout"], FontSize -> 10, 1422 | FontVariations -> {"Underline" -> False}, FontColor -> 1423 | GrayLevel[0]]}, Closed]], 1424 | Cell[ 1425 | CellGroupData[{ 1426 | Cell[ 1427 | StyleData["DemosLink"], StyleMenuListing -> None, 1428 | ButtonStyleMenuListing -> Automatic, FontColor -> 1429 | RGBColor[0.269993, 0.308507, 0.6], 1430 | ButtonBoxOptions -> { 1431 | Active -> True, Appearance -> {Automatic, None}, 1432 | ButtonFunction :> (FrontEndExecute[{ 1433 | FrontEnd`HelpBrowserLookup["Demos", #]}]& )}], 1434 | Cell[ 1435 | StyleData["DemosLink", "SlideShow"]], 1436 | Cell[ 1437 | StyleData["DemosLink", "Printout"], 1438 | FontVariations -> {"Underline" -> False}, FontColor -> 1439 | GrayLevel[0]]}, Closed]], 1440 | Cell[ 1441 | CellGroupData[{ 1442 | Cell[ 1443 | StyleData["TourLink"], StyleMenuListing -> None, 1444 | ButtonStyleMenuListing -> Automatic, FontColor -> 1445 | RGBColor[0.269993, 0.308507, 0.6], 1446 | ButtonBoxOptions -> { 1447 | Active -> True, Appearance -> {Automatic, None}, 1448 | ButtonFunction :> (FrontEndExecute[{ 1449 | FrontEnd`HelpBrowserLookup["Tour", #]}]& )}], 1450 | Cell[ 1451 | StyleData["TourLink", "SlideShow"]], 1452 | Cell[ 1453 | StyleData["TourLink", "Printout"], 1454 | FontVariations -> {"Underline" -> False}, FontColor -> 1455 | GrayLevel[0]]}, Closed]], 1456 | Cell[ 1457 | CellGroupData[{ 1458 | Cell[ 1459 | StyleData["OtherInformationLink"], StyleMenuListing -> None, 1460 | ButtonStyleMenuListing -> Automatic, FontColor -> 1461 | RGBColor[0.269993, 0.308507, 0.6], 1462 | ButtonBoxOptions -> { 1463 | Active -> True, Appearance -> {Automatic, None}, 1464 | ButtonFunction :> (FrontEndExecute[{ 1465 | FrontEnd`HelpBrowserLookup["OtherInformation", #]}]& )}], 1466 | Cell[ 1467 | StyleData["OtherInformationLink", "Presentation"], FontSize -> 1468 | 16], 1469 | Cell[ 1470 | StyleData["OtherInformationLink", "Condensed"], FontSize -> 11], 1471 | 1472 | Cell[ 1473 | StyleData["OtherInformationLink", "SlideShow"]], 1474 | Cell[ 1475 | StyleData["OtherInformationLink", "Printout"], FontSize -> 10, 1476 | FontVariations -> {"Underline" -> False}, FontColor -> 1477 | GrayLevel[0]]}, Closed]], 1478 | Cell[ 1479 | CellGroupData[{ 1480 | Cell[ 1481 | StyleData["MasterIndexLink"], StyleMenuListing -> None, 1482 | ButtonStyleMenuListing -> Automatic, FontColor -> 1483 | RGBColor[0.269993, 0.308507, 0.6], 1484 | ButtonBoxOptions -> { 1485 | Active -> True, Appearance -> {Automatic, None}, 1486 | ButtonFunction :> (FrontEndExecute[{ 1487 | FrontEnd`HelpBrowserLookup["MasterIndex", #]}]& )}], 1488 | Cell[ 1489 | StyleData["MasterIndexLink", "SlideShow"]], 1490 | Cell[ 1491 | StyleData["MasterIndexLink", "Printout"], 1492 | FontVariations -> {"Underline" -> False}, FontColor -> 1493 | GrayLevel[0]]}, Closed]]}, Open]], 1494 | Cell[ 1495 | CellGroupData[{ 1496 | Cell["Palette Styles", "Section"], 1497 | Cell[ 1498 | "The cells below define styles that define standard ButtonFunctions, \ 1499 | for use in palette buttons.", "Text"], 1500 | Cell[ 1501 | StyleData["Paste"], StyleMenuListing -> None, 1502 | ButtonStyleMenuListing -> Automatic, 1503 | ButtonBoxOptions -> {ButtonFunction :> (FrontEndExecute[{ 1504 | FrontEnd`NotebookApply[ 1505 | FrontEnd`InputNotebook[], #, After]}]& )}], 1506 | Cell[ 1507 | StyleData["Evaluate"], StyleMenuListing -> None, 1508 | ButtonStyleMenuListing -> Automatic, 1509 | ButtonBoxOptions -> {ButtonFunction :> (FrontEndExecute[{ 1510 | FrontEnd`NotebookApply[ 1511 | FrontEnd`InputNotebook[], #, All], 1512 | FrontEnd`SelectionEvaluate[ 1513 | FrontEnd`InputNotebook[], All]}]& )}], 1514 | Cell[ 1515 | StyleData["EvaluateCell"], StyleMenuListing -> None, 1516 | ButtonStyleMenuListing -> Automatic, 1517 | ButtonBoxOptions -> {ButtonFunction :> (FrontEndExecute[{ 1518 | FrontEnd`NotebookApply[ 1519 | FrontEnd`InputNotebook[], #, All], 1520 | FrontEnd`SelectionMove[ 1521 | FrontEnd`InputNotebook[], All, Cell, 1], 1522 | FrontEnd`SelectionEvaluateCreateCell[ 1523 | FrontEnd`InputNotebook[], All]}]& )}], 1524 | Cell[ 1525 | StyleData["CopyEvaluate"], StyleMenuListing -> None, 1526 | ButtonStyleMenuListing -> Automatic, 1527 | ButtonBoxOptions -> {ButtonFunction :> (FrontEndExecute[{ 1528 | FrontEnd`SelectionCreateCell[ 1529 | FrontEnd`InputNotebook[], All], 1530 | FrontEnd`NotebookApply[ 1531 | FrontEnd`InputNotebook[], #, All], 1532 | FrontEnd`SelectionEvaluate[ 1533 | FrontEnd`InputNotebook[], All]}]& )}], 1534 | Cell[ 1535 | StyleData["CopyEvaluateCell"], StyleMenuListing -> None, 1536 | ButtonStyleMenuListing -> Automatic, 1537 | ButtonBoxOptions -> {ButtonFunction :> (FrontEndExecute[{ 1538 | FrontEnd`SelectionCreateCell[ 1539 | FrontEnd`InputNotebook[], All], 1540 | FrontEnd`NotebookApply[ 1541 | FrontEnd`InputNotebook[], #, All], 1542 | FrontEnd`SelectionEvaluateCreateCell[ 1543 | FrontEnd`InputNotebook[], All]}]& )}]}, Open]], 1544 | Cell[ 1545 | CellGroupData[{ 1546 | Cell["Slide Show Styles", "Section"], 1547 | Cell[ 1548 | CellGroupData[{ 1549 | Cell[ 1550 | StyleData["SlideShowNavigationBar"], Editable -> False, 1551 | CellFrame -> True, CellMargins -> {{0, 0}, {3, 3}}, 1552 | CellElementSpacings -> {"CellMinHeight" -> 0.8125}, 1553 | CellGroupingRules -> {"SectionGrouping", 30}, CellFrameMargins -> 1554 | False, CellFrameColor -> GrayLevel[1], CellFrameLabelMargins -> 1555 | False, TextAlignment -> Center, CounterIncrements -> 1556 | "SlideShowNavigationBar", StyleMenuListing -> None, FontSize -> 1557 | 10, Magnification -> 1, Background -> GrayLevel[0.8], 1558 | GridBoxOptions -> { 1559 | BaselinePosition -> Center, 1560 | GridBoxAlignment -> { 1561 | "Columns" -> { 1562 | Center, Center, Center, Center, Center, Center, Right, { 1563 | Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, 1564 | "RowsIndexed" -> {}}, 1565 | GridBoxItemSize -> { 1566 | "Columns" -> {3.5, 3.5, 3.5, 3.5, 13, 5, {4}}, 1567 | "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, 1568 | "RowsIndexed" -> {}}, GridBoxSpacings -> {"Columns" -> { 1569 | Offset[0.27999999999999997`], { 1570 | Offset[0.]}, 1571 | Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, 1572 | "Rows" -> { 1573 | Offset[0.2], { 1574 | Offset[0.]}, 1575 | Offset[0.2]}, "RowsIndexed" -> {}}}], 1576 | Cell[ 1577 | StyleData["SlideShowNavigationBar", "Presentation"]], 1578 | Cell[ 1579 | StyleData["SlideShowNavigationBar", "SlideShow"], Deletable -> 1580 | False, ShowCellBracket -> False, 1581 | CellMargins -> {{-1, -1}, {-1, -1}}, PageBreakAbove -> True, 1582 | CellFrameMargins -> {{1, 1}, {0, 0}}], 1583 | Cell[ 1584 | StyleData["SlideShowNavigationBar", "Printout"], 1585 | CellMargins -> {{18, 4}, {4, 4}}, LineSpacing -> {1, 3}, 1586 | FontSize -> 10]}, Closed]], 1587 | Cell[ 1588 | CellGroupData[{ 1589 | Cell[ 1590 | StyleData["SlideShowSection"], CellFrame -> {{0, 0}, {0, 0.5}}, 1591 | CellMargins -> {{0, 0}, {10, 0}}, 1592 | CellGroupingRules -> {"SectionGrouping", 40}, PageBreakBelow -> 1593 | False, CellFrameMargins -> {{12, 4}, {6, 12}}, 1594 | InputAutoReplacements -> {"TeX" -> StyleBox[ 1595 | RowBox[{"T", 1596 | AdjustmentBox[ 1597 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 1598 | BoxBaselineShift -> 0.5], "X"}]], "LaTeX" -> StyleBox[ 1599 | RowBox[{"L", 1600 | StyleBox[ 1601 | AdjustmentBox[ 1602 | "A", BoxMargins -> {{-0.36, -0.1}, {0, 0}}, 1603 | BoxBaselineShift -> -0.2], FontSize -> Smaller], "T", 1604 | AdjustmentBox[ 1605 | "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, 1606 | BoxBaselineShift -> 0.5], "X"}]], "mma" -> "Mathematica", 1607 | "Mma" -> "Mathematica", "MMA" -> "Mathematica", 1608 | "gridMathematica" -> FormBox[ 1609 | RowBox[{"grid", 1610 | AdjustmentBox[ 1611 | StyleBox["Mathematica", FontSlant -> "Italic"], 1612 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 1613 | "webMathematica" -> FormBox[ 1614 | RowBox[{"web", 1615 | AdjustmentBox[ 1616 | StyleBox["Mathematica", FontSlant -> "Italic"], 1617 | BoxMargins -> {{-0.175, 0}, {0, 0}}]}], TextForm], 1618 | Inherited}, CounterIncrements -> "Section", 1619 | CounterAssignments -> {{"Subsection", 0}, {"Subsubsection", 0}}, 1620 | StyleMenuListing -> None, FontFamily -> "Helvetica", FontSize -> 1621 | 18, FontWeight -> "Plain", FontColor -> GrayLevel[1], Background -> 1622 | RGBColor[0.408011, 0.440726, 0.8]], 1623 | Cell[ 1624 | StyleData["SlideShowSection", "Presentation"], 1625 | CellFrameMargins -> {{18, 10}, {10, 16}}, FontSize -> 27], 1626 | Cell[ 1627 | StyleData["SlideShowSection", "SlideShow"], ShowCellBracket -> 1628 | False, PageBreakAbove -> True], 1629 | Cell[ 1630 | StyleData["SlideShowSection", "Printout"], 1631 | CellMargins -> {{18, 30}, {0, 30}}, CellFrameMargins -> 5, 1632 | FontSize -> 14]}, Closed]], 1633 | Cell[ 1634 | CellGroupData[{ 1635 | Cell[ 1636 | StyleData["SlideHyperlink"], StyleMenuListing -> None, 1637 | ButtonStyleMenuListing -> Automatic, FontSize -> 26, FontColor -> 1638 | GrayLevel[0.400015], 1639 | ButtonBoxOptions -> { 1640 | Active -> True, ButtonFunction :> (FrontEndExecute[{ 1641 | FrontEnd`NotebookLocate[#2]}]& ), ButtonMargins -> 0.5, 1642 | ButtonMinHeight -> 0.85, ButtonNote -> None}], 1643 | Cell[ 1644 | StyleData["SlideHyperlink", "Presentation"], 1645 | CellMargins -> {{10, 10}, {8, 12}}, FontSize -> 36], 1646 | Cell[ 1647 | StyleData["SlideHyperlink", "SlideShow"]], 1648 | Cell[ 1649 | StyleData["SlideHyperlink", "Printout"], FontSize -> 10, 1650 | FontVariations -> {"Underline" -> False}, FontColor -> 1651 | GrayLevel[0]]}, Closed]], 1652 | Cell[ 1653 | CellGroupData[{ 1654 | Cell[ 1655 | StyleData["SlideTOCLink"], 1656 | CellMargins -> {{24, Inherited}, {Inherited, Inherited}}, 1657 | StyleMenuListing -> None, ButtonStyleMenuListing -> Automatic, 1658 | FontFamily -> "Helvetica", 1659 | ButtonBoxOptions -> { 1660 | Active -> True, ButtonFunction :> (FrontEndExecute[{ 1661 | FrontEnd`NotebookLocate[#2]}]& ), ButtonMargins -> 1.5, 1662 | ButtonNote -> ButtonData}], 1663 | Cell[ 1664 | StyleData["SlideTOCLink", "Presentation"], 1665 | CellMargins -> {{35, 10}, {4, 6}}, FontSize -> 18], 1666 | Cell[ 1667 | StyleData["SlideTOCLink", "SlideShow"]], 1668 | Cell[ 1669 | StyleData["SlideTOCLink", "Printout"], 1670 | FontVariations -> {"Underline" -> False}, FontColor -> 1671 | GrayLevel[0]]}, Closed]], 1672 | Cell[ 1673 | CellGroupData[{ 1674 | Cell[ 1675 | StyleData["SlideTOC"], CellDingbat -> "\[Bullet]", 1676 | CellMargins -> {{18, Inherited}, {Inherited, Inherited}}, 1677 | StyleMenuListing -> None, FontFamily -> "Helvetica"], 1678 | Cell[ 1679 | StyleData["SlideTOC", "Presentation"], 1680 | CellMargins -> {{25, 10}, {8, 6}}, FontSize -> 18], 1681 | Cell[ 1682 | StyleData["SlideTOC", "SlideShow"], FontSize -> 14], 1683 | Cell[ 1684 | StyleData["SlideTOC", "Printout"], FontSize -> 10, FontColor -> 1685 | GrayLevel[0]]}, Closed]]}, Open]]}, Open]]}, Visible -> False, 1686 | FrontEndVersion -> 1687 | "10.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (October 16, 2013)", 1688 | StyleDefinitions -> "Default.nb"] 1689 | ] 1690 | (* End of Notebook Content *) 1691 | 1692 | (* Internal cache information *) 1693 | (*CellTagsOutline 1694 | CellTagsIndex->{} 1695 | *) 1696 | (*CellTagsIndex 1697 | CellTagsIndex->{} 1698 | *) 1699 | (*NotebookFileOutline 1700 | Notebook[{ 1701 | Cell[545, 20, 26, 0, 51, "Title"], 1702 | Cell[574, 22, 27, 0, 35, "Subtitle"], 1703 | Cell[CellGroupData[{ 1704 | Cell[626, 26, 87, 4, 28, "Text"], 1705 | Cell[716, 32, 277, 7, 77, "Input"], 1706 | Cell[996, 41, 41, 0, 28, "Text"], 1707 | Cell[1040, 43, 60, 1, 47, "Input"], 1708 | Cell[1103, 46, 23, 0, 28, "Text"], 1709 | Cell[1129, 48, 170, 5, 47, "Input"] 1710 | }, Open ]], 1711 | Cell[1314, 56, 25, 0, 35, "Subtitle"], 1712 | Cell[CellGroupData[{ 1713 | Cell[1364, 60, 172, 6, 45, "Text"], 1714 | Cell[1539, 68, 67, 1, 47, "Input"], 1715 | Cell[1609, 71, 28, 0, 46, "Input"] 1716 | }, Open ]], 1717 | Cell[1652, 74, 29, 0, 46, "Input"], 1718 | Cell[CellGroupData[{ 1719 | Cell[1706, 78, 165, 6, 28, "Text"], 1720 | Cell[1874, 86, 31, 0, 46, "Input"] 1721 | }, Open ]], 1722 | Cell[1920, 89, 117, 5, 35, "Subtitle"], 1723 | Cell[2040, 96, 676, 19, 113, "Text"], 1724 | Cell[CellGroupData[{ 1725 | Cell[2741, 119, 42, 0, 28, "Text"], 1726 | Cell[2786, 121, 62, 0, 46, "Input"], 1727 | Cell[2851, 123, 71, 0, 46, "Input"] 1728 | }, Open ]], 1729 | Cell[CellGroupData[{ 1730 | Cell[2959, 128, 38, 0, 28, "Text"], 1731 | Cell[3000, 130, 48, 0, 46, "Input"], 1732 | Cell[3051, 132, 46, 0, 46, "Input"] 1733 | }, Open ]], 1734 | Cell[CellGroupData[{ 1735 | Cell[3134, 137, 31, 0, 28, "Text"], 1736 | Cell[3168, 139, 45, 0, 46, "Input"], 1737 | Cell[3216, 141, 32, 0, 46, "Input"] 1738 | }, Open ]], 1739 | Cell[CellGroupData[{ 1740 | Cell[3285, 146, 425, 17, 62, "Text"], 1741 | Cell[3713, 165, 57, 0, 46, "Input"], 1742 | Cell[3773, 167, 35, 0, 46, "Input"], 1743 | Cell[3811, 169, 72, 0, 46, "Input"], 1744 | Cell[3886, 171, 36, 0, 46, "Input"] 1745 | }, Open ]], 1746 | Cell[CellGroupData[{ 1747 | Cell[3959, 176, 230, 8, 45, "Text"], 1748 | Cell[4192, 186, 140, 7, 111, "Input"] 1749 | }, Open ]], 1750 | Cell[CellGroupData[{ 1751 | Cell[4369, 198, 47, 0, 28, "Text"], 1752 | Cell[4419, 200, 51, 0, 46, "Input"] 1753 | }, Open ]], 1754 | Cell[CellGroupData[{ 1755 | Cell[4507, 205, 190, 6, 45, "Text"], 1756 | Cell[4700, 213, 20, 0, 28, "Text"], 1757 | Cell[4723, 215, 53, 0, 46, "Input"], 1758 | Cell[4779, 217, 21, 0, 28, "Text"], 1759 | Cell[4803, 219, 63, 0, 46, "Input"], 1760 | Cell[4869, 221, 28, 0, 28, "Text"], 1761 | Cell[4900, 223, 68, 0, 46, "Input"] 1762 | }, Open ]], 1763 | Cell[4983, 226, 139, 5, 28, "Text"], 1764 | Cell[5125, 233, 52, 0, 46, "Input"], 1765 | Cell[5180, 235, 156, 7, 34, "Subtitle"], 1766 | Cell[CellGroupData[{ 1767 | Cell[5361, 246, 57, 0, 28, "Text"], 1768 | Cell[5421, 248, 166, 5, 46, "Input"], 1769 | Cell[5590, 255, 116, 3, 45, "Text"], 1770 | Cell[5709, 260, 145, 4, 46, "Input"], 1771 | Cell[CellGroupData[{ 1772 | Cell[5879, 268, 29, 0, 28, "Text"], 1773 | Cell[5911, 270, 428, 14, 77, "Input"] 1774 | }, Open ]] 1775 | }, Open ]], 1776 | Cell[CellGroupData[{ 1777 | Cell[6388, 290, 173, 4, 45, "Text"], 1778 | Cell[6564, 296, 174, 10, 150, "Input"], 1779 | Cell[6741, 308, 33, 0, 46, "Input"] 1780 | }, Open ]] 1781 | } 1782 | ] 1783 | *) 1784 | 1785 | (* End of internal cache information *) 1786 | -------------------------------------------------------------------------------- /Pythonika.tm: -------------------------------------------------------------------------------- 1 | :Begin: 2 | :Function: Py 3 | :Pattern: Py[input_String] 4 | :Arguments: {input} 5 | :ArgumentTypes: {String} 6 | :ReturnType: Manual 7 | :End: 8 | 9 | :Begin: 10 | :Function: PyInteger 11 | :Pattern: PyInteger[name_String, value_Integer] 12 | :Arguments: {name, N[value]} 13 | :ArgumentTypes: {String, LongInteger} 14 | :ReturnType: Null 15 | :End: 16 | 17 | :Begin: 18 | :Function: PyReal 19 | :Pattern: PyReal[name_String, value_Real] 20 | :Arguments: {name, N[value]} 21 | :ArgumentTypes: {String, Real} 22 | :ReturnType: Null 23 | :End: 24 | 25 | :Begin: 26 | :Function: PyComplex 27 | :Pattern: PyComplex[name_String, value_Complex] 28 | :Arguments: {name, Re[N[value]], Im[N[value]]} 29 | :ArgumentTypes: {String, Real, Real} 30 | :ReturnType: Null 31 | :End: 32 | 33 | :Begin: 34 | :Function: PyString 35 | :Pattern: PyString[name_String, value_String] 36 | :Arguments: {name, ToCharacterCode[value]} 37 | :ArgumentTypes: {String, IntegerList} 38 | :ReturnType: Manual 39 | :End: 40 | 41 | :Begin: 42 | :Function: PyUnicodeString 43 | :Pattern: PyString[name_String, value_UnicodeString] 44 | :Arguments: {name, value} 45 | :ArgumentTypes: {String, UnicodeString} 46 | :ReturnType: Null 47 | :End: 48 | 49 | :Begin: 50 | :Function: PySymbol 51 | :Pattern: PySymbol[name_String, value_Symbol] 52 | :Arguments: {name, value} 53 | :ArgumentTypes: {String, Symbol} 54 | :ReturnType: Null 55 | :End: 56 | 57 | :Begin: 58 | :Function: PyOpenList 59 | :Pattern: PyOpenList[name_String] 60 | :Arguments: {name} 61 | :ArgumentTypes: {String} 62 | :ReturnType: Manual 63 | :End: 64 | 65 | :Begin: 66 | :Function: PyCloseList 67 | :Pattern: PyCloseList[] 68 | :Arguments: {} 69 | :ArgumentTypes: {} 70 | :ReturnType: Null 71 | :End: 72 | 73 | :Evaluate: ToPy[arg_, obj_:Null] := If[StringQ[arg], ToPySingle[arg, obj], If[ListQ[arg], Map[ToPySingle[#[[1]], #[[2]]]&, arg];] ] 74 | 75 | :Evaluate: ToPySingle[name_, obj_] := Switch[obj, _Integer, PyInteger[name, obj], _String, PyString[name, obj], _Real, PyReal[name, obj], _Symbol, PySymbol[name, obj], _Complex, PyComplex[name, obj], _UnicodeString, PyUnicodeString[name, obj], _List, PyOpenList[name]; Map[ToPy["", #]&, obj]; PyCloseList[]; ] 76 | 77 | :Evaluate: code = "import parser, symbol\ndef scan(tree):\n if tree[0] == symbol.funcdef:\n return tree[2][1] # Function name\n elif isinstance(tree[1], tuple):\n return scan(tree[1])\n return None\n\ndef __get_function_name__(code):\n ast = parser.suite(code)\n tup = ast.totuple()\n return scan(tup)\n" 78 | 79 | :Evaluate: PyFunctionCreator[funcDef_, args__] = { 80 | If[Length[Names["code"]]==1, Py[code]; Remove["code"]]; 81 | Py[funcDef]; 82 | ToPy["__function_code__", funcDef]; 83 | ToPy[ 84 | "__function_arguments__", If[Length[{args}] == 1, {args}, { 85 | args}]]; 86 | funcName = Py["__get_function_name__(__function_code__)"]; 87 | result = Py[funcName <> "(*__function_arguments__)"]; 88 | Py["del __function_code__, __function_arguments__"]; 89 | result}[[1]] &; 90 | 91 | :Evaluate: PyFunction=Function[{funcDef},PyFunctionCreator[funcDef,##]]; 92 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Pythonika 1.0 - Python Interpreter Interface for Mathematica. 2 | Copyright (c) 2005-2010 Ero Carrera 3 | 4 | 5 | Introduction: 6 | ------------- 7 | 8 | Pythonika is a MathLink module that allows to write and evaluate Python code 9 | from within Mathematica Notebooks. 10 | 11 | Pythonika automatically translates all basic types from Mathematica into Python 12 | and back. Python expressions returning complex, integer or long numbers, 13 | strings, lists, tuples, sets or dictionaries will evaluate into the 14 | corresponding objects in Mathematica. Dictionaries are returned as list of 15 | lists containing key/value pairs. 16 | 17 | It's also possible to define Mathematica functions which are just Python code 18 | where all the conversion of the arguments is done transparently. It's not even 19 | necessary to tell how many arguments the Python function is taking!! Pythonika 20 | is clever enough to figure it out. 21 | 22 | Why? 23 | ---- 24 | 25 | Personally, I have always found Mathematica's Notebook interface to be 26 | perfectly suited for the way I conduct research. Which usually requires me to 27 | write code to test hypothesis or to develop concepts. Frequently the way I 28 | approach a problem changes as I discover its details and gain insight. 29 | 30 | I find of great utility having the ability of writing notes together with code 31 | which I can readily evaluate in small blocks. Repeating small parts of an 32 | algorithm as necessary or grouping the code in different cells according to its 33 | functionality; for instance, data set loading, parsing and analysis. 34 | 35 | 36 | Pythonika has been tested mainly with Python 2.5 and 2.4 but should work with 37 | 2.3 and probably other, older versions. 38 | 39 | Pythonika should compile and work with Mathematica in all OS X, Linux and 40 | Windows operating systems. 41 | 42 | My main working environment is OS X, so it has been more thoroughly tested on 43 | that platform. I successfully compiled and tested it on others. If someone 44 | would find that it does not work on a certain environment I would be glad to 45 | include whatever changes are found to be needed to get it to work correctly. 46 | 47 | 48 | Requirements: 49 | ------------- 50 | 51 | -Windows: 52 | 53 | In order to build it I used Visual Express C++ and the Platform SDK. Both 54 | downloadable from Microsoft. 55 | If not already set, one will need to setup all the appropriate environment 56 | variables (INCLUDE & LIB) pointing to the include and library directories 57 | provided by Visual C++ and the SDK. 58 | 59 | -Linux/OSX: 60 | 61 | GCC 62 | 63 | -All: 64 | 65 | The MathLink development kit is also needed and can be found at: 66 | 67 | http://www.wolfram.com/solutions/mathlink/devkits.html 68 | 69 | Mathematica is needed in order to run it. 70 | 71 | 72 | Compilation: 73 | ------------ 74 | 75 | Be sure to link or add the path to the directory containing the needed 76 | Mathematica files. Information is available in each architecture's Makefile. 77 | 78 | It should suffice with running the appropriate platform's equivalent to "make" 79 | with the corresponding Makefile: 80 | 81 | OS X: make -f Makefile.osx 82 | 83 | Linux: make -f Makefile.linux 84 | 85 | Windows: nmake -f Makefile.win 86 | 87 | The compilation will produce a Pythonika executable. If this point has been 88 | reached successfully it should now be possible to just load it within 89 | Mathematica. 90 | 91 | 92 | Installation: 93 | ------------- 94 | 95 | In order to load Pythonika it should be enough with calling the Mathematica 96 | function Install["path/to/the/Pythonika/executable"]. 97 | If the loading is successful, calling Links["path/to/the/Pythonika/executable"] 98 | will return a list with a LinkObject pointing to Pythonika. 99 | 100 | It should now all be ready to start writing Python code! 101 | 102 | 103 | Usage: 104 | ------ 105 | 106 | For common usage examples, please refer to the example Notebook. 107 | 108 | The Python instance is common to all Notebooks. So the global namespace is 109 | shared. And it's possible to share calculations and data across Notebooks. 110 | 111 | It's possible to write multiline code in Pythonika. In order to enter multiline 112 | code one must use "\<" "\>" which tells Mathematica to keep newlines as such. 113 | 114 | Using double quotes is not a good idea, as Mathematica will interpret that as 115 | the end of the current string. The solution is using single quotes in the 116 | Python code. 117 | 118 | Unicode should be properly converted back and forth. I haven't thoroughly 119 | tested this so there might be some problems. 120 | 121 | Escape sequences: It's possible to use backslash escaped sequences although 122 | it's necessary to double the backslashes for them to get to Pythonika as a 123 | single backslash as Mathematica will try to interpret them. 124 | --------------------------------------------------------------------------------