2 * Introduction for Runtime Environment::
4 * Functions and Variables for Runtime Environment::
7 @c -----------------------------------------------------------------------------
8 @node Introduction for Runtime Environment, Interrupts, Runtime Environment, Runtime Environment
9 @section Introduction for Runtime Environment
10 @c -----------------------------------------------------------------------------
12 @c THIS DISCUSSION OF maxima-init.mac REPLACES AN EARLIER WRITE-UP. !!!
13 @c HOWEVER IT SEEMS THAT THIS TEXT REALLY WANTS TO BE UNDER A DIFFERENT HEADING. !!!
14 @code{maxima-init.mac} is a file which is loaded automatically when Maxima
15 starts. You can use @code{maxima-init.mac} to customize your Maxima
16 environment. @code{maxima-init.mac}, if it exists, is typically placed in the
17 directory named by @code{maxima_userdir},
18 although it can be in any directory searched by the function @code{file_search}.
20 Here is an example @code{maxima-init.mac} file:
23 setup_autoload ("specfun.mac", ultraspherical, assoc_legendre_p);
27 In this example, @code{setup_autoload} tells Maxima to load the
29 (@code{specfun.mac}) if any of the functions (@code{ultraspherical},
30 @code{assoc_legendre_p}) are called but not yet defined.
31 Thus you needn't remember to load the file before calling the functions.
33 The statement @code{showtime: all} tells Maxima to set the @code{showtime}
34 variable. The @code{maxima-init.mac} file can contain any other assignments or
35 other Maxima statements.
37 @opencatbox{Categories:}
38 @category{Session management}
41 @c -----------------------------------------------------------------------------
42 @node Interrupts, Functions and Variables for Runtime Environment, Introduction for Runtime Environment, Runtime Environment
44 @c -----------------------------------------------------------------------------
46 The user can stop a time-consuming computation with the
47 ^C (control-C) character.
48 The default action is to stop the computation
49 and print another user prompt.
50 In this case, it is not possible to restart a stopped computation.
52 If the Lisp variable @code{*debugger-hook*} is set to @code{nil}, by executing
55 :lisp (setq *debugger-hook* nil)
59 then upon receiving ^C, Maxima will enter the Lisp debugger,
60 and the user may use the debugger to inspect the Lisp environment.
61 The stopped computation can be restarted by entering
62 @code{continue} in the Lisp debugger.
63 The means of returning to Maxima from the Lisp debugger
64 (other than running the computation to completion)
65 is different for each version of Lisp.
67 On Unix systems, the character ^Z (control-Z) causes Maxima
68 to stop altogether, and control is returned to the shell prompt.
69 The @code{fg} command causes Maxima
70 to resume from the point at which it was stopped.
72 @opencatbox{Categories:}
73 @category{Console interaction}
76 @c end concepts Runtime Environment
78 @c -----------------------------------------------------------------------------
79 @node Functions and Variables for Runtime Environment, , Interrupts, Runtime Environment
80 @section Functions and Variables for Runtime Environment
81 @c -----------------------------------------------------------------------------
83 @c -----------------------------------------------------------------------------
84 @anchor{maxima_tempdir}
85 @defvr {System variable} maxima_tempdir
87 @code{maxima_tempdir} names the directory in which Maxima creates some temporary
88 files. In particular, temporary files for plotting are created in
89 @code{maxima_tempdir}.
91 The initial value of @code{maxima_tempdir} is the user's home directory, if
92 Maxima can locate it; otherwise Maxima makes a guess about a suitable directory.
94 @code{maxima_tempdir} may be assigned a string which names a directory.
96 @opencatbox{Categories:}
97 @category{Global variables}
101 @c -----------------------------------------------------------------------------
102 @anchor{maxima_userdir}
103 @defvr {System variable} maxima_userdir
105 @code{maxima_userdir} names a directory which Maxima searches to find Maxima and
106 Lisp files. (Maxima searches some other directories as well;
107 @code{file_search_maxima} and @code{file_search_lisp} are the complete lists.)
109 The initial value of @code{maxima_userdir} is a subdirectory of the user's home
110 directory, if Maxima can locate it; otherwise Maxima makes a guess about a
113 @code{maxima_userdir} may be assigned a string which names a directory.
114 However, assigning to @code{maxima_userdir} does not automatically change
115 @code{file_search_maxima} and @code{file_search_lisp};
116 those variables must be changed separately.
118 @opencatbox{Categories:}
119 @category{Global variables}
123 @c -----------------------------------------------------------------------------
125 @deffn {Function} room @
127 @fname{room} (true) @
130 Prints out a description of the state of storage and
131 stack management in Maxima. @code{room} calls the Lisp function of
136 @code{room ()} prints out a moderate description.
138 @code{room (true)} prints out a verbose description.
140 @code{room (false)} prints out a terse description.
143 @opencatbox{Categories:}
148 @c -----------------------------------------------------------------------------
150 @deffn {Function} sstatus (@var{keyword}, @var{item})
152 When @var{keyword} is the symbol @code{feature}, @var{item} is put on the list
153 of system features. After @code{sstatus (keyword, item)} is executed,
154 @code{status (feature, item)} returns @code{true}. If @var{keyword} is the
155 symbol @code{nofeature}, @var{item} is deleted from the list of system features.
156 This can be useful for package writers, to keep track of what features they have
159 See also @mrefdot{status}
161 @opencatbox{Categories:}
162 @category{Programming}
166 @c -----------------------------------------------------------------------------
168 @deffn {Function} status @
169 @fname{status} (@code{feature}) @
170 @fname{status} (@code{feature}, @var{item})
172 Returns information about the presence or absence of certain system-dependent
177 @code{status (feature)} returns a list of system features. These include Lisp
178 version, operating system type, etc. The list may vary from one Lisp type to
182 @code{status (feature, item)} returns @code{true} if @var{item} is on the
183 list of items returned by @code{status (feature)} and @code{false} otherwise.
184 @code{status} quotes the argument @var{item}. The quote-quote operator
185 @code{'@w{}'} defeats quotation. A feature whose name contains a special
186 character, such as a hyphen, must be given as a string argument. For example,
187 @code{status (feature, "ansi-cl")}.
190 See also @mrefdot{sstatus}
192 The variable @code{features} contains a list of features which apply to
193 mathematical expressions. See @code{features} and @code{featurep} for more
196 @opencatbox{Categories:}
197 @category{Programming}
201 @c NEEDS CLARIFICATION
203 @c -----------------------------------------------------------------------------
205 @deffn {Function} system (@var{command})
207 Executes @var{command} as a separate process. The command is passed to the
208 default shell for execution. @code{system} is not supported by all operating
209 systems, but generally exists in Unix and Unix-like environments.
211 Supposing @code{_hist.out} is a list of frequencies which you wish to plot as a
212 bar graph using @code{xgraph}.
215 (%i1) (with_stdout("_hist.out",
216 for i:1 thru length(hist) do (
218 system("xgraph -bar -brw .7 -nl < _hist.out"));
221 In order to make the plot be done in the background (returning control to
222 Maxima) and remove the temporary file after it is done do:
225 system("(xgraph -bar -brw .7 -nl < _hist.out; rm -f _hist.out)&")
229 @c -----------------------------------------------------------------------------
231 @deffn {Function} time (%o1, %o2, %o3, @dots{})
233 Returns a list of the times, in seconds, taken to compute the output lines
234 @code{%o1}, @code{%o2}, @code{%o3}, @dots{} The time returned is Maxima's
235 estimate of the internal computation time, not the elapsed time. @code{time}
236 can only be applied to output line variables; for any other variables,
237 @code{time} returns @code{unknown}.
239 Set @code{showtime: true} to make Maxima print out the computation time
240 and elapsed time with each output line.
242 @opencatbox{Categories:}
247 @c -----------------------------------------------------------------------------
249 @deffn {Function} timedate @
250 @fname{timedate} (@var{T}, @var{tz_offset}) @
251 @fname{timedate} (@var{T}) @
254 @code{timedate(@var{T}, @var{tz_offset})} returns a string
255 representing the time @var{T} in the time zone @var{tz_offset}.
256 The string format is @code{YYYY-MM-DD HH:MM:SS.NNN[+|-]ZZ:ZZ}
257 (using as many digits as necessary to represent the fractional part)
258 if @var{T} has a nonzero fractional part,
259 or @code{YYYY-MM-DD HH:MM:SS[+|-]ZZ:ZZ} if its fractional part is zero.
261 @var{T} measures time, in seconds, since midnight, January 1, 1900,
262 in the GMT time zone.
264 @var{tz_offset} measures the offset of the time zone, in hours,
265 east (positive) or west (negative) of GMT.
266 @var{tz_offset} must be an integer, rational, or float between -24 and 24, inclusive.
267 If @var{tz_offset} is not a multiple of 1/60,
268 it is rounded to the nearest multiple of 1/60.
270 @code{timedate(@var{T})} is equivalent to @code{timedate(@var{T}, @var{tz_offset})}
271 with @var{tz_offset} equal to the offset of the local time zone.
273 @code{timedate()} is equivalent to @code{timedate(absolute_real_time())}.
274 That is, it returns the current time in the local time zone.
278 @code{timedate} with no argument returns a string representing the current time and date.
282 @c print ("timedate reports current time", d) $
285 (%i1) d : timedate ();
286 (%o1) 2010-06-08 04:08:09+01:00
287 (%i2) print ("timedate reports current time", d) $
288 timedate reports current time 2010-06-08 04:08:09+01:00
291 @code{timedate} with an argument returns a string representing the argument.
295 @c timedate (absolute_real_time () - 7*24*3600);
299 (%o1) 1900-01-01 01:00:00+01:00
300 (%i2) timedate (absolute_real_time () - 7*24*3600);
301 (%o2) 2010-06-01 04:19:51+01:00
304 @code{timedate} with optional timezone offset.
307 @c timedate (1000000000, -9.5);
310 (%i1) timedate (1000000000, -9.5);
311 (%o1) 1931-09-09 16:16:40-09:30
314 @opencatbox{Categories:}
315 @category{Time and date functions}
319 @c -----------------------------------------------------------------------------
320 @anchor{parse_timedate}
321 @deffn {Function} parse_timedate @
322 @fname{parse_timedate} (@var{S})
324 Parses a string @var{S} representing a date or date and time of day
325 and returns the number of seconds since midnight, January 1, 1900 GMT.
326 If there is a nonzero fractional part, the value returned is a rational number,
327 otherwise, it is an integer.
328 @code{parse_timedate} returns @code{false}
329 if it cannot parse @var{S} according to any of the allowed formats.
331 The string @var{S} must have one of the following formats,
332 optionally followed by a timezone designation:
336 @code{YYYY-MM-DD[ T]hh:mm:ss[,.]nnn}
338 @code{YYYY-MM-DD[ T]hh:mm:ss}
343 where the fields are year, month, day, hours, minutes, seconds, and fraction of a second,
344 and square brackets indicate acceptable alternatives.
345 The fraction may contain one or more digits.
347 Except for the fraction of a second,
348 each field must have exactly the number of digits indicated:
349 four digits for the year, and two for the month, day of the month, hours, minutes, and seconds.
351 A timezone designation must have one of the following forms:
364 where @code{hh} and @code{mm} indicate hours and minutes east (@code{+}) or west (@code{-}) of GMT.
365 The timezone may be from +24 hours (inclusive) to -24 hours (inclusive).
367 A literal character @code{Z} is equivalent to @code{+00:00} and its variants,
370 If no timezone is indicated,
371 the time is assumed to be in the local time zone.
373 Any leading or trailing whitespace (space, tab, newline, and carriage return) is ignored,
374 but any other leading or trailing characters cause @code{parse_timedate} to fail and return @code{false}.
376 See also @mref{timedate} and @mrefdot{absolute_real_time}
380 Midnight, January 1, 1900, in the local time zone, in each acceptable format.
381 The result is the number of seconds the local time zone
382 is ahead (negative result) or behind (positive result) GMT.
383 In this example, the local time zone is 8 hours behind GMT.
386 @c parse_timedate ("1900-01-01 00:00:00,000");
387 @c parse_timedate ("1900-01-01 00:00:00.000");
388 @c parse_timedate ("1900-01-01T00:00:00,000");
389 @c parse_timedate ("1900-01-01T00:00:00.000");
390 @c parse_timedate ("1900-01-01 00:00:00");
391 @c parse_timedate ("1900-01-01T00:00:00");
392 @c parse_timedate ("1900-01-01");
395 (%i1) parse_timedate ("1900-01-01 00:00:00,000");
397 (%i2) parse_timedate ("1900-01-01 00:00:00.000");
399 (%i3) parse_timedate ("1900-01-01T00:00:00,000");
401 (%i4) parse_timedate ("1900-01-01T00:00:00.000");
403 (%i5) parse_timedate ("1900-01-01 00:00:00");
405 (%i6) parse_timedate ("1900-01-01T00:00:00");
407 (%i7) parse_timedate ("1900-01-01");
411 Midnight, January 1, 1900, GMT, in different indicated time zones.
414 @c parse_timedate ("1900-01-01 19:00:00+19:00");
415 @c parse_timedate ("1900-01-01 07:00:00+07:00");
416 @c parse_timedate ("1900-01-01 01:00:00+01:00");
417 @c parse_timedate ("1900-01-01Z");
418 @c parse_timedate ("1899-12-31 21:00:00-03:00");
419 @c parse_timedate ("1899-12-31 13:00:00-11:00");
420 @c parse_timedate ("1899-12-31 08:00:00-16:00");
423 (%i1) parse_timedate ("1900-01-01 19:00:00+19:00");
425 (%i2) parse_timedate ("1900-01-01 07:00:00+07:00");
427 (%i3) parse_timedate ("1900-01-01 01:00:00+01:00");
429 (%i4) parse_timedate ("1900-01-01Z");
431 (%i5) parse_timedate ("1899-12-31 21:00:00-03:00");
433 (%i6) parse_timedate ("1899-12-31 13:00:00-11:00");
435 (%i7) parse_timedate ("1899-12-31 08:00:00-16:00");
439 @opencatbox{Categories:}
440 @category{Time and date functions}
444 @c -----------------------------------------------------------------------------
446 @deffn {Function} encode_time @
447 @fname{encode_time} (@var{year}, @var{month}, @var{day}, @var{hours}, @var{minutes}, @var{seconds}, @var{tz_offset}) @
448 @fname{encode_time} (@var{year}, @var{month}, @var{day}, @var{hours}, @var{minutes}, @var{seconds})
450 Given a time and date specified by
451 @var{year}, @var{month}, @var{day}, @var{hours}, @var{minutes}, and @var{seconds},
452 @code{encode_time} returns the number of seconds (possibly including a fractional part)
453 since midnight, January 1, 1900 GMT.
455 @var{year} must be an integer greater than or equal to 1899.
456 However, 1899 is allowed only if the resulting encoded time is greater than or equal to 0.
458 @var{month} must be an integer from 1 to 12, inclusive.
460 @var{day} must be an integer from 1 to @var{n}, inclusive,
461 where @var{n} is the number of days in the month specified by @var{month}.
463 @var{hours} must be an integer from 0 to 23, inclusive.
465 @var{minutes} must be an integer from 0 to 59, inclusive.
467 @var{seconds} must be an integer, rational, or float
468 greater than or equal to 0 and less than 60.
469 When @var{seconds} is not an integer,
470 @code{encode_time} returns a rational,
471 such that the fractional part of the return value is equal to the fractional part of @var{seconds}.
472 Otherwise, @var{seconds} is an integer, and the return value is likewise an integer.
474 @var{tz_offset} measures the offset of the time zone, in hours,
475 east (positive) or west (negative) of GMT.
476 @var{tz_offset} must be an integer, rational, or float between -24 and 24, inclusive.
477 If @var{tz_offset} is not a multiple of 1/3600,
478 it is rounded to the nearest multiple of 1/3600.
480 If @var{tz_offset} is not present, the offset of the local time zone is assumed.
482 See also @mrefdot{decode_time}
487 @c encode_time (1900, 1, 1, 0, 0, 0, 0);
488 @c encode_time (1970, 1, 1, 0, 0, 0, 0);
489 @c encode_time (1970, 1, 1, 8, 30, 0, 8.5);
490 @c encode_time (1969, 12, 31, 16, 0, 0, -8);
491 @c encode_time (1969, 12, 31, 16, 0, 1/1000, -8);
495 (%i1) encode_time (1900, 1, 1, 0, 0, 0, 0);
497 (%i2) encode_time (1970, 1, 1, 0, 0, 0, 0);
499 (%i3) encode_time (1970, 1, 1, 8, 30, 0, 8.5);
501 (%i4) encode_time (1969, 12, 31, 16, 0, 0, -8);
503 (%i5) encode_time (1969, 12, 31, 16, 0, 1/1000, -8);
507 (%i6) % - 2208988800;
513 @opencatbox{Categories:}
514 @category{Time and date functions}
518 @c -----------------------------------------------------------------------------
520 @deffn {Function} decode_time @
521 @fname{decode_time} (@var{T}, @var{tz_offset}) @
522 @fname{decode_time} (@var{T})
524 Given the number of seconds (possibly including a fractional part)
525 since midnight, January 1, 1900 GMT,
526 returns the date and time as represented by a list comprising
527 the year, month, day of the month, hours, minutes, seconds, and time zone offset.
529 @var{tz_offset} measures the offset of the time zone, in hours,
530 east (positive) or west (negative) of GMT.
531 @var{tz_offset} must be an integer, rational, or float between -24 and 24, inclusive.
532 If @var{tz_offset} is not a multiple of 1/3600,
533 it is rounded to the nearest multiple of 1/3600.
535 If @var{tz_offset} is not present, the offset of the local time zone is assumed.
537 See also @mrefdot{encode_time}
542 @c decode_time (0, 0);
544 @c decode_time (2208988800, 9.25);
545 @c decode_time (2208988800);
546 @c decode_time (2208988800 + 1729/1000, -6);
547 @c decode_time (2208988800 + 1729/1000);
550 (%i1) decode_time (0, 0);
551 (%o1) [1900, 1, 1, 0, 0, 0, 0]
552 (%i2) decode_time (0);
553 (%o2) [1899, 12, 31, 16, 0, 0, - 8]
554 (%i3) decode_time (2208988800, 9.25);
556 (%o3) [1970, 1, 1, 9, 15, 0, --]
558 (%i4) decode_time (2208988800);
559 (%o4) [1969, 12, 31, 16, 0, 0, - 8]
560 (%i5) decode_time (2208988800 + 1729/1000, -6);
562 (%o5) [1969, 12, 31, 18, 0, ----, - 6]
564 (%i6) decode_time (2208988800 + 1729/1000);
566 (%o6) [1969, 12, 31, 16, 0, ----, - 8]
570 @opencatbox{Categories:}
571 @category{Time and date functions}
575 @c -----------------------------------------------------------------------------
576 @anchor{absolute_real_time}
577 @deffn {Function} absolute_real_time ()
579 Returns the number of seconds since midnight, January 1, 1900 GMT.
580 The return value is an integer.
582 See also @mref{elapsed_real_time} and @mrefdot{elapsed_run_time}
587 @c absolute_real_time ();
588 @c 1900 + absolute_real_time () / (365.25 * 24 * 3600);
591 (%i1) absolute_real_time ();
593 (%i2) 1900 + absolute_real_time () / (365.25 * 24 * 3600);
594 (%o2) 2007.265612087104
597 @opencatbox{Categories:}
598 @category{Time and date functions}
602 @c -----------------------------------------------------------------------------
603 @anchor{elapsed_real_time}
604 @deffn {Function} elapsed_real_time ()
606 Returns the number of seconds (including fractions of a second)
607 since Maxima was most recently started or restarted.
608 The return value is a floating-point number.
610 See also @mref{absolute_real_time} and @mrefdot{elapsed_run_time}
615 @c elapsed_real_time ();
616 @c expand ((a + b)^500)$
617 @c elapsed_real_time ();
620 (%i1) elapsed_real_time ();
622 (%i2) expand ((a + b)^500)$
623 (%i3) elapsed_real_time ();
627 @opencatbox{Categories:}
628 @category{Time and date functions}
632 @c -----------------------------------------------------------------------------
633 @anchor{elapsed_run_time}
634 @deffn {Function} elapsed_run_time ()
636 Returns an estimate of the number of seconds (including fractions of a second)
637 which Maxima has spent in computations since Maxima was most recently started
638 or restarted. The return value is a floating-point number.
640 See also @mref{absolute_real_time} and @mrefdot{elapsed_real_time}
645 @c elapsed_run_time ();
646 @c expand ((a + b)^500)$
647 @c elapsed_run_time ();
650 (%i1) elapsed_run_time ();
652 (%i2) expand ((a + b)^500)$
653 (%i3) elapsed_run_time ();
657 @opencatbox{Categories:}
658 @category{Time and date functions}