Commit 6279d898 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Define *nf-t-hook*, load grid/format-output.lisp

Format (nf) grids in the T method of #'nf by using newly defined
*nf-t-hook*. If grid is not loaded, this variable is nil; once grid is
loaded, then it tells the method to call nf-grid on the object if it's
a grid. All tests pass on several combinations of system loads.
parent 363580ca
......@@ -3,10 +3,11 @@ Antik: a Common Lisp library for computational mathematics, science, and enginee
Antik defines library functions for common mathematical operations used in science and engineering including arrays and physical (dimensioned) quantities. It is expressly designed to facilitate the interchange of data with foreign (that is, non-lisp) libraries. For example, GSLL, the GNU Scientific Library for Lisp, uses Antik.
There are several systems that comprise Antik and included in this repository:
1) grid, generalized arrays
2) foreign-array, grids whose content is in foreign memory
3) input-output, getting data into and out of CL calculation sets
4) physical-dimension, quantities with physical properties (e.g., mass, length) and relationships
5) mathematics, various definitions for applied mathematics
- antik-base, formatting (numbers, etc.)
- grid, generalized arrays
- foreign-array, grids whose content is in foreign memory
- physical-dimension, quantities with physical properties (e.g., mass, length) and relationships
- mathematics, various definitions for applied mathematics
- date-time, manipulation and computation with dates and times
In addition, there are other systems used internally.
;; Antik system definition
;; Liam Healy 2010-12-24 09:43:28EST antik.asd
;; Time-stamp: <2014-01-08 23:13:23EST grid.asd>
;; Time-stamp: <2014-01-14 22:42:51EST grid.asd>
;; Copyright 2011, 2012, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -50,6 +50,7 @@
(:file "mathematics" :depends-on ("map"))
(:file "index-functions")
(:file "indexed" :depends-on ("specification"))
(:file "format-output")
(:file "parameters")))))
(asdf:defsystem-connection #:grid-tests
......
;; Format numerical output for grids and sequences
;; Liam Healy Wed Dec 11 2002 - 16:37
;; Time-stamp: <2014-01-08 22:56:50EST format-output.lisp>
;; Time-stamp: <2014-01-14 22:27:36EST format-output.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -90,6 +90,9 @@
stream)
object)
;;; Set the hook in the T method for #'nf so that the nf-grid is called if the argument is a grid.
(setf *nf-t-hook* (list 'grid:grid #'nf-grid))
(defun nf-vector (object &optional (stream *standard-output*))
"Format the one dimensional grid."
;; Note: cannot handle lists yet.
......
;; Format numerical output
;; Liam Healy Wed Dec 11 2002 - 16:37
;; Time-stamp: <2014-01-08 23:04:11EST format-output.lisp>
;; Time-stamp: <2014-01-14 22:47:00EST format-output.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -64,10 +64,15 @@
(defmacro princn (object stream)
`(if ,stream (princ ,object ,stream) ,object))
(defvar *nf-t-hook* nil
"A list of a type and function, or nil. If an object passed to nf is of the type in the first element of the list, then the function in the second element is called on the object and the stream.")
(defgeneric nf (object &optional stream)
(:documentation "Format output for numerical objects. If stream is nil, use *standard-output*.")
(:documentation "Format output for numerical objects. Default stream is *standard-output*.")
(:method ((object t) &optional (stream *standard-output*))
(princ object stream)))
(if (and *nf-t-hook* (typep object (first *nf-t-hook*)))
(funcall (second *nf-t-hook*) object stream)
(princ object stream))))
(defun nf-string (object)
"Format output for numerical objects to a new string."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment