Go to the previous, next section.
This appendix describes the collection of useful macros, written by a variety
of people, that are to be found in the default macro directory, i.e.
the directory pointed to by the macro
entry in your `.sm' file. If ever you write a useful (or simply clever) macro, why
not send it to us for inclusion in the next version of SM?
The macros are arranged in a number of files which may be read using the
load
macro. For example, to load the file fonts
type
load fonts
. To forget a set of definitions, use unload
.
Under Unix, there is a macro lsm
that can be used to list the
contents of macro libraries, e.g. lsm utils
. It is more-or-less
complete depending on the value of VERBOSE
, just like LIST MACRO
.
The list that follows gives the name and a one-line synopsis of all the macros
in the default files as of the date of this manual. The full text of any macro
may be examined via the help <macroname>
command in SM; the
default files may be printed for those who desire a hardcopy.
file `abbrev' in directory `macro' (This is a file of all unambigous abbreviations of keywords. It is created using the shell script `abbrev' in the main SM directory. Its use may intefere with cunning macros, and is not recommended).
file `cover' in directory `macro'
cover # draw the coverfile `default' in directory `macro'
batch ## run the history buffer, but don't delete from history list bell ## ring terminal bell calc ## evaluate an expression cd ## change directories compatible ## define macros to be compatible with Mongo declare ## declare a vector $1: declare name size del ## delete last command from history list del1 ## don't put command on history list echo ## write to terminal ed ## edit a macro, or the previous one if no argument edall ## edit history buffer edit_all ## edit history buffer edit_hist ## edit the history list emacs_all ## edit the history list using an external editor. emacs_hist ## edit the history list using an external editor. error_handler ## Handle ^C interrupts execute # read and execute an SM file of commands (1 per line) extend_history # Extend history buffer to be of size $1 for # Repeat a macro while a condition is true, like C's for(;;) gripe ## complain to Robert (Unix only) h ## get help head ## print the top of the current data (or other) file hm ## help with the last macro edited hv ## help with variable insert ## insert text after line $1 load ## load macros in default directory load2 ## load macros in (second) default directory ls ## list macros lsm ## list macros in a file in default macro directory lsv ## list variables q ## check, then quit re ## macro read reset_ctype # Reset the default ctypes (except "default") repeat # Repeat a macro `name' while the condition is true sav ## save to a file $1, don't save from files `$mfiles' show ## show current values of various things startup ## macro invoked upon startup undef ## undefine a variable undo ## undo [macro] : undo (i.e. erase lines drawn by) macro $1 unload ## forget macros from a file v ## set verbosity wr ## macro writefile `demos' in directory `macro'
square # sum the Fourier series for a square wave, using $1 terms colours # draw a circle in a number of colours until ^C stops it crings # draw a set of coloured circles gauss_convolve # convolve 2 gaussians with sigmas $1 and $2 grey_sincos # draw a grey scale image of a sin(x)cos(y) surface scribble # use cursor to draw a line, and then shade the interior shading # draw an ammonite sundial # draw a sundial, allowing for the analemmafile `fonts' in directory `macro'
fonts # draw the font table TeX_defs # draw the "TeX" definitions make_char # help create a new character
file `fourier' in directory `macro'
# # Macros to make dealing with complex numbers for FFT's easier # Assumes that complex vector `name' is represented by two vectors # called name_r and name_i # fft # Direct FFT: fft name name ifft # Inverse FFT: ifft name name cadd # Add complex numbers: $1 = $2 + $3 cdiv # Divide complex numbers: $1 = $2/$3 cmod # Modulus: $1 = |$2| cmult # Multiply complex numbers: $1 = $2*$3 csub # Subtract complex numbers: $1 = $2 - $3 imag # Imaginary part: $1 = Im($2) real # Real part: $1 = Re($2)file `math' in directory `macro'
# # Written by Daniel Pfenniger (PFENNIGER@obs.unige.ch) # `A&S' is Abramowitz & Stegun # J0 # Bessel func. J0(|x|), A&S, 9.4.1,.3 Y0 # Bessel func. Y0(|x|), |x|>0, A&S, 9.4.2-3 J1 # Bessel func. J1(|x|), A&S, 9.4.4,.6 Y1 # Bessel func. Y1(|x|), |x|>0, A&S, 9.4.5-6 I0 # Modified Bessel func. I0(|x|), A&S, 9.8.1-2 I1 # Modified Bessel func. I1(|x|), A&S, 9.8.3-4 K0 # Modified Bessel func. K0(|x|), |x|>0, A&S, 9.8.5-6 K1 # Modified Bessel func. K1(|x|), |x|>0, A&S, 9.8.7-8 K # Complete elliptic integral K(m), 0<=m<1, A&S 17.3.34 E # Complete elliptic integral E(m), 0<=m<=1, A&S 17.3.36
file `mongo' in directory `macro'
(omitting those that are simply abbreviations, like ang
)
da ## set data file dev ## set device dra ## draw, accepting expressions ecolumn ## define vector error_col as error vector end ## quit, not on history era ## erase screen, not on history lis ## list history, not on history hard ## make a hardcopy of what you type (or get by history) hardcopy ## close the old device and set dev type to 0 hcopy ## hcopy [printer] [l1] [l2]: Make hardcopy of playback buffer hmacro ## hmacro [macro] [printer]: make hardcopy of `macro' on `printer' identification ## write an id to the top right hand corner of screen input ## execute an Mongo file mongo # make SM resemble Mongo as closely as possible pcolumn ## set point column (Mongo) playback ## define "all" from buffer, and run it read_all ## read a macro file, putting `all' onto the history buffer read_hist ## read history from a file read_old ## read an Mongo file onto the history buffer rel ## relocate, accepting expressions save_all ## write the playback list to a file (use sav instead) terminal ## device toplabel ## put label at top of plot xcolumn ## read a column into vector x (Mongo) xlogarithm ## take log of vector x (Mongo) ycolumn ## read a column into vector y (Mongo) ylogarithm ## take log of vector yfile `stats' in directory `macro'
cgauss # evaluate a Cumulated Gaussian : N($mean,$sig) draw_KS # Draw a cumulated curve, for looking at KS statistics erfc # calculate complentary error function erfc($1) factorial # Use Stirling's formula to calculate a factorial ($1)! gauss # evaluate a Gaussian : N($mean,$sig) gaussdev # return a N(0,1) random vector lsq # do a least squares fit to a set of vectors lsq2 # do a least squares fit to a set of vectors, errors in x and y linfit # linear least squares fit for any number of parameters prob_KS # probability of getting a given value of the KS statistic prob_wilc # return probability in $$2 that x exceeds $1 from Wilcoxon rxy # find Correlation Coefficient for two vectors smirnov1 # calculate 1 sided Kolmogorov-Smirnov statistic for vector smirnov2 # calculate 2 sided Kolmogorov-Smirnov statistic for vectors spear # calculate Spearman rank correlation coefficient for 2 vectors stats # stats vector mean sigma kurtosis : calculate $mean $sigma etc stats2 # stats vector weights mean sigma kurtosis stats_med # stats_med vector median SIQR : calc $median $SIQR from vector wilcoxon # calculate Wilcoxon statistic for 2 vectors
file `utils' in directory `macro'
alpha_poi # alpha_poi x y z. Like poi x y, but use z as labels for points arc # the arclength along the curve ($1,$2), e.g. set v=arc(x,y) arrow # use the cursor to define an arrow. barhist # draw a bar histogram boxit # use the cursor to define a box, and draw it circle # draw a circle, centre ($1,$2) radius $3 cumulate # find the cumulative distribution of $1 in $2 draw_arrow # draw an arrow from ($1,$2) to ($3,$4) draw_box # draw a box, defined by two corners error_x # draw x-error bars: error x y size error_y # draw y-error bars: error x y size get_hist # get_hist input output-x output-y base top width gauss # evaluate a Gaussian : N($mean,$sig) get # syntax: get i j. Read a column from a file glevels # Set grey levels. Usage: glevels expr greyscale # Draw a grey-scale image. Usage: greyscale [npx npy maxweight dmargin] info # Get help about a command from SM's info files interp # Linearily interpolate $3 into ($1,$2), giving $4 interp2 # Linearily interpolate $3 into ($1,$2), giving $4 is_file # Return true if file $1 exists is_set # define variable $$1 if the $3'rd bit is set in $2 logerr # syntax: logerr x y error, where y is logged, and error isn't mconcat # Concatenate 2 macros, optionally renaming result modulo # find $1 modulo $2 number # convert a string vector to an arithmetic one pairs # pairs x1 y1 x2 y2. connect (x1,y1) to (x2,y2) polar # draw a circle as an `axis' for polar coordinates pmatrix # print the matrix $1 puts # Draw a line of text, then move to the start of the next line qminv # Quick matrix inversion, done in place reverse # reverse the order of a vector save_vec # put the definition of a vector onto the history list shade_box # shade a box, spacing $1, defined by two corners shed # shade region between x y and x2 y2 with n lines simp # Simpson's rule integration: simp answer x y smooth # boxcar smooth a vector smooth2 # smooth a vector with a given filter upper # define a variable giving an `upper limit' symbol vecminmax # find the minimum and maximum of a vector vfield # plot a vector field: vfield x y len angle
Go to the previous, next section.