Commit 63fa8e0a authored by Liam M. Healy's avatar Liam M. Healy

Foreign arrays obey *print-length*

parent afc6fb36
;; Format numerical output for grids and sequences
;; Liam Healy Wed Dec 11 2002 - 16:37
;; Time-stamp: <2014-01-14 22:27:36EST format-output.lisp>
;; Time-stamp: <2015-04-26 22:45:46EDT format-output.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy
;; Copyright 2011, 2013, 2014, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;; This program is free software: you can redistribute it and/or modify
......@@ -97,7 +97,9 @@
"Format the one dimensional grid."
;; Note: cannot handle lists yet.
;; This is called from nf-grid, called only when :vector-format is :coordinate-unit-vectors.
(dotimes (i (grid:dim0 object))
(dotimes (i (if (numberp *print-length*)
(min *print-length* (grid:dim0 object))
(grid:dim0 object)))
;; iterate formatting each element
;; If formatting as a linear combination with element labels,
......@@ -121,7 +123,12 @@
(:coordinate-unit-vectors (vector-component-names i))
(:vertical #\newline)
(:horizontal #\space))))
(when (and (numberp *print-length*) (cl:> (grid:dim0 object) *print-length*))
(if texstyle
(princ "\\dots" stream)
(princ "..." stream)))
(defun parenstyle (outer)
"Parentheses should be used in this case."
......@@ -137,13 +144,15 @@
(case (nf-option :vector-format)
(:vertical (grid:aref object i))
(:horizontal (grid:aref object j))))))
(let ((dim1 (or (grid:dim1 object)
(if (eq (nf-option :vector-format) :vertical)
(grid:dim0 object))))
(dim0 (if (or (grid:dim1 object) (eq (nf-option :vector-format) :vertical))
(grid:dim0 object)
(let* ((dim1n (or (grid:dim1 object)
(if (eq (nf-option :vector-format) :vertical)
(grid:dim0 object))))
(dim0n (if (or (grid:dim1 object) (eq (nf-option :vector-format) :vertical))
(grid:dim0 object)
(dim0 (if (numberp *print-length*) (min dim0n *print-length*) dim0n))
(dim1 (if (numberp *print-length*) (min dim1n *print-length*) dim1n)))
(when texstyle
(format stream "\\left[\\begin{array}{~a}~&"
(if (nf-option :tex-decimal-align)
......@@ -168,6 +177,10 @@
(if texstyle
(princ (nf-option :tex-element-separator) stream)
(princ (nf-option :vertical-element-separator) stream))))
(when (and (numberp *print-length*) (or (> dim0n *print-length*) (> dim1n *print-length*)))
(if texstyle
(princ "\\dots" stream)
(princ "..." stream)))
;; close out TeX array
(when texstyle (format stream "~&\\end{array}\\right]"))
(when (parenstyle t) (princ #\) stream)))) ; close paren for whole array
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