clana
API Referenceclana.binarytree
Simple binarytree implementation, not meant for highperformance code.
CLANA.BINARYTREE

Function
NODELEAFP
(node) 
Function
NODEVALUE
(tree) 
Function
NODELEFTCHILD
(tree) 
Function
NODERIGHTCHILD
(tree) 
Function
MAKEBALANCEDTREE
(list &key key sorted (comparison #'<) (test #'equal)) 
Function
BREF
(tree val &key (key #'identity))Returns a cons pair of node values which form the most constraining interval around val using key.
clana.calculus
A few numerical and/or symbolic calculus functions.
CLANA.CALCULUS

Function
DIFF
(fn &key (prec 1.d9))Returns the onesided numerical derivative of a function. 
Function
NEWTON
(fn guess &key (value 0) (maxtries 50) (prec 1.d4) (diffprec 1.d9))1D Newton's method for solving an equation. If the method converges, returns the values of x_sol, fn(x_sol), and the number of iterations it took to converge. If the method does not converge, returns the values of nil and the number of iterations on failure. value is the value that fn should evaluate to. maxtries is the maximum number of iterations to attempt a solution. prec is the precision in the residue, below which convergence is assumed. diffprec is the precision to use in calculating the derivative of fn via diff. 
Function
INVERT
(fn &key (guessfn (constantly 1)) (newtonprec 1.d4) (diffprec 1.d9))Inverts a function numerically using Newton's method. Returns the inverse function using the precision parameters given. guessfn is a function which evaluates to a guess value for each input value to the inverse function to use in Newton's method. newtonprec is the precision argument to give to Newton's method for the precision in the residue of the result. diffprec is the precision to give to diff during Newton's method.
clana.closutils
closutils provides various lacking utilities for working with structures and CLOS class instances as well as utilities for transforming them into clists which can be written/read with standard stream objects portably.
CLANA.CLOSUTILS

Function
SLOTNAMES
(obj)Returns the list of slot symbols for a structure/CLOS class instance. 
Function
SLOTKEYWORDNAMES
(obj) 
Function
SLOTVALUES
(obj)Returns a list of the slot values in a structure/CLOS class instance. 
Function
CLISTTYPE
(clist)Returns the type symbol for the type of the object the clist represents. 
Function
CLISTFIELDSYMBOLS
(clist)Returns the field symbols for the object the clist represents. 
Function
CLISTFIELDVALUES
(clist) 
Function
OBJECT>CLIST
(obj)Returns a clist for the object obj. Supports structures/CLOS classes, arbitrary cons structures, nested sequences of any structure; all other objects are returned asis. 
Function
OBJECT>PLIST
(obj)Returns a plist for the object obj. 
Function
CLIST>OBJECT
(clist)Currently only works for oneleveldeep clists; needs to be fixed to allow arbitrary depth. 
GenericFunction
TYPECONSTRUCTOR
(object)Returns the function responsible for constructing objects of the same type as the object. Default value is nil unless a method is defined for an object/type. 
Method
TYPECONSTRUCTOR
(obj) 
Method
TYPECONSTRUCTOR
(obj) 
Method
TYPECONSTRUCTOR
(obj)
clana.csvtable
clana.errorpropogation
clana.fileutils
Various utilities for working with files
CLANA.FILEUTILS

Function
READLINESFROMFILE
(file) 
Function
READLINESFROMPATHNAME
(pathname) 
Function
READFIELDSFROMFILE
(file) 
Function
READFIELDSFROMPATHNAME
(pathname) 
Function
WRITELINESTOFILE
(lines file) 
Function
WRITELINESTOPATHNAME
(lines pathname &key ifexists ifdoesnotexist) 
Function
FILELASTCHANGED
(pathnameorstring)Returns time in seconds since epoch of when the file data was changed.
clana.fitting
clana.functionalutils
Utilities for doing functional programming not already provided by Alexandria.
CLANA.FUNCTIONALUTILS

Function
FLIP
(f)Takes a function of two parameters and creates a new function which takes the same parameters in reverse order; particularly useful in conjunction with reduce. 
Function
SPLICE
(xsplit fn1 fn2)Splices two functions togother at xsplit. If either function is nil, returns the other function or nil if both are nil. 
Function
TOPAIRFUNCTION
(f)Makes f apply to a pair instead of two arguments 
Function
LFUNCALL
(fn &rest args)Applies a function which takes a single list argument to an arbitrary number of arguments. 
Function
MINBY
(x y &key (key #'identity)) 
Function
MINIMUM
(xs &key (key #'identity)) 
Function
MAXBY
(x y &key (key #'identity)) 
Function
MAXIMUM
(xs &key (key #'identity)) 
Function
ITERATE
(fn initial count)Calls a function on its own result for count iterations. Returns the final result. 
Function
ITERATECOLLECT
(fn initial count)Calls a function on its own result for count iterations. Returns the full list of results. 
Function
SAFEFUNCALL
(keyargs &rest args)Only calls a function when it is in fact a function, and returns all other objects.
clana.genericmath
Provides generic versions of (most ATM) the standard Common Lisp math functions; this allows easy extension to new mathematical objects.
CLANA.GENERICMATH

Function
USEGMATH
(package)shadowingimports all the exported symbols from gmath into the current package 
Variable
*GMATHGENERICMAP*
(makehashtable :test 'equal)
Hash table mapping generic function symbols to the argument specification for the function. 
Macro
DEFMATH
(fname (&rest args) &body body)Defines a generic function for use in genericmath. Necessary to allow for programmatically generated methods of certain mathematical types. Can use body just like with defgeneric to specify methods etc. 
Macro
DEFMETHODCOMMUTATIVE
(methodname (leftarg rightarg) &body body) 
Macro
INCF
(place &optional (delta 1)) 
Macro
DECF
(place &optional (delta 1)) 
Function
+
(&rest xs) 
Function
SUM
(xs)Convenience function for summing a list of values (it's reducing + across them). 
Function
PRODUCT
(xs)Convenience function for multiplying a list of values 
GenericFunction
ADD
(x y)Binary addition function 
Function

(&rest xs) 
GenericFunction
SUB
(x y)Binary subtraction function 
GenericFunction
UNARYSUB
(x)Unary subtraction function. 
Function
*
(&rest xs) 
GenericFunction
MULT
(x y)Binary multiplication function 
Function
/
(&rest xs) 
Function
PROTECTED/
(&rest xs) 
GenericFunction
DIV
(x y)Binary division function 
GenericFunction
UNARYDIV
(x)Unary division function. Also known as multiplicative inversion. 
GenericFunction
PROTECTEDDIV
(x y &key protectedvalue)Binary division protected from division by zero; returns protectedvalue whenever y is zero 
Method
PROTECTEDDIV
(x y &key (protectedvalue 0)) 
Method
PROTECTEDDIV
(x y &key (protectedvalue 0)) 
Method
PROTECTEDDIV
(x y &key (protectedvalue 0)) 
GenericFunction
PROTECTEDUNARYDIV
(x &key protectedvalue)Protected unary division function. Returns protectedvalue whenever x is zero. 
Method
PROTECTEDUNARYDIV
(x &key (protectedvalue 0)) 
Method
PROTECTEDUNARYDIV
(x &key (protectedvalue 0)) 
Method
PROTECTEDUNARYDIV
(x &key (protectedvalue 0)) 
GenericFunction
SQRT
(x)Square root function 
GenericFunction
EXPT
(x y)Raises x to the y power 
GenericFunction
EXP
(x)e^x 
GenericFunction
LOG
(x)Natural logarithm function 
GenericFunction
SIN
(x)Sine, in radians 
GenericFunction
COS
(x)Cosine, in radians 
GenericFunction
TAN
(x)Tangent, in radians 
GenericFunction
SEC
(x)Secant, in radians 
Method
SEC
(x) 
Method
SEC
(x) 
Method
SEC
(x) 
GenericFunction
CSC
(x)Cosecant, in radians 
Method
CSC
(x) 
Method
CSC
(x) 
Method
CSC
(x) 
GenericFunction
COT
(x)Cotangent, in radians 
Method
COT
(x) 
Method
COT
(x) 
Method
COT
(x) 
GenericFunction
SINH
(x)Hyperbolic sine function 
GenericFunction
COSH
(x)Hyperbolic cosine function 
GenericFunction
TANH
(x)Hyperbolic tangent function 
GenericFunction
SECH
(x)Hyperbolic secant function 
Method
SECH
(x) 
Method
SECH
(x) 
Method
SECH
(x) 
GenericFunction
CSCH
(x)Hyperbolic cosecant function 
Method
CSCH
(x) 
Method
CSCH
(x) 
Method
CSCH
(x) 
GenericFunction
COTH
(x)Hyperbolic cotangent function 
Method
COTH
(x) 
Method
COTH
(x) 
Method
COTH
(x) 
Method
ADD
((x number) (y number)) 
Method
SUB
((x number) (y number)) 
Method
UNARYSUB
((x number)) 
Method
MULT
((x number) (y number)) 
Method
DIV
((x number) (y number)) 
Method
UNARYDIV
((x number)) 
Method
PROTECTEDDIV
(x (y number) &key (protectedvalue 0)) 
Method
PROTECTEDUNARYDIV
((x number) &key (protectedvalue 0)) 
Method
SQRT
((x number)) 
Method
EXPT
((x number) (y number)) 
Method
EXP
((x number)) 
Method
LOG
((x number)) 
Method
SIN
((x number)) 
Method
COS
((x number)) 
Method
TAN
((x number)) 
Method
SINH
((x number)) 
Method
COSH
((x number)) 
Method
TANH
((x number))
clana.gnuplotinterface
Interface for spawning & communicating with gnuplot sessions from LISP.
CLANA.GNUPLOTINTERFACE

Function
GNUPLOTINIT

Function
GNUPLOTCLOSE
(session) 
Function
GNUPLOTCMD
(session commandstring)
clana.gslcffi
Functions for interfacing with GSL which don't seem to work/aren't currently provided through GSLL.
CLANA.GSLCFFI

Variable
+GSLEOF+
32
Endoffile return value for gsl functions
clana.hashtableutils
Utilities for working with hash tables
CLANA.HASHTABLEUTILS

Function
HASHTABLE>ALIST
(hashtable) 
Function
HASHKEYS
(hashtable) 
Function
HASHVALUES
(hashtable) 
Function
HMAP
(fn hashtable)hmap is a more functional version of maphash; instead of returning nil and relying on mutable state, hmap returns a new hash table with the same keys but mapped values in the resulting hash table. fn is a function which takes a key and value from hashtable and returns an updated value for the resulting hash table. 
Function
ALIST>HASHTABLE
(alist &optional (test 'eql))
clana.hdfcffi
HDF5 cffi bindings
CLANA.HDFCFFI

CffiType
SIZET

CffiType
HIDT

CffiType
HERRT

CffiType
HSIZET

CffiType
HSSIZET

CffiEnum
H5TCLASST

CffiEnum
H5TDIRECTIONT

CffiEnum
H5SSELOPERT

Variable
+H5SUNLIMITED+
18446744073709551615

Variable
+H5SALL+
0

Variable
+H5FACCTRUNC+
2

Variable
+H5FACCRDONLY+
0

Variable
+H5FACCRDWR+
1

Variable
+H5PDEFAULT+
0

Variable
+H5PDATASETCREATE+
150994953

Variable
+H5TNATIVECHAR+
50331656

Variable
+H5TNATIVEUCHAR+
50331657

Variable
+H5TNATIVESHORT+
50331658

Variable
+H5TNATIVEUSHORT+
50331659

Variable
+H5TNATIVEINT+
50331660

Variable
+H5TNATIVEUINT+
50331661

Variable
+H5TNATIVELONG+
50331662

Variable
+H5TNATIVEULONG+
50331663

Variable
+H5TNATIVELLONG+
50331688

Variable
+H5TNATIVEULLONG+
50331689

Variable
+H5TNATIVEFLOAT+
50331690

Variable
+H5TNATIVEDOUBLE+
50331691

Variable
+H5TCOMPOUND+
6

Variable
+H5FOBJFILE+
1

Variable
+H5FOBJDATASET+
2

Variable
+H5FOBJGROUP+
4

Variable
+H5FOBJDATATYPE+
8

Variable
+H5FOBJATTR+
16

Variable
+H5FOBJALL+
31

Variable
*HDFCFFITYPEMAP*
(list (cons clana.hdfcffi:+h5tnativechar+ :char) (cons clana.hdfcffi:+h5tnativeuchar+ :uchar) (cons clana.hdfcffi:+h5tnativeshort+ :short) (cons clana.hdfcffi:+h5tnativeushort+ :ushort) (cons clana.hdfcffi:+h5tnativeint+ :int) (cons clana.hdfcffi:+h5tnativeuint+ :uint) (cons clana.hdfcffi:+h5tnativellong+ :longlong) (cons clana.hdfcffi:+h5tnativeullong+ :ullong) (cons clana.hdfcffi:+h5tnativefloat+ :float) (cons clana.hdfcffi:+h5tnativedouble+ :double))

Function
CFFINATIVETYPE
(hdfnativetype) 
Function
HDFNATIVETYPE
(cffinativetype)
clana.hdftable
Table subclass specializing on HDF5 datasets
CLANA.HDFTABLE

Class
HDFTABLE
(TYPEDTABLE
)
ROWBUFFERSIZE
Accessor:HDFTABLEBUFFERSIZE
 buffer size in number of rows

CHUNKINDEX
Accessor:HDFTABLECHUNKINDEX
 index to the inmemory chunk

ROWBUFFER
Accessor:HDFTABLEROWBUFFER
 Object for storing a row to be read from/written to hdf table. It's stored as part of the table for efficiency purposes and should not be handled directly by the user; use the awesome higher level tools for that.

ROWBUFFERINDEX
Accessor:HDFTABLEROWBUFFERINDEX
 Index to the row in the buffer which is currently being modified prior to writing.

HDFDATASET
Accessor:HDFTABLEDATASET
 hdf dataset which the table is reading from/writing to.

HDFROWTYPE
Accessor:HDFTABLEROWTYPE
 hdf type for the row data object

READROWINDEX
Accessor:HDFTABLEREADROWINDEX
 Index to row which should be sequentually read next

NROWS
Accessor:HDFTABLENROWS
 number of rows in hdftable


Function
OPENHDFTABLE
(hdffile datasetname &key buffersize) 
Function
CREATEHDFTABLE
(hdffile datasetpath namesspecs &key (buffersize 1000))Creates a hdftable for writing in hdffile with datasetpath as the path to the dataset in the hdffile and the alist namesspecs which maps the field names to their typespecs (this is just applying rest to the typespec for the table). Buffer size will be used as both the chunksize for the hdf dataset and as the size of the buffer for writing into the file. 
Class
HDFTABLECHAIN
(TABLE
)
DATASETPATH
Accessor:HDFTABLECHAINDATASETPATH
 Path to dataset within each file. The path should be uniform if the hdf files truly are a chain.

ACTIVETABLE
Accessor:HDFTABLECHAINACTIVETABLE
 The inmemory hdftable

ACTIVEFILE
Accessor:HDFTABLECHAINACTIVEFILE
 hdffile currently opened by the active hdftable.

FILEPATHS
Accessor:HDFTABLECHAINFILEPATHS
 List of filepaths which contain one hdftable each

TABLELENGTHS
Accessor:HDFTABLECHAINTABLELENGTHS
 Length (in indices) of each table

TABLEINDEXOFFSETS
Accessor:HDFTABLECHAINTABLEINDEXOFFSETS
 Start indexes for each table

CURRENTTABLEINDEX
Accessor:HDFTABLECHAINCURRENTTABLEINDEX
 index for inmemory hdftable in (virtual) list of tables

CURRENTTABLESTART
Accessor:HDFTABLECHAINCURRENTTABLESTART
 starting row index for the current table

CURRENTTABLEEND
Accessor:HDFTABLECHAINCURRENTTABLEEND
 last row index for the current table

TABLEINDEXBINARYTREE
Accessor:HDFTABLECHAINBINARYTREE
 binary search tree storing the indeces for efficient searching

READROWINDEX
Accessor:HDFTABLECHAINREADROWINDEX
 Index to row which should be sequentually read next

NROWS
Accessor:HDFTABLECHAINNROWS
 number of rows in hdftable


Function
OPENHDFTABLECHAIN
(filenamelist datasetpath)Creates and initializes hdftablechain given the filenamelist and datasetpath
clana.hdftypespec
Utilities for creating/reading HDF5 types from/into typespecs.
CLANA.HDFTYPESPEC

Function
TYPESPEC>HDFTYPE
(&rest xs3) 
Function
HDFTYPE>TYPESPEC
(&rest xs135)
clana.hdfutils
Utilities for a more lispy interface to HDF5
CLANA.HDFUTILS

Macro
WITHCLEANUP
((&rest specs) &body body)Executes body inside of a lexical environment where objects described by specs are bound and then freed upon concluding the body. Each spec is a list of 3 elements: 1. A symbol which will denote a variable inside the body, 2. A form which will be evaluated and its value bound to the symbol, 3. A function for cleaning up the object referenced by the symbol; it will be given the symbol as the sole argument. 
Macro
WITHOPENDATASPACE
((dataspace dataset) &body body)Safely work with dataspace taken from dataset 
Macro
WITHCREATEDATASPACE
((dataspace rank dims maxdims) &body body)Creates a new dataspace and cleans up after it 
Macro
WITHDATASETTYPE
((type dataset) &body body) 
Function
OPENHDFFILE
(filename &key direction (ifexists nil ifexistssuppliedp) (ifdoesnotexist nil ifdoesnotexistsuppliedp) (readaccessparameters +h5pdefault+) (writeaccessparameters (list +h5pdefault+ +h5pdefault+)))Opens an hdf file, returning a handle to the file (hidt). direction can be :input or :output. ifexists can be :supersede :error nil ifdoesnotexist can be :create :error nil 
Function
CLOSEHDFFILE
(hdffile)Closes all datatype objects associated with file along with the file 
Macro
WITHOPENHDFFILE
((hdffile filepathorstring &key direction (ifexists nil ifexistssuppliedp) (ifdoesnotexist nil ifdoesnotexistsuppliedp) (readaccessparameters +h5pdefault+) (writeaccessparameters (list +h5pdefault+ +h5pdefault+))) &body body)Macro providing lispy access to hdf (HDF5) files. Use just like you would withopenfile, just give a file and a path/string. The usual key arguments for access mode, etc. are honored and transformed into HDF5 terms. The argument hdffile is the symbol you'll use to refer to the file handle inside of the macro body. 
Function
HDFMKGROUP
(file groupname)Creates a group with name groupname in hdffile file; returns path to group with final '/' included.
clana.histogram
clana.intchar
For some reason my SBCL doesn't support intchar anymore, so here it is.
CLANA.INTCHAR

Function
INTCHAR
(integer)
clana.linearalgebra
(minimal) Linear algebra library which is integrated into the generic math framework.
CLANA.LINEARALGEBRA

Function
MAKEMATRIX
(nrows ncols &key (initialelement 0.0d0)) 
Function
MAKEVECTOR
(nelts &key (initialelement 0.0d0)) 
Function
MATRIXTRANSPOSE
(matrix &optional (type 'vector)) 
Function
VECTOR>MATRIX
(vector &key (orientation :column) (type 'vector)) 
Function
MATRIXMULT
(x y &optional (type 'vector)) 
Function
EUCLIDEANDOT
(x y) 
Function
EUCLIDEANNORM2
(x) 
Function
EUCLIDEANNORM
(x) 
Function
PHI
(vector) 
Function
THETA
(vector) 
Function
CROSSPRODUCT
(a b)Returns cross product of vectors a and b
clana.listutils
Utilities for working with lists not already provided by Alexandria.
CLANA.LISTUTILS

Function
RANGE
(start end &optional (step 1)) 
Function
ZIP
(x y) 
Function
LZIP
(&rest lists)Like zip, but uses lists instead of cons pairs thus allowing ntuples 
Function
UNZIP
(xs)Returns a cons with the car being the cars of the zipped xs and the cdr being the cdrs. 
Function
UNLZIP
(xs)lzip is an inverse (through apply) of itself, simply applies lzip to its argument, returning a list of the previously zipped lists in xs. 
Function
MAPZIP
(fn &rest lists)Returns an alist mapping the list of corresponding elements from each input list to the value of fn for those values; it's just zipping together the arguments with the value of fn. If only one list is given, the elements are mapped directly (i.e. not in a list) 
Function
TREEMAP
(fn &rest trees)Maps function over identically structured trees (lists) 
Function
INTERSPERSE
(obj lst)Inserts obj in between each pair of elements in lst 
Function
TRANSPOSE
(xs) 
Function
CARTESIANPRODUCT
(&rest xs) 
Function
EVERYNTH
(list n &optional (start 0)) 
Function
EXCEPTNTH
(x n) 
Function
ATINDICES
(lst indices)Returns the values from lst located at positions given by indices 
Function
EXCEPTAT
(xs ns &key (test #'eql) uniquelysorted)Yields the list of xs except for the elements at the positions in ns. Set uniquelysorted to t if you want exceptat to assume the ns are already unique and sorted least to greatest. 
Function
COMPRESS
(list &key (key #'identity) (test 'eql) sortby singletonpairs)Compress list such that duplicate elements are combined into a single pair entry which has as the car the element value and as the cdr the count. The singletonpairs option controls whether single elements are still placed inside a pair. This is useful when the elements of the list you wish to compress are cons cells, as this would otherwise lead to ambiguity in the result. 
Function
LISTLESSTHAN
(list1 list2) 
Function
LISTGREATERTHAN
(list1 list2) 
Function
AREFBYLIST
(array indexlist)Access array element via index list instead of individual indices 
Function
MAKEOFFSETS
(sizes)Takes a list of sizes and returns a list containing 0, (first sizes), (+ (first sizes) (second sizes)), ... summing the sizes as the list goes. This pattern has turned out to be recurrent, and the result can be interpreted as finding the starting index of the ith list in the concatenation of n lists. 
Function
CDRS
(xs) 
Function
CARS
(xs) 
Function
LIST>SET
(list &optional (test #'eql))Returns list with duplicates removed 
Function
PARTITION
(list &key (key #'identity) (test #'eql))Regroups the contents of a list into partitions using the test function provided. Guarantees that the elements of each group pass test with every member of the partition as long as the test function is transitive. Does not necessarily preserve order of partitions, but preserves order of the elements relative to each partition. This function supports two different conceptual approaches to partitioning: * By relation: the test function is the equivalence relation operator * By association: using a key function which maps into a set of index values allows the user to partition according to association with that value. 
Function
LENGTHEQUAL
(list length)Returns t/nil as soon as it is apparent that the list does not contain exactly length elements. 
Function
SINGLE
(list)Checks to see if list is a list with exactly one element. 
Function
APPEND1
(list object)Creates a list containing object and appends list to it. 
Function
CONC1
(list object)Like append1, but uses nconc instead of append 
Function
MKLIST
(object)Ensures that object is a list, if not object is packaged in a list. 
Macro
ENSURELISTS
((&rest listbindings) &body body)Ensures and rebinds variables as lists via mklist. Each listbinding must be either a symbol or a list (symbol form); for a symbol it will be bound to (mklist symbol) in the body; for a list the first element of the listbinding will be bound to (mklist (second listbinding)). 
Function
LONGER
(x y)Efficiently compares two lists, or if they're not both lists simply calls length on each and compares. This could be sped up a bit if one argument is a list and the other not, so it's a work in progress. 
Function
GROUP
(source n)Takes a list and returns a list of lists of the elements in the list grouped in lists of size n with the remainder in the last list. 
Function
PRUNE
(test tree)Like removeif, but for lists treated as trees. 
Function
FIND2
(fn list)Like find, but it returns two values: the list element and the value that fn returned. 
Function
BEFORE
(x y list &key (test #'eql))Tells you if x is found before y in list. 
Function
AFTER
(x y list &key (test #'eql))Tells you if x is found after y in list. 
Function
DUPLICATE
(object list &key (test #'eql))Tells you if the object occurs more than once in the list. 
Function
PERMUTE
(list permutation)Rearranges the elements in list according to the permutation. 
Function
PLIST>ALIST
(plist)Forms an alist from a plist 
Function
ALIST>PLIST
(alist)Forms a plist from an alist 
Function
PLISTSELECTFIELDS
(plist &rest fields)Returns a list of the fields from plist in the order specified; the element will be nil if the field is not present. 
Macro
DOPLIST
((fieldsymbol fieldvalue plist) &body body)Executes body via looping over plist, binding each field symbol to fieldsymbol and each field value to fieldvalue. Returns nil. 
Macro
DOPLISTS
(plists &body body)Loops over a plist, binding each field in the plist to a variable of the same name as the field symbol but in the current package.
clana.lorentz
Implements lorentz vectors, lorentz transformations, etc.
CLANA.LORENTZ

Function
MINKOWSKIDOT
(leftvector rightvector)Computes the inner product using the Minkowski metric; only requires the tensorref function to be defined and that the vectors each have exactly 4 elements each. 
Function
MINKOWSKINORM
(vector) 
Function
MINKOWSKINORM2
(vector) 
Function
MAKELORENTZBOOST
(betavector)Construct lorentz boost matrix from beta vector 
Function
GAMMA
(beta)Returns gamma factor from beta 
Function
GAMMAFROMBETA2
(beta2)Computes gamma from beta^2, for efficiency purposes 
Function
LORENTZVECTORSPATIAL
(vector)Returns spatial part of the lorentzvector 
Function
FOURMOMENTUMBETAVECTOR
(fourmomentum)Returns the beta vector from the fourmomentum. Assumes that your units are chosen such that c is effectively 1 (e.g. GeV/c^2 for mass, GeV/c for momentum, etc.) 
Function
LORENTZPHI
(lorentzvector) 
Function
LORENTZTHETA
(lorentzvector)
clana.macroutils
Basic macro utilities
CLANA.MACROUTILS

Macro
DEFPLURAL
(fname)Defines a function which maps the function with symbol fname across a list. The defined function has as its symbol fname with a trailing s character appended. 
Macro
MAPBIND
(fn symbols &body body)Binds each symbol in symbols to the value of (funcall fn symbol) and executes body inside of this lexical scope. 
Macro
ABBREV
(short long)Defines abbreviated operator with name short expanding to a call to long. 
Macro
ABBREVS
(&rest names)Defines multiple abbreviations simultaneously. Arguments are interpreted as: (abbrevs short1 long1 short2 long2 ...) 
Macro
DBIND
(&rest args) 
Macro
MVBIND
(&rest args) 
Macro
MVSETQ
(&rest args) 
Macro
FVBIND
(&rest args) 
Macro
POLL
(test wait &body body)Repeatedly executes test form; if test returns true, executes body; otherwise waits for wait seconds and tries again. Returns last form in body. 
Macro
INRANGE
(xlo op1 x op2 xhi &key (prec 0)) 
Macro
CASEEQUAL
(form &body cases) 
Macro
CONDSETF
(place value &optional (condition t))Only sets the place when the condition is met. condition may be one of three values: :place, :value, or :both. :place specifies that the place must evaluate to a nonnil value, :value specifies that the value must evaluate to a nonnil value, and :both specifies that both place and value must evaluate to nonnil values. 
Macro
PRINTEVAL
(arg) 
Macro
WITHDEFAULTARGS
(fn (&rest argbindings) &body body)Executes body with default argument values supplied to fn in a convenient way. fn is either the name of a function or a list (function localname); fn is defined via flet and takes no arguments, but refers to the arguments in argbindings. argbindings are used analogously to let. Example: (withdefaultargs (list fn) ((x 3)) (fn)) yields (3). More useful examples would involve conditionally setting argument values in the body. 
Macro
WHENKEYWORDS
(&body keywordargspecs)Creates a plist containing the keyword arguments only when the values are nonnil; if a keywordargspec is a list, then the first element is taken to be the field symbol and the second element the expression to be passed as the value. 
Macro
DEFUNWITHSETF
(fname (&rest lambdalist) &body body)Defines function along with setfable version when body is a single expression; throws error otherwise. This is limited to cases where the expression is already understandable to setf. 
Function
SYMB
(&rest args) 
Macro
ALAMBDA
(parms &body body) 
Macro
AIF
(test then &optional else) 
Macro
AWHEN
(test &body body) 
Macro
TIMEPROC
(&body body)Times the execution of body and returns multiple values: 1. Real time in seconds, 2. Run time in seconds, and the rest being the return values of body. 
Function
LAMBDALISTCALLFORM
(fname lambdalist)Returns the appropriate lambdalist call form for a function named fname and a lambdalist given by lambdalist. Macros are more difficult since lambda lists can have nested structure, so I'm only considering function lambda lists for now. This still works for macros which have this limited sort of lambda list however. One issue that is not currently resolved is supplying arguments which have a suppliedp argument. Functions can be handled, but not in the same way as macros (since apply does not work). Also: &rest is handled only for functions becuause, again, there is no practical way to use this method for macros. 
Macro
SUPPRESSOUTPUT
(&body body)suppressoutput redirects all output to /dev/null, thus silencing any messages printed to *standardoutput*. 
Macro
KLAMBDA
((&rest keyargs) &body body)Modified lambda which returns a keyword argaccepting function with &allowotherkeys 
Macro
OLET
((&rest bindings) &body body)olet (at the moment) functions much like let*, except that each binding is only evaluated once at most, and not at all if the lexical binding is never used in the body. This can result in a tremendous speedup when used in creating context, e.g. looping over a table but only needing a few fields from the table. In test cases the compiler appeared to remove unused bindings entirely thanks to the symbolmacrolet. 
Macro
DLAMBDA
(&rest ds)
clana.makeres
clana.makeresblock
clana.makeresbranch
clana.makeresgraphviz
clana.makeresmacro
clana.makeresprogress
clana.makerestable
clana.makeresutils
clana.map
Defines generic functions for working with/converting things which behave like maps (in the mathematical sense), e.g. hash tables, alists, etc.
CLANA.MAP

GenericFunction
MAP>ALIST
(object)Returns the values of a datasource as an alist mapping the independent value to the dependent one. Multidimensional independent variable data can be represented as a list of values. 
Method
MAP>ALIST
((obj hashtable)) 
Method
MAP>ALIST
((obj hashtable)) 
Method
MAP>ALIST
((obj hashtable)) 
Function
MAP>HASHTABLE
(object &optional test)
clana.mathfunctions
clana.memoization
Provides memoized functions (only compute for new arguments, otherwise lookup in a hash table)
CLANA.MEMOIZATION

Function
GETMEMOMAP
(memofn)Returns the memoized function's value hash table. 
Function
RESETMEMOMAP
(memofn)Resets the memoization hash table for memofn 
Macro
MEMOIZE
(fn &key (test 'equal))Macro for memoizing any function; test argument allows you to specify how arguments will be looked up. 
Macro
MEMOLET
(memofns &body body)A macro for defining mutually recursive memoized functions and executing body with knowledge of them. Cannot access the lookup tables via *memoizedmap* in the body, since this would prevent garbage collection of the memoized function hash tables. 
Function
UNMEMOIZE
(fn)Removes fn from the memoization lookup table; this prevents access to the lookup map from outside the function but allows the function to be garbage collected if necessary. 
Macro
DEFUNMEMOIZED
(functionname arglist &body body)Macro for defining a memoized function. Note that currently there is a small inconvenience in that lambdalists are not automatically added to the documentation used by things like SLIME.
clana.ntupletable
clana.packageutils
Provides various utilities for using packages as well as the abstraction of a package group
CLANA.PACKAGEUTILS

Function
SHADOWINGUSEPACKAGE
(frompackage &optional topackage)shadowingimports all the exported symbols from gmath into the current package 
Function
ADDPACKAGETOGROUP
(package group)Adds the package to the package group given by group. 
Macro
DEFPACKAGEINGROUP
(packagename group &body packagebody)Defines a package while placing this package into the group specified by group. group can technically be any object, but I like to stick to keyword symbols. Any package statements can be used in the packagebody portion. 
Function
USEPACKAGEGROUP
(group &optional destpackage)Calls shadowingusepackage on each package in group and either the current package or destpackage.
clana.pathnameutils
Utilities for working with pathnames
CLANA.PATHNAMEUTILS

Function
PATHNAMEABSOLUTEP
(pathnameorstring) 
Function
PATHNAMERELATIVEP
(pathnameorstring) 
Function
>ABSOLUTEPATHNAME
(pathnameorstring) 
Function
DIRECTORYPATHNAMEP
(pathnameorstring)Returns t iff pathnameorstring refers to a directory 
Function
MKDIRPATH
(pathnameorstring)Returns a path which always refers to a directory (platform independent) 
Function
BASENAME
(pathname)Returns basename of pathname; pathnamename strips the extension while this utility function preserves it.
clana.plotting
clana.quantity
clana.reusabletable
Table wrapper for reading which automatically reloads table for reading after fully reading the contents (not guarranteed by the raw table types).
CLANA.REUSABLETABLE

Class
REUSABLETABLE

CREATIONFN
Accessor:REUSABLETABLECREATIONFN
 Function which creates the table being wrapped.

CREATIONFNFORM
Accessor:REUSABLETABLEOPENERFORM
 Lisp form which returns the table opener function when evaluated. A table opener An optional field which assists in serializing reusable tables.

RAWTABLE
Accessor:INTERNALTABLE
 The table which is being wrapped.

NEEDSRELOADING
Accessor:REUSABLETABLENEEDSRELOADING
 Boolean which tells the wrapper when it needs to close and reopen the table.


Function
MAKEREUSABLETABLE
(creationfn &optional openerform)Returns result of creationfn if reusabletable, else returns reusabletable which will make use of creationfn to generate new copies when needed. 
Macro
WRAPFORREUSE
(tablecreationform &optional openerform)Creates a reusable (when tablecreationfrom does not return a reusabletable) table which places the tablecreationform into a closure which will be evaluated each time the table gets reread from the beginning. If the creation form returns a reusabletable, simply returns the table.
clana.serialization
clana.statistics
clana.stringutils
String utilities not already provided by Alexandria
CLANA.STRINGUTILS

Function
LISPIFY
(symbolorstring)Converts symbol or string into a string and replaces all spaces and underscores with , and convert to uppercase. 
Function
STRINGAPPEND
(&rest strings) 
Function
LINES
(string)Splits a string into a list of the lines comprising the string. 
Function
UNLINES
(lines &optional (trailingnewlinep t))Joins a list of lines into original string, with optional trailing newline. 
Function
WORDS
(string)Returns the read words (symbols, numbers, etc.) contained in a string 
Function
MKSTR
(&rest args)
clana.symbolutils
Basic utilities for working with symbols
CLANA.SYMBOLUTILS

Function
KEYWORDIFY
(symbolorstring)Returns the keyword version of a symbol or string. 
Function
KEYSYMB
(args)Returns a keyword symbol formed by symbol versions of each element in args interspersed with hyphens (). 
Macro
KEYSYMBQ
(&rest args)Convenient macro for using keysymb; quotes the list of args and passes it to keysymb.
clana.table
Table class; provides basic necessary interface for working with sets of data.
CLANA.TABLE

Class
TABLE

FIELDNAMES
Accessor:TABLEFIELDNAMES
 List of field names.

ACCESSMODE
Accessor:TABLEACCESSMODE
 :write for a writable table, :read for a readable table, and :both for a table which has no restriction on being written to or read from only. nil for a table which is not open.


Function
TABLEOPENP
(table) 
Function
TABLEFIELDSYMBOLS
(table) 
GenericFunction
TABLELOADNEXTROW
(table)Loads the next row into the current row buffer. Returns nil if the next row does not exist/there is a read failure (which can be the same thing), nonnil otherwise. 
GenericFunction
TABLEACTIVATEFIELDS
(table fieldnames)Function for optimization based on which fields are to be read from the table; default method is to do nothing which works when these optimizations do nothing for a particular table type. 
Method
TABLEACTIVATEFIELDS
(table fieldnames) 
Method
TABLEACTIVATEFIELDS
(table fieldnames) 
Method
TABLEACTIVATEFIELDS
(table fieldnames) 
GenericFunction
TABLEGETFIELD
(table fieldsymbol)Gets the field datum from the current row for field denoted by the fieldsymbol 
GenericFunction
TABLESETFIELD
(table fieldsymbol value)Sets the field value of the current output row 
GenericFunction
TABLECOMMITROW
(table)Commits (writes) the current output row to the table 
Macro
TABLEPUSHFIELDS
(table &body fieldspecs)Sets fields and commits row of table using fieldspecs. Each fieldspec is either a symbol which represents both the fieldsymbol and the variable storing the field data. 
GenericFunction
TABLECLOSE
(table)Close any open files, etc. 
Method
TABLECLOSE
(table) 
Method
TABLECLOSE
((tab table)) 
GenericFunction
TABLENROWS
(table)When available, returns the number of rows stored in the table, otherwise returns nil. 
Method
TABLENROWS
(table) 
Method
TABLENROWS
(table) 
Method
TABLENROWS
(table) 
Function
TABLEREDUCE
(table fields fn &key initialvalue)tablereduce mimics reduce but with the modification that fn should take one more argument than the number of fields specified with the first argument used to store the state as fn is called across the table. tablereduce can be used as a functional/nonmacro solution to looping over the table. fields is a list of field names/symbols. They will be passed in the order specified to fn. fn is function taking the computation state as the first argument and then each selected field as an argument in the order given in fields; can use the state argument to collect a list of values for example. 
Macro
DOTABLE
((rowvar table) fieldselections &body body)Macro for iterating over a table. rowvar is a symbol which will be bound to the row number inside the loop body. You can optionally use a list (rowtype rowvar) which will allow for the rowvar to have a type declared for it. table is the table which will be looped upon. To select specific fields from the table for reading, specify all the desired field names in fieldselections; if fieldselections is nil then all fields will be read. Note that it is still more efficient to specify all desired fields; for two field data this results in about a 16% running time difference. Also you must specify either none or all of the desired fields to work with during the loop body. Each fieldselection is a list of 1. field names to access during the loop, by default the value will be bound to the lispified field name as a symbol, 2. A list containing a symbol as the first element and the field name as the second which will be bound to the symbol given as the first element of the list. The code body will be run for each row in the table. If fields are explicitly selected, then you can use declare statements at the beginning of the loop body; otherwise this is not supported. 
Function
OPENTABLECHAIN
(creationfunctions)Creates a chain of tables by running the appropriate creationfunction when the previous table fails on tableloadnextrow. Each creation function should be a function taking zero arguments and returning a table. 
Function
RESETTABLECHAIN
(tablechain)Resets the table counter in the chain so that it can be reread. 
Method
TABLELOADNEXTROW
((table tablechain)) 
Method
TABLEGETFIELD
((table tablechain) fieldsymbol) 
Function
OPENPLISTTABLE
(plists) 
Method
TABLELOADNEXTROW
((table plisttable)) 
Method
TABLEGETFIELD
((table plisttable) fieldsymbol) 
Method
TABLECLOSE
((table plisttable)) 
Function
CREATEPLISTTABLE
(fieldnames) 
Method
TABLESETFIELD
((tab plisttable) fieldsymbol value) 
Method
TABLECOMMITROW
((tab plisttable)) 
Method
TABLENROWS
((tab plisttable))
clana.tableutils
Utilities for working with tables
CLANA.TABLEUTILS

Function
TABLE>PLISTS
(table &key fieldnames (reversep t))Returns a list of plists containing the field values you specify. Only do this for tables that will reasonably fit into memory. If no fieldnames are specified, then all fields will be present in the result. Note that the resulting plists will occur in the reverse order as they occur in the table for efficiency. 
Function
TABLEROW>PLIST
(table fieldnames)Reads the current row from table and generates a plist containing the field values of each fieldname in the row. 
Function
TABLECOPY
(from to &optional fields)Reads all entries from from and writes them to to. If fields are specified, only selected fields are used, otherwise all fields are copied.
clana.tableviewing
clana.tensor
tensor provides utilities for treating nested sequences as multidimensional arrays; integration into the generic math framework yields MATLAB/GNU Octavestyle functionality with arrays, lists, etc.
CLANA.TENSOR

Function
SEQUENCEP
(x) 
Function
MAKETENSOR
(dimensionlist &key (type 'vector) (initialelement 0.0d0))Creates a tensor with each dimension in dimensionlist denoting the length of the sequence at that dimension with the type of the sequences given by the optional type argument. 
Function
FUNCTION>TENSOR
(dimensionlist fn &key (type 'vector)) 
Function
TENSORREF
(tensor &rest subscripts)References tensor via subscripts 
Function
TREF
(tensor &rest subscripts)Abbreviation for tensorref; setfable. 
Function
TENSORFLATREF
(tensor subscript)References tensor by single subscript; done in such a way to mimick the way multidimensional arrays are stored in memory by e.g. C. Assumes rectangular tensor. 
Function
TFREF
(tensor subscript)Abbreviation for tensorflatref; setfable. 
Function
(setf TENSORFLATREF)
(value tensor subscript) 
Function
(setf TFREF)
(value tensor subscript) 
Function
(setf TENSORREF)
(value tensor &rest subscripts) 
Function
(setf TREF)
(value tensor &rest subscripts) 
Function
TENSORRANK
(tensor) 
Function
TENSORDIMENSIONS
(tensor)Returns a list of the sizes of the tensor for each dimension. 
Function
TENSORMAP
(fn &rest xs)Maps fn across xs for arbitrarily deep sequences. Treats nonsequences as sequences of arbitrary depth. 
Function
TENSOR+
(&rest xs)Convenient nickname for mapping + over tensors. 
Function
TENSOR
(&rest xs)Convenient nickname for mapping  over tensors. 
Function
TENSOR*
(&rest xs)Convenient nickname for mapping * over tensors. 
Function
TENSOR/
(&rest xs)Convenient nickname for mapping / over tensors. 
Function
TENSORCONTRACT
(tensorindexpairs &key (type 'vector))Contracts each tensor along the dimension specified by the specified index, resulting in a tensor of recursively rectangular sequences of type type. Each tensorindexpair is a cons with the car being the tensor to contract and the cdr being the index denoting the dimension to contract along for this tensor. It is just the mathematical notion of tensor contraction. Example: multiplying matrices: A . B ==> (tensorcontract (list (cons A 1) (cons B 0))) In words, contract tensors A and B along the second index of A and the first index of B.
clana.typedtable
Table types which have typed columns. Provides automatic conversion between foreign and LISP objects.
CLANA.TYPEDTABLE

Class
TYPEDTABLE
(TABLE
)
FIELDSPECS
Accessor:TABLEFIELDSPECS
 list of typespecs, one per field

ROWCSTRUCT
Accessor:TYPEDTABLEROWCSTRUCT
 CFFI cstruct type designator for the row object

ROWPOINTER
Accessor:TYPEDTABLEROWPOINTER
 pointer to foreign object storing current row information.

LISP>CCONVERTERMAP
Accessor:TYPEDTABLELISP>CCONVERTERMAP
 Hash table which maps the field symbols to the lisp>c converter function for corresponding field.

C>LISPCONVERTERMAP
Accessor:TYPEDTABLEC>LISPCONVERTERMAP
 Hash table which maps the field symbols to the c>lisp converter function for corresponding field.


Function
TYPESPEC>FIELDNAMES
(compoundtypespec)Returns field names from the compound type designation. 
Function
TYPESPEC>FIELDSPECS
(compoundtypespec)Returns field typespecs from the compound type designation. 
Function
TYPEDTABLE>TYPESPEC
(table)Creates a typespec from the table
clana.typespec
typespec provides a mechanism for referring to foreign or LISP datatypes as well as utilities for conversion between the two.
CLANA.TYPESPEC

Function
TYPESPEC>CFFITYPE
(&rest xs3) 
Function
TYPESPECCOMPOUNDP
(typespec)Tests a typespec for being a compound typespec. 
Function
TYPESPECCOMPOUNDFIELDALIST
(typespec)Returns the alist mapping field name to typespec. 
Function
TYPESPECCOMPOUNDFIELDNAMES
(typespec)Returns the field names for the compound type. 
Function
TYPESPECCOMPOUNDFIELDSPECS
(typespec)Returns the typespecs for the fields in the compound type. 
Function
TYPESPECARRAYP
(typespec)Tests a typespec for being an array typespec. 
Function
TYPESPECARRAYELEMENTTYPE
(typespec)Returns the element type for the array type. 
Function
TYPESPECARRAYDIMLIST
(typespec)Returns the list of dimension sizes for the array type. 
Function
TYPESPECARRAYRANK
(typespec)Returns the number of dimensions (rank) of the array type. 
Function
TYPESPECARRAYSIZE
(typespec)Returns the total number of elements in the array type. 
Function
TYPESPECFLATTENARRAYS
(typespec)Flattens an array typespec if typespec is an array typespec, otherwise returns typespec unchanged. Note that this operation is recursive, in that if there are arrays in the typespec(s) of the component type(s), then they are flattened as well. 
Function
TYPESPECFOREIGNALLOC
(typespec &optional (count 1))Allocates space for count foreign objects of type specified by typespec. 
Function
TYPESPEC>LISPTOC
(typespec)Returns a function which takes 1. a lisp object, 2. a corresponding C pointer and sets the fields/values of the C object recursively. The pointer to the Cobject is returned. 
Function
TYPESPEC>CTOLISP
(typespec)Returns a function which takes a cpointer argument and returns a lisp object containing the converted values. 
Function
CHARVECTOR>STRING
(charvector &optional length)Returns a string version of a vector of integers interpreted as the numerical codes for characters. If argument length is given, the result contains only the first length characters, or if length is longer than the charvector, the charvector interpreted into a string as if length were not given.