diff --git a/grid/types.lisp b/grid/types.lisp
new file mode 100644
index 0000000000000000000000000000000000000000..bd5c72f813e64abd1ea4d5682aa40a8d8ea176a6
--- /dev/null
+++ b/grid/types.lisp
@@ -0,0 +1,153 @@
+;; Number types used by GSL functions, and specification conversion
+;; Liam Healy 2008-12-31 21:06:34EST types.lisp
+;; Time-stamp: <2009-12-06 10:55:10EST types.lisp>
+;; $Id: $
+
+(in-package :gsl)
+
+;;;;****************************************************************************
+;;;; Unsigned address types size_t
+;;;;****************************************************************************
+
+(case (cffi:foreign-type-size :long)
+  (8
+   (push :int64 *features*)
+   #+fsbv (fsbv:defsynonym sizet :uint64))
+  (4
+   (push :int32 *features*)
+   #+fsbv (fsbv:defsynonym sizet :uint32)))
+
+;;;;****************************************************************************
+;;;; Type specification conversion
+;;;;****************************************************************************
+
+;; cffi-features:no-long-long doesn't work for me, but ought to be checked? 
+
+;;; The different element type forms:
+;;; C standard full, or "CFFI"  :unsigned-char
+;;; GSL splice name             "uchar"
+;;; C explicit                  :uint8     (not used here)
+;;; CL                          '(unsigned-byte 8)
+;;; Single                      'unsigned-byte-8 
+
+;;; Functions to perform conversions
+;;; CL -> single in function #'cl-single
+;;; CL -> CFFI (Cstd) in function #'cl-cffi
+;;; CFFI (Cstd) -> CL in function #'cffi-cl
+
+;;; Sources of equivalence
+;;; Cstd -> CL in alist *cstd-cl-type-mapping*
+
+;;; :long-double may be pushed onto *features* if
+;;; the implementation supports long doubles in CFFI.
+
+;;;;****************************************************************************
+;;;; Basic definition
+;;;;****************************************************************************
+
+;;; Preliminary definitions.  These are not used directly outside this
+;;; file; they exist to define the two variables
+;;; *cstd-cl-type-mapping* and *cstd-gsl-mapping* which are used by
+;;; the conversion functions.
+
+(defparameter *cstd-integer-types*
+  '(:char :unsigned-char
+    :short :unsigned-short
+    :int :unsigned-int
+    :long :unsigned-long
+    #+int64
+    :long-long
+    #+int64
+    :unsigned-long-long)
+  ;; http://common-lisp.net/project/cffi/manual/html_node/Built_002dIn-Types.html
+  "List of integer types supported by CFFI, from the CFFI docs.")
+
+(defparameter *fp-type-mapping*
+  '((:float . single-float) (:double . double-float)
+    ;; For those implementations that support a separate long-double
+    ;; type assume this mapping:
+    #+long-double (:long-double . long-float)
+    (complex-float-c . (complex single-float))
+    (complex-double-c . (complex double-float))
+    ;; For those implementations that support a separate long-double
+    ;; type assume this mapping:
+    #+long-double
+    (complex-long-double-c . (complex long-float)))
+  ;; Ordered by: real shortest to longest, then complex shortest to longest.
+  "List of floating point types supported by CFFI from the CFFI docs
+   plus corresponding complex types.")
+
+;;; Mapping alists used by conversion functions.
+
+;;; Used by #'cl-gsl
+(defparameter *cstd-cl-type-mapping*
+  (append
+   *fp-type-mapping*
+   (mapcar
+    (lambda (type)
+      (cons
+       type
+       (list
+	(if (string-equal type "uns" :end1 3)
+	    'unsigned-byte
+	    'signed-byte)
+	(* 8 (cffi:foreign-type-size type)))))
+    *cstd-integer-types*))
+  ;; Be careful when reverse associating, as there may be several C
+  ;; types that map to a single CL type.
+  "An alist of the C standard types as keywords, and the CL type
+   The exception is complex types, which don't have a definition
+   in the C standard; in that case, the C type is the GSL struct
+   definition.")
+
+(defmacro floating-point-association (splice-list)
+  `(mapcar
+   #'cons
+   (mapcar #'first *fp-type-mapping*)
+   (subseq ,splice-list 0 (length *fp-type-mapping*))))
+
+(defparameter *blas-splice-fp-types*
+  ;; Ordered by: real shortest to longest, then complex shortest to longest.
+  ;; Must match *fp-type-mapping*.
+  '("s" "d" #+long-double nil
+    "c" "z" #+long-double nil)
+  "The list of floating point types that can be spliced into BLAS function names.")
+
+(defparameter *cstd-blas-mapping*
+  ;; The floating types are associated by order, so it is important that
+  ;; order of *fp-type-mapping* and *blas-splice-fp-types* match,
+  ;; though the latter may be longer.
+  (floating-point-association *blas-splice-fp-types*)
+  "Mapping the C standard types to the BLAS splice name.")
+
+;;;;****************************************************************************
+;;;; Conversions
+;;;;****************************************************************************
+
+(defun all-types (alist &optional right-side)
+  "A list of all types defined by symbol or definition."
+  (mapcar (if right-side #'rest #'first) alist))
+
+(defun lookup-type (symbol alist &optional reverse)
+  "Lookup the symbol defined in the alist."
+  (or 
+   (if reverse
+       (first (rassoc symbol alist :test #'equal))
+       (rest (assoc symbol alist)))
+   ;;(error "Did not find ~a in ~a" symbol (mapcar #'first alist))
+   ))
+
+(defun cl-cffi (cl-type)
+  "The CFFI element type from the CL type."
+  (lookup-type (clean-type cl-type) *cstd-cl-type-mapping* t))
+
+(defun cffi-cl (cffi-type)
+  "The CL type from the CFFI element type."
+  (unless (eq cffi-type :pointer)
+    (lookup-type cffi-type *cstd-cl-type-mapping*)))
+
+;;; For future use
+(defparameter *cl-numeric-classes* '(ratio integer rational float real complex number))
+(defun number-class (type)
+  "Find the class corresponding to the numeric type."
+  (find-if (lambda (class) (subtypep type class)) *cl-numeric-classes*))