id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
33,259 | prompt-selections.lsp | rwoldford_Quail/source/views/prompt-plot/prompt-selections.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; prompt-selections.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1994 George Washington University
;;;
(in-package :vw)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(selected-view-window top-view top-views batch-plot-cases
prompt-plot-args
selected-dataset link-selected-views unlink-selected-views list-plot-cases)))
(defun selected-view-window ()
(let ((w (first (wb::canvases))))
(if (and (wb:at-top-p w) (typep w 'view-window))
w)))
(defun top-views()
(let* (( c (selected-view-window))
(vw (if c (viewports-and-views-of c))))
(if vw (mapcar #'cdr vw))))
(defun all-views()
(loop for c in (wb::canvases)
when (typep c 'view-window)
append (mapcar #'cdr (viewports-and-views-of c))))
(defun top-view()
(car (top-views)))
(defun selected-dataset (plots)
(let ((p (or (loop for p in plots
thereis (and (typep p 'plot) (dataset-p (viewed-object-of p)) p))
(loop for p in plots
thereis (and (dataset-p (viewed-object-of p)) p)))))
(if p
(viewed-object-of p))))
(defun current-dataset()
(declare (special *current-dataset*))
(or (selected-dataset (top-views))
*current-dataset*))
(defun link-selected-views(&rest views)
(let ((v (or views (top-views) (all-views))))
(if v
(if (loop for vi in v
thereis (has-highlit-subviews? vi))
(apply #'link-highlit-views v)
(apply #'link-views v)))))
(defun unlink-top-views(&rest views)
(let ((v (or views (top-views) (all-views))))
(if v
(if (loop for vi in v
thereis (has-highlit-subviews? vi))
(apply #'unlink-highlit-views v)
(apply #'unlink-views v)))))
(defun list-plot-cases(plots &key (highlit?) )
(if plots
(let* ((sub-list
(cond (highlit?
(find-highlit-cases plots))
(t
(find-cases plots)))))
(values-list sub-list))))
;;---------------------------------------------------------------------------
(defmethod find-cases((self view))
(let ((vo (viewed-object-of self)))
(if (list-of-datasets-p vo)
(list vo nil)
(list (list vo) (list self)))))
(defmethod find-highlit-cases((self view))
(let ((vo (viewed-object-of self)))
(if (list-of-datasets-p vo)
(cond ((and (typep self 'multiple-draw-style-mixin)
(= (length vo) (length (drawing-styles-of self))))
(list (loop for d in (drawing-styles-of self)
for e in vo
when (draw-style d :highlight?)
collect e)))
((any-highlight? self)
(list (list vo) nil))
(t nil))
(when (any-highlight? self)
(list (list vo) (list self) )))))
(defmethod find-cases((view one-per-case-mixin))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
for status in (case-status-of view)
unless (ignore-status-p status)
collect vo into vos and
collect s into views
finally (return (list vos views))))
(defmethod find-highlit-cases((view one-per-case-mixin))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
for status in (case-status-of view)
unless (ignore-status-p status)
when (any-highlight? s)
collect vo into vos and
collect s into views
finally (return (list vos views))))
(defmethod find-cases((view case-display-list))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
collect vo into vos
finally (return (list vos nil))))
(defmethod find-highlit-cases((view case-display-list))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
when (any-highlight? s)
collect vo into vos
finally (return (list vos ))))
(defmethod find-cases((view d-view))
(loop for vo in (cases-of view)
for status in (case-status-of view)
unless (ignore-status-p status)
collect vo into vos
finally (return (if vos (list vos)))))
(defmethod find-highlit-cases((view d-view))
(loop with vos
for s in (sub-views-of view)
for vo = (viewed-object-of s)
when (list-of-datasets-p vo) do
(cond ((and (typep s 'multiple-draw-style-mixin)
(= (length vo) (length (drawing-styles-of s))))
(loop for d in (drawing-styles-of s)
for e in vo
when (draw-style d :highlight?)
do (push e vos)))
((any-highlight? s)
(setq vos (append vo vos)))
(t nil))
else do
(when (any-highlight? s)
(push vo vos ))
finally (return (if vos (list (nreverse vos) nil)))))
(defmethod find-cases((view display-list))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
when (list-of-datasets-p vo)
append vo into vos
else
collect vo into vos
finally (return (if vos (list vos nil)))))
(defmethod find-highlit-cases((view display-list))
(loop with vos
for s in (sub-views-of view)
for vo = (viewed-object-of s)
when (list-of-datasets-p vo) do
(cond ((and (typep s 'multiple-draw-style-mixin)
(= (length vo) (length (drawing-styles-of s))))
(loop for d in (drawing-styles-of s)
for e in vo
when (draw-style d :highlight?)
do (push e vos)))
((any-highlight? s)
(setq vos (append vo vos)))
(t nil))
else do
(when (any-highlight? s)
(push vo vos ))
finally (return (if vos (list (nreverse vos) nil)))))
(defmethod find-cases((view plot))
(find-cases (interior-view-of view)))
(defmethod find-highlit-cases((view plot))
(find-highlit-cases (interior-view-of view)))
(defmethod find-highlit-cases((view compound-view))
(loop for v in (subviews-of view)
thereis (find-highlit-cases v)))
(defmethod find-cases((view compound-view))
(loop for v in (subviews-of view)
thereis (find-cases v)))
(defmethod find-highlit-cases((view pairs-layout))
(loop for v in (subviews-of view)
thereis (find-highlit-cases v)))
(defmethod find-cases((view pairs-layout))
(loop for v in (subviews-of view)
thereis (find-cases v)))
(defmethod find-cases((view view-layout))
(loop with answer
for v in (subviews-of view)
for cs = (find-cases v)
for c = (first cs)
for s = (second cs) when c do
(setq answer
(if s
(append answer (mapcar #'cons c s))
(append answer (mapcar #'list c))))
finally (setq answer (remove-duplicates answer :key #'first :test #'eq-dataset))
(return (loop for (x . y) in answer collect x into xs
when y collect y into ys
finally (return
(if (= (length xs) (length ys))
(list xs ys)
(list xs nil)))))))
(defmethod find-highlit-cases((view view-layout))
(loop with answer
for v in (subviews-of view)
for cs = (find-highlit-cases v)
for c = (first cs)
for s = (second cs) when c do
(setq answer
(if s
(append answer (mapcar #'cons c s))
(append answer (mapcar #'list c))))
finally (setq answer (remove-duplicates answer :key #'first :test #'eq-dataset))
(return (loop for (x . y) in answer collect x into xs
when y collect y into ys
finally (return
(if (= (length xs) (length ys))
(list xs ys)
(list xs nil)))))))
(defmethod find-cases((view table-layout))
(list
(loop for v in (subviews-of view)
append (list-viewed-elements v)) nil))
(defmethod find-highlit-cases((view table-layout))
(list
(loop for v in (subviews-of view)
append
(if (typep v 'bar)
(loop for e in (list-viewed-elements v)
for d in (drawing-styles-of v)
when ( draw-style d :highlight?)
collect e)
(car (find-highlit-cases v))))
nil))
(defmethod find-cases((view bar-chart))
(list
(loop for v in (subviews-of view)
append (list-viewed-elements v)) nil))
(defmethod find-highlit-cases((view bar-chart))
(list
(loop for v in (subviews-of view)
append
(if (typep v 'bar)
(loop for e in (list-viewed-elements v)
for d in (drawing-styles-of v)
when ( draw-style d :highlight?)
collect e)
(car (find-highlit-cases v))))
nil))
(defmethod find-cases((views list))
(loop with answer
for v in views
for cs = (find-cases v)
for c = (first cs)
for s = (second cs) when c do
(setq answer
(if s
(append answer (mapcar #'cons c s))
(append answer (mapcar #'list c))))
finally (setq answer (remove-duplicates answer :key #'first :test #'eq-dataset))
(return (loop for (x . y) in answer collect x into xs
when y collect y into ys
finally (return
(if (= (length xs) (length ys))
(list xs ys)
(list xs nil)))))))
(defmethod find-highlit-cases((views list))
(loop with answer
for v in views
for cs = (find-highlit-cases v)
for c = (first cs)
for s = (second cs) when c do
(setq answer
(if s
(append answer (mapcar #'cons c s))
(append answer (mapcar #'list c))))
finally (setq answer (remove-duplicates answer :key #'first :test #'eq-dataset))
(return (loop for (x . y) in answer collect x into xs
when y collect y into ys
finally (return
(if (= (length xs) (length ys))
(list xs ys)
(list xs nil)))))))
(defun batch-plot-cases(plots &key highlit?)
(let* ((subject-views (append (descendant-views-of-type plots 'd-view)
(descendant-views-of-type plots 'case-display-list)))
colors cases result dataset plot group-vals)
(if (setq plot
(loop for p in plots
thereis (and (dataset-p (viewed-object-of p)) p)))
(setq dataset (viewed-object-of plot)))
(if highlit?
(loop for view in subject-views
;; until cases
do
(if (typep view '(or one-per-case-mixin case-display-list))
(loop with status = (if (typep view 'd-view) (case-status-of view))
for s in (sub-views-of view)
for vo = (viewed-object-of s)
for i upfrom 0
unless (and status (ignore-status-p (elt status i)))
when (any-highlight? s)
do (push vo cases)
(push (draw-style s :color) colors))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
for i upfrom 0
when (list-of-datasets-p vo) do
(cond ((and (typep s 'multiple-draw-style-mixin)
(= (length vo) (length (drawing-styles-of s))))
(loop for d in (drawing-styles-of s)
for e in vo
when (draw-style d :highlight?)
do (push e cases) (push (draw-style d :color) colors)))
((and (typep s 'multiple-draw-style-mixin) (any-highlight? s))
(setq cases (append vo cases))
(setq colors
(append (loop for c in cases
collect (draw-style s :color :element c ))
colors)))
((and (typep s 'single-draw-style-mixin) (draw-style s :highlight?))
(push (draw-style s :color) colors)
(push (cons 'xxlist vo) cases))
(t nil))
else do
(when (any-highlight? s)
(push vo cases )
(push (draw-style s :color) colors)))))
(loop for view in subject-views
;; until cases
do
(if (typep view '(or one-per-case-mixin case-display-list))
(loop with status = (if (typep view 'd-view) (case-status-of view))
for s in (sub-views-of view)
for vo = (viewed-object-of s)
for i upfrom 0
unless (and status (ignore-status-p (elt status i))) do
(push vo cases)
(push (draw-style s :color) colors))
(loop for s in (sub-views-of view)
for vo = (viewed-object-of s)
for i upfrom 0
when (list-of-datasets-p vo) do
(cond ((and (typep s 'multiple-draw-style-mixin)
(= (length vo) (length (drawing-styles-of s))))
(loop for d in (drawing-styles-of s)
for e in vo
do (push e cases) (push (draw-style d :color) colors)))
((typep s 'multiple-draw-style-mixin)
(setq cases (append vo cases))
(setq colors
(append (loop for c in cases
collect (draw-style s :color :element c ))
colors)))
((typep s 'single-draw-style-mixin)
(push (draw-style s :color) colors)
(push (cons 'xxlist vo) cases))
)
else do
(push vo cases )
(push (draw-style s :color) colors)))))
(setq group-vals (remove-duplicates colors :test #'wb:eq-colors))
(setq result
(loop with groups = (make-list (length group-vals))
for case in cases
for col in colors
for p = (position col group-vals :test #'wb:eq-colors)
when p
do (if (and (listp case) (eql (car case) 'xxlist))
(nconc (elt groups p) (cdr case))
(push case (elt groups p)))
finally (return (loop for g in groups
collect (remove-duplicates g :test #'eq-dataset)))))
(values (if dataset
(loop for r in result
collect (make-data-subset dataset r))
result) (list group-vals))))
(defgeneric prompt-plot-args(dataset case-list &optional vars)
(:documentation "Used by prompted plots to transform cases. "))
(defgeneric prompt-plot-batches(dataset batches)
(:documentation "Used by prompted plots to transform batches."))
(defmethod prompt-plot-args((dataset t) case-list &optional vars)
(if (and (= (length case-list) 1)
(dataset-with-info-p (car case-list)))
(values (car case-list) (list-cases (car case-list)) vars)
(values dataset (if (list-of-datasets-p case-list) case-list) vars )))
(defmethod prompt-plot-batches((dataset t) batches)
(values dataset batches))
(defun dataset-with-info-p(d)
(and (dataset-p d)
(dataset-name d)
(list-variates d)))
| 17,591 | Common Lisp | .l | 388 | 30.536082 | 124 | 0.494996 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | f9fe08b731687b8ced0a4b2176af478c8a5ee2a00cfea4d01dd0f9073d6a1914 | 33,259 | [
-1
] |
33,260 | single-plot.lsp | rwoldford_Quail/source/views/prompt-plot/single-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; single-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1994 George Washington University
;;;
(in-package :vw)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(single-plot *default-2d-plot* *default-1d-plot*
*AUTO-SHARE-CASE-VIEWS?*)))
(defvar *default-2d-plot* 'scatterplot)
(defvar *default-1d-plot* 'histogram)
(defvar *AUTO-SHARE-CASE-VIEWS?* t)
(setq *AUTO-SHARE-CASE-VIEWS?* t)
(defgeneric single-plot-by-dim (dim
&key
plot-fn
dataset cases
vars args)
(:documentation "A generic function to be called by single-plot that ~
allows dispatching by dimension dim. dim must be an integer."))
(defmethod single-plot-by-dim ((dim (eql 0))
&key
plot-fn
dataset cases
vars args)
(declare (ignore args vars plot-fn))
(let* ((plot (car (wb:prompt-for-items (list "Case Display" "Variate Display")))))
(if (string-equal plot "Variate Display")
(variate-display-list :data dataset :draw? t)
(case-display-list :data dataset :cases cases :draw? t))))
(defmethod single-plot-by-dim ((dim (eql 1))
&key
plot-fn
dataset cases
vars args)
(declare (ignore dataset cases))
(let ((var (or (first vars) :prompt)))
(cond ((eq plot-fn #'bar-plot)
(apply #'bar-plot :by var args))
(plot-fn (apply plot-fn :var var args))
(t (apply #'1d-plot :var var :interior-view :prompt args)))))
(defmethod single-plot-by-dim ((dim (eql 2))
&key
plot-fn
dataset cases
vars args)
(declare (ignore dataset cases))
(let (plot
(x (or (first vars) :prompt))
(y (or (second vars) :prompt)))
(if plot-fn
(apply plot-fn :x x :y y args )
(progn
(setq plot (car (wb:prompt-for-items (list "2d-plot" "Side by side"))))
(cond ((string-equal plot "Side by side")
(if (wb:prompt-true-or-false "Common scale?")
(apply #'1d-layout-plot :vars (or vars :prompt) args )
(apply #'1d-layout-plot :left-view nil :link-bounds-x? nil
:bottom-view nil :link-bounds-y? nil :vars (or vars :prompt) args )))
(t (apply #'2d-plot :x x :y y :interior-view :prompt args )))))))
(defmethod single-plot-by-dim ((dim number)
&key
plot-fn
dataset cases
vars args)
(declare (ignore dataset cases))
(if (>= dim 3)
(let ((x (or (first vars) :prompt))
(y (or (second vars) :prompt))
(z (or (third vars) :prompt))
(v (or vars :prompt))
(items (append (if (= dim 3) '("Rotating Plot" "Rotating Lines"))
(list "Scatterplot Matrix" "Plot matrix" "Side by side"))))
(setq plot-fn (or plot-fn (car (wb:prompt-for-items items))))
(cond ((functionp plot-fn) (apply plot-fn :vars v args))
((not (stringp plot-fn)) nil)
((string-equal plot-fn "Scatterplot Matrix")
(apply #'scat-mat :vars v args))
((string-equal plot-fn "Plot Matrix")
(apply #'scat-mat :pairs-view :prompt :vars v args))
((string-equal plot-fn "Rotating Plot")
(apply #'rotating-plot :x x :y y :z z args))
((string-equal plot-fn "Rotating Lines")
(apply #'rotating-lines-plot :x x :y y :z z args))
((string-equal plot-fn "Side by side")
(if (wb:prompt-true-or-false "Common scale?")
(apply #'1d-layout-plot :vars v args )
(apply #'1d-layout-plot :left-view nil :link-bounds-x? nil
:bottom-view nil :link-bounds-y? nil :vars v args )))
(t nil))
)))
| 4,917 | Common Lisp | .l | 101 | 33.831683 | 114 | 0.471362 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 1be676d938bf9c6fab7e91d7ecd7a6d104ba6ea6b2d25dddabb94946fa7e2fce | 33,260 | [
-1
] |
33,261 | prompt-plot-menu.lsp | rwoldford_Quail/source/views/prompt-plot/prompt-plot-menu.lsp | (in-package :vw)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '( plot-menu-items)))
(defun make-data-display-menu-items()
`( ("DataInfo" nil ""
:sub-items (
("Cases" (prompt-case-display))
("Variates" (prompt-variable-display))
("By Group" (prompt-case-display-by))))
("Single variate" nil ""
:sub-items (("Histogram" (prompt-plot :dim 1 :plot-fn ,#'histogram))
("Barchart" (prompt-plot :dim 1 :plot-fn ,#'bar-plot))
("Boxplot" (prompt-plot :dim 1 :plot-fn ,#'boxplot))
("Dot plot" (prompt-plot :dim 1 :plot-fn ,#'dot-plot))
("Plot" (prompt-plot :dim 1))
("-")
("Histogram by" (prompt-plot-by :dim 1 :plot-fn 'histogram-view))
("Barchart by" (prompt-plot-by :dim 1 :plot-fn 'bar-chart))
("Boxplot by" (prompt-plot-by :dim 1 :plot-fn 'boxplot-view))
("Dot plot by" (prompt-plot-by :dim 1 :plot-fn '1d-point-cloud))
("Plot by" (prompt-plot-by :dim 1))))
("Two variates" nil ""
:sub-items (("Scatterplot" (prompt-plot :dim 2 :plot-fn ,#'scatterplot))
("Lines plot" (prompt-plot :dim 2 :plot-fn ,#'lines-plot))
("Line Segments" (prompt-plot :dim 2 :plot-fn ,#'line-segment-2d-plot))
("Plot" (prompt-plot :dim 2))
("-")
("Scatterplot by" (prompt-plot-by :dim 2 :plot-fn ,#'2d-point-cloud))
("Lines plot by" (prompt-plot-by :dim 2 :plot-fn ,#'lines))
("Plot by" (prompt-plot-by :dim 2))
;; ("Plot by: overlay" (prompt-plot-by :dim 2 :overlay? t))
))
("Multiple variates" nil ""
:sub-items (("3D Scatterplot" (prompt-plot :dim 3 :plot-fn "Rotating Plot"))
("3D Line Segments" (prompt-plot :dim 3 :plot-fn "Rotating Lines"))
("Scatterplot matrix" (prompt-plot :dim 3 :plot-fn "Scatterplot Matrix"))
("Andrews' Trace" (prompt-plot :dim 3 :plot-fn "Andrews' Trace"))
("Tukey's Trace" (prompt-plot :dim 3 :plot-fn "Tukey's Trace"))
("-")
("Plot matrix" (prompt-plot :dim 3 :plot-fn "Plot Matrix"))
("Side by side" (prompt-plot :dim 3 :plot-fn "Side by side"))
("Cross plot" (prompt-plot :dim '(nil nil)))
("-")
("Scatterplot matrix by" (prompt-plot-by :dim 3 :plot-fn 'pairs-layout))
("3D Scatterplots by"
(prompt-plot-by :dim 3 :plot-fn 'rotating-plot))
))
("Table" (prompt-plot-by :dim 0))))
(defvar *saved-selections* nil)
(defun choose-view-set()
(declare (special *saved-selections*))
(third (first (wb:prompt-for-items
*saved-selections* :prompt-text "Choose view set"
:item-function #'first))))
(defun view-set-menu-items()
(declare (special *selected-views* *saved-selections*))
`(("View Sets" nil ""
:sub-items
(("Name" ,#'(lambda(ignore)
(declare (ignore ignore))
(when *selected-views*
(push
(let ((s (list-plot-cases *selected-views*))
(name (wb:prompt-user :result-type 'symbol
:read-type :read
:prompt-string "Enter name")))
(list name
(if *current-dataset*
(make-data-subset *current-dataset* s :name name :save? nil)
(dataset s :cases s :name name :save? nil))
*selected-views*))
*saved-selections*))))
("Show"
,#'(lambda(ignore)
(declare (ignore ignore))
(when *saved-selections*
(with-update-style-cache
(loop for v in *selected-views* do
(set-highlight-style v nil))
(set-selected-views (choose-view-set))
(loop for v in *selected-views* do
(set-highlight-style v t))))))
("Union"
,#'(lambda(ignore)
(declare (ignore ignore))
(when *saved-selections*
(let ((new (choose-view-set)))
(with-update-style-cache
(loop for v in new do
(set-highlight-style v t)
(pushnew v *selected-views*)))))))
("Intersection"
,#'(lambda(ignore)
(declare (ignore ignore))
(when *saved-selections*
(let* ((old-views (remove-duplicates (highlighted-views)))
(sel-views (choose-view-set)))
(loop for v in old-views
do (set-highlight-style v nil :not-from sel-views :draw-links? nil))
(set-selected-views sel-views)))))
("Difference"
,#'(lambda(ignore)
(declare (ignore ignore))
(when *saved-selections*
(let ((new (choose-view-set)))
(with-update-style-cache
(loop for v in new
;; when (any-highlight? v)
do (set-highlight-style v nil)
(set-selected-views (delete v *selected-views*)))
*selected-views* )))))
))))
(let ((plot-menu-items nil)
)
(defun plot-menu-items ()
(or plot-menu-items
(setq plot-menu-items
`(,@(make-data-display-menu-items)
("Function" nil ""
:sub-items ( ("Single variable function" (function-plot))
("Two variable function" (surface-plot))))
("Grid Layout" ,#'(lambda(ignore)
(declare (ignore ignore))
(let ((subs (selected-views)))
(if subs
(grid-layout :subviews subs :draw? t)
(grid-layout :draw? t :nsubviews
(wb:prompt-user :result-type 'number :read-type :eval
:prompt-string "Enter number of subviews")
)))))
("View Layout" (view-layout :nsubviews 0 :draw? t))
("-")
("Linking" nil ""
:sub-items
(("Link views" (link-selected-views))
#|
("Background link table"
,#'(lambda(ignore)
(declare (ignore ignore) (special *foreground-link-tables*))
(mapcar #'background-link-table
(choose-link-tables *foreground-link-tables*))))
("Foreground link table"
,#'(lambda(ignore)
(declare (ignore ignore) (special *background-link-tables*))
(mapcar #'foreground-link-table
(choose-link-tables *background-link-tables*))))
|#
("Unlink views" (unlink-top-views))
("New link table" ,#'(lambda(ignore)
(declare (ignore ignore))
(let ((f (wb::prompt-user :result-type t
:prompt-string "Enter a link test function"
:read-type :read))
name
new)
(setq new (make-link-table :test (get-function f)))
(setq name (wb:prompt-user :result-type 'symbol
:read-type :read
:initial-string (link-table-name-of new)
:prompt-string "Name of table"))
(setf (link-table-name-of new) name))))
("Delete all link tables" (delete-link-tables))
))
,@(view-set-menu-items)
)))))
;;(setq q::*quail-plot-menu-items* (plot-menu-items ))
;;(q::install-default-quail-menubar)
| 9,280 | Common Lisp | .l | 166 | 32.63253 | 120 | 0.431839 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 0f1962cbb64da3686cd7f703e98d01be280abe0004c69ba5d274d29faaa68243 | 33,261 | [
-1
] |
33,262 | prompt-plot.lsp | rwoldford_Quail/source/views/prompt-plot/prompt-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; prompt-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1994 George Washington University
;;;
(in-package :vw)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '( prompt-plot default-group-variable
prompt-variable-display prompt-case-display prompt-case-display-by
)))
(defgeneric default-group-variable(obj)
)
(defmethod default-group-variable ((self t)) nil)
(defun prompt-plot(&key data views dim plot-fn)
"Prompts the user for inputs to construct a single plot~
of dimension dim."
(let* (cases subject-views args vars
(sel-plot (or views (top-views))))
(setq data (or data (selected-dataset sel-plot) ))
(multiple-value-setq (cases subject-views)
(list-plot-cases sel-plot :highlit? t))
(if (null cases)
(multiple-value-setq (cases subject-views)
(list-plot-cases sel-plot)))
(multiple-value-setq (data cases vars)
(prompt-plot-args data cases vars))
(if (null data)
(setq data (choose-dataset)
cases nil
subject-views nil
vars nil))
(unless (and *AUTO-SHARE-CASE-VIEWS?*
(= (length cases) (length subject-views)))
(setq subject-views nil))
(setq args (list :ordered-case-views? t
:case-views-from subject-views
:data data :cases cases
))
(if (and dim (listp dim))
(apply #'xy-layout-plot :xvars (first dim) :yvars (second dim) args)
(single-plot-by-dim dim
:dataset data :cases cases
:plot-fn plot-fn :vars vars
:args args)
)))
(defun prompt-variable-display(&key data views)
"Prompts the user for inputs to construct a variable display"
(declare (ignore ignore))
(setq views (or views (top-views)))
(setq data (or data (selected-dataset views) ))
(let ((cases (or (list-plot-cases views :highlit? t)
(list-plot-cases views))))
(multiple-value-setq (data cases)
(prompt-plot-args data cases nil))
(if (null data)
(setq data (choose-dataset)))
(variate-display-list :data data :draw? t)))
(defun prompt-case-display(&key data views)
"Prompts the user for inputs to construct a case display"
(setq views (or views (top-views)))
(setq data (or data (selected-dataset views) ))
(let ((cases (or (list-plot-cases views :highlit? t)
(list-plot-cases views))))
(multiple-value-setq (data cases)
(prompt-plot-args data cases nil))
(if (null data)
(setq data (choose-dataset)
cases nil))
(case-display-list :data data :draw? t
:cases cases
)))
(defun prompt-case-display-by(&key data views)
"Prompts the user for inputs to construct~
a case display by group."
(let* ( menu-list byvar
cases)
(setq views (or views (top-views)))
(setq data (or data (selected-dataset views) ))
(setq cases (or (list-plot-cases views :highlit? t)
(list-plot-cases views)))
(multiple-value-setq (data cases)
(prompt-plot-args data cases nil))
(if (null data)
(setq data (choose-dataset)
cases nil))
(setq menu-list (variable-menu-items data))
(setq byvar
(or (default-group-variable data)
(choose-some-variables
data 1 "Choose group variable(s)" menu-list)))
(batch-display-list
:data data :draw? t
:by byvar
:cases cases)))
| 4,233 | Common Lisp | .l | 104 | 31.288462 | 103 | 0.556793 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 6df902d55d5015539513e9b13f2b3414b8c5da9f23d8fa80b64e50cae70f6fa3 | 33,262 | [
-1
] |
33,263 | group-plot.lsp | rwoldford_Quail/source/views/prompt-plot/group-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; group-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1994 George Washington University
;;;
(in-package :vw)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(prompt-plot-by)))
(defun prompt-plot-by(&key data views dim overlay? plot-fn)
"Prompts the user for inputs to construct a group plot~
of dimension dim (if provided)."
(unless (numberp dim) (setq dim nil))
(unless views (setq views (top-views)))
(setq data (or data (selected-dataset views) (choose-dataset)))
(let* (byvars menu-list cases subject-views vars
batches batch-args colors highlits?
)
(multiple-value-setq (cases subject-views)
(list-plot-cases views :highlit? t))
(setq highlits? (and cases t))
(if (null cases)
(multiple-value-setq (cases subject-views)
(list-plot-cases views)))
(if (default-group-variable data)
(setq byvars (list (default-group-variable data))))
(unless byvars
(setq menu-list (variable-menu-items data))
(when views
(setq menu-list (cons (list "Color" :view-color) menu-list))
;; (if (every #'(lambda(s) (dataset-with-info-p s))
;; cases)
;; (setq menu-list (cons (list "Cases" :cases) menu-list)))
)
(setq byvars
(choose-some-variables nil 1 "Choose one or more by variables" menu-list)))
(cond ((and views (member :view-color byvars))
(multiple-value-setq (batches colors)
(batch-plot-cases views :highlit? highlits?))
(multiple-value-setq (data batches)
(prompt-plot-batches data batches))
(setq batch-args (list :margin-string-left (mapcar #'color-to-string (car colors))
:data data
:batches batches)))
((and views (member :cases byvars))
(setq batches (mapcar #'viewed-object-of subject-views))
(setq batch-args (list :data data
:batches batches)))
(t
(multiple-value-setq (data cases vars)
(prompt-plot-args data cases vars))
(setq batch-args (list :cases cases
:data data
:by byvars))))
(unless (and *AUTO-SHARE-CASE-VIEWS?*
(= (length cases) (length subject-views)))
(setq subject-views nil))
(if plot-fn
(setq batch-args
(append (list :subview-type plot-fn) batch-args)))
(cond
((= dim 0)
(apply #'table-plot batch-args))
((and (= dim 1) overlay?))
((= dim 1)
(apply #'batch-plot :box-views? nil
:subviews `(( :case-views-from ,subject-views
:ordered-case-views? nil))
:vars vars batch-args))
((= dim 2)
(apply #'batch-plot
:subview-superclass '2d-view
:subviews `((:case-views-from ,subject-views
:ordered-case-views? nil))
:vars vars batch-args))
((>= dim 3)
(if (eq plot-fn 'pairs-layout)
(if vars
(apply #'batch-plot
:subview-type plot-fn :vars vars
:link-bounds-y? :by-block-row :link-bounds-x? :by-col
:subviews `(( :case-views-from ,subject-views
:ordered-case-views? nil :title nil))
batch-args)
(apply #'batch-plot
:subview-type plot-fn
:link-bounds-y? :by-block-row :link-bounds-x? :by-col
:subviews `(( :case-views-from ,subject-views
:ordered-case-views? nil :title nil))
batch-args))
(if vars
(apply #'batch-plot
:subview-type plot-fn :vars vars
:subviews `(( :case-views-from ,subject-views
:ordered-case-views? nil :title nil))
batch-args)
(apply #'batch-plot
:subview-type plot-fn
:subviews `(( :case-views-from ,subject-views
:ordered-case-views? nil :title nil))
batch-args)))))))
| 5,028 | Common Lisp | .l | 110 | 31.445455 | 94 | 0.497143 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | fc35d6f047cd207e7574d04f442b79d1e06084c0093d2601deb878b2e4bc06f0 | 33,263 | [
-1
] |
33,264 | connected-points.lsp | rwoldford_Quail/source/views/other/connected-points.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; connected-points.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1999 NUIM
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '( connected-points
)))
(defclass connected-points (line-segment-mixin compound-view)
()
)
(defmethod construct-sub-views ((self connected-points) &rest initargs
&key point-view)
(declare (ignore initargs))
(let ((subview-arglist (subview-arg-list point-view 'point-symbol))
(vo (viewed-object-of self)))
(setf (subviews-of self)
(loop repeat (length (lines-coords-of self))
collect (apply #'view :data vo
:left-fn '(identify-view :viewport)
subview-arglist)))))
(defmethod init-position-subviews ((self connected-points) &key )
(let* ((br (bounding-region-of self))
(wid/2 (/ (width-of br) 20))
(ht/2 (/ (height-of br) 20))
(coords (lines-coords-of self))
)
(setf (sub-view-locns-of self) (loop
for (x y) in coords
collect (make-region
(- x wid/2) (+ x wid/2)
(- y ht/2) (+ y ht/2))))))
(defmethod compute-sub-viewports ((self connected-points)
&optional viewport subviews)
(let ((viewports (if viewport (list viewport) (viewports-of self)))
(maps (if viewport (list (select-map-to-viewport self viewport))
(maps-to-viewports-of self)))
(subview-locns
(if subviews
(loop for s in subviews collect
(select-sub-view-locn self s))
(sub-view-locns-of self)))
sv-vp)
(setq subviews (or subviews (subviews-of self)))
(loop with left and right and bottom and top
for sv in subviews
for svl in subview-locns
for sv-rad = (if (typep sv 'view-with-size)
(view-size-of sv) 5)
do
(loop for vp in viewports for map in maps
for xy = (apply-transform map (centre-of svl))
for x = (2d-position-x xy)
for y = (2d-position-y xy)
for vp-win = (window-of vp)
do
(setq left (- x sv-rad)
right (+ x sv-rad)
bottom (- y sv-rad)
top (+ y sv-rad))
(cond ((typep sv 'justified-line)
(case (justification-of sv)
(:left (setq left (left-of vp) right x))
(:right (setq right (right-of vp) left x))
(:top (setq top (top-of vp) bottom y ))
(:bottom (setq bottom (bottom-of vp) top y))
(:left-right (setq right (right-of vp) left (left-of vp)))
(:top-bottom (setq bottom (bottom-of vp) top (top-of vp)))))
((typep sv 'oriented-line)
(if (eql (orientation-of sv) :horizontal)
(setq left (left-of vp) right x)
(setq bottom (bottom-of vp) top y)))
((typep sv 'label)
(let ((rad (* 3 (length (get-text sv)))))
(when (> rad sv-rad)
(if (eql (orientation-of sv) :horizontal)
(setq left (- x rad)
right (+ x rad)
)
(setq bottom (- y rad)
top (+ y rad)
)))))
(t nil))
(setq sv-vp (make-viewport vp-win left right bottom top))
(add-viewport sv sv-vp vp)))))
(defmethod draw-view :after ((self connected-points) &key viewport)
(loop for vp in (enlist-viewport self viewport) do
(loop for sv in (subviews-of self)
for sv-vp = (select-viewport sv vp)
do
(draw-view sv :viewport sv-vp :check-viewport? nil))))
(defmethod erase-view :after ((self connected-points)
&key viewport )
(loop for vp in (enlist-viewport self viewport) do
(loop for sv in (subviews-of self)
for sv-vp = (select-viewport sv vp)
do
(erase-view sv :viewport sv-vp :check-viewport? nil))))
(defmethod invert-view :after ((self connected-points)
&key viewport )
(loop for vp in (enlist-viewport self viewport) do
(loop for sv in (subviews-of self)
for sv-vp = (select-viewport sv vp)
do
(invert-view sv :viewport sv-vp :check-viewport? nil))))
(defmethod highlight-view :after ((self connected-points)
&key viewport )
(loop for vp in (enlist-viewport self viewport) do
(loop for sv in (subviews-of self)
for sv-vp = (select-viewport sv vp)
do
(highlight-view sv :viewport sv-vp :check-viewport? nil))))
(defmethod downlight-view :after ((self connected-points)
&key viewport )
(loop for vp in (enlist-viewport self viewport) do
(loop for sv in (subviews-of self)
for sv-vp = (select-viewport sv vp)
do
(downlight-view sv :viewport sv-vp :check-viewport? nil))))
(defmethod set-endpoints ((self connected-points) &key endpoints (draw? t))
(if draw? (erase-view self))
(if (null endpoints)
(setf endpoints
(list
(wb::prompt-user :result-type 'list :read-type :read
:prompt-string "Enter first point as list")
(wb::prompt-user :result-type 'list :read-type :read
:prompt-string "Enter second point as list"))))
(setf (lines-coords-of self) endpoints)
(init-position-subviews self)
(remap-to-viewports self :draw? nil :erase? nil)
(if draw? (draw-view self)))
;;; Following was in views/d-views/rotating-lines.lsp
;(defmethod subsubview-styles ((self rotating-line-segments) style &optional default)
; (when (typep (car (subviews-of self)) 'connected-points)
; (loop for sv in (subviews-of self) append
; (loop for s in (subviews-of sv)
; collect (draw-style (drawing-style-of s) style :default default)))))
| 7,365 | Common Lisp | .l | 152 | 33.519737 | 92 | 0.495097 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e77cb504c7f042eded69ffa2fc156ea5516d7e985872442d8fb00c92971c26cb | 33,264 | [
-1
] |
33,265 | make-plots.lsp | rwoldford_Quail/source/views/plots/make-plots.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; make-plots.lsp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1992 George Washington University
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :views)
(make-view-constructor-with-doc 'plot 'plot)
(make-view-constructor-with-doc 'standard-plot 'standard-plot)
(make-view-constructor-with-doc 'grid-plot 'grid-plot)
(make-view-constructor-with-doc 'd-plot 'd-plot)
(make-view-constructor-with-doc '1d-plot '1d-plot)
(make-view-constructor-with-doc '2d-plot '2d-plot)
(make-view-constructor-with-doc '3d-plot '3d-plot)
(let ((pie-local (make-view-constructor-fn 'plot
:initform-fn #'get-batch-inits
:default-interior 'pie
:size nil)))
(setf (get 'pie-plot 'view-class) 'plot)
(pushnew 'pie-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'pie-plot))
(defun pie-plot (&rest args &key data &allow-other-keys)
"Produces a pie plot. ~
(:key ~
(:arg data :prompt The dataset to be displayed. ))~
(:examples (:files
(general eg:Views;Plots;general.lsp)))~
"
(declare (ignore data by batches var))
(apply pie-local args))
)
(let ((hist-local (make-view-constructor-fn '1d-plot
:default-interior 'histogram-view)))
(setf (get 'histogram 'view-class) '1d-plot)
(pushnew 'histogram *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'histogram))
(defun histogram(&rest args &key data var &allow-other-keys)
"Produces a histogram. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then var is to construct the plot.)~
(:arg var :prompt The variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(boxplot :function)~
(dot-plot :function)~
(scatterplot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data var))
(apply hist-local args))
)
(let ((plot-local (make-view-constructor-fn '1d-plot
:default-interior 'boxplot-view)))
(setf (get 'boxplot 'view-class) '1d-plot)
(pushnew 'boxplot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'boxplot))
(defun boxplot(&rest args &key data var &allow-other-keys)
"Produces a boxplot. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then var is to construct the plot.)~
(:arg var :prompt The variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(dot-plot :function)~
(scatterplot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data var))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn '1d-plot
:default-interior '1d-point-cloud)))
(setf (get 'dot-plot 'view-class) '1d-plot)
(pushnew 'dot-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'dot-plot))
(defun dot-plot(&rest args &key data var &allow-other-keys)
"Produces a dot plot. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then var is to construct the plot.)~
(:arg var :prompt The variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(boxplot :function)~
(scatterplot :function)~
(rotating-plot :function)~
(rotating-lines-plot :function)~
(scat-mat :function))"
(declare (ignore data var))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn '2d-plot
:default-interior '2d-point-cloud)))
(setf (get 'scatterplot 'view-class) '2d-plot)
(pushnew 'scatterplot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'scatterplot))
(defun scatterplot(&rest args &key data x y &allow-other-keys)
"Produces a scatterplot of y versus x. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(boxplot :function)~
(dot-plot :function)~
(lines-plot :function)~
(fitted-line-plot :function)~
(smooth-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y ))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn '2d-plot
:default-interior 'lines)))
(setf (get 'lines-plot 'view-class) '2d-plot)
(pushnew 'lines-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'lines-plot))
(defun lines-plot(&rest args &key data x y &allow-other-keys)
"Produces a lines plot of y versus x. ~
(x,y) points are joined by line segments in order of increasing x. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(scatterplot :function)~
(lines-plot :function)~
(smooth-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y ))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn '2d-plot
:default-interior 'line-segments-per-case
:initform-fn #'get-data-inits-2lists)))
(setf (get 'line-segment-2d-plot 'view-class) '2d-plot)
(pushnew 'line-segment-2d-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'line-segment-2d-plot))
(defun line-segment-2d-plot(&rest args &key data x y &allow-other-keys)
"Produces a plot with one or more line segment for each case, ~
with endpoints given by the x and y coordinates. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variates.)~
(:arg y :prompt The y variates.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(scatterplot :function)~
(lines-plot :function)~
(smooth-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y ))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'rotating-plot)))
(setf (get 'rotating-plot 'view-class) 'rotating-plot)
(pushnew 'rotating-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'rotating-plot))
(defun rotating-plot(&rest args &key data x y z &allow-other-keys)
"Produces a rotating plot of x, y and z. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x, y and z are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.)
(:arg z :prompt The z variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(scatterplot :function)~
(rotating-lines-plot :function)~
(scat-mat :function))"
(declare (ignore data x y z ))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'rotating-plot
:default-interior 'rotating-line-segments
:initform-fn #'get-data-inits-3lists)))
(setf (get 'rotating-lines-plot 'view-class) 'rotating-plot )
(pushnew 'rotating-lines-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'rotating-lines-plot))
(defun rotating-lines-plot(&rest args &key data x y z &allow-other-keys)
"Produces a rotating lines plot of segments ~
with endpoints given by x, y and z. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x, y and z are used to construct the plot.)~
(:arg x :prompt The x variates.)~
(:arg y :prompt The y variates.)
(:arg z :prompt The z variates.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(scatterplot :function)~
(lines-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y z ))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn '2d-plot
:default-interior '(2d-point-cloud fitted-line))))
(setf (get 'fitted-line-plot 'view-class) '2d-plot)
(pushnew 'fitted-line-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'fitted-line-plot))
(defun fitted-line-plot(&rest args &key data x y &allow-other-keys)
"Produces a fitted line plot of y versus x. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(boxplot :function)~
(dot-plot :function)~
(lines-plot :function)~
(smooth-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn '2d-plot
:default-interior '(2d-point-cloud smooth))))
(setf (get 'smooth-plot 'view-class) '2d-plot)
(pushnew 'smooth-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'smooth-plot))
(defun smooth-plot(&rest args &key data x y &allow-other-keys)
"Produces a smooth plot of y versus x. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(boxplot :function)~
(dot-plot :function)~
(lines-plot :function)~
(fitted-line-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y))
(apply plot-local args))
)
#|
(let ((plot-local (make-view-constructor-fn '2d-plot
:default-interior 'lines)))
(setf (get 'lines-plot 'view-class) '2d-plot)
(pushnew 'lines-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'lines-plot))
(defun lines-plot(&rest args &key data x y &allow-other-keys)
"Produces a lines plot of y versus x, where coordinates are joined by line segments ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(boxplot :function)~
(dot-plot :function)~
(simple-lines-plot :function)~
(fitted-line-plot :function)~
(smooth-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y))
(apply plot-local args))
)
|#
(let ((plot-local (make-view-constructor-fn '2d-plot
:default-interior 'simple-lines)))
(setf (get 'simple-lines-plot 'view-class) '2d-plot)
(pushnew 'simple-lines-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'simple-lines-plot))
(defun simple-lines-plot(&rest args &key data x y &allow-other-keys)
"Produces a lines plot of y versus x, where coordinates are joined by line segments ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x and y are used to construct the plot.)~
(:arg x :prompt The x variate.)~
(:arg y :prompt The y variate.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(histogram :function)~
(boxplot :function)~
(dot-plot :function)~
(lines-plot :function)~
(fitted-line-plot :function)~
(smooth-plot :function)~
(line-segment-2d-plot :function)~
(rotating-plot :function)~
(scat-mat :function))"
(declare (ignore data x y))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn 'standard-plot
:default-interior 'function-view)))
(setf (get 'function-plot 'view-class) 'standard-plot)
(pushnew 'function-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'function-plot))
(defun function-plot(&rest args &key function &allow-other-keys)
"Produces a plot of a single variable function.~
(:key ~
(:arg function :prompt The function to be plotted.)) ~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))"
(declare (ignore function))
(apply plot-local args))
)
(let ((plot-local (make-view-constructor-fn 'standard-plot
:default-interior 'line-segment)))
(setf (get 'line-segment-plot 'view-class) 'standard-plot)
(pushnew 'line-segment-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'line-segment-plot))
(defun line-segment-plot(&rest args &key endpoints &allow-other-keys)
"Produces a plot of line segment(s).~
(:key ~
(:arg endpoints '((0 0) (1 1)) The endpoint of the line segment(s))) ~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))"
(declare (ignore endpoints))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:default-interior 'pairs-layout
:left-view t :bottom-view t
:link-bounds-x? :by-col :link-bounds-y? :by-row)))
(setf (get 'scat-mat 'view-class) 'grid-plot)
(pushnew 'scat-mat *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'scat-mat))
(defun scat-mat(&rest args &key data vars &allow-other-keys)
"Produces a scatterplot matrix. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then vars are used to construct the plot.)~
(:arg vars :prompt The variates.))~
(:examples (:files (grid-plot eg:Views;Plots;grid-plot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(1d-layout-plot :function)~
(xy-layout-plot :function)~
(batch-plot :function)~
(case-layout-plot :function)~
)"
(declare (ignore data vars))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:default-interior '1d-layout
:bottom-label t :left-view t
:bottom-view t :left-label t)))
(setf (get '1d-layout-plot 'view-class) 'grid-plot)
(pushnew '1d-layout-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '1d-layout-plot))
(defun 1d-layout-plot(&rest args &key data vars subview-type &allow-other-keys)
"Produces displays of variables in a grid. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then vars are used to construct the plot.)~
(:arg vars :prompt The variates.)
(:subview-type :prompt The type of display to be used for each panel.))~
(:examples (:files (grid-plot eg:Views;Plots;grid-plot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(scat-mat :function)~
(xy-layout-plot :function)~
(batch-plot :function)~
(case-layout-plot :function)~)"
(declare (ignore data vars subview-type))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:default-interior 'xy-layout
:bottom-label t :left-view t
:bottom-view t :left-label t
:link-bounds-x? :by-col :link-bounds-y? :by-row)))
(setf (get 'xy-layout-plot 'view-class) 'grid-plot)
(pushnew 'xy-layout-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'xy-layout-plot))
(defun xy-layout-plot(&rest args &key data x-vars y-vars subview-type &allow-other-keys)
"Produces displays of pairs of x and y variables in a grid. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. ~
If :prompt, then x-vars and y-vars are used to construct the plot.)~
(:arg x-vars :prompt The x variates.)
(:arg y-vars :prompt The y variates.)
(:subview-type :prompt The type of display to be used for each panel.))~
(:examples (:files (grid-plot eg:Views;Plots;grid-plot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(scat-mat :function)~
(1d-layout-plot :function)~
(batch-plot :function)~
(case-layout-plot :function)~)"
(declare (ignore data x-vars y-vars subview-type))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:initform-fn #'get-batch-inits
:default-interior 'batch-layout
:title-text nil
:left-label t :bottom-label t :top-label nil
:right-label nil :left-label-size .2
:left-view t :bottom-view t)))
(setf (get 'batch-plot 'view-class) 'grid-plot)
(pushnew 'batch-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'batch-plot))
(defun batch-plot(&rest args &key data by batches subview-type &allow-other-keys)
"Produces displays of batches in a grid. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. )~
(:arg by :prompt A batch is constructed using values of by. )~
(:arg batches nil Batches if supplied should be a list of datasets,~
in which case the by value is ignored.)~
(:subview-type :prompt The type of display to be used for each panel.))~
(:examples (:files (grid-plot eg:Views;Plots;grid-plot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(scat-mat :function)~
(1d-layout-plot :function)~
(xy-layout-plot :function)~
(case-layout-plot :function)~
)"
(declare (ignore data by batches subview-type))
(apply plot-local args))
)
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:default-interior 'case-layout
:left-label t :bottom-label t :top-label :if-string
:right-label :if-string
:left-view t :bottom-view t)))
(setf (get 'case-layout-plot 'view-class) 'grid-plot)
(pushnew 'case-layout-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'case-layout-plot))
(defun case-layout-plot (&rest args &key data subview-type &allow-other-keys)
"Produces one display per case in a grid. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. )~
(:subview-type :prompt The type of display to be used for each panel.))~
(:examples (:files (grid-plot eg:Views;Plots;grid-plot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(scat-mat :function)~
(1d-layout-plot :function)~
(xy-layout-plot :function)~)"
(declare (ignore data subview-type))
(apply plot-local args)))
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:title-text nil
:left-label t :bottom-label t
:initform-fn #'get-barchart-inits
:gap-x *default-grid-gap* :gap-y *default-grid-gap*
:default-interior 'bar-chart
:left-view t :left-label-size .2
:left-view-size 0.05 :bottom-view-size 0.05)))
(setf (get 'bar-plot 'view-class) 'grid-plot)
(pushnew 'bar-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'bar-plot))
(defun bar-plot (&rest args &key data by batches var &allow-other-keys)
"Produces a barplot. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. )~
(:arg by :prompt There is one bar per batch. ~
A batch is constructed using values of by. )~
(:arg batches nil Batches if supplied should be a list of datasets,~
in which case the by value is ignored.)~
(:arg var nil If var is non-nil, then batches and by are ignored.~
The values of var are used for bar heights.))~
(:examples (:files (scatterplot eg:Views;Plots;scatterplot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(batch-plot :function)~
(case-layout-plot :function)~)"
(declare (ignore data by batches var))
(apply plot-local args)))
(let ((plot-local
(make-view-constructor-fn 'grid-plot
:title-text nil
:left-label t :bottom-label t :left-label-size .2
:default-interior 'table-layout)))
(setf (get 'table-plot 'view-class) 'grid-plot)
(pushnew 'table-plot *view-constructors*)
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'table-plot))
(defun table-plot (&rest args &key data by batches subview-type &allow-other-keys)
"Produces displays of batches in a grid, where displays can be resized. ~
(:key ~
(:arg data :prompt The dataset whose values are to be plotted. )~
(:arg by :prompt A batch is constructed using values of by. )~
(:arg batches nil Batches if supplied should be a list of datasets,~
in which case the by value is ignored.)~
(:subview-type :bar-with-text The type of display to be used for each panel.))~
(:examples (:files (grid-plot eg:Views;Plots;grid-plot.lsp)~
(general eg:Views;Plots;general.lsp)))~
(:see-also
(scatterplot :function)~
(batch-plot :function)~)"
(declare (ignore data by batches subview-type ))
(apply plot-local args)))
| 26,172 | Common Lisp | .l | 566 | 37.026502 | 95 | 0.600442 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 681a2b0afe6363767e2a2047266d30db2d108f5c74013781771ddaaa99348256 | 33,265 | [
-1
] |
33,266 | plot-mixins.lsp | rwoldford_Quail/source/views/plots/plot-mixins.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; plot-mixins.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1992 George Washington University
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '( title-of
position-key-mixin titled-view-mixin margined-view-mixin
set-position-value *default-title-dims* *default-margin-size*)))
(defvar *default-title-dims* '(:width 0.9 :height 0.1))
(defvar *default-margin-size* 0.01)
(defclass position-key-mixin ()
((position-keys :initform nil :allocation :class)
(default-positions
:initform nil
:accessor default-positions-of)
)
(:documentation "Mixin has a slot for storing parameters for positioning subviews."))
(defclass titled-view-mixin (position-key-mixin)
((title :initarg :title
:accessor title-of
:initform t)
(position-keys :initform '(:title-height :title-width) :allocation :class)
(right-menu :allocation :class :initform nil)
)
(:default-initargs
:title-height (getf *default-title-dims* :height)
:title-width (getf *default-title-dims* :width)
:title-font nil :title-text #'dataset-name)
(:documentation "Mixin for view with a title "))
(defclass margined-view-mixin (position-key-mixin)
((right-menu :allocation :class :initform nil)
(position-keys :allocation :class
:initform '(:left-margin-size :right-margin-size
:bottom-margin-size :top-margin-size) ))
(:default-initargs
:left-margin-size *default-margin-size*
:right-margin-size *default-margin-size*
:bottom-margin-size *default-margin-size* :top-margin-size *default-margin-size*)
(:documentation "Mixin for view with margins.~
Should be included in precedence list before any other view~
which adjusts the subview-position-region."))
(defmethod initialize-instance :around ((self margined-view-mixin)
&rest initargs
&key no-margins?
&allow-other-keys)
(if no-margins?
(apply #'call-next-method self :left-margin-size 0 :right-margin-size 0
:top-margin-size 0 :bottom-margin-size 0 initargs)
(call-next-method)))
(defgeneric set-position-value (position-key-mixin parameter &key &allow-other-keys)
(:documentation "Sets the position parameter"))
;;;----------------------------------------------------------------------------------
(defmethod initialize-instance :before ((self position-key-mixin)
&rest keyword-pairs
&key)
(setf (default-positions-of self)
(loop for key in (slot-value self 'position-keys)
for val = (getf keyword-pairs key :no-value)
unless (eql val :no-value)
nconc (list key val))))
(defmethod reposition-view :around ((self position-key-mixin)
&rest keyword-pairs
&key
(default-positions (default-positions-of self )))
;; extra arg default-positions
(call-next-method self :default-positions
(append keyword-pairs default-positions)))
(defmethod set-position-value ((self position-key-mixin) parameter &key value (recompute? t))
(let* ((pars (default-positions-of self))
(old (getf pars parameter)))
(unless (numberp value)
(setq value
(if (and (numberp old) (not (zerop old)))
(case value
(:larger (* 1.5 old))
(:smaller (* 0.67 old))
(t (wb:prompt-user :result-type 'number :read-type :eval
:prompt-string
(format nil "Change ~A from ~S" parameter old))))
(wb:prompt-user :result-type 'number :read-type :eval
:prompt-string (format nil "Change ~A from ~S" parameter old)))))
(setf (getf pars parameter) value)
(if recompute? (reposition-view self))))
(defmethod position-parameter-menu-list ((self position-key-mixin))
(flet ((key-list (k)
`(("larger" (set-position-value ,k :value :larger ))
("smaller" (set-position-value ,k :value :smaller ))
("prompt" (set-position-value ,k )) )))
(loop for k in (default-positions-of self) by #'cddr
collect (list (string-downcase (princ-to-string k))
nil "" :sub-items (key-list k)))))
(defmethod get-menu-items :around ((self position-key-mixin) (slot-name (eql 'right-menu)))
(let ((result (call-next-method))
(size-list (position-parameter-menu-list self)))
(add-menu-items self result
`(( "Positions" nil "" :sub-items ,size-list) ))))
(defmethod subview-position-region-of :before ((self margined-view-mixin))
(if (null (slot-value self 'subview-position-region))
(setf (slot-value self 'subview-position-region)
(make-region (bounding-region-of self)))))
(defmethod init-position-subviews :before ((self margined-view-mixin)
&key left-margin-size right-margin-size
bottom-margin-size top-margin-size
)
(let* ((interior-region (subview-position-region-of self))
(br (bounding-region-of self))
(w (width-of br ))
(h (height-of br )))
(incf (left-of interior-region) (max 0 (* w left-margin-size )))
(incf (bottom-of interior-region) (max 0 (* h bottom-margin-size)))
(decf (right-of interior-region) (max 0 (* w right-margin-size)))
(decf (top-of interior-region) (max 0 (* h top-margin-size)))
(valid-region-check interior-region)
))
(defmethod view-title-string ((self titled-view-mixin))
"TITLE"
)
(defmethod construct-sub-views :before ((self titled-view-mixin )
&key title-font title-text subviews-all?)
(with-accessors ( (title title-of)
(viewed-obj viewed-object-of))
self
(if (and (null title) subviews-all?) (setq title t))
(setf title
(cond ((null title) nil)
((legal-label-construct-p title)
(view-from-arg
title
(list :font title-font :data viewed-obj :text title-text)
'label #'sublabel-arg-list))
((and (listp title) (legal-label-construct-p (car title)))
(view-from-arg
(car title)
(list :font title-font :data viewed-obj :text title-text)
'label #'sublabel-arg-list))))
(if (and title (typep title 'label))
(unless (or (stringp (text-of title))
(and (functionp (text-of title)) (funcall (text-of title) viewed-obj)))
(setf (text-of title) (view-title-string self))))))
(defmethod subview-position-region-of :before ((self titled-view-mixin))
(if (null (slot-value self 'subview-position-region))
(setf (slot-value self 'subview-position-region)
(make-region (bounding-region-of self)))))
(defmethod init-position-subviews :before ((self titled-view-mixin)
&key title-height title-width )
(let ((interior-region (subview-position-region-of self))
(br (bounding-region-of self))
(title (title-of self)))
(when title
(place-subview self title
(sub-region interior-region :n
:width (* (width-of br) title-width)
:height (* (height-of br) title-height)
:remains interior-region))
)
(valid-region-check interior-region)
))
| 8,830 | Common Lisp | .l | 172 | 38.226744 | 98 | 0.54437 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | c16ec075ecc925bd53487cdba16a76bb756cdd2ba8cc6cc6a6c560747e820020 | 33,266 | [
-1
] |
33,267 | plot-d.lsp | rwoldford_Quail/source/views/plots/plot-d.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; plot-d.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1988-1991 George Washington University
;;; R.W. Oldford 1988-1991
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(3d-plot 2d-plot 1d-plot d-plot )))
(defclass d-plot (plot)
((middle-menu :allocation :class :initform nil))
(:default-initargs
;;:initform-fn #'get-data-inits
:initform-fn #'get-dataset-init
:right-margin-size 0.01))
(defclass 3d-plot (plot )
((middle-menu :allocation :class :initform nil) )
(:default-initargs
:initform-fn #'get-data-inits-3
;;:initform-fn #'get-dataset-init
:default-interior 'rotating-cloud
:right-margin-size *default-margin-size*
:left-view nil :bottom-view nil
:left-label nil :bottom-label nil))
(defclass 2d-plot (standard-plot)
((middle-menu :allocation :class :initform nil)
(position-keys :allocation :class
:initform '(:left-view-size :right-view-size
:bottom-view-size :top-view-size
:bottom-label-size :top-label-size
:left-label-size :right-label-size
:title-height :title-width
:left-margin-size :right-margin-size
:bottom-margin-size :top-margin-size
:gap-x :gap-y :xy-ratio) ))
(:default-initargs
:default-interior '2d-point-cloud
:initform-fn #'get-data-inits-2
;;:initform-fn #'get-dataset-init
))
(defclass 1d-plot (standard-plot)
((middle-menu :allocation :class :initform nil))
(:default-initargs
:default-interior 'histogram-view
:initform-fn #'get-data-inits-1
;;:initform-fn #'get-dataset-init
))
(defmethod prompt-for-plot-interior((self d-plot))
(choose-view-from-menu
:prompt-string "Select plot interior"
:superclass 'd-view))
(defmethod prompt-for-plot-interior((self 3d-plot))
(choose-view-from-menu
:prompt-string "Select plot interior"
:superclass '3d-view))
(defmethod prompt-for-plot-interior((self 2d-plot))
(choose-views-from-menu
:prompt-string "Select plot interior(s)"
:superclass '2d-view))
(defmethod prompt-for-plot-interior((self 1d-plot))
(choose-views-from-menu
:prompt-string "Select plot interior(s)"
:superclass '1d-view))
| 3,190 | Common Lisp | .l | 76 | 32.355263 | 102 | 0.528928 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | b00103a0079344242a4fd5e3031a0fdcef698fe59a1fc394152209d3fb1a8f5c | 33,267 | [
-1
] |
33,268 | grid-plot.lsp | rwoldford_Quail/source/views/plots/grid-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; grid-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1992 George Washington University
;;;
;;;
;;;
;;;------------------------------------------------
(in-package :views)
(defclass grid-plot (plot)
()
(:default-initargs :link-bounds-x? t :link-bounds-y? t
:gap-x *default-grid-gap* :gap-y *default-grid-gap*
:default-interior 'grid-layout
))
(defmethod init-label-text ((self grid-plot)
(margin T) label)
(if (typep label 'label)
(let* ((iv (interior-view-of self))
(lab (text-of label)))
(if (and (typep iv 'batch-layout) (listp (batches-of iv)))
(loop with the-b
for b in (batches-of iv)
until (and (dataset-p b)
(equal (identifier-name b) lab) (setq the-b b))
finally (if the-b
(setf (viewed-object-of label) the-b)))
(if (typep iv 'case-layout)
(loop with the-b
for c in (list-case-views iv)
for b = (viewed-object-of c)
until (and (dataset-p b)
(equal (identifier-name b) lab) (setq the-b b))
finally (if the-b
(setf (viewed-object-of label) the-b)))))
(when (and lab (not (string-equal lab "")))
(loop for v in (descendant-views-of-type iv 'd-view)
do
(if (equal lab (coord-string-x v))
(text-link v label :x)
(if (equal lab (coord-string-y v)) (text-link v label :y)
(if (equal lab (coord-string-z v)) (text-link v label :z)))))))))
;; changes to grab the variable for the margin view. this may be dangerous... 11/2/97
;; goal of this is to use a 1d-view with case-labels in the margin.
;; it already works for scatterplot becuse it automatically gets the data
;; from the interior
(defmethod construct-margin-views ((self grid-plot)
&key (delete-useless-axes? t)
link-bounds-x?
link-bounds-y?)
"Constructs margin views using information provided by~
the :left-views :right-views :bottom-views :top-views initargs.~
Each initarg should pass the legal-view-construct-p test,~
or be a list whose elements pass the legal-view-construct-p test.~
If an initarg is null, the corresponding view is not constructed.~
The default view type is axis. ~
Each legal-view-construct, together with keyword-pairs,~
is used to construct views which are placed in the appropriate slot."
(with-accessors ((lv left-views-of) (rv right-views-of)
(iv interior-views-of)
(tv top-views-of) (bv bottom-views-of))
self
(flet ((get-br(views)
(let ((v (loop for vi in (flatten-views views)
until (typep vi '2d-view)
finally (return vi))))
(if v (if (typep v 'd-view)
(smallest-bounding-region v)
(bounding-region-of v))
)))
(get-data(views axis)
(let ((d (loop for vi in (if (or (eql axis :right) (eql axis :top))
(reverse (flatten-views views))
views)
until (typep vi '2d-view)
finally (return vi))))
(cond
((typep d 'd-view)
(append (plot-margin-br-info self axis d)
(plot-margin-coord-info self axis d)
(list :data (dataset-of d))))
(t (list :data (viewed-object-of self))))))
)
(multiple-value-setq (lv rv bv tv)
(values-list
(loop with rows = (row-views (car iv))
with cols = (col-views (car iv))
with nrows = (length rows)
with ncols = (length cols)
for v in (list lv rv bv tv)
for axis in (list :vertical :vertical :horizontal :horizontal)
for just in (list :right :left :top :bottom )
for axis-info = (list :bounding-region nil :orientation axis :justification just
:ntics 2 :pretty? t)
for n = (if (eq axis :vertical) nrows ncols)
for slices = (if (eq axis :vertical) rows cols)
collect
(cond ((null v) nil)
;; added this next clause 11/2/97
((and (listp v) (= (length v) n)
(every #'legal-view-construct-p v))
(loop with d
for r in v
for s in slices
do (setf (second axis-info) (get-br s))
(setq d (append axis-info (get-data s axis)))
collect (list (view-from-arg r d 'axis))))
((and (listp v) (= (length v) n)
(every #'(lambda(x) (and (listp x)
(every #'legal-view-construct-p x)))
v))
(loop with d
for r in v
for s in slices
do (setf (second axis-info) (get-br s))
(setq d (append axis-info (get-data s axis)))
collect (loop for vi in r
collect (view-from-arg vi d 'axis))))
(t (loop with d
for s in slices
do (setf (second axis-info) (get-br s))
(setq d (append axis-info (get-data s axis)))
collect
(cond
((legal-view-construct-p v)
(list (view-from-arg v d 'axis)))
((and (listp v) (every #'legal-view-construct-p v))
(loop for vi in v collect (view-from-arg vi d 'axis)))
(t (quail-error "Illegal subview argument ~A" v))))))))))
(constrain-bounds self :link-bounds-x? link-bounds-x?
:link-bounds-y? link-bounds-y? :recompute? t)
(if delete-useless-axes? (delete-useless-axes self))
))
(defun flatten-views (views)
(loop for v in views
when (listp v) append (flatten-views v)
when (not (listp v)) collect v
))
(defmethod nrows-of ((self grid-plot))
(nrows-of (interior-view-of self)))
(defmethod ncols-of ((self grid-plot))
(ncols-of (interior-view-of self)))
(defmethod compute-row-locns((self grid-plot) )
(let* ((iv (interior-view-of self))
(rows (if iv (row-views iv))))
(loop for (sub) in rows
for p = (and sub (compute-descendant-locn self sub))
while p
collect p into reg
finally (return
(and p reg)))))
(defmethod compute-col-locns((self grid-plot) )
(let* ((iv (interior-view-of self))
(cols (if iv (col-views iv))))
(loop for (sub) in cols
for p = (and sub (compute-descendant-locn self sub))
while p
collect p into reg
finally (return
(and p reg)))))
(defmethod init-position-margin-views ((self grid-plot)
outer-space inner-space
&key bottom-view-size top-view-size
left-view-size right-view-size gap-x gap-y )
(declare (ignore outer-space))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of))
self
(multiple-value-bind (li ri bi ti)
(bounds-of inner-space)
(let (row-locns col-locns)
(if lv
(loop with regions = (or row-locns
(setq row-locns (compute-row-locns self))
(tile-region-list
(make-region (- li left-view-size) li bi ti)
(length lv) 1 nil 0 gap-y))
for lvi in lv
for mv-region in regions
do
(setq mv-region (copy-region mv-region))
(setf (left-of mv-region) (- li left-view-size))
(setf (right-of mv-region) li)
(loop for v in lvi do
(place-subview self v (copy-region mv-region)))))
(if rv
(loop with regions = (or row-locns
(setq row-locns (compute-row-locns self))
(tile-region-list
(make-region ri (+ ri right-view-size) bi ti)
(length rv) 1 nil 0 gap-y))
for rvi in rv
for mv-region in regions
do
(setq mv-region (copy-region mv-region))
(setf (left-of mv-region) ri)
(setf (right-of mv-region) (+ ri right-view-size))
(loop for v in rvi do
(place-subview self v (copy-region mv-region)))))
(if bv
(loop with regions = (or col-locns
(setq col-locns (compute-col-locns self))
(tile-region-list
(make-region li ri (- bi bottom-view-size) bi)
1 (length bv) nil gap-x 0))
for bvi in bv
for mv-region in regions
do
(setq mv-region (copy-region mv-region))
(setf (bottom-of mv-region) (- bi bottom-view-size))
(setf (top-of mv-region) bi)
(loop for v in bvi do
(place-subview self v (copy-region mv-region)))))
(if tv
(loop with regions = (or col-locns
(setq col-locns (compute-col-locns self))
(tile-region-list
(make-region li ri ti (+ ti top-view-size))
1 (length tv) nil gap-x 0))
for tvi in tv
for mv-region in regions
do
(setq mv-region (copy-region mv-region))
(setf (bottom-of mv-region) ti)
(setf (top-of mv-region) (+ ti top-view-size))
(loop for v in tvi do
(place-subview self v (copy-region mv-region)))))))))
(defmethod init-position-margin-labels ((self grid-plot) outer-space inner-space
&key bottom-label-size top-label-size
left-label-size right-label-size gap-x gap-y)
(with-accessors ((ll left-labels-of) (rl right-labels-of)
(tl top-labels-of) (bl bottom-labels-of))
self
(multiple-value-bind (li ri bi ti)
(bounds-of inner-space)
(multiple-value-bind (lo ro bo to)
(bounds-of outer-space)
(let (row-locns col-locns)
(when ll
(setq row-locns (or row-locns (compute-row-locns self)))
(when (and (> (length ll) 3) (< left-label-size .2 ))
(setf left-label-size .2)
(setf (getf (default-positions-of self) :left-label-size) left-label-size))
(if (= (length row-locns) (length ll))
(loop for lli in ll
for mv-region in row-locns
do (setq mv-region (copy-region mv-region))
(setf (left-of mv-region) lo)
(setf (right-of mv-region) (+ lo left-label-size))
(place-subview self lli mv-region))
(loop for lli in ll
for l-region in
(tile-region-list
(make-region lo (+ lo left-label-size) bi ti)
(length ll) 1 nil 0 gap-y) do
(place-subview self lli l-region))))
(if rl
(loop for rli in rl
for l-region in
(tile-region-list
(make-region (- ro right-label-size) ro bi ti)
(length rl) 1 nil 0 gap-y) do
(place-subview self rli l-region)))
(when bl
(setq col-locns (or col-locns (compute-col-locns self)))
(if (= (length col-locns) (length bl))
(loop for bli in bl
for mv-region in col-locns do
(setq mv-region (copy-region mv-region))
(setf (bottom-of mv-region) bo)
(setf (top-of mv-region) (+ bottom-label-size bo))
(place-subview self bli mv-region))
(loop for bli in bl
for l-region in
(tile-region-list
(make-region li ri bo (+ bottom-label-size bo))
1 (length bl) nil gap-x 0 ) do
(place-subview self bli l-region))))
(if tl
(loop for tli in tl
for l-region in
(tile-region-list
(make-region li ri (- to top-label-size ) to)
1 (length tl) nil gap-x 0 ) do
(place-subview self tli l-region))))))))
(defmethod set-aspect-ratio ((self grid-plot)
&key viewport (ratio 1) (draw? t))
(declare (ignore viewport ratio draw? ))
(quail-error "Does nothing"))
(defmethod delete-subview :before ((self grid-plot) view)
(cond ((member view (interior-views-of self))
(setf (interior-views-of self)
(delete view (interior-views-of self))))
((loop for vs in (left-views-of self)
for i upfrom 0
until (member view vs)
finally (if (member view vs)
(setf (elt (left-views-of self) i) (delete view vs))
nil))
nil)
((loop for vs in (right-views-of self)
for i upfrom 0
until (member view vs)
finally (if (member view vs)
(setf (elt (right-views-of self) i) (delete view vs))
nil))
nil)
((loop for vs in (bottom-views-of self)
for i upfrom 0
until (member view vs)
finally (if (member view vs)
(setf (elt (bottom-views-of self) i) (delete view vs))
nil))
nil)
((loop for vs in (top-views-of self)
for i upfrom 0
until (member view vs)
finally (if (member view vs)
(setf (elt (top-views-of self) i) (delete view vs))
nil))
nil)
((member view (left-labels-of self))
(setf (left-labels-of self)
(delete view (left-labels-of self))))
((member view (right-labels-of self))
(setf (right-labels-of self)
(delete view (right-labels-of self))))
((member view (bottom-labels-of self))
(setf (bottom-labels-of self)
(delete view (bottom-labels-of self))))
((member view (top-labels-of self))
(setf (top-labels-of self)
(delete view (top-labels-of self))))
((eq view (title-of self)) (setf (title-of self) nil))
(t nil)))
(defmethod delete-useless-axes ((self grid-plot))
(let ((del-views nil)
(new nil)
(subviews (subviews-of self)))
(when (every #'(lambda(v) (and (typep v 'axis)
(hide-axis-p v)))
(setq new (flatten-views (left-views-of self))))
(setq del-views (append del-views new))
(setf (left-views-of self) nil))
(when (every #'(lambda(v) (and (typep v 'axis)
(hide-axis-p v)))
(setq new (flatten-views (right-views-of self))))
(setq subviews (remove del-views subviews))
(setf (right-views-of self) nil))
(when (every #'(lambda(v) (and (typep v 'axis)
(hide-axis-p v)))
(setq new (flatten-views (bottom-views-of self))))
(setq del-views (append del-views new))
(setf (bottom-views-of self) nil))
(when (every #'(lambda(v) (and (typep v 'axis)
(hide-axis-p v)))
(setq new (flatten-views (top-views-of self))))
(setq del-views (append del-views new))
(setf (top-views-of self) nil))
(setq subviews (remove del-views subviews))
(setf (subviews-of self) subviews)
(loop for del in del-views
do
(loop for v in (link-bounds-of del)
unless (eq v del) do
(remove-y-link v del)
(remove-x-link v del)))))
(defmethod row-format ((self grid-plot))
(let* ((iv (interior-views-of self))
(rows (if (typep (car iv) 'grid-layout)
(row-format (car iv))
(if iv (list iv))))
(left (left-views-of self))
(right (right-views-of self))
(bottom (bottom-views-of self))
(top (top-views-of self)))
(setq rows
(cond ((and rows left right)
(loop for v-mids in rows
for l-view in left
for r-view in right
collect
(append (list l-view) v-mids (list r-view))))
((and left right)
(mapcar #'list left right))
((and rows left)
(loop for v-mids in rows
for v in left
collect
(cons v v-mids)))
((and rows right)
(loop for v-mids in rows
for v in right
collect
(append v-mids (list v))))
(t (or rows (mapcar #'list left)
(mapcar #'list right)))))
(if top
(setq rows (cons top rows)))
(if bottom
(setq rows (append rows (list bottom))))
rows
))
(defmethod col-format ((self grid-plot))
(let* ((iv (interior-views-of self))
(cols (if (typep (car iv) 'grid-layout)
(col-format (car iv))
(if iv (list iv))))
(left (left-views-of self))
(right (right-views-of self))
(bottom (bottom-views-of self))
(top (top-views-of self)))
(setq cols
(cond ((and cols top bottom)
(loop for v-mids in cols
for l-view in top
for r-view in bottom
collect
(append (list l-view) v-mids (list r-view))))
((and top bottom)
(mapcar #'list top bottom))
((and cols top)
(loop for v-mids in cols
for v in top
collect
(cons v v-mids)))
((and cols bottom)
(loop for v-mids in cols
for v in bottom
collect
(append v-mids (list v))))
(t (or cols (mapcar #'list top)
(mapcar #'list bottom)))))
(if left
(setq cols (cons left cols)))
(if right
(setq cols (append cols (list right))))
cols
))
(defmethod row-views ((self grid-plot))
(let* ((iv (interior-views-of self))
(rows (row-views (car iv)))
(left (left-views-of self))
(right (right-views-of self))
(bottom (bottom-views-of self))
(top (top-views-of self)))
(setq rows
(cond ((and rows left right)
(if (= (length rows) (length left) (length right))
(mapcar #'append left rows right)))
((and left right)
(if (= (length left) (length right))
(mapcar #'append left right)))
((and rows left)
(if (= (length left) (length rows))
(mapcar #'append left rows)))
((and rows right)
(if (= (length right) (length rows))
(mapcar #'append rows right)))
(t (or rows left right))))
(if top
(setq rows (cons (reduce #'append top) rows)))
(if bottom
(setq rows (append rows (list (reduce #'append bottom)))))
rows
))
(defmethod col-views ((self grid-plot))
(let* ((iv (interior-views-of self))
(cols (col-views (car iv)))
(left (left-views-of self))
(right (right-views-of self))
(bottom (bottom-views-of self))
(top (top-views-of self)))
(setq cols
(cond ((and cols top bottom)
(if (= (length top) (length cols) (length bottom))
(mapcar #'append top cols bottom)))
((and top bottom)
(if (= (length top) (length bottom))
(mapcar #'append top bottom)))
((and cols top)
(if (= (length top) (length cols))
(mapcar #'append top cols )))
((and cols bottom)
(if (= (length bottom) (length cols))
(mapcar #'append cols bottom )))
(t (or cols top bottom))))
(if left
(setq cols (cons (reduce #'append left) cols)))
(if right
(setq cols (append cols (list (reduce #'append right)))))
cols
))
(defmethod merge-rows ((self grid-plot))
(let* ((iv (interior-views-of self))
(mrows (merge-rows (car iv)))
(rows-per-block (length mrows))
(rows (row-views (car iv)))
(left (left-views-of self))
(right (right-views-of self))
(bottom (bottom-views-of self))
(top (top-views-of self)))
(setq mrows
(cond ((and rows left right)
(if (= (length rows) (length left) (length right))
(loop for l in left
for r in right
for i upfrom 0
for j = (mod i rows-per-block) do
(setf (nth j mrows) (append l (nth j mrows) r))
finally (return mrows))))
((and left right)
(if (= (length left) (length right))
(mapcar #'append left right)))
((and rows left)
(if (= (length left) (length rows))
(loop for l in left
for i upfrom 0
for j = (mod i rows-per-block) do
(setf (nth j mrows) (append l (nth j mrows) ))
finally (return mrows))))
((and rows right)
(if (= (length right) (length rows))
(loop for r in right
for i upfrom 0
for j = (mod i rows-per-block) do
(setf (nth j mrows) (append (nth j mrows) r))
finally (return mrows))))
(t (or mrows left right))))
(if top
(setq mrows (cons (reduce #'append top) mrows)))
(if bottom
(setq mrows (append mrows (list (reduce #'append bottom)))))
mrows
))
(defmethod merge-cols ((self grid-plot))
(let* ((iv (interior-views-of self))
(mcols (merge-cols (car iv)))
(cols-per-block (length mcols))
(cols (col-views (car iv)))
(top (top-views-of self))
(bottom (bottom-views-of self))
(left (left-views-of self))
(right (right-views-of self)))
(setq mcols
(cond ((and cols top bottom)
(if (= (length cols) (length top) (length bottom))
(loop for l in top
for r in bottom
for i upfrom 0
for j = (mod i cols-per-block) do
(setf (nth j mcols) (append l (nth j mcols) r))
finally (return mcols))))
((and top bottom)
(if (= (length top) (length bottom))
(mapcar #'append top bottom)))
((and cols top)
(if (= (length top) (length cols))
(loop for l in top
for i upfrom 0
for j = (mod i cols-per-block) do
(setf (nth j mcols) (append l (nth j mcols) ))
finally (return mcols))))
((and cols bottom)
(if (= (length bottom) (length cols))
(loop for r in bottom
for i upfrom 0
for j = (mod i cols-per-block) do
(setf (nth j mcols) (append (nth j mcols) r))
finally (return mcols))))
(t (or mcols top bottom))))
(if left
(setq mcols (cons (reduce #'append left) mcols)))
(if right
(setq mcols (append mcols (list (reduce #'append right)))))
mcols
))
| 27,510 | Common Lisp | .l | 588 | 29.032313 | 95 | 0.454974 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | b664d2215784eee647ef478fab5d3f2d3f9158201dd74500c69dbb342bf9bc71 | 33,268 | [
-1
] |
33,269 | bar-plot.lsp | rwoldford_Quail/source/views/plots/bar-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; bar-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1996
(in-package :views)
(defmethod init-position-margin-labels :around ((self plot)
outer-space inner-space
&rest key-args )
(let ((i (interior-view-of self)))
(cond ((typep i 'bar-chart)
(apply #'bar-plot-position-margin-labels self outer-space inner-space key-args))
((and (typep i 'batch-layout)
(typep (car (subviews-of i)) 'bar-chart))
(apply #'bar-plot-position-margin-labels self outer-space inner-space key-args))
(t (call-next-method)))))
(defmethod bar-plot-position-margin-labels ((self plot) outer-space inner-space
&key bottom-label-size top-label-size
left-label-size right-label-size gap-x gap-y
&allow-other-keys)
(with-accessors ((ll left-labels-of) (rl right-labels-of)
(tl top-labels-of) (bl bottom-labels-of))
self
(multiple-value-bind (li ri bi ti)
(bounds-of inner-space)
(multiple-value-bind (lo ro bo to)
(bounds-of outer-space)
(let* ((iv (interior-view-of self))
(bar-chart (if (typep iv 'bar-chart) iv
(car (descendant-views-of-type iv 'bar-chart) )))
(orientation (if bar-chart (orientation-of bar-chart)))
(batch-strings (if bar-chart (generate-bar-strings bar-chart)))
tiles)
(when ll
(setq tiles
(if (and (eq orientation :horizontal)
(= (length ll) (reduce #'+ batch-strings :key #'length )))
(loop with w = (/ left-label-size (length batch-strings))
with f = (+ lo left-label-size)
for c in batch-strings
append (tile-region-list
(make-region (- f w) f bi ti)
(length c) 1 nil 0 0 )
do (decf f w))
(tile-region-list
(make-region lo (+ lo left-label-size) bi ti)
(length ll) 1 nil 0 gap-y)))
(loop for lli in ll
for l-region in tiles
do
(place-subview self lli l-region)))
(when rl
(setq tiles
(if (and (eq orientation :horizontal)
(= (length rl) (reduce #'+ batch-strings :key #'length )))
(loop with w = (/ right-label-size (length batch-strings))
with f = (- ro right-label-size)
for c in batch-strings
append (tile-region-list
(make-region f (+ f w) bi ti)
(length c) 1 nil 0 0 )
do (incf f w))
(tile-region-list
(make-region (- ro right-label-size) ro bi ti)
(length rl) 1 nil 0 gap-y)))
(loop for rli in rl
for l-region in tiles
do
(place-subview self rli l-region)))
(when bl
(setq tiles
(if (and (eq orientation :horizontal)
(= (length bl) (reduce #'+ batch-strings :key #'length )))
(loop with w = (/ bottom-label-size (length batch-strings))
with f = (+ bo bottom-label-size)
for c in batch-strings
append (tile-region-list
(make-region li ri (- f w) f )
1 (length c) nil 0 0 )
do (decf f w))
(tile-region-list
(make-region li ri bo (+ bottom-label-size bo))
1 (length bl) nil gap-x 0 )))
(loop for bli in bl
for l-region in tiles do
(place-subview self bli l-region)))
(when tl
(setq tiles
(if (and (eq orientation :horizontal)
(= (length bl) (reduce #'+ batch-strings :key #'length )))
(loop with w = (/ top-label-size (length batch-strings))
with f = (- to top-label-size)
for c in batch-strings
append (tile-region-list
(make-region li ri f (+ f w))
1 (length c) nil 0 0 )
do (incf f w))
(tile-region-list
(make-region li ri (- to top-label-size ) to)
1 (length tl) nil gap-x 0 )))
(loop for tli in tl
for l-region in tiles do
(place-subview self tli l-region)))
))))) | 5,788 | Common Lisp | .l | 114 | 30.763158 | 92 | 0.416922 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 331b8f05e17efdc71636c21c57e82364516a23997622d9d2bb0ed81f4c30c3f5 | 33,269 | [
-1
] |
33,270 | overlay-plots.lsp | rwoldford_Quail/source/views/plots/overlay-plots.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; overlay-plots.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1992 George Washington University
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '( overlay-plot )))
(defun overlay-plot (&rest keyword-pairs
&key
(initform-fn #'get-batch-inits)
(cases #'list-cases) (title t)
(colors (mapcar #'second *color-menu-list*))
(plot-fn #'2d-plot) (draw? t) (by :prompt)
case-views-from
&allow-other-keys)
(setq keyword-pairs (append (apply initform-fn keyword-pairs) keyword-pairs))
(disable-keyword keyword-pairs :initform-fn)
(disable-keyword keyword-pairs :type)
(let* ( (dataset (getf keyword-pairs :data))
(groups (get-batches :batches (getf keyword-pairs :batches)
:by by
:order-levels (getf keyword-pairs :order-levels)
:level-function (or (getf keyword-pairs :level-function)
(getf keyword-pairs :level-functions))
:dataset dataset :cases cases))
(p (apply plot-fn
:title (cond ((eq title t) (list :data dataset))
((legal-label-construct-p title )
(append (sublabel-arg-list title)
(list :data dataset)))
(t title))
:top-label (loop repeat (length groups)
collect (view :type 'data-label))
:data (first groups)
:color (first colors)
:draw? nil
:case-views-from case-views-from
keyword-pairs))
(fs (mapcar #'clone-view-fn (interior-views-of p))))
(loop with int = (interior-views-of p)
for l in (top-labels-of p)
for b in groups
for c in colors
do
(loop for i in int
do (text-unlink i l))
(setf (viewed-object-of l) b)
(setf (text-of l) (dataset-name b))
(set-drawing-style l :color c))
(loop with i = (interior-view-of p)
with var-args = (var-info i nil)
for b in (cdr groups)
for c in (cdr colors) do
(loop for f in fs
for new =
(apply f :data b
:cases cases
:case-views-from case-views-from
var-args ) do
(set-drawing-style new :color c :draw? nil)
(layer-subview p new i :draw? nil :clip-region :max)))
(if draw? (draw-view p))
p))
#|
(setq foo (list (sub-cases (car (list-drills assay)))
(sub-cases (fifth (list-drills assay)))))
(length foo)
(overlay-plot :data vw::assay
:batches (list (sub-cases (car (list-drills assay)))
(sub-cases (fifth (list-drills assay))))
;; :colors (list wb:*white-color* wb:*light-gray-color*)
)
(overlay-plot :data vw::assay
:batches (list (car (list-drills assay))
(fifth (list-drills assay)))
:cases #'sub-cases
;; :colors (list wb:*white-color* wb:*light-gray-color*)
)
try scatmat
varinfor for scatmat
|#
| 4,377 | Common Lisp | .l | 95 | 29.663158 | 92 | 0.438823 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | d5e27646fc38576b2ab53ff99aaba657964b5aae1b96143c7ad437869e310e46 | 33,270 | [
-1
] |
33,271 | plot.lsp | rwoldford_Quail/source/views/plots/plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1988-1991 George Washington University
;;; R.W. Oldford 1988-1991
;;;
;;; 7/15/93 added label handling to delete-subview :before ((self plot) view)
;;; also allowed subview argument to be function
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(plot *default-plot-gap* standard-plot prompt-for-plot-interior row-views col-views
margin-string-left margin-string-right margin-string-bottom margin-string-top )))
(defvar *default-plot-gap* 0)
;;;----------------------------------------------------------------------------------
(defclass plot-mixin (bordered-view-mixin titled-view-mixin
margined-view-mixin)
()
)
(defclass plot (plot-mixin compound-view)
((right-menu :allocation :class :initform nil)
(middle-menu :allocation :class :initform nil)
(default-interior :initform 'view
:accessor default-interior-of :initarg :default-interior)
(position-keys :allocation :class
:initform '(:left-view-size :right-view-size
:bottom-view-size :top-view-size
:bottom-label-size :top-label-size
:left-label-size :right-label-size
:title-height :title-width
:left-margin-size :right-margin-size
:bottom-margin-size :top-margin-size
:gap-x :gap-y ) ))
(:default-initargs
:link-bounds-x? :by-col :link-bounds-y? :by-row
:gap-x *default-plot-gap* :gap-y *default-plot-gap*
:interior-view :default
)
(:documentation "The basic plot. "))
(defclass standard-plot (plot)
()
(:default-initargs
:right-margin-size 0.07
:left-view 'axis :bottom-view 'axis
:left-label 'label :bottom-label 'label
)
(:documentation "Plot with left and bottom axes and labels . "))
(defmethod initialize-instance :around ((self plot)
&rest initargs
&key (margins :default)
&allow-other-keys)
(case margins
(:none (if (getf initargs :title)
(apply #'call-next-method self
:no-margin-views? t
:no-labels? t
initargs)
(apply #'call-next-method self
:title nil :no-margin-views? t
:no-labels? t
initargs)))
(t (call-next-method))))
(defgeneric prompt-for-plot-interior (plot)
(:documentation "Prompts user for plot interior")
)
(defgeneric margin-string-bottom (view)
(:documentation "A string to be used on a bottom plot margin around view."))
(defgeneric margin-string-right (view)
(:documentation "A string to be used on a right plot margin around view."))
(defgeneric margin-string-left (view)
(:documentation "A string to be used on a left plot margin around view."))
(defgeneric margin-string-top (view)
(:documentation "A string to be used on a top plot margin around view."))
(defmethod prompt-for-plot-interior ((self plot))
(choose-view-from-menu
:prompt-string "Select plot interior"
:superclass 'view))
;;;----------------------------------------------------------------------------------
(defmethod auto-draw-p ((self plot))
*auto-draw-plot?*)
(defmethod subview-position-region-of :before ((self plot))
(if (null (slot-value self 'subview-position-region))
(setf (slot-value self 'subview-position-region)
(make-region (bounding-region-of self)))))
(defmethod allowed-subview-movement ((self plot) subview)
;; may returns :x :y :both or :none
;; determines how subview may be moved within view
(cond
((or (member subview (left-views-of self))
(member subview (right-views-of self)))
:x)
((or (member subview (bottom-views-of self))
(member subview (top-views-of self)))
:y)
((member subview (interior-views-of self))
:none)
(t :both)))
(defmethod layer-subview ((self plot) (view linkable-bounds-mixin )
(on linkable-bounds-mixin )
&rest arg
&key (ignore-x? :default)
(ignore-y? :default))
(if
(member on (append (bottom-views-of self)
(top-views-of self)))
(if (eq ignore-y? :default) (setq ignore-y? t))
(if (member on (append (left-views-of self)
(right-views-of self)))
(if (eq ignore-x? :default) (setq ignore-x? t))))
(let ((locn (select-sub-view-locn self on)))
(if (null locn)
(quail-error "~S is not a subview of ~S" on self))
(place-subview self view (make-region locn))
(apply #'layer-link-view view on :parent self
:ignore-x? ignore-x? :ignore-y? ignore-y? arg)
(add-to-named-slot self on view)
)
view
)
;;;----------------------------------------------------------------------------------
(defun keyword-list-p(arg)
(and arg
(listp arg)
(evenp (length arg))
(loop for key in arg by #'cddr
always (keywordp key))))
(defun legal-view-construct-p(arg)
"Tests if the argument can be used to construct a view.~
Argument should be a view, symbol,function or a list. ~
If the argument is a list, it should contain~
keywords followed by their values."
(or (symbolp arg) (functionp arg)
(view-p arg)
(keyword-list-p arg)))
(defun legal-label-construct-p(arg)
"Tests if the argument can be used to construct a label.~
Argument should be a label, symbol, function, string or a list. ~
If the argument is a list, it should contain~
keywords followed by their values."
(or (symbolp arg) (functionp arg) (stringp arg)
(typep arg 'label)
(keyword-list-p arg)))
(defun subview-arg-list(arg &optional default-type)
(let* ((arglist
(cond
((or (null arg) (eq t arg)) nil)
((or (symbolp arg) (functionp arg)) (list :type arg))
((and (listp arg) (evenp (length arg)))
arg)
(t nil)))
(type-val (getf arglist :type)))
(if (and type-val (not (eq t type-val)))
arglist
(setf (getf arglist :type) default-type))
(setf (getf arglist :draw?) nil)
arglist))
(defun sublabel-arg-list(arg &optional (default-type 'label))
(let* ((arglist
(cond ((or (symbolp arg) (functionp arg)) (list :type arg))
((stringp arg) (list :text arg))
((and (listp arg) (evenp (length arg)))
arg)
(t nil)))
(type-val (getf arglist :type)))
(if (and type-val (not (eq t type-val)))
arglist
(setf (getf arglist :type) default-type))
(setf (getf arglist :draw?) nil)
arglist))
(defun view-from-arg(view-args other-args
&optional
(default-type 'view)
(arg-list-fn #'subview-arg-list))
(if (view-p view-args)
view-args
(apply #'view
(append
(funcall arg-list-fn view-args default-type)
other-args))))
(defun margin-view-from-arg(view-args other-args data-args
&optional
(default-type 'view)
(arg-list-fn #'subview-arg-list))
(if (view-p view-args)
view-args
(let* ((args (funcall arg-list-fn view-args default-type))
(new-var (getf args :var)) (new-data (getf args :data)))
(setq args (append args other-args))
(cond (new-data
(apply #'view args))
(new-var
(apply #'view (append args (list :function nil :transform nil :coords nil)
data-args)))
(t (apply #'view (append args data-args)))))))
(defmethod construct-margin-labels ((self plot) &key label-font)
"Constructs label views using information provided by~
the :left-label :right-label :bottom-label :top-label initargs.~
Each label initarg should pass the legal-label-construct-p test,~
or be a list whose elements pass the legal-label-construct-p test.~
If an initarg is null, the corresponding label is not constructed.~
If the initarg does not provide a string, it will be obtained from~
the interior-view.~
Each legal-label-construct, together with keyword-pairs,~
is used to construct labels, which are stored in the~
corresponding label slot.~
Label font will be used as the font for any constructed label, when~
the legal-label-construct does not have a font value."
(with-accessors ((ll left-labels-of) (rl right-labels-of)
(tl top-labels-of) (bl bottom-labels-of)
(vo viewed-object-of))
self
(flet ((label-from-arg(arg margin &optional string)
(let ((new (view-from-arg
arg
(list :orientation nil :font label-font :data vo :text string)
'label #'sublabel-arg-list)))
(init-label-text self margin new)
new)))
(multiple-value-setq (tl bl rl ll)
(values-list
(loop for l in (list tl bl rl ll)
for margin in (list :top :bottom :right :left)
collect
(if (null l) nil
(cond
((typep l 'view)
(list (label-from-arg l margin)))
((eql l :if-string)
(loop for s in (case margin
(:top (margin-string-top self))
(:bottom (margin-string-bottom self))
(:right (margin-string-right self))
(:left (margin-string-left self)))
collect
(label-from-arg t margin s)))
((legal-label-construct-p l)
(loop for s in (or (case margin
(:top (margin-string-top self))
(:bottom (margin-string-bottom self))
(:right (margin-string-right self))
(:left (margin-string-left self)))
(list ""))
collect
(label-from-arg l margin s)))
((and (listp l) (every #'legal-label-construct-p l))
(loop for li in l
collect (label-from-arg li margin)))
(t (quail-error "Illegal subview argument ~A" l))))))))))
(defmethod construct-interior-view ((self plot)
&rest keyword-pairs &key )
"Constructs an interior-view using information provided by~
the :interior-view initarg.~
The interior-view initarg should pass the legal-view-construct-p test,~
or be a list whose elements pass the legal-view-construct-p test.~
Each legal-view-construct, together with keyword-pairs,~
is used to construct a view placed in the interior-view slot. ~
There must be at least one such view."
(with-accessors ((iv interior-views-of))
self
(let (var-args mem)
(labels ((local-make-view(arg)
(let ((v
(view-from-arg arg (append keyword-pairs var-args))))
(setq var-args (var-info v var-args))
v)))
(cond ((eql iv :prompt)
(setf iv (prompt-for-plot-interior self)))
((or (null iv) (eql iv :default))
(setf iv (default-interior-of self)))
((and (listp iv) (setq mem (member :default iv)))
(let ((default (default-interior-of self)))
(if (legal-view-construct-p default)
(setf (car mem) default)
(setf iv (append (butlast
(nreverse (member :default (reverse iv))))
default
(cdr mem)))))))
(setf iv
(cond ((legal-view-construct-p iv)
(list (local-make-view iv)))
((and (listp iv) (every #'legal-view-construct-p iv))
(mapcar #'local-make-view iv))
(t (quail-error "Illegal subview argument ~A" iv))))
))))
(defmethod view-title-string ((self plot))
nil
)
(defmethod construct-sub-views :after ((self plot)
&rest keyword-pairs &key )
(declare (ignore keyword-pairs))
(let ((ti (title-of self))
(iv (interior-view-of self)))
(when (and ti iv (null (text-of ti)))
(setf (text-of ti)
(view-title-string iv)))))
(defmethod plot-margin-br-info ((self plot) axis &optional from-view)
(let* ((iv (or from-view (interior-view-of self)))
(br (if (typep iv 'd-view)
(smallest-bounding-region iv)
(bounding-region-of iv)))
(iv-axis (if (typep iv '1d-view) (orientation-of iv))))
(cond
((typep iv '2d-view)
(if (eq axis :horizontal)
(list :bounding-region (if (null (x-variate-of iv)) br)
:pretty? t
:flip-x? (flip-x-p iv))
(list :bounding-region (if (or (null (y-variate-of iv))
(typep iv 'line-segments-per-case)) br)
:pretty? t
:flip-y? (flip-y-p iv))))
((and (typep iv '1d-view) (eq iv-axis axis))
(list :bounding-region (if (null (variate-of iv)) br)
:pretty? t
:flip-x? (if (eq iv-axis :horizontal) (flip-x-p iv))
:flip-y? (if (eq iv-axis :vertical) (flip-y-p iv))))
((typep iv '1d-view)
(list :bounding-region (smallest-bounding-region iv)
:pretty? t
:flip-x? (if (eq iv-axis :vertical) (flip-x-p iv))
:flip-y? (if (eq iv-axis :horizontal) (flip-y-p iv))))
(t (list :pretty? t
:bounding-region br)))))
(defmethod plot-margin-coord-info ((self plot) axis &optional from-view)
(let* ((iv (or from-view (interior-view-of self)))
(iv-axis (if (typep iv '1d-view) (orientation-of iv))))
(append (if (typep iv 'd-view)
(list :cases (cases-of iv)
:value-fn (value-fn-of iv)
:variates (variates-of iv)))
(cond
((typep iv 'line-segments-per-case)
(if (eq axis :horizontal)
(list :var (x-variate-of iv)
:function (x-func-of iv)
:transform (x-transform-of iv)
:coords (mapcar #'first (x-coords-of iv)))
(list :var (y-variate-of iv)
:function (y-func-of iv)
:transform (y-transform-of iv)
:coords (mapcar #'first (y-coords-of iv)))))
((typep iv '2d-view)
(if (eq axis :horizontal)
(list :var (x-variate-of iv)
:function (x-func-of iv)
:transform (x-transform-of iv)
:coords (x-coords-of iv))
(list :var (y-variate-of iv)
:function (y-func-of iv)
:transform (y-transform-of iv)
:coords (y-coords-of iv))))
((and (typep iv '1d-view) (eq iv-axis axis))
(list :var (variate-of iv)
:function (func-of iv)
:transform (transform-of iv)
:coords (coords-of iv)))
(t (list :var nil
:function nil
:transform nil))))))
(defmethod construct-margin-views ((self plot)
&key (delete-useless-axes? t)
link-bounds-x?
link-bounds-y?)
"Constructs margin views using information provided by~
the :left-view :right-view :bottom-view :top-view initargs.~
Each initarg should pass the legal-view-construct-p test,~
or be a list whose elements pass the legal-view-construct-p test.~
If an initarg is null, the corresponding view is not constructed.~
The default view type is axis. ~
Each legal-view-construct, together with keyword-pairs,~
is used to construct a view which is placed in the appropriate slot."
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of)
(vo viewed-object-of))
self
(multiple-value-setq (lv rv bv tv)
(values-list
(loop for v in (list lv rv bv tv)
for axis in (list :vertical :vertical :horizontal :horizontal)
for just in (list :right :left :top :bottom )
for coord-info = (plot-margin-coord-info self axis)
for br-info = (append (list :data vo :orientation axis :justification just)
(plot-margin-br-info self axis))
collect
(cond ((null v) nil)
((legal-view-construct-p v)
(list (margin-view-from-arg v br-info coord-info 'axis)))
((and (listp v) (every #'legal-view-construct-p v) )
(loop for vi in v collect (margin-view-from-arg vi br-info coord-info 'axis)))
(t (quail-error "Illegal subview argument ~A" v))))))
(constrain-bounds self :link-bounds-x? link-bounds-x?
:link-bounds-y? link-bounds-y?)
(if delete-useless-axes? (delete-useless-axes self))
(loop with x-views = (append bv tv) with y-views = (append lv rv)
for vi in iv
when (typep vi 'histogram-view) do
(if (eq :horizontal (orientation-of vi))
(loop for v in x-views
when (typep v 'axis) do
(setf (tic-list-of v) (break-points-of vi)))
(loop for v in y-views
when (typep v 'axis) do
(setf (tic-list-of v) (break-points-of vi)))))))
(defmethod compute-interior-region ((self plot)
&key left-view-size right-view-size
bottom-view-size top-view-size
bottom-label-size top-label-size
left-label-size right-label-size
xy-ratio )
"Computes the region to be occupied by the interior view"
(with-bordered-plot-subs
self iv lv rv bv tv ll rl bl tl
(declare (ignorable iv))
(let* ((space (subview-position-region self))
y-view-len x-view-len x-mid y-mid
interior-region)
(setq y-view-len (- (height-of space)
(if bv bottom-view-size 0.0) (if tv top-view-size 0)
(if bl bottom-label-size 0) (if tl top-label-size 0)))
(setq x-view-len (- (width-of space)
(if lv left-view-size 0.0) (if rv right-view-size 0 )
(if ll left-label-size 0 ) (if rl right-label-size 0)))
(setq y-mid (+ (bottom-of space) (if bv bottom-view-size 0 )
(if bl bottom-label-size 0) (* 0.5 y-view-len)))
(setq x-mid (+ (left-of space) (if ll left-label-size 0)
(if lv left-view-size 0 ) (* 0.5 x-view-len)))
(when xy-ratio
(setq y-view-len (min y-view-len (/ x-view-len xy-ratio)))
(setq x-view-len (* xy-ratio y-view-len )))
(setq interior-region
(make-region (- x-mid (* .5 x-view-len)) (+ x-mid (* .5 x-view-len))
(- y-mid (* .5 y-view-len)) (+ y-mid (* .5 y-view-len))))
(valid-region-check interior-region)
interior-region)))
(defmethod init-position-margin-labels ((self plot) outer-space inner-space
&key bottom-label-size top-label-size
left-label-size right-label-size gap-x gap-y)
(with-accessors ((ll left-labels-of) (rl right-labels-of)
(tl top-labels-of) (bl bottom-labels-of))
self
(multiple-value-bind (li ri bi ti)
(bounds-of inner-space)
(multiple-value-bind (lo ro bo to)
(bounds-of outer-space)
(if ll
(loop for lli in ll
for l-region in
(tile-region-list
(make-region lo (+ lo left-label-size) bi ti)
(length ll) 1 nil 0 gap-y) do
(place-subview self lli l-region)))
(if rl
(loop for rli in rl
for l-region in
(tile-region-list
(make-region (- ro right-label-size) ro bi ti)
(length rl) 1 nil 0 gap-y) do
(place-subview self rli l-region)))
(if bl
(loop for bli in bl
for l-region in
(tile-region-list
(make-region li ri bo (+ bottom-label-size bo))
1 (length bl) nil gap-x 0 ) do
(place-subview self bli l-region)))
(if tl
(loop for tli in tl
for l-region in
(tile-region-list
(make-region li ri (- to top-label-size ) to)
1 (length tl) nil gap-x 0 ) do
(place-subview self tli l-region)))))))
(defmethod init-position-margin-views ((self plot) outer-space inner-space
&key bottom-view-size top-view-size
left-view-size right-view-size )
(declare (ignore outer-space))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of))
self
(multiple-value-bind (li ri bi ti)
(bounds-of inner-space)
(if lv
(loop for lvi in lv
for mv-region =
(make-region (- li left-view-size) li bi ti) do
(place-subview self lvi mv-region)))
(if rv
(loop for rvi in rv
for mv-region =
(make-region ri (+ ri right-view-size) bi ti) do
(place-subview self rvi mv-region)))
(if bv
(loop for bvi in bv
for mv-region =
(make-region li ri (- bi bottom-view-size) bi) do
(place-subview self bvi mv-region)))
(if tv
(loop for tvi in tv
for mv-region =
(make-region li ri ti (+ ti top-view-size)) do
(place-subview self tvi mv-region))))))
(defmethod init-position-margin-views :after ((self plot) outer-space inner-space &key)
(declare (ignore outer-space inner-space))
(hide-useless-axes self))
(defmethod init-position-interior-views ((self plot) space &key)
(loop for v in (interior-views-of self) do
(place-subview self v (make-region space))))
(defmethod constrain-bounds ((self plot) &key draw? link-bounds-x? link-bounds-y? recompute?)
(if (and link-bounds-x? (or (top-views-of self) (bottom-views-of self))
)
(loop for views in (case link-bounds-x?
(:by-row (row-views self))
(:by-col (col-views self))
(:by-block-row (merge-rows self))
(:by-block-col (merge-cols self))
(t (list (apply #'append (row-views self)))))
for x-views = (loop for v in views
when (linkable-bounds-x-p v) collect v)
for d-views = (loop for v in x-views
when (and (typep v 'd-view) (use-x-axis-p v)) collect v)
when (> (length x-views) 1)
do
(link-view-bounds x-views :x)
(set-view-extents x-views :x :recompute? recompute?
:region (if d-views (maximize-x-extents d-views)) )))
(if (and link-bounds-y? (or (left-views-of self) (right-views-of self)))
(loop for views in (case link-bounds-y?
(:by-row (row-views self))
(:by-block-row (merge-rows self))
(:by-block-col (merge-cols self))
(:by-col (col-views self))
(t (list (apply #'append (row-views self)))))
for y-views = (loop for v in (flatten-views views)
when (linkable-bounds-y-p v) collect v)
for d-views = (loop for v in y-views
when (and (typep v 'd-view) (use-y-axis-p v)) collect v)
when (> (length y-views) 1)
do
(link-view-bounds y-views :y)
(set-view-extents y-views :y :recompute? recompute?
:region (if d-views (maximize-y-extents d-views)) )))
(when (or link-bounds-x? link-bounds-y?)
(remap-to-viewports self :erase? draw? :draw? draw?)))
(defmethod enlist-views ((self plot) view)
(if (listp view) view (list view)))
(defmethod set-aspect-ratio ((self plot)
&key viewport (ratio 1) (draw? t))
;; an x unit / y unit becomes ratio for interior view and margin views
(setq viewport (or viewport (car (viewports-of self))))
(when viewport
(if draw? (erase-view self :viewport viewport))
(let* ((iv (interior-view-of self))
;(vp-iv (select-viewport iv viewport)) ; 30JUL2023
(tr (select-map-to-viewport self viewport))
(max-vp (apply-transform tr (subview-position-region self)))
(br (bounding-region-of iv))
(s (min (/ (width-of max-vp) (width-of br))
(* ratio (/ (height-of max-vp) ( height-of br)))))
(new-w (* s (width-of br)))
(new-h (/ (* s (height-of br)) ratio))
(new-loc ))
(set-viewport-width-height max-vp new-w new-h)
(setq new-loc (apply-transform
(invert-transform tr)
max-vp))
(loop for v in (interior-views-of self) do
(place-subview self v (make-region new-loc )))
(when (left-views-of self)
(loop with views = (left-views-of self)
with region = ( select-sub-view-locn self (car views))
for v in views
for mv-region =
(make-region
(left-of region) (right-of region)
(bottom-of new-loc) (top-of new-loc))
do
(place-subview self v mv-region)))
(when (right-views-of self)
(loop with views = (right-views-of self)
with region = ( select-sub-view-locn self (car views))
for v in views
for mv-region =
(make-region
(left-of region) (right-of region)
(bottom-of new-loc) (top-of new-loc))
do
(place-subview self v mv-region)))
(when (bottom-views-of self)
(loop with views = (bottom-views-of self)
with region = ( select-sub-view-locn self (car views))
for v in views
for mv-region =
(make-region
(left-of new-loc) (right-of new-loc)
(bottom-of region) (top-of region))
do
(place-subview self v mv-region)))
(when (top-views-of self)
(loop with views = (top-views-of self)
with region = ( select-sub-view-locn self (car views))
for v in views
for mv-region =
(make-region
(left-of new-loc) (right-of new-loc)
(bottom-of region) (top-of region))
do
(place-subview self v mv-region)))
(map-subviews-to-viewport self )
(if draw? (draw-view self)))))
(defmethod add-to-named-slot ((self plot) old new)
(cond ((member old (interior-views-of self))
(setf (interior-views-of self)
(append (interior-views-of self) (list new))))
((member old (left-views-of self))
(setf (left-views-of self)
(append (left-views-of self) (list new))))
((member old (right-views-of self))
(setf (right-views-of self)
(append (right-views-of self) (list new))))
((member old (bottom-views-of self))
(setf (bottom-views-of self)
(append (bottom-views-of self) (list new))))
((member old (top-views-of self))
(setf (top-views-of self)
(append (top-views-of self) (list new))))
(t nil)))
(defmethod delete-subview :before ((self plot) view)
(cond ((member view (interior-views-of self))
(setf (interior-views-of self)
(delete view (interior-views-of self))))
((member view (left-views-of self))
(setf (left-views-of self)
(delete view (left-views-of self))))
((member view (right-views-of self))
(setf (right-views-of self)
(delete view (right-views-of self))))
((member view (bottom-views-of self))
(setf (bottom-views-of self)
(delete view (bottom-views-of self))))
((member view (top-views-of self))
(setf (top-views-of self)
(delete view (top-views-of self))))
((member view (left-labels-of self))
(setf (left-labels-of self)
(delete view (left-labels-of self))))
((member view (right-labels-of self))
(setf (right-labels-of self)
(delete view (right-labels-of self))))
((member view (bottom-labels-of self))
(setf (bottom-labels-of self)
(delete view (bottom-labels-of self))))
((member view (top-labels-of self))
(setf (top-labels-of self)
(delete view (top-labels-of self))))
((eq view (title-of self)) (setf (title-of self) nil))
(t nil)))
(defmethod change-variable ((self plot) &rest keyword-args
)
(let ((iv (interior-view-of self)))
(if (typep iv 'd-view)
(apply #'change-variable-when-vars iv keyword-args)
(if (compute-applicable-methods #'change-variable (list iv) )
(apply #'change-variable iv keyword-args)))))
(defmethod add-fitted-line ((self plot) &rest keyword-args )
(apply #'add-fitted-line (interior-view-of self) keyword-args))
(defmethod add-lines ((self plot) &rest keyword-args)
(apply #'add-lines (interior-view-of self) keyword-args))
(defmethod add-simple-lines ((self plot) &rest keyword-args)
(apply #'add-simple-lines (interior-view-of self) keyword-args))
(defmethod add-smooth ((self plot) &rest keyword-args)
(apply #'add-smooth (interior-view-of self) keyword-args))
(defmethod add-simple-smooth ((self plot) &rest keyword-args)
(apply #'add-simple-smooth (interior-view-of self) keyword-args))
(defmethod change-case-status ((self plot) cases status &rest args )
(let ((iv (interior-view-of self)))
(if (compute-applicable-methods #'change-case-status
(list iv cases status args))
(apply #'change-case-status iv cases status args))))
(defmethod activate-cases ((self plot) cases &rest args &key )
(let ((iv (interior-view-of self)))
(if (compute-applicable-methods #'activate-cases
(list iv cases args))
(apply #'activate-cases iv cases args))))
(defmethod deactivate-cases ((self plot) cases &rest args &key )
(let ((iv (interior-view-of self)))
(if (compute-applicable-methods #'deactivate-cases
(list iv cases args))
(apply #'deactivate-cases iv cases args))))
(defmethod activate-all-cases ((self plot) &rest args &key )
(let ((iv (interior-view-of self)))
(if (compute-applicable-methods #'activate-all-cases (list iv args) )
(apply #'activate-all-cases iv args))))
(defmethod menu-properties ((self plot)
(slot-name (eql 'middle-menu)))
(let ((iv (interior-view-of self)))
(if iv
(acons :iv-type (class-name (class-of iv))
(if (typep iv 'data-menu-item-mixin)
(copy-tree (menu-properties iv 'middle-menu )))))))
(defmethod get-menu-items ((self plot) (slot-name (eql 'middle-menu)))
(let ((iv (interior-view-of self))
menu-items
var-menu
case-menu)
(when (typep iv 'data-menu-item-mixin)
(setq var-menu (var-menu-items (interior-view-of self)
:target 'interior-view-of))
(setq case-menu (case-menu-items (interior-view-of self)
:target 'interior-view-of))
(if var-menu
(setq menu-items
`(("Variables" nil "" :sub-items ,var-menu))))
(if case-menu
(setq menu-items
(append menu-items
`(("Cases" nil "" :sub-items ,case-menu))))
))
(setq menu-items
(append menu-items
`(("Point symbols" nil "" :sub-items ,(ps-subview-menu-items)))))
(unless (string-equal "-" (caar menu-items))
(push '("-" nil) menu-items))
menu-items
))
(defun ps-subview-menu-items()
(labels ((get-ps(self)
(let* ((point-clouds (descendant-views-of-type self 'one-per-case-mixin))
(ps (or (loop for p in point-clouds append (some-subviews p :highlit? t))
(loop for p in point-clouds append (subviews-of p)))))
ps))
(set-ps-colours(self color)
(if (eq color :prompt)
(setq color (wb::prompt-user-for-color)))
(with-update-style-cache
(loop for s in (get-ps self)
do (set-drawing-style s :color color))))
(set-ps-fill(self fill)
(with-update-style-cache
(loop for s in (get-ps self)
do (set-drawing-style s :fill? fill))))
(set-ps-size(self size)
(with-update-style-cache
(loop for s in (remove-duplicates (get-ps self))
when (typep s 'view-with-size)
do (set-view-size s size))))
(set-ps-symbol(self symbol)
(loop for s in (get-ps self)
do (set-drawing-style s :symbol symbol )))
)
(let ((color-change-list
(loop for c in
(if (wb:color-device-p)
*color-menu-list*
*shade-menu-list*)
collect
(list (car c) (list #'set-ps-colours (cadr c)))))
( shape-change-list
(loop for s in *point-symbol-types*
collect
(list (string-downcase s) (list #'set-ps-symbol s))))
( size-change-list
(loop for s in (list :smaller :larger )
collect
(list (string-downcase s) (list #'set-ps-size s))))
( fill-change-list
(list (list "On" (list #'set-ps-fill t))
(list "Off" (list #'set-ps-fill nil))))
)
(list (list "Colors" nil "" :sub-items color-change-list)
(list "Shape" nil "" :sub-items shape-change-list)
(list "Size" nil "" :sub-items size-change-list)
(list "Fill?" nil "" :sub-items fill-change-list)))))
(defmethod hide-useless-axes ((self plot))
(loop for sv in (flatten-views (append (left-views-of self)
(right-views-of self)
(bottom-views-of self)
(top-views-of self)))
when (and (typep sv 'axis)
(hide-axis-p sv))
do
(set-drawing-style sv :invisible? t)))
(defmethod delete-useless-axes ((self plot))
(setf (left-views-of self)
(loop for sv in (left-views-of self)
unless (and (typep sv 'axis)
(hide-axis-p sv))
collect sv))
(setf (right-views-of self)
(loop for sv in (right-views-of self)
unless (and (typep sv 'axis)
(hide-axis-p sv))
collect sv))
(setf (bottom-views-of self)
(loop for sv in (bottom-views-of self)
unless (and (typep sv 'axis)
(hide-axis-p sv))
collect sv))
(setf (top-views-of self)
(loop for sv in (top-views-of self)
unless (and (typep sv 'axis)
(hide-axis-p sv))
collect sv)))
(defmethod margin-string-bottom ((self view))
(let* ((s (coord-string-x self)))
(if (listp s) s (list s))))
(defmethod margin-string-top ((self view))
(let* ((s (coord-string-x self)))
(if (listp s) s (list s))))
(defmethod margin-string-left ((self view))
(let* ((s (coord-string-y self)))
(if (listp s) s (list s))))
(defmethod margin-string-right ((self view))
(let* ((s (coord-string-y self)))
(if (listp s) s (list s))))
;;------------------------------------------------------------------------------
(defmethod margin-string-top ((self plot))
(let* ((iv (interior-view-of self))
(s (if iv (margin-string-top iv))))
(if (listp s) s (list s))))
(defmethod margin-string-bottom ((self plot))
(let* ((iv (interior-view-of self))
(s (if iv (margin-string-bottom iv))))
(if (listp s) s (list s))))
(defmethod margin-string-left ((self plot))
(let* ((iv (interior-view-of self))
(s (if iv (margin-string-left iv))))
(if (listp s) s (list s))))
(defmethod margin-string-right ((self plot))
(let* ((iv (interior-view-of self))
(s (if iv (margin-string-right iv))))
(if (listp s) s (list s))))
(defmethod initialize-instance :before ((self plot)
&key margin-string-left margin-string-right
margin-string-top margin-string-bottom)
(if margin-string-left
(defmethod margin-string-left ((view (eql self)))
(if (functionp margin-string-left)
(funcall margin-string-left view) margin-string-left)))
(if margin-string-right
(defmethod margin-string-right ((view (eql self)))
(if (functionp margin-string-right)
(funcall margin-string-right view)
margin-string-right)))
(if margin-string-bottom
(defmethod margin-string-bottom ((view (eql self)))
(if (functionp margin-string-bottom)
(funcall margin-string-bottom view)
margin-string-bottom)))
(if margin-string-top
(defmethod margin-string-top ((view (eql self)))
(if (functionp margin-string-top)
(funcall margin-string-top view)
margin-string-top))))
(defmethod row-format ((self plot))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of))
self
(let (row1 row2 row3)
(setq row1 (if tv (list tv)))
(setq row2 (remove nil (list lv iv rv)))
(setq row3 (if bv (list bv)))
(remove nil (list row1 row2 row3)))))
(defmethod col-format ((self plot))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of))
self
(let (col1 col2 col3)
(setq col1 (if lv (list lv)))
(setq col2 (remove nil (list tv iv bv)))
(setq col3 (if rv (list rv)))
(remove nil (list col1 col2 col3)))))
#|
(defmethod row-views ((self plot))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of))
self
(cond ((not (or lv bv tv lv rv))
(or (if (= 1 (length iv)) (row-views (car iv)))
(if iv (list iv))))
(t
(remove nil (list tv (append lv iv rv) bv))))))
(defmethod col-views ((self plot))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of))
self
(cond ((not (or lv bv tv lv rv))
(or (if (= 1 (length iv)) (col-views (car iv)))
(if iv (list iv))))
(t
(remove nil (list lv (append tv iv bv) rv))))))
|#
(defgeneric row-views (view)
(:documentation "Returns lists of descendant views in view with ~
sublist i containing views in row i."))
(defgeneric col-views(view)
(:documentation "Returns lists of descendant views in view with ~
sublist i containing views in column i."))
(defmethod row-views ((self plot))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of))
self
(cond ((not (or lv bv tv lv rv))
(list (loop for v in iv
append (car (row-views v)))))
(t
(remove nil (list tv
(append lv
(loop for v in iv
append (car (row-views v)))
rv)
bv))))))
(defmethod col-views ((self plot))
(with-accessors ((lv left-views-of) (rv right-views-of)
(tv top-views-of) (bv bottom-views-of)
(iv interior-views-of))
self
(cond ((not (or lv bv tv lv rv))
(list (loop for v in iv
append (car (col-views v)))))
(t
(remove nil (list lv
(append tv
(loop for v in iv
append (car (col-views v)))
bv)
rv))))))
(defmethod col-views ((self view))
(list (list self)))
(defmethod row-views((self view))
(list (list self)))
#|
(defmethod merge-rows ((self plot))
(loop with all = (loop for views in (row-format self)
collect (mapcar #'row-views (reduce #'append views)))
with n = (loop for v in all
maximize (apply #'max (mapcar #'length v)))
with new = (make-list n )
for views in all
do (loop for vi in views do
(loop for vij in vi
for j upfrom 0
do (setf (nth j new) (append (nth j new) vij))))
finally (return new)))
(defmethod merge-cols ((self plot))
(loop with all = (loop for views in (col-format self)
collect (mapcar #'col-views (reduce #'append views)))
with n = (loop for v in all
maximize (apply #'max (mapcar #'length v)))
with new = (make-list n )
for views in all
do (loop for vi in views do
(loop for vij in vi
for j upfrom 0
do (setf (nth j new) (append (nth j new) vij))))
finally (return new)))
|#
(defmethod merge-rows ((self plot))
(row-views self))
(defmethod merge-cols ((self plot))
(col-views self))
| 46,298 | Common Lisp | .l | 976 | 33.226434 | 149 | 0.515698 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 0bf7955c688ca466cda68417f7d972a8f345e6eae2ff9dc817f55388ebaab180 | 33,271 | [
-1
] |
33,272 | prompt-plot.lsp | rwoldford_Quail/source/views/plots/prompt-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; prompt-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1994 George Washington University
;;;
(in-package :vw)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(selected-view-window view-of-selected-window top-view plot-of-selected-window
cases-of-selected-plot single-plot group-plot prompt-plot
prompt-single-plot prompt-plot-by
prompt-variable-display prompt-case-display prompt-case-display-by
*auto-share-case-views?* plot-batch-fn-by-color)))
(defvar *auto-share-case-views?* t)
(defgeneric cases-of-selected-plot(plot)
(:documentation "Returns the cases of the selected plot as a list."))
(defgeneric plot-batch-fn-by-color (plot &optional subviews subjts)
(:documentation "Returns a function that will batch the cases in~
plot by color"))
(defun selected-view-window ()
(let ((w (first (wb::canvases))))
(if (typep w 'view-window)
w)))
(defun view-of-selected-window()
(let* ((c (selected-view-window))
(vw (if c (viewports-and-views-of c))))
(if vw (cdar vw))))
(defun top-view()
(let* (( c (first (ccl::windows :class 'view-window)))
(vw (viewports-and-views-of c)))
(cdar vw)))
(defun plot-of-selected-window()
(let ((p (view-of-selected-window)))
(and (typep p 'plot) p)))
(defmethod cases-of-selected-plot(sel-plot)
(if (null sel-plot)
(setq sel-plot (plot-of-selected-window)))
(if (typep sel-plot 'plot)
(cases-of-selected-plot sel-plot )))
(defmethod cases-of-selected-plot((self plot))
(let* ((one-per-case-view (car (descendant-views-of-type self 'one-per-case-mixin)))
(views
(if one-per-case-view
(or (loop for sub in (subviews-of one-per-case-view)
when
(draw-style sub :highlight?)
collect sub)
(loop for sub in (subviews-of one-per-case-view)
for s in (case-status-of one-per-case-view)
when
(active-status-p s)
collect sub)))))
;;(if views (values (mapcar #'viewed-object-of views) views))
(if views (values (loop for v in views
append (list-viewed-elements v)) views))
))
(defun single-plot (dataset vars &optional sel-plot)
"Constructs a plot from dataset and vars using the cases in~
sel-plot if provided."
(let* ((cases (cases-of-selected-plot sel-plot))
(args (append (list :data dataset :cases cases )
(if *auto-share-case-views?* (list :case-views-from sel-plot ))))
n)
(if (numberp vars)
(setq n vars vars nil)
(setq n (length vars)))
(cond
((= n 0)
(let ((interior (choose-views-from-menu :menu-list
(view-menu-list '(and simple-view (not d-view)
(not control-mixin))))))
(if (and (= (length interior) 1)
(eq (car interior) 'label))
(case-display-list :data dataset :cases cases)
(plot :data dataset :interior-view
interior :cases cases))))
((= n 1) (let ((plot (car (wb:prompt-for-items (list "Default" "1d-plot")))))
(cond ((string-equal plot "Default")
(if (fboundp 'default-1d-plot)
(apply #'default-1d-plot :var (first vars) args)
(apply #'1d-plot :var (first vars) :interior-view :default args)))
((string-equal plot "1d-plot")
(apply #'1d-plot :var (first vars) :interior-view :prompt args))
(t nil))))
((= n 2) (let ((plot (car (wb:prompt-for-items (list "Default" "2d-plot" "Parallel")))))
(cond ((string-equal plot "Default")
(if (fboundp 'default-2d-plot)
(apply #'default-2d-plot :x (first vars) :y (second vars) args)
(apply #'2d-plot :x (first vars) :y (second vars) :interior-view :default
args )))
((string-equal plot "2d-plot")
(apply #'2d-plot :x (first vars) :y (second vars) :interior-view :prompt args ))
((string-equal plot "Parallel")
(apply #'1d-layout-plot :nvars 2 :vars vars args ))
(t nil))))
((>= n 3)
(let ((plot
(car (wb:prompt-for-items
(append (if (fboundp 'default-d-plot) '("Default"))
(append (if (= n 3) '("Rotating Plot"))
(list "Scatterplot Matrix" "Parallel"
"Andrews' Trace" "Tukeys' Trace")))))))
(cond ((string-equal plot "Default")
(apply #'default-d-plot :vars vars args))
((string-equal plot "Rotating Plot")
(apply #'rotating-plot :x (first vars) :y (second vars)
:z (third vars) args))
((string-equal plot "Scatterplot Matrix")
(apply #'scat-mat :vars vars args))
((string-equal plot "Parallel")
(apply #'1d-layout-plot :vars vars args ))
((string-equal plot "Andrews' Trace")
(apply #'prompt-projection-trace :andrews :vars vars args))
(plot (apply #'prompt-projection-trace :tukey :vars vars args))
(t nil))))
)))
(defun group-plot(dataset vars byvars &optional sel-plot (overlay-groups? nil))
"Constructs a plot from dataset and vars for each value of byvars,~
using the cases in sel-plot (if provided)."
(let* ((dataset-vars (list-variates dataset))
(x (second byvars))
(y (first byvars))
(cases (cases-of-selected-plot sel-plot))
(batches (construct-batch-fn byvars sel-plot))
(title (if (and x y) (format nil "~A by ~A" x y )
(format nil "~A" y)))
(plot-args (list :title title :data dataset
:left-label t :bottom-label t
:gap-x 0.02 :gap-y 0.02))
(batch-args (list :type 'batch-layout
:cases cases
:data dataset
:batches batches))
n
)
(if (numberp vars)
(setq n vars vars nil)
(setq n (length vars)))
(flet ((gxf (self)
(let ((c (car (cases-of self))))
(if (and c x)
(format nil "~S" (value-of c x :vars dataset-vars))
)))
(gyf (self)
(let ((c (car (cases-of self))))
(if (and c y)
(format nil "~S" (value-of c y :vars dataset-vars))
))))
(cond
((= n 0)
(let* (;;(menu-list (view-menu-list '(and simple-view (not d-view)
;; (not control-mixin))))
(menu-list (loop for l in '(label bar-with-count rectangle-with-count)
collect (list (format nil "~A" l) l)))
(interior (choose-views-from-menu :menu-list
menu-list)
))
(apply #'grid-plot
:interior-view
`(,@batch-args
:subview-type ,interior
:subviews ((:coord-string-y ,#'gyf :coord-string-x ,#'gxf
:text ,#'(lambda(vo)
(length (list-cases vo))))))
plot-args)))
((and (= n 1) overlay-groups?)
)
((= n 1)
(apply #'grid-plot
:interior-view
`(,@batch-args
:subview-superclass 1d-view
:subviews ((:coord-string-y ,#'gyf :coord-string-x ,#'gxf
,@(if vars (list :var (car vars)))
:case-views-from
,(if *auto-share-case-views?*
sel-plot))))
plot-args))
((and (= n 2) overlay-groups?)
)
((= n 2)
(apply #'grid-plot
:interior-view
`(,@batch-args
:subview-superclass 2d-view
:subviews ((:coord-string-y ,#'gyf
:coord-string-x ,(if (= 2 (length byvars)) #'gxf)
,@(if vars (list :x (first vars) :y (second vars)))
:case-views-from ,(if *auto-share-case-views?*
sel-plot))))
plot-args))
(t nil)))))
(defmethod plot-batch-fn-by-color ((self plot) &optional subviews subjts)
(if (null subjts)
(multiple-value-setq (subjts subviews)
(cases-of-selected-plot self)))
#'(lambda(data &key cases)
(declare (ignore cases))
(let* ((case-vals (loop for sub in subviews
collect (draw-style sub :color)))
(group-vals (remove-duplicates case-vals :test #'wb:eq-colors))
(result (loop with groups = (make-list (length group-vals) )
for c in subjts
for cval in case-vals
for p = (position cval group-vals :test #'wb:eq-colors)
when p
do (push c (elt groups p))
finally (return groups))))
(values
(loop for r in result
collect (make-data-subset data r))
(length result)))))
(defun construct-batch-fn(byvars &optional (sel-plot (plot-of-selected-window)))
(let (subjts subviews)
(if sel-plot
(multiple-value-setq (subjts subviews)
(cases-of-selected-plot sel-plot)))
(if (and (listp byvars) (member :view-color byvars))
(plot-batch-fn-by-color sel-plot subviews subjts)
(data-subsets-fn byvars))))
(defgeneric default-group-variable(obj)
)
(defmethod default-group-variable ((self t)) nil)
(defun prompt-plot(&optional dim)
"Prompts the user for inputs to construct a plot~
of dimension dim (if provided)."
(let* ((sel-plot (plot-of-selected-window))
dataset vars byvars menu-list sel-byvar)
(if (and (typep sel-plot 'plot) (viewed-object-of sel-plot))
(setq dataset (viewed-object-of sel-plot))
(setq sel-plot nil
dataset (choose-dataset)))
(unless (numberp dim) (setq dim nil))
(setq vars (cond
((null dim) (choose-some-variables dataset 0 "Choose variables"))
(t dim)))
(setq dim (if (numberp dim) dim (length vars)))
(when (<= dim 2)
(setq menu-list (variable-menu-items dataset))
(if sel-plot (setq menu-list (cons (list "color" :view-color) menu-list))))
(setq sel-byvar (default-group-variable dataset))
(setq byvars
(if (zerop dim)
(or (if sel-byvar
(list sel-byvar))
(choose-some-variables
dataset 1 "Choose 1 or 2 by variables" menu-list))
(if (<= dim 2)
(or (if sel-byvar
(list sel-byvar))
(choose-some-variables
dataset 0 "Choose upto 2 by variables" menu-list)))))
(if (zerop (length byvars))
(single-plot dataset vars sel-plot)
(group-plot dataset vars byvars sel-plot))))
(defun prompt-single-plot(&optional dim)
"Prompts the user for inputs to construct a single plot~
of dimension dim (if provided)."
(let* ((sel-plot (plot-of-selected-window))
dataset vars )
(if (and (typep sel-plot 'plot) (viewed-object-of sel-plot))
(setq dataset (viewed-object-of sel-plot))
(setq sel-plot nil
dataset (choose-dataset)))
(unless (numberp dim) (setq dim nil))
(setq vars (cond
((null dim) (choose-some-variables dataset 0 "Choose plot variables"))
(t dim)))
(single-plot dataset vars sel-plot)))
(defun prompt-plot-by(&optional (dim nil))
"Prompts the user for inputs to construct a group plot~
of dimension dim (if provided)."
(unless (numberp dim) (setq dim nil))
(let* ((sel-plot (plot-of-selected-window))
dataset vars byvars menu-list)
(if (and (typep sel-plot 'plot) (viewed-object-of sel-plot))
(setq dataset (viewed-object-of sel-plot))
(setq sel-plot nil
dataset (choose-dataset)))
(setq menu-list (variable-menu-items dataset))
(if sel-plot (setq menu-list (cons (list "color" :view-color)
menu-list)))
(setq byvars
(if (default-group-variable dataset)
(list (default-group-variable dataset))
(if (eql 0 dim)
(choose-some-variables
dataset 1 "Choose 1 or 2 by variables" menu-list)
(choose-some-variables
dataset 0 "Choose upto 2 by variables" menu-list))))
(setq vars (cond
((null dim) (choose-some-variables dataset 0 "Choose plot variables"))
(t (min 2 dim))))
(setq menu-list (cons (if sel-plot (list "color" :view-color))
(variable-menu-items dataset)))
(if (zerop (length byvars))
(single-plot dataset vars sel-plot)
(group-plot dataset vars byvars sel-plot))))
(defun prompt-variable-display(&optional ignore)
"Prompts the user for inputs to construct a variable display"
(declare (ignore ignore))
(let* ((sel-plot (plot-of-selected-window))
dataset)
(if (and (typep sel-plot 'plot) (viewed-object-of sel-plot))
(setq dataset (viewed-object-of sel-plot))
(setq sel-plot nil
dataset (choose-dataset)))
(variate-display-list :data dataset :draw? t)))
(defun prompt-case-display(&optional ignore)
"Prompts the user for inputs to construct a case display"
(declare (ignore ignore))
(let* ((sel-plot (plot-of-selected-window))
dataset)
(if (and (typep sel-plot 'plot) (viewed-object-of sel-plot))
(setq dataset (viewed-object-of sel-plot))
(setq sel-plot nil
dataset (choose-dataset)))
(case-display-list :data dataset :draw? t
:cases (cases-of-selected-plot sel-plot)
:labels #'(lambda(c)
(identifier-name (car (list-viewed-elements c)))))))
(defun prompt-case-display-by(&optional ignore)
"Prompts the user for inputs to construct~
a case display by group."
(declare (ignore ignore))
(let* ((sel-plot (plot-of-selected-window))
dataset menu-list byvar batches dataset-vars)
(if (and (typep sel-plot 'plot) (viewed-object-of sel-plot))
(setq dataset (viewed-object-of sel-plot))
(setq sel-plot nil
dataset (choose-dataset)))
(setq dataset-vars (list-variates dataset))
(setq menu-list (variable-menu-items dataset))
(if sel-plot (setq menu-list (cons (list "color" :view-color) menu-list)))
(setq byvar
(or (default-group-variable dataset)
(choose-variable
dataset 1 "Choose group variable" menu-list)))
(setq batches (construct-batch-fn byvar sel-plot))
(case-display-list
:data dataset :draw? t :draw? t
:labels #'(lambda(c)
(value-of (car (list-viewed-elements c)) byvar :vars dataset-vars ))
:cases (funcall batches dataset :cases (cases-of-selected-plot sel-plot)))))
| 17,113 | Common Lisp | .l | 353 | 33.872521 | 143 | 0.511467 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 3bd5cad55a9543fad3f2279e53af6a601d00db47453c6115a0c3c8ae3b020c53 | 33,272 | [
-1
] |
33,273 | rotating-plot.lsp | rwoldford_Quail/source/views/plots/rotating-plot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; rotating-plot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1992 George Washington University
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '( rotating-plot rotate-controls)))
(defclass rotating-plot (3d-plot )
((position-keys :allocation :class :initform
'(:panel-size :left-margin-size :right-margin-size
:bottom-margin-size :top-margin-size
:title-height :title-width) )
(controls :initform nil :accessor controls-of :initarg :controls))
(:default-initargs :panel-size 0.1 :default-interior 'rotating-cloud))
;;;----------------------------------------------------------------------------------
(defmethod construct-sub-views ((self rotating-plot) &rest keyword-pairs)
(apply #'construct-interior-view self keyword-pairs)
(setf (controls-of self)
(rotate-controls :target (interior-view-of self)))
)
(defmethod init-position-subviews ((self rotating-plot)
&key panel-size)
(let ((space-left (make-region (subview-position-region self))))
(place-subview self (controls-of self)
(sub-region space-left :w
:width (* panel-size (width-of space-left))
:remains space-left))
(place-subview self (interior-view-of self) space-left)))
;;;----------------------------------------------------------------------------------
(defun rotate-controls ( &rest args &key (x-text "X") target (y-text "Y") (z-text "Z") (draw? nil)
&allow-other-keys)
;(declare (ignore args))
(let ((r
(make-instance 'rotate-controls :x-text x-text
:y-text y-text
:z-text z-text
:target target)))
(if draw? (draw-view r))
r))
(defclass rotate-controls (compound-view orientation-mixin)
((x-button :initform nil :accessor x-button-of )
(y-button :initform nil :accessor y-button-of )
(z-button :initform nil :accessor z-button-of )
(speed-control :initform nil :accessor speed-control-of )
)
(:default-initargs :orientation :vertical))
(defmethod construct-sub-views ((self rotate-controls) &rest keyword-pairs
&key target x-text y-text z-text orientation )
(declare (ignore keyword-pairs))
(setf (x-button-of self)
(control-button :text x-text
:left-fn #'move-points
:target (list target :direction :x)))
(setf (y-button-of self)
(control-button :text y-text
:left-fn #'move-points
:target (list target :direction :y)))
(setf (z-button-of self)
(control-button :text z-text
:left-fn #'move-points
:target (list target :direction :z)))
(let* ((sc (needle-slider :min (- (/ pi 10)) :max (/ pi 10) :orientation orientation
:level (if target (increment-of target) 0)
:left-fn #'set-increment
:needle-size 2
))
(sc-plot
(plot :title "" :draw? NIL
:right-view-size 0.5
:interior-view sc
:right-view `(:type axis :orientation :vertical :color nil
:tic-list ((,(- (/ pi 10)) "Back") (0 "Stop") (,(/ pi 10) "Ahead"))
)
:left-label "Speed"
)))
(setf (target-of sc) `(,target (slider-level-of ,sc)))
(setf (speed-control-of self) sc-plot);;sc)
)
)
(defmethod init-position-subviews ((self rotate-controls)
&key )
(let* ((region (subview-position-region self))
(g 0.05)
(l (+ g (left-of region)))
(b (+ g (bottom-of region)))
w h)
(if (eql (orientation-of self) :horizontal)
(progn
(setq w (/ (- (width-of region) (* 5 g)) 5)
h (- (height-of region) (* 2 g)))
(loop for button in
(list (x-button-of self) (y-button-of self) (z-button-of self))
do (place-subview self button
(make-region l (+ l w) b (+ b h)))
(incf l (+ w g)))
(place-subview self (speed-control-of self)
(make-region l (+ l (* 2 g)) b (+ b h))))
(progn
(setq h (/ (- (height-of region) (* 5 g)) 5) w (- (width-of region) (* 2 g)))
(loop for button in
(list (z-button-of self) (y-button-of self) (x-button-of self))
do (place-subview self button
(make-region l (+ l w) b (+ b h)))
(incf b (+ h g)))
(place-subview self (speed-control-of self)
(make-region l (+ l w) b (+ b (* 2 h)) ))
))))
| 5,759 | Common Lisp | .l | 121 | 34.413223 | 104 | 0.469455 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 2d3399ef9ae7579d351ea4a33add2b2b7a25aac09f59a12fd380447c1fc524dc | 33,273 | [
-1
] |
33,274 | batch-plots.lsp | rwoldford_Quail/source/views/plots/batch-plots.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; batch-plots.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1992 George Washington University
;;;
;;;
;;; EXPERIMENTAL
;;;----------------------------------------------------------------------------------
(in-package :views)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(table-plot 1d-batch-plot 2d-batch-plot )))
(defmethod select-view-menu-list((view-symbol (eql 'table-entry)))
'(("label" linkable-label)
("rectangle" rectangle-with-text)))
(defun table-plot (&rest keyword-pairs
&key (text-fn #'(lambda(vo)
(length (list-cases vo))))
(subview-superclass 'table-entry)
(initform-fn #'get-batch-inits)
(gap-x 0) (gap-y 0)
subviews
left-view bottom-view
bottom-label (top-label :default) (left-label :default)
(title :default)
(format :default)
link-bounds-x? link-bounds-y?
&allow-other-keys)
(setq keyword-pairs (append (apply initform-fn keyword-pairs) keyword-pairs))
(disable-keyword keyword-pairs :initform-fn)
(let* ((byvars (getf keyword-pairs :batches))
(x (if (listp byvars) (second byvars)))
(y (if (listp byvars) (first byvars) byvars))
(data (getf keyword-pairs :data))
(name (or (dataset-name data) "")))
(setq format (if (eq format :default)
(if (and x y) :grid :col) format))
(apply #'batch-plot :subview-superclass subview-superclass
:format format
:gap-x gap-x :gap-y gap-y
:subviews (or subviews `((:text ,text-fn)))
:left-view left-view
:bottom-view bottom-view
:bottom-label bottom-label :orientation :horizontal
:link-bounds-x? link-bounds-x? :link-bounds-y? link-bounds-y?
:top-label (if (eq top-label :default)
(not (eq format :col))
top-label)
:left-label (if (eq left-label :default)
(not (eq format :row))
left-label)
:title (if (eq title :default)
(cond
((and x y)
(format nil "~A:~A by ~A" name x y ))
(y (format nil "~A:~A" name y))
(t name))
title)
:size t
keyword-pairs)))
(defun 1d-batch-plot (&rest keyword-pairs
&key
(initform-fn #'get-batch-inits)
(gap-x 0.02) (gap-y 0.02)
(subview-superclass '1d-view)
(format :default)
(orientation :vertical)
(left-view :default) (bottom-view :default)
(bottom-label :default) (left-label :default)
(top-label :default) (right-label :default)
(title :default)
&allow-other-keys)
(setq keyword-pairs (append (apply initform-fn keyword-pairs) keyword-pairs))
(disable-keyword keyword-pairs :initform-fn)
(let* ((byvars (getf keyword-pairs :batches))
(x (if (listp byvars) (second byvars)))
(y (if (listp byvars) (first byvars) byvars))
(data (getf keyword-pairs :data))
(name (or (dataset-name data) ""))
oargs p dview)
(setq oargs
(if (eq orientation :vertical)
(list
:format (setq format (if (eq format :default)
(if (and x y) :grid :row)
format))
:left-view (if (eq left-view :default) t left-view)
:bottom-view (if (eq bottom-view :default) nil bottom-view))
(list
:format (setq format (if (eq format :default)
(if (and x y) :grid :col)
format))
:left-view (if (eq left-view :default) nil left-view)
:bottom-view (if (eq bottom-view :default) t bottom-view))))
(setq p (apply #'batch-plot :subview-superclass subview-superclass
:gap-x gap-x :gap-y gap-y
:common-vars? t :orientation orientation
:top-label (if (eq top-label :default)
(not (eq format :col))
top-label)
:left-label (if (eq left-label :default)
(not (eq format :row))
left-label)
:bottom-label (if (eq bottom-label :default)
(label) bottom-label)
:right-label (if (eq right-label :default)
nil right-label)
:title (if (eq title :default)
(cond
((and x y)
(format nil "~A:~A by ~A" name x y ))
(y (format nil "~A:~A" name y))
(t name))
title)
:draw? nil
(append oargs keyword-pairs)))
(setq dview
(car (or (subviews-of-type (interior-view-of p) 'd-view)
(subviews-of (interior-view-of p)))))
(when (eq bottom-label :default)
(let ((lab (bottom-label-of p)))
(when lab
(setf (text-of lab) (coord-string dview))
(text-link dview lab))))
(draw-view p)
p
))
(defun 2d-batch-plot (&rest keyword-pairs
&key
(initform-fn #'get-batch-inits)
(gap-x 0.02) (gap-y 0.02)
(subview-superclass '2d-view)
(format :default)
(top-label :default) (right-label :default)
(bottom-label :default) (left-label :default)
(title :default)
&allow-other-keys)
(setq keyword-pairs (append (apply initform-fn keyword-pairs) keyword-pairs))
(disable-keyword keyword-pairs :initform-fn)
(let* ((byvars (getf keyword-pairs :batches))
(x (if (listp byvars) (second byvars)))
(y (if (listp byvars) (first byvars) byvars))
(data (getf keyword-pairs :data))
(name (or (dataset-name data) ""))
p dview)
(setq format (if (eq format :default)
(if (and x y) :grid :row)
format))
(setq p (apply #'batch-plot :subview-superclass subview-superclass
:gap-x gap-x :gap-y gap-y :format format
:common-vars? t
:top-label (if (eq top-label :default)
(not (eq format :col))
top-label)
:left-label (if (eq left-label :default)
(not (eq format :row))
left-label)
:bottom-label (if (eq bottom-label :default)
(label) bottom-label)
:right-label (if (eq right-label :default)
(label :orientation :vertical) right-label)
:title (if (eq title :default)
(cond
((and x y)
(format nil "~A:~A by ~A" name x y ))
(y (format nil "~A:~A" name y))
(t name))
title)
:draw? nil
keyword-pairs))
(setq dview
(car (or (subviews-of-type (interior-view-of p) 'd-view)
(subviews-of (interior-view-of p)))))
(when (eq right-label :default)
(let ((lab (right-label-of p)))
(setf (text-of lab) (coord-string-y dview))
(text-link dview (text-of lab) :y))
(let ((lab (bottom-label-of p)))
(setf (text-of lab) (coord-string-x dview))
(text-link dview (text-of lab) :x)))
(draw-view p)
p
))
#|
;; do an improved batch-plot function
(table-plot :data (car (list-drills assay))
:cases #'sub-cases
:batches '(alteration)
)
(1d-batch-plot :data (car (list-drills assay))
:cases #'sub-cases
:format :col :orientation :horizontal
:batches '(alteration)
:justification :bottom :size t
)
(1d-batch-plot :data (car (list-drills assay))
:cases #'sub-cases
:batches '(alteration lithology)
)
(2d-batch-plot :data (fourth (list-drills assay))
:cases #'sub-cases
:batches '(alteration))
(2d-batch-plot :data (fourth (list-drills assay))
:cases #'sub-cases :format :col
:subview-type '2d-point-cloud
:subviews '(:x gold :y silver)
:batches '(alteration))
|#
| 10,337 | Common Lisp | .l | 217 | 29.299539 | 108 | 0.442469 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 6816affb33f63666568a275b9bf2b2f5f73dd232124d438673b4d28198d4c94d | 33,274 | [
-1
] |
33,275 | restore-sblx.lsp | rwoldford_Quail/source/initialization/restore-sblx.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; restore-sblx.lsp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W.Oldford 2000
;;; G.W.Bennett 2000
;;;
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail-kernel)
(defun find-quail ()
"A dummy for now. in restore-pc there is a real job to do"
NIL) | 629 | Common Lisp | .l | 20 | 28.55 | 83 | 0.3125 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | c615ae75e5f7e195ace8adcdf85257fd6a14a67c2aa37342b670d0793b960aff | 33,275 | [
-1
] |
33,276 | export-syms-from-quail.lsp | rwoldford_Quail/source/initialization/export-syms-from-quail.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; export-syms-from-quail.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1991.
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(quail-import-export)))
(defun quail-import-export (symbols)
"Import symbols to the Quail package and then ~
export them from Quail. ~
(:see-also packages import export unexport ~
unintern intern shadowing-import shadow)"
(import symbols :quail)
(export symbols :quail))
;;;
;;; Export the external symbols of :quail-kernel from
;;; quail as well
;;;
(defun visible-to-package-p (symbol package)
"True if the given symbol (after coercion to a string) ~
is visible to the specified package."
(multiple-value-bind
(sym type)
(find-symbol (string symbol) package)
(and sym (or (eq type :external)
(eq type :inherited)))))
(defun export-from-quail (&key symbols package)
"Exports from the quail package ~
all symbols in symbols that are visible to the ~
quail package, or all external symbols ~
of package."
(cond
(symbols
(loop for s in symbols
when (visible-to-package-p s :quail)
do (export s :quail)))
(package (do-external-symbols (s package)
(export s :quail)))))
(export-from-quail :package :quail-kernel)
(export-from-quail :package :new-math)
(export-from-quail :package :views)
;;;
;;; Selected symbols from window-basics if it exists
;;;
(if (find-package :window-basics)
(quail-import-export
'(wb::prompt-user wb::pick-one wb::prompt-t-or-f wb::prompt-true-or-false
wb::check-items wb::collect-input)
))
| 2,093 | Common Lisp | .l | 58 | 31.017241 | 88 | 0.56129 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 3346cfc23ec055899fc3db7588dd0a0cad9ab770426913b2a531d9d40d7dec9a | 33,276 | [
-1
] |
33,277 | update-special-vars.lsp | rwoldford_Quail/source/initialization/update-special-vars.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; update-special-vars.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Copyright (c) Statistical Computing Laboratory
;;; University of Waterloo
;;; Canada.
;;;
;;; This file is part of the Views system, a toolkit for interactive statistical graphics.
;;;
;;;
;;; Authors:
;;; C.B. Hurley 1988-1991 George Washington University
;;; R.W. Oldford 1988-1991
;;;
;;;
;;;
;;;----------------------------------------------------------------------------------
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '(sqr)))
(defun sqr (x) (* x x))
(setf vw::*variable-transforms* '(sqr identity sqrt log inverse))
| 897 | Common Lisp | .l | 25 | 33.08 | 92 | 0.403935 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 1f75fcafa56245cab1de1f78094426d956a3dd8036289427052bfa3eb9cfec4b | 33,277 | [
-1
] |
33,278 | views-init.lsp | rwoldford_Quail/source/initialization/views-init.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; views-init.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1996 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1996.
;;;
;;;
;;;----------------------------------------------------------------------------
(in-package :quail)
(eval-when (load eval compile)
(vw::get-function 'vw::median)
(vw::get-function 'vw::mean))
| 618 | Common Lisp | .l | 19 | 28.105263 | 80 | 0.293423 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | f54b392f58467c9367c16bb7ce16ac939d74c292b09a7a419c14a58bf1f2942d | 33,278 | [
-1
] |
33,279 | redefine-quail-io.lsp | rwoldford_Quail/source/initialization/redefine-quail-io.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; redefine-quail-io.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1992.
;;;
;;;
;;;----------------------------------------------------------------------------------
;;;
(in-package :qk)
(when (find-package :window-basics)
(defun quail-y-or-n-p (&optional format-string &rest format-args)
"Prints a message from format-string and format-args, followed by (y or n), ~
and waits for the user to type y or n. ~
Returns T if the user typed y, or nil if the user typed n. ~
(:see-also y-or-n-p quail-yes-or-no-p prompt-t-or-f quail-query)"
;;(apply #'y-or-n-p format-string format-args)
(wb::prompt-t-or-f
(if format-string
(apply #'format NIL format-string format-args)
"") :true-text "Yes" :false-text "No")
)
(defun quail-yes-or-no-p (&optional format-string &rest format-args)
"Prints a message from format-string and format-args, followed by (yes or no), ~
and waits for the user to type yes or no followed by a carriage return. ~
Returns t if the user typed yes, nil if the user typed no. ~
(:see-also yes-or-no-p quail-y-or-n-p prompt-true-or-false)"
;;(apply #'yes-or-no-p format-string format-args)
(wb::prompt-true-or-false
(if format-string
(apply #'format NIL format-string format-args)
"") :true-text "Yes" :false-text "No"))
(defun quail-query (format-string &rest args)
"Prompts the user with format-string and reads in user-typed expression. ~
(:see-also prompt-user quail-yes-or-no-p *quail-query-io* quail-y-or-n-p ~
quail-query)"
(wb::prompt-user
:type T
:read-type :read
:prompt-string (apply #'format NIL format-string args))
)
(setf *help-in-windows* T)
) | 2,097 | Common Lisp | .l | 50 | 36.62 | 86 | 0.545455 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 9043bd829c21f1974206bd52d42820403ef21dfc32617ce3340bbe6ca66f7953 | 33,279 | [
-1
] |
33,281 | release-path.lsp | rwoldford_Quail/source/initialization/release-path.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; release-path.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1992.
;;;
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail-kernel)
(defun quail-release-file ()
(merge-pathnames
(cl-user::path-quail) ;cl-user::*quail-init-directory*
"release-info.lsp"))
| 680 | Common Lisp | .l | 20 | 29.3 | 84 | 0.315549 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | fd6506aeb139eb37299b61635f3dbb1813ab58ba59d46f14eb9c1685aad553b6 | 33,281 | [
-1
] |
33,282 | release.lsp | rwoldford_Quail/source/initialization/release.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; release.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1992.
;;;
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail-kernel)
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '(*months* *days* current-day current-month current-date
get-quail-release-info auto-doc-release
make-release quail-release)))
;--------------------------------------------------------------------------------
(defconstant *months*
'("January" "February" "March" "April" "May" "June" "July" "August" "September"
"October" "November" "December")
"A list containing the names of the twelve months of the year.")
(defconstant *days*
'("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")
"A list containing the days of the week beginning with Monday.")
(defun current-month ()
"Returns the current calendar month"
(declare (special *months*))
(elt *months* (- (elt (multiple-value-list (get-decoded-time)) 4) 1)))
(defun current-day ()
"Returns the current day of the week."
(declare (special *days*))
(elt *days* (elt (multiple-value-list (get-decoded-time)) 6)))
(defun current-date ()
"Returns the current date as a string: Dayname month day, year."
(declare (special *months* *days*))
(let* ((date-info (multiple-value-list (get-decoded-time)))
(month (elt *months* (- (elt date-info 4) 1)))
(day-number (elt date-info 3))
(day-name (elt *days* (elt date-info 6)))
(year (elt date-info 5)))
(concatenate 'string
day-name
", "
month
" "
(format nil "~s" day-number)
", "
(format nil "~s" year))))
(defun get-quail-release-info ()
"Returns a list containing the current Quail release information: ~&
(version distribution date *quail-systems* *features*)."
(let ((fname (qk::quail-release-file)))
(if (probe-file fname)
(with-open-file (ofile fname :direction :input)
(read ofile)))))
(defun put-quail-release-info (release-info)
"Stores the given Quail release information."
(with-open-file (ofile (qk::quail-release-file)
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write release-info :stream ofile)))
(defun quail-release ()
"Returns a string giving the current Quail release identification."
(let* ((info (get-quail-release-info))
(version (first info))
(type (second info))
(date (third info))
release)
(if type
(setf release (concatenate 'string
(format nil "~s" version)
(case type
(:alpha "(alpha)")
(:beta "(beta)")
(t (format nil "~S" type)))))
(setf release version))
(format NIL "Quail Release ~a ~a" release date)))
(defvar *quail-release-printed* t)
;; MCL seems to do the restore functions twice. This should
;; avoid printing the release info more than once, but I can't
;; seem to get this to happen properly.
(defun quail-release-print ()
(or *quail-release-printed*
(format *terminal-io* "~&~A" (quail-release)))
(setf *quail-release-printed* t))
;; this is useful if user makes an image of their own
(defun quail-release-unprint ()
(setf *quail-release-printed* nil))
(defun auto-doc-release (&key (auto-index? T)
(auto-topics? T)
(auto-doc-symbols? T))
"Saves the current Quail image in the named file and declares it a release.~
(:key ~
(:arg auto-index? T Non-NIL if the indices of external variables are to be produced ~
for major Quail packages: Quail, Quail-Kernel, Views, and Window-Basics.)~
(:arg auto-topics? T Non-NIL if the Quail source files are to be used to produce ~
topic documentation automatically.) ~
(:arg auto-doc-symbols? T Non-NIL if the external symbols of the Quail package ~
are to have documentation files automatically produced for them.)~
)~
"
(let ((packages-to-doc (list :quail :quail-kernel :window-basics :views)))
;; auto-index?
(when auto-index?
(loop for package in packages-to-doc
do
(vw:inform-user
(format NIL "Creating sorted index for the package ~s." package))
(make-sorted-documentation-index :package package)
(vw:inform-user (format NIL "Finished index for ~s" package))
)
)
;; auto-topics?
(when auto-topics?
(vw:inform-user "Creating topics for the Quail system.")
(auto-create-and-file-topics)
(vw:inform-user "Finished topics for the Quail system.")
)
;; auto-doc-symbols?
(when auto-doc-symbols?
(loop for package in packages-to-doc
do
(vw:inform-user
(format NIL "Creating documentation for all external symbols
of the package ~s."
package))
(document-symbols :package package
:types '(:macro :function :generic-function
:special-form :constant :variable
:topic :structure :built-in-class
:package))
(vw:inform-user
(format NIL "Finished documenting symbols for ~s." package))
)
)
(vw:inform-user "Done.")
)
)
(defun make-release (&key (file NIL)
(version NIL)
(distribution NIL)
(auto-index? NIL)
(auto-topics? NIL)
(auto-doc-symbols? NIL)
(update? NIL))
"Saves the current Quail image in the named file and declares it a release.~
(:key ~
(:arg file The name to be given to the Quail image file.) ~
(:arg version NIL Version number if non-NIL. If NIL, the version number ~
of the last release is used.) ~
(:arg distribution NIL Breadth of distribution: :alpha for developers, ~
:beta for beta-test sites, and NIL for true releases.)
(:arg auto-index? NIL Non-NIL if the indices of external variables are to be produced ~
for major Quail packages: Quail, Quail-Kernel, Views, and Window-Basics.)~
(:arg auto-topics? NIL Non-NIL if the Quail source files are to be used to produce ~
topic documentation automatically.) ~
(:arg auto-doc-symbols? NIL Non-NIL if all external symbols of the Quail package ~
are to have documentation files automatically produced for them.)~
(:arg update? NIL Non-NIL if the release information is to be updated on file.)~
)~
"
(declare (special *features* cl-user::*quail-systems*))
(auto-doc-release :auto-index? auto-index?
:auto-topics? auto-topics?
:auto-doc-symbols? auto-doc-symbols?)
(vw:inform-user "TIME TO MAKE THE IMAGE.")
(let ((release-info (get-quail-release-info))
old-version
(date (current-date)))
(when release-info
(unless version
(setf old-version (first release-info))
(if (numberp old-version)
(setf version (float
(/ (round (+ old-version 0.01) 0.01)
100)))
(setf version (format nil "~s+" old-version)))))
(if update?
(put-quail-release-info
(list version distribution date cl-user::*quail-systems* *features*)))
(setf vw::*info-window* NIL)
(setf vw::*info-text* NIL)
(save file)
))
| 8,383 | Common Lisp | .l | 189 | 33.936508 | 91 | 0.549607 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 582c668c6f635bb52857e287825e1dc5bc21a1b3c6a0735debaa5ba3781a2dfe | 33,282 | [
-1
] |
33,285 | load-quail-init.lsp | rwoldford_Quail/source/initialization/load-quail-init.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; load-quail-init.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Greg Anglin 1993.
;;;
;;;
;;;----------------------------------------------------------------------------
(in-package :quail-kernel)
(defun load-quail-init ()
(let ((file (probe-file (cl-user::quail-init-file))))
(when file
(load file))))
;; pushed onto the restore functions in restored-lisp-functions.lsp | 711 | Common Lisp | .l | 21 | 29.47619 | 80 | 0.360176 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | d0dcb6d4fde9539b1379e80da598f71b3fab99a37098bd68ce21d7f8c075d793 | 33,285 | [
-1
] |
33,287 | synonyms.lsp | rwoldford_Quail/source/initialization/synonyms.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; synonyms.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1989, 1990, 1991.
;;;
;;;
;;;----------------------------------------------------------------------------
;;;
;;; Includes:
;;; make-synonym
;;; alias
;;; _
;;; **
;;; ^
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '(make-synonym alias _ ** ^)))
;;;----------------------------------------
;;;
;;; Example: Some synonyms for assignment.
;;;
(make-synonym :old <- :new _ :warn nil)
;;;----------------------------------------
;;;
;;; A synonym for make-synonym
;;;
(make-synonym :old make-synonym :new alias :warn nil)
;;;-------------------------------------------------------------------------------
;;;
;;; A method for exponentiation of numbers and a synonym.
;;; - a method is used since ref-arrays have the same method for exponentiation.
;;;
;;;-------------------------------------------------------------------------------
#+:aclpc-linux (excl:without-package-locks
(make-synonym :old expt :new ** :warn nil))
#+:sbcl-linux (sb-ext:without-package-locks
(make-synonym :old expt :new ** :warn nil))
#-(or :aclpc-linux :sbcl-linux) (make-synonym :old expt :new ** :warn nil)
(make-synonym :old expt :new ^ :warn nil)
| 1,684 | Common Lisp | .l | 48 | 31.583333 | 83 | 0.390062 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | fd5543a08aa79b5b83e9d7549a093ec4be600482e293f02caf7723072d1b7fc1 | 33,287 | [
-1
] |
33,288 | restore-pc.lsp | rwoldford_Quail/source/initialization/restore-pc.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; restore-pc.lsp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W.Oldford 2000
;;; G.W.Bennett 2000
;;;
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail-kernel)
;;;
;;; The single acl dependency here. Due to the fact that
;;; Work-around to define (logical-pathname-translations "q")
;;; until Franz deals with the rescuing of single-letter logical-pathnames
;;; in images created by dumplisp.
;;; In fact this is probably a better way to do the job
;;; and is to be a permanent part of Quail .. 16FEB00
;;; A directory dialog is popped up and the choice parsed
;;; If the directory is a top-level one then its namestring
;;; ends in \\, otherwise it seems it does not..
;;; in any case we need to check so that only one set of \\
;;; at a time appears in the result
;;;
(defun find-quail ()
(let (location)
(cond
((probe-file "sys:quail-location.lsp")
(with-open-file (s "sys:quail-location.lsp" :direction :input)
(setf location (read s))
)
)
(T
(setf location (cg::name-string (cg::ask-user-for-directory
:prompt
"Quail directory ...")
)
)
(with-open-file (s "sys:quail-location.lsp" :direction :output
:if-exists :supersede)
(prin1 location s))
))
(if (string-equal "\\" (subseq location (1- (length location))))
(setf (logical-pathname-translations "q")
(list (append (list "**;*.*")
(list (concatenate 'string location "**\\*.*")))))
(setf (logical-pathname-translations "q")
(list (append (list "**;*.*")
(list (concatenate 'string location "\\**\\*.*")))))
)
(setf (logical-pathname-translations "eg")
(list (list "**;*.*" "q:examples;**;*.*")
(list "*.*" "q:examples;*.*")
)
)
(setf (logical-pathname-translations "data")
(list (list "**;*.*" "q:data;**;*.*")
(list "*.*" "q:data;*.*")
)
)
(setf (logical-pathname-translations "doc")
(list (list "**;*.*" "q:doc;**;*.*")
(list "*.*" "q:doc;*.*")
)
)
)
)
| 2,809 | Common Lisp | .l | 73 | 28.547945 | 84 | 0.437363 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | a1e7c677bf58f4b8a5e5494daf7b6287e1024b9d4ce35e0b4b024302b26e20de | 33,288 | [
-1
] |
33,289 | misc-defs.lsp | rwoldford_Quail/source/linear/misc-defs.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; misc-defs.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(ref-variable add-ones quail-reciprocal multiple-position-if
mat1dp mat2dp nrows ncols)))
(defgeneric nrows (thing)
(:documentation "Returns the number of rows in the thing. ~
(:see-also (ncols :generic-function) ~
(dimensions-of :generic-function) ~
)"
)
)
(defmethod nrows ((thing T))
(or (first (dimensions-of thing)) 1))
(defgeneric ncols (thing)
(:documentation "Returns the number of columns in the thing. ~
(:see-also (nrows :generic-function) ~
(dimensions-of :generic-function) ~
)"
)
)
(defmethod ncols ((thing T))
(or (second (dimensions-of thing)) 1))
;-------------------------------------------------------------------
;METHODS: ref-variable, (setf ref-variable)
;-------------------------------------------------------------------
(defgeneric ref-variable (matrix key)
(:documentation
"Args: matrix, a quail matrix, and key, a number ~
for now, possibly a label later. If the matrix ~
has one dimension (i.e.; a vector), the function ~
returns the key-th element; if the matrix has ~
rows and columns, it returns the key-th column."))
(defmethod ref-variable ((self matrix) key)
(cond ((mat1dp self) (ref self key))
(t (ref self t key))))
(defgeneric (setf ref-variable) (new-value matrix key)
(:documentation
"Args: new-value; matrix, a quail matrix, and key, a number ~
for now, possibly a label later. Sets the portion ~
of matrix relating to the key-th element (if matrix is actually ~
a vector) or key-th column to new-value."))
(defmethod (setf ref-variable) (new-value (self matrix) key)
(cond ((mat1dp self)
(setf (ref self key) new-value))
(t
(setf (ref self t key) new-value))))
;--------------------------------------------------------------
;DEMETHODS: add-ones
;--------------------------------------------------------------
(defgeneric add-ones (X)
(:documentation
"Adds a column of ones before a matrix X."))
(defmethod add-ones (X)
(missing-method 'add-ones X))
(defmethod add-ones ((X matrix))
(cglue (array 1
:dimensions (list (first (dimensions-of x))))
X))
;-----
(defgeneric multiple-position-if (sequence predicate)
(:documentation
"Returns a list of the positions of elements of sequence ~
that satisfy the predicate, which must take one argument."))
(defmethod multiple-position-if ((sequence matrix) predicate)
(do ((i 0 (+ i 1))
(n (first (dimensions-of sequence)))
(z '()))
((= i n) (nreverse z))
(when (funcall predicate (eref sequence i))
(push i z))))
(defmethod multiple-position-if :around ((sequence matrix) predicate)
(declare (ignore predicate))
(if (mat1dp sequence) (call-next-method)
(quail-error "~s is not a one-dimensional matrix (vector)."
sequence)))
(defmethod multiple-position-if ((sequence sequence) predicate)
(do ((i 0 (+ i 1))
(n (first (dimensions-of sequence)))
(z '()))
((= i n) (nreverse z))
(when (funcall predicate (eref sequence i))
(push i z))))
;-----
(defun mat2dp (z)
(and (or (typep z 'array)
(typep z 'matrix))
(= (array-rank z) 2)))
(defun mat1dp (z)
(or (typep z 'sequence)
(and (or (typep z 'array)
(typep z 'matrix))
(= (array-rank z) 1))))
| 4,203 | Common Lisp | .l | 108 | 32.287037 | 125 | 0.522462 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e5d4e7572497295cbc101910cea0710c1b91ccc7a5cdd40f670e049505765f85 | 33,289 | [
-1
] |
33,290 | dsidi.lsp | rwoldford_Quail/source/linear/dsidi.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dsidi-hook (a lda n kpvt det inert work job)
(declare (type fixnum job))
;(declare (type (simple-array double-float (*)) work))
;(declare (type (simple-array fixnum (*)) inert))
;(declare (type (simple-array double-float (*)) det))
;(declare (type (simple-array fixnum (*)) kpvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (temp 0.0d0) (akkp1 0.0d0) (akp1 0.0d0) (ak 0.0d0)
(d 0.0d0) (kstep 0) (ks 0) (km1 0) (k 0) (jb 0) (j 0)
(noert nil) (nodet nil) (noinv nil))
(declare (type t noinv))
(declare (type t nodet))
(declare (type t noert))
(declare (type fixnum j))
(declare (type fixnum jb))
(declare (type fixnum k))
(declare (type fixnum km1))
(declare (type fixnum ks))
(declare (type fixnum kstep))
(declare (type double-float d))
(declare (type double-float t_))
(declare (type double-float ak))
(declare (type double-float akp1))
(declare (type double-float akkp1))
(declare (type double-float temp))
(setf noinv (= (mod job 10) 0))
(setf nodet (= (f2cl/ (mod job 100) 10) 0))
(setf noert (= (f2cl/ (mod job 1000) 100) 0))
(if (and nodet noert) (go label140))
(if noert (go label10))
(setf (fref inert 1) 0)
(setf (fref inert 2) 0)
(setf (fref inert 3) 0)
label10 (if nodet (go label20))
(setf (fref det 1) 1.0)
(setf (fref det 2) 0.0)
label20 (setf t_ 0.0d0)
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf d (fref a k k))
(if (> (fref kpvt k) 0) (go label50))
(if (/= t_ 0.0d0) (go label30))
(setf t_ (dabs (fref a k (+ k 1))))
(setf d
(+ (* (f2cl/ d t_) (fref a (+ k 1) (+ k 1)))
(- t_)))
(go label40)
label30 (setf d t_)
(setf t_ 0.0d0)
label40 label50 (if noert (go label60))
(if (> d 0.0d0) (setf (fref inert 1) (+ (fref inert 1) 1)))
(if (< d 0.0d0) (setf (fref inert 2) (+ (fref inert 2) 1)))
(if (= d 0.0d0) (setf (fref inert 3) (+ (fref inert 3) 1)))
label60 (if nodet (go label120))
(setf (fref det 1) (* d (fref det 1)))
(if (= (fref det 1) 0.0) (go label110))
label70 (if (>= (dabs (fref det 1)) 1.0) (go label80))
(setf (fref det 1) (* 10.0 (fref det 1)))
(setf (fref det 2) (- (fref det 2) 1.0))
(go label70)
label80 label90 (if (< (dabs (fref det 1)) 10.0) (go label100))
(setf (fref det 1) (f2cl/ (fref det 1) 10.0))
(setf (fref det 2) (+ (fref det 2) 1.0))
(go label90)
label100 label110 label120))
label140 (if noinv (go label270))
(setf k 1)
label150 (if (> k n) (go label260))
(setf km1 (- k 1))
(if (< (fref kpvt k) 0) (go label180))
(setf (fref a k k) (f2cl/ 1.0 (fref a k k)))
(if (< km1 1) (go label170))
(dcopy-hook km1 (vec-ref a 1 k) 1 work 1)
(fdo (j 1 (+ j 1))
((> j km1) nil)
(tagbody (setf (fref a j k) (ddot j (vec-ref a 1 j) 1 work 1))
(daxpy-hook (- j 1) (fref work j) (vec-ref a 1 j) 1
(vec-ref a 1 k) 1)))
(setf (fref a k k) (+ (fref a k k) (ddot km1 work 1 (vec-ref a 1 k) 1)))
label170 (setf kstep 1)
(go label220)
label180 (setf t_ (dabs (fref a k (+ k 1))))
(setf ak (f2cl/ (fref a k k) t_))
(setf akp1 (f2cl/ (fref a (+ k 1) (+ k 1)) t_))
(setf akkp1 (f2cl/ (fref a k (+ k 1)) t_))
(setf d (* t_ (+ (* ak akp1) (- 1.0d0))))
(setf (fref a k k) (f2cl/ akp1 d))
(setf (fref a (+ k 1) (+ k 1)) (f2cl/ ak d))
(setf (fref a k (+ k 1)) (f2cl/ (- akkp1) d))
(if (< km1 1) (go label210))
(dcopy-hook km1 (vec-ref a 1 (+ k 1)) 1 work 1)
(fdo (j 1 (+ j 1))
((> j km1) nil)
(tagbody (setf (fref a j (+ k 1)) (ddot j (vec-ref a 1 j) 1 work 1))
(daxpy-hook (- j 1) (fref work j) (vec-ref a 1 j) 1
(vec-ref a 1 (+ k 1)) 1)))
(setf (fref a (+ k 1) (+ k 1)) (+ (fref a (+ k 1) (+ k 1))
(ddot km1 work 1 (vec-ref a 1 (+ k 1)) 1)))
(setf (fref a k (+ k 1)) (+ (fref a k (+ k 1))
(ddot km1 (vec-ref a 1 k) 1 (vec-ref a 1 (+ k 1)) 1)))
(dcopy-hook km1 (vec-ref a 1 k) 1 work 1)
(fdo (j 1 (+ j 1))
((> j km1) nil)
(tagbody
(setf (fref a j k) (ddot j (vec-ref a 1 j) 1 work 1))
(daxpy-hook (- j 1) (fref work j) (vec-ref a 1 j) 1 (vec-ref a 1 k) 1)))
(setf (fref a k k) (+ (fref a k k)
(ddot km1 work a (vec-ref a 1 k) 1)))
label210 (setf kstep 2)
label220 (setf ks (iabs (fref kpvt k)))
(if (= ks k) (go label250))
(dswap-hook ks (vec-ref a 1 ks) 1 (vec-ref a 1 k) 1)
(fdo (jb ks (+ jb 1))
((> jb k) nil)
(tagbody (setf j (+ (+ k ks) (- jb)))
(setf temp (fref a j k))
(setf (fref a j k) (fref a ks j))
(setf (fref a ks j) temp)))
(if (= kstep 1) (go label240))
(setf temp (fref a ks (+ k 1)))
(setf (fref a ks (+ k 1)) (fref a k (+ k 1)))
(setf (fref a k (+ k 1)) temp)
label240 label250 (setf k (+ k kstep))
(go label150)
label260 label270 (return (values a lda n kpvt det inert work job))))
| 6,155 | Common Lisp | .l | 129 | 34.27907 | 91 | 0.442173 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | f5814b3dff3ff3a0481269ccbc21e6039ee806e45d11d3811a67742c38a91556 | 33,290 | [
-1
] |
33,291 | dsico.lsp | rwoldford_Quail/source/linear/dsico.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dsico-hook (a lda n kpvt rcond z)
;(declare (type (simple-array double-float (*)) z))
;(declare (type double-float rcond))
;(declare (type (simple-array fixnum (*)) kpvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (ek 0.0d0) (bkm1 0.0d0) (bk 0.0d0) (akm1 0.0d0) (ak 0.0d0)
(ynorm 0.0d0) (s 0.0d0) (anorm 0.0d0) (ks 0) (kps 0) (kp 0) (k 0)
(jm1 0) (j 0) (info (array 0 :dimensions 'nil)) (i 0) (denom 0.0d0))
;(ddot 0.0d0)) ; 31JUL2023
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum jm1))
(declare (type fixnum k))
(declare (type fixnum kp))
(declare (type fixnum kps))
(declare (type fixnum ks))
(declare (type double-float anorm))
(declare (type double-float s))
(declare (type double-float ynorm))
(declare (type double-float ak))
(declare (type double-float akm1))
(declare (type double-float bk))
(declare (type double-float bkm1))
;(declare (type double-float ddot))
(declare (type double-float denom))
(declare (type double-float ek))
(declare (type double-float t_))
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) (dasum j (vec-ref a 1 j) 1))
(setf jm1 (- j 1))
(if (< jm1 1) (go label20))
(fdo (i 1 (+ i 1))
((> i jm1) nil)
(tagbody (setf (fref z i) (+ (fref z i)
(dabs (fref a i j))))))
label20))
(setf anorm 0.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf anorm (dmax1 anorm (fref z j)))))
(dsifa-hook a lda n kpvt info)
(setf ek 1.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) 0.0)))
(setf k n)
label60 (if (= k 0) (go label120))
(setf ks 1)
(if (< (fref kpvt k) 0) (setf ks 2))
(setf kp (iabs (fref kpvt k)))
(setf kps (- (+ k 1) ks))
(if (= kp kps) (go label70))
(setf t_ (fref z kps))
(setf (fref z kps) (fref z kp))
(setf (fref z kp) t_)
label70 (if (/= (fref z k) 0.0) (setf ek (dsign ek (fref z k))))
(setf (fref z k) (+ (fref z k) ek))
(daxpy-hook (- k ks) (fref z k) (vec-ref a 1 k) 1 (vec-ref z 1) 1)
(if (= ks 1) (go label80))
(if (/= (fref z (- k 1)) 0.0)
(setf ek (dsign ek (fref z (- k 1)))))
(setf (fref z (- k 1)) (+ (fref z (- k 1)) ek))
(daxpy-hook (- k ks) (fref z (- k 1)) (vec-ref a 1 (- k 1)) 1
(vec-ref z 1) 1)
label80 (if (= ks 2) (go label100))
(if (<= (dabs (fref z k)) (dabs (fref a k k))) (go label90))
(setf s (f2cl/ (dabs (fref a k k)) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ek (* s ek))
label90 (if (/= (fref a k k) 0.0) (setf (fref z k) (/ (fref z k) (fref a k k))))
(if (= (fref a k k) 0.0) (setf (fref z k) 1.0))
(go label110)
label100 (setf ak (f2cl/ (fref a k k) (fref a (- k 1) k)))
(setf akm1
(f2cl/ (fref a (- k 1) (- k 1)) (fref a (- k 1) k)))
(setf bk (f2cl/ (fref z k) (fref a (- k 1) k)))
(setf bkm1 (f2cl/ (fref z (- k 1)) (fref a (- k 1) k)))
(setf denom (- (* ak akm1) 1.0d0))
(setf (fref z k) (f2cl/ (- (* akm1 bk) bkm1) denom))
(setf (fref z (- k 1)) (f2cl/ (- (* ak bkm1) bk) denom))
label110 (setf k (- k ks))
(go label60)
label120 (setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf k 1)
label130 (if (> k n) (go label160))
(setf ks 1)
(if (< (fref kpvt k) 0) (setf ks 2))
(if (= k 1) (go label150))
(setf (fref z k) (+ (fref z k)
(ddot (- k 1) (vec-ref a 1 k) 1 (vec-ref z 1) 1)))
(if (= ks 2)
(setf (fref z (+ k 1))
(+ (fref z (+ k 1))
(ddot-hook (- k 1) (vec-ref a 1 (+ k 1)) 1 (vec-ref z 1) 1))))
(setf kp (iabs (fref kpvt k)))
(if (= kp k) (go label140))
(setf t_ (fref z k))
(setf (fref z k) (fref z kp))
(setf (fref z kp) t_)
label140 label150 (setf k (+ k ks))
(go label130)
label160 (setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm 1.0d0)
(setf k n)
label170 (if (= k 0) (go label230))
(setf ks 1)
(if (< (fref kpvt k) 0) (setf ks 2))
(if (= k ks) (go label190))
(setf kp (iabs (fref kpvt k)))
(setf kps (- (+ k 1) ks))
(if (= kp kps) (go label180))
(setf t_ (fref z kps))
(setf (fref z kps) (fref z kp))
(setf (fref z kp) t_)
label180 (daxpy-hook (- k ks) (fref z k) (vec-ref a 1 k) 1 (vec-ref z 1) 1)
(if (= ks 2)
(daxpy-hook (- k ks) (fref z (- k 1)) (vec-ref a 1 (- k 1)) 1
(vec-ref z 1) 1))
label190 (if (= ks 2) (go label210))
(if (<= (dabs (fref z k)) (dabs (fref a k k))) (go label200))
(setf s (f2cl/ (dabs (fref a k k)) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label200 (if (/= (fref a k k) 0.0) (setf (fref z k) (/ (fref z k) (fref a k k))))
(if (= (fref a k k) 0.0) (setf (fref z k) 1.0))
(go label220)
label210 (setf ak (f2cl/ (fref a k k) (fref a (- k 1) k)))
(setf akm1
(f2cl/ (fref a (- k 1) (- k 1)) (fref a (- k 1) k)))
(setf bk (f2cl/ (fref z k) (fref a (- k 1) k)))
(setf bkm1 (f2cl/ (fref z (- k 1)) (fref a (- k 1) k)))
(setf denom (+ (* ak akm1) (- 1.0d0)))
(setf (fref z k) (f2cl/ (- (* akm1 bk) bkm1) denom))
(setf (fref z (- k 1)) (f2cl/ (- (* ak bkm1) bk) denom))
label220 (setf k (+ k (- ks)))
(go label170)
label230 (setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(setf k 1)
label240 (if (> k n) (go label270))
(setf ks 1)
(if (< (fref kpvt k) 0) (setf ks 2))
(if (= k 1) (go label260))
(setf (fref z k) (+ (fref z k)
(ddot (- k 1) (vec-ref a 1 k) 1 (vec-ref z 1) 1)))
(if (= ks 2)
(setf (fref z (+ k 1))
(+ (fref z (+ k 1))
(ddot-hook (- k 1) (vec-ref a 1 (+ k 1)) 1 (vec-ref z 1) 1))))
(setf kp (iabs (fref kpvt k)))
(if (= kp k) (go label250))
(setf t_ (fref z k))
(setf (fref z k) (fref z kp))
(setf (fref z kp) t_)
label250 label260 (setf k (+ k ks))
(go label240)
label270 (setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(if (/= anorm 0.0d0) (setf (fref rcond 1) (f2cl/ ynorm anorm)))
(if (= anorm 0.0d0) (setf (fref rcond 1) 0.0))
(return (values a lda n kpvt rcond z))))
| 7,383 | Common Lisp | .l | 170 | 32.7 | 85 | 0.451214 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 7d3be87975d05db7d5e92e1e7aa9dac62cc1a3f4c274468d9808d995c60d57be | 33,291 | [
-1
] |
33,292 | dqrsl.lsp | rwoldford_Quail/source/linear/dqrsl.lsp | (in-package :q)
(defvar *tag-hack*) ;; prevents ACL compiler overflow! gwb
;; used to enclose tagbody forms below. gwb
(defun dqrsl-hook (x ldx n k qraux y qy qty b rsd xb job info)
;;(declare (type fixnum info))
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) xb))
;;(declare (type (simple-array double-float (*)) rsd))
;;(declare (type (simple-array double-float (*)) b))
;;(declare (type (simple-array double-float (*)) qty))
;;(declare (type (simple-array double-float (*)) qy))
;;(declare (type (simple-array double-float (*)) y))
;;(declare (type (simple-array double-float (*)) qraux))
(declare (type fixnum k))
(declare (type fixnum n))
(declare (type fixnum ldx))
;;(declare (type (simple-array double-float (* *)) x))
(prog ((t_ 0.0d0) (kp1 0) (ju 0) (jj 0) (j 0) (i 0) (temp 0.0d0)
(cxb nil) (cr nil) (cqty nil) (cqy nil) (cb nil))
;(ddot 0.0d0)) ; 31JUL2023
(declare (type t cb))
(declare (type t cqy))
(declare (type t cqty))
(declare (type t cr))
(declare (type t cxb))
;(declare (type double-float ddot))
(declare (type double-float t_))
(declare (type double-float temp))
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum jj))
(declare (type fixnum ju))
(declare (type fixnum kp1))
(setf (fref info 1) 0)
(setf cqy (/= (f2cl/ job 10000) 0))
(setf cqty (/= (mod job 10000) 0))
(setf cb (/= (f2cl/ (mod job 1000) 100) 0))
(setf cr (/= (f2cl/ (mod job 100) 10) 0))
(setf cxb (/= (mod job 10) 0))
(setf ju (min0 k (+ n (- 1))))
(if (/= ju 0) (go label40))
(if cqy (setf (fref qy 1) (fref y 1)))
(if cqty (setf (fref qty 1) (fref y 1)))
(if cxb (setf (fref xb 1) (fref y 1)))
(if (not cb) (go label30))
(if (/= (fref x 1 1) 0.0) (go label10))
(setf (fref info 1) 1)
(go label20)
label10 (setf (fref b 1) (f2cl/ (fref y 1) (fref x 1 1)))
label20 label30 (if cr (setf (fref rsd 1) 0.0))
(go label250)
label40 (if cqy
(dcopy-hook n y 1 qy 1))
(if cqty
(dcopy-hook n y 1 qty 1))
(if (not cqy) (go label70))
(fdo (jj 1 (+ jj 1))
((> jj ju) nil)
(let (*tag-hack*)
(tagbody (setf j (+ (+ ju (- jj)) 1))
(if (= (fref qraux j) 0.0) (go label50))
(setf temp (fref x j j))
(setf (fref x j j) (fref qraux j))
(setf t_ (f2cl/ (- (ddot-hook (+ (- n j) 1) (vec-ref x j j) 1
(vec-ref qy j) 1))
(fref x j j)))
(daxpy-hook (+ (- n j) 1) t_ (vec-ref x j j) 1 (vec-ref qy j) 1)
(setf (fref x j j) temp)
label50))
)
label70 (if (not cqty) (go label100))
(fdo (j 1 (+ j 1))
((> j ju) nil)
(let (*tag-hack*)
(tagbody (if (= (fref qraux j) 0.0) (go label80))
(setf temp (fref x j j))
(setf (fref x j j) (fref qraux j))
(setf t_ (f2cl/ (- (ddot-hook (+ (- n j) 1) (vec-ref x j j) 1
(vec-ref qty j) 1))
(fref x j j)))
(daxpy-hook (+ (- n j) 1) t_ (vec-ref x j j) 1 (vec-ref qty j) 1)
(setf (fref x j j) temp)
label80))
)
label100 (if cb
(dcopy-hook k qty 1 b 1))
(setf kp1 (+ k 1))
(if cxb
(dcopy-hook k qty 1 xb 1))
(if (and cr (< k n))
(dcopy-hook (- n k) (vec-ref qty kp1) 1 (vec-ref rsd kp1) 1))
(if (or (not cxb) (> kp1 n)) (go label120))
(fdo (i kp1 (+ i 1))
((> i n) nil)
(let (*tag-hack*)
(tagbody (setf (fref xb i) 0.0)))
)
label120 (if (not cr) (go label140))
(fdo (i 1 (+ i 1))
((> i k) nil)
(let (*tag-hack*)
(tagbody (setf (fref rsd i) 0.0)))
)
label140 (if (not cb) (go label190))
(fdo (jj 1 (+ jj 1))
((> jj k) nil)
(let (*tag-hack*)
(tagbody (setf j (+ (+ k (- jj)) 1))
(if (/= (fref x j j) 0.0) (go label150))
(setf (fref info 1) j)
(go label180)
label150 (setf (fref b j) (f2cl/ (fref b j) (fref x j j)))
(if (= j 1) (go label160))
(setf t_ (- (fref b j)))
(daxpy-hook (- j 1) t_ (vec-ref x 1 j) 1 b 1)
label160))
)
label180 label190 (if (and (not cr) (not cxb)) (go label240))
(fdo (jj 1 (+ jj 1))
((> jj ju) nil)
(let (*tag-hack*)
(tagbody (setf j (+ (+ ju (- jj)) 1))
(if (= (fref qraux j) 0.0) (go label220))
(setf temp (fref x j j))
(setf (fref x j j) (fref qraux j))
(if (not cr) (go label200))
(setf t_
(f2cl/ (* -1
(ddot-hook (+ (+ n (- j)) 1) (vec-ref x j j) 1
(vec-ref rsd j) 1))
(fref x j j)))
(daxpy-hook (+ (+ n (- j)) 1) t_ (vec-ref x j j) 1 (vec-ref rsd j)
1)
label200 (if (not cxb) (go label210))
(setf t_
(f2cl/ (* -1
(ddot-hook (+ (+ n (- j)) 1) (vec-ref x j j) 1
(vec-ref xb j) 1))
(fref x j j)))
(daxpy-hook (+ (+ n (- j)) 1) t_ (vec-ref x j j) 1 (vec-ref xb j)
1)
label210 (setf (fref x j j) temp)
label220))
)
label240 label250 (return (values x ldx n k qraux y qy qty b rsd xb job info))))
| 6,462 | Common Lisp | .l | 145 | 29.131034 | 89 | 0.404026 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | b470a07be2cf9dc16697f7a37e6f62042ed0a44466d8403e5d9701369dddd978 | 33,292 | [
-1
] |
33,293 | list-of-files | rwoldford_Quail/source/linear/list-of-files | ./condition-number.lsp
./cholesky-decomposition.lsp
./jacobi.lsp
./linpack-macros.lsp
./matrix-decomposition.lsp
./matrix-sqrt.lsp
./misc-defs.lsp
./pivot.lsp
./qr-decomposition.lsp
./sv-decomposition.lsp
./dasum.lsp
./dgbco.lsp
./dnrm2.lsp
./inverse.lsp
./linpack-envs.lsp
./qr-solution.lsp
./rank.lsp
./solve.lsp
./table-mixin.lsp
./daxpy.lsp
./dchdc.lsp
./dgbdi.lsp
./linpack.lsp
./trace.lsp
./triangular.lsp
./dcopy.lsp
./ddot.lsp
./determinant.lsp
./dgbfa.lsp
./dgedi.lsp
./dgefa.lsp
./dgels.lsp
./dgesl.lsp
./diagonal.lsp
./dpbco.lsp
./dpodi.lsp
./dpofa.lsp
./dposl.lsp
./dqrdc.lsp
./dqrls.lsp
./dqrsl.lsp
./drot.lsp
./drotg.lsp
./dscal.lsp
./dsico.lsp
./dsidi.lsp
./dsifa.lsp
./dsisl.lsp
./dsvdc.lsp
./dswap.lsp
./dtrco.lsp
./dtrdi.lsp
./dtrls.lsp
./dtrsl.lsp
./eigen-decomposition.lsp
./idamax.lsp
./identity-matrix.lsp
./lin-binary-methods.lsp
./lu-decomposition.lsp
./dgbsl.lsp
./dgeco.lsp
./dpbdi.lsp
./dpbfa.lsp
./dpbsl.lsp
./dpoco.lsp
./apply-weight.lsp
| 1,033 | Common Lisp | .l | 66 | 13.651515 | 29 | 0.709411 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 11fde4b166e1532e6466334df04656e7a9fa20f1805ea15e966c5b1709d9d29e | 33,293 | [
-1
] |
33,294 | dtrls.lsp | rwoldford_Quail/source/linear/dtrls.lsp | (in-package :q)
(defun dtrls-hook (t_ ldt n b m job info)
;;(declare (type fixnum info))
;;(declare (type fixnum job))
(declare (type fixnum m))
;;(declare (type (simple-array single-float (* *)) b))
(declare (type fixnum n))
(declare (type fixnum ldt))
;;(declare (type (simple-array single-float (* *)) t_))
(prog ((j 0))
(declare (type fixnum j))
(fdo (j 1 (+ j 1))
((> j m) nil)
(tagbody (dtrsl-hook t_ ldt n (vec-ref b 1 j) job info)))
(return (values t_ ldt n b m job info))))
| 568 | Common Lisp | .l | 15 | 31.2 | 71 | 0.550091 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 85aeb9c37bfe5d177ebb9a37e8a2436c22c1e8bcb107987cfeed9882d83897f2 | 33,294 | [
-1
] |
33,295 | dsvdc.lsp | rwoldford_Quail/source/linear/dsvdc.lsp | (in-package :q)
(defvar *tag-hack1*) ;; Prevents ACL compiler overflow. gwb
;; encloses tagbody forms below. gwb
(defun dsvdc-hook (x ldx n p s e u ldu v ldv work job info)
;;(declare (type fixnum info))
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) work))
(declare (type fixnum ldv))
;;(declare (type (simple-array double-float (* *)) v))
(declare (type fixnum ldu))
;;(declare (type (simple-array double-float (* *)) u))
;;(declare (type (simple-array double-float (*)) e))
;;(declare (type (simple-array double-float (*)) s))
(declare (type fixnum p))
(declare (type fixnum n))
(declare (type fixnum ldx))
;;(declare (type (simple-array double-float (* *)) x))
(prog ((t_ 0.0d0) (nrtp1 0) (nrt 0) (ncu 0) (nctp1 0) (nct 0)
(mp1 0) (mm1 0) (mm 0) (maxit 0) (m 0) (lu 0) (ls 0) (lp1 0) (lm1 0)
(lls 0) (ll 0) (l 0) (kk 0) (kase 0) (k 0) (jobu 0) (j 0) (iter 0)
(i 0) (ztest 0.0d0) (test 0.0d0) (t1 0.0d0)
(smm1 0.0d0) (sn 0.0d0) (sm 0.0d0) (sl 0.0d0) (shift 0.0d0) (scale 0.0d0)
(g 0.0d0) (f 0.0d0) (emm1 0.0d0) (el 0.0d0) (cs 0.0d0) (c 0.0d0)
(b 0.0d0) (wantv nil) (wantu nil))
(declare (type t wantu))
(declare (type t wantv))
(declare (type double-float b))
(declare (type double-float c))
(declare (type double-float cs))
(declare (type double-float el))
(declare (type double-float emm1))
(declare (type double-float f))
(declare (type double-float g))
(declare (type double-float scale))
(declare (type double-float shift))
(declare (type double-float sl))
(declare (type double-float sm))
(declare (type double-float sn))
(declare (type double-float smm1))
(declare (type double-float t1))
(declare (type double-float test))
(declare (type double-float ztest))
(declare (type double-float t_))
(declare (type fixnum i))
(declare (type fixnum iter))
(declare (type fixnum j))
(declare (type fixnum jobu))
(declare (type fixnum k))
(declare (type fixnum kase))
(declare (type fixnum kk))
(declare (type fixnum l))
(declare (type fixnum ll))
(declare (type fixnum lls))
(declare (type fixnum lm1))
(declare (type fixnum lp1))
(declare (type fixnum ls))
(declare (type fixnum lu))
(declare (type fixnum m))
(declare (type fixnum maxit))
(declare (type fixnum mm))
(declare (type fixnum mm1))
(declare (type fixnum mp1))
(declare (type fixnum nct))
(declare (type fixnum nctp1))
(declare (type fixnum ncu))
(declare (type fixnum nrt))
(declare (type fixnum nrtp1))
(setf maxit 30)
(setf wantu NIL)
(setf wantv NIL)
(setf jobu (f2cl/ (mod job 100) 10))
(setf ncu n)
(if (> jobu 1) (setf ncu (min0 n p)))
(if (/= jobu 0) (setf wantu t))
(if (/= (mod job 10) 0) (setf wantv t))
(setf (fref info 1) 0)
(setf nct (min0 (+ n (- 1)) p))
(setf nrt (max0 0 (min0 (+ p (- 2)) n)))
(setf lu (max0 nct nrt))
(if (< lu 1) (go label170))
(fdo (l 1 (+ l 1))
((> l lu) nil)
(let (*tag-hack1*)
(tagbody (setf lp1 (+ l 1))
(if (> l nct) (go label20))
(setf (fref s l) (dnrm2 (+ (- n l) 1) (vec-ref x l l) 1))
(if (= (fref s l) 0.0) (go label10))
(if (/= (fref x l l) 0.0)
(setf (fref s l) (sign (fref s l)
(fref x l l))))
(dscal-hook (+ (- n l) 1) (f2cl/ 1.0 (fref s l))
(vec-ref x l l) 1)
(setf (fref x l l) (+ 1.0 (fref x l l)))
label10 (setf (fref s l) (- (fref s l)))
label20 (if (< p lp1) (go label50))
(fdo (j lp1 (+ j 1))
((> j p) nil)
(tagbody (if (> l nct) (go label30))
(if (= (fref s l) 0.0) (go label30))
(setf t_
(f2cl/
(*
-1
(ddot-hook
(+ (+ n (- l)) 1)
(vec-ref x l l)
1
(vec-ref x l j)
1))
(fref x l l)))
(daxpy-hook (+ (- n l) 1) t_ (vec-ref x l l)
1 (vec-ref x l j) 1)
label30 (setf (fref e j) (fref x l j))))
label50 (if (or (not wantu) (> l nct)) (go label70))
(fdo (i l (+ i 1))
((> i n) nil)
(tagbody (setf (fref u i l) (fref x i l))))
label70 (if (> l nrt) (go label150))
(setf (fref e l) (dnrm2-hook (- p l) (vec-ref e lp1) 1))
(if (= (fref e l) 0.0) (go label80))
(if (/= (fref e lp1) 0.0)
(setf (fref e l) (sign (fref e l) (fref e lp1))))
(dscal-hook (- p l) (f2cl/ 1.0 (fref e l)) (vec-ref e lp1)
1)
(setf (fref e lp1) (+ 1.0 (fref e lp1)))
label80
(setf (fref e l) (- (fref e l)))
(if (or (> lp1 n) (= (fref e l) 0.0)) (go label120))
(fdo (i lp1 (+ i 1))
((> i n) nil)
(tagbody (setf (fref work i) 0.0)))
(fdo (j lp1 (+ j 1))
((> j p) nil)
(tagbody (daxpy-hook (- n l) (fref e j)
(vec-ref x lp1 j) 1 (vec-ref work lp1) 1)))
(fdo (j lp1 (+ j 1))
((> j p) nil)
(tagbody (daxpy-hook (- n l)
(f2cl/ (* -1 (fref e j)) (fref e lp1))
(vec-ref work lp1) 1 (vec-ref x lp1 j) 1)))
label120 (if (not wantv) (go label140))
(fdo (i lp1 (+ i 1))
((> i p) nil)
(tagbody (setf (fref v i l) (fref e i))))
label140 label150))
)
label170 (setf m (min0 p (+ n 1)))
(setf nctp1 (+ nct 1))
(setf nrtp1 (+ nrt 1))
(if (< nct p) (setf (fref s nctp1) (fref x nctp1 nctp1)))
(if (< n m) (setf (fref s m) 0.0))
(if (< nrtp1 m) (setf (fref e nrtp1) (fref x nrtp1 m)))
(setf (fref e m) 0.0)
(if (not wantu) (go label300))
(if (< ncu nctp1) (go label200))
(fdo (j nctp1 (+ j 1))
((> j ncu) nil)
(let (*tag-hack1*)
(tagbody (fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf (fref u i j) 0.0)))
(setf (fref u j j) 1.0)))
)
label200 (if (< nct 1) (go label290))
(fdo (ll 1 (+ ll 1))
((> ll nct) nil)
(let (*tag-hack1*)
(tagbody (setf l (+ (+ nct (- ll)) 1))
(if (= (fref s l) 0.0) (go label250))
(setf lp1 (+ l 1))
(if (< ncu lp1) (go label220))
(fdo (j lp1 (+ j 1))
((> j ncu) nil)
(tagbody (setf t_
(f2cl/
(*
-1
(ddot-hook
(+ (+ n (- l)) 1)
(vec-ref u l l)
1
(vec-ref u l j)
1))
(fref u l l)))
(daxpy-hook (+ (- n l) 1) t_ (vec-ref u l l)
1 (vec-ref u l j) 1)))
label220 (dscal-hook (+ (- n l) 1) (- 1.0) (vec-ref u l l) 1)
(setf (fref u l l) (+ 1.0 (fref u l l)))
(setf lm1 (+ l (- 1)))
(if (< lm1 1) (go label240))
(fdo (i 1 (+ i 1))
((> i lm1) nil)
(tagbody (setf (fref u i l) 0.0)))
label240 (go label270)
label250 (fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf (fref u i l) 0.0)))
(setf (fref u l l) 1.0)
label270))
)
label290 label300 (if (not wantv) (go label350))
(fdo (ll 1 (+ ll 1))
((> ll p) nil)
(let (*tag-hack1*)
(tagbody (setf l (+ (+ p (- ll)) 1))
(setf lp1 (+ l 1))
(if (> l nrt) (go label320))
(if (= (fref e l) 0.0) (go label320))
(fdo (j lp1 (+ j 1))
((> j p) nil)
(let (*tag-hack1*)
(tagbody (setf t_
(f2cl/
(*
-1
(ddot-hook
(+ p (- l))
(vec-ref v lp1 l)
1
(vec-ref v lp1 j)
1))
(fref v lp1 l)))
(daxpy-hook (- p l) t_ (vec-ref v lp1 l) 1
(vec-ref v lp1 j) 1)))
)
label320 (fdo (i 1 (+ i 1))
((> i p) nil)
(let (*tag-hack1*)
(tagbody (setf (fref v i l) 0.0)))
)
(setf (fref v l l) 1.0)))
)
label350 (setf mm m)
(setf iter 0)
label360 (if (= m 0) (go label620))
(if (< iter maxit) (go label370))
(setf (fref info 1) m)
(go label620)
label370 (fdo (ll 1 (+ ll 1))
((> ll m) nil)
(let (*tag-hack1*)
(tagbody (setf l (+ m (- ll)))
(if (= l 0) (go label400))
(setf test
(+ (dabs (fref s l)) (dabs (fref s (+ l 1)))))
(setf ztest (+ test (dabs (fref e l))))
(if (/= ztest test) (go label380))
(go label400)
label380))
)
label400 (if (/= l (+ m (- 1))) (go label410))
(setf kase 4)
(go label480)
label410 (setf lp1 (+ l 1))
(setf mp1 (+ m 1))
(fdo (lls lp1 (+ lls 1))
((> lls mp1) nil)
(let (*tag-hack1*)
(tagbody (setf ls (+ (+ m (- lls)) lp1))
(if (= ls l) (go label440))
(setf test 0.0d0)
(if (/= ls m) (setf test (+ test (dabs (fref e ls)))))
(if (/= ls (+ l 1))
(setf test (+ test (dabs (fref e (+ ls (- 1)))))))
(setf ztest (+ test (dabs (fref s ls))))
(if (/= ztest test) (go label420))
(go label440)
label420))
)
label440 (if (/= ls l) (go label450))
(setf kase 3)
(go label470)
label450 (if (/= ls m) (go label460))
(setf kase 1)
(go label470)
label460 (setf kase 2)
(setf l ls)
label470 label480 (setf l (+ l 1))
(case kase (1 (go label490))
(2 (go label520))
(3 (go label540))
(4 (go label570)))
label490 (setf mm1 (+ m (- 1)))
(setf f (fref e (+ m (- 1))))
(setf (fref e (- m 1)) 0.0)
(fdo (kk l (+ kk 1))
((> kk mm1) nil)
(let (*tag-hack1*)
(tagbody (setf k (+ (+ mm1 (- kk)) l))
(setf t1 (fref s k))
(multiple-value-setq (t1 f cs sn)
(drotg-hook t1 f cs sn))
(setf (fref s k) t1)
(if (= k l) (go label500))
(setf f (* (* -1 sn) (fref e (+ k (- 1)))))
(setf (fref e (- k 1)) (* cs (fref e (- k 1))))
label500 (if wantv
(drot-hook p (vec-ref v 1 k) 1 (vec-ref v 1 m) 1 cs sn))))
)
(go label610)
label520 (setf f (fref e (- l 1)))
(setf (fref e (- l 1)) 0.0)
(fdo (k l (+ k 1))
((> k m) nil)
(let (*tag-hack1*)
(tagbody (setf t1 (fref s k))
(multiple-value-setq (t1 f cs sn)
(drotg-hook t1 f cs sn))
(setf (fref s k) t1)
(setf f (* (* -1 sn) (fref e k)))
(setf (fref e k) (* cs (fref e k)))
(if wantu
(drot-hook n (vec-ref u 1 k) 1 (vec-ref u 1 (+ l (- 1))) 1 cs
sn))))
)
(go label610)
label540 (setf scale
(dmax1 (dabs (fref s m))
(dabs (fref s (+ m (- 1))))
(dabs (fref e (+ m (- 1))))
(dabs (fref s l))
(dabs (fref e l))))
(setf sm (f2cl/ (fref s m) scale))
(setf smm1 (f2cl/ (fref s (+ m (- 1))) scale))
(setf emm1 (f2cl/ (fref e (+ m (- 1))) scale))
(setf sl (f2cl/ (fref s l) scale))
(setf el (f2cl/ (fref e l) scale))
(setf b (f2cl/ (+ (* (+ smm1 sm) (+ smm1 (- sm))) (expt emm1 2)) 2.0d0))
(setf c (expt (* sm emm1) 2))
(setf shift 0.0d0)
(if (and (= b 0.0d0) (= c 0.0d0)) (go label550))
(setf shift (dsqrt (+ (expt b 2) c)))
(if (< b 0.0d0) (setf shift (- shift)))
(setf shift (f2cl/ c (+ b shift)))
label550 (setf f (+ (* (+ sl sm) (+ sl (- sm))) shift))
(setf g (* sl el))
(setf mm1 (+ m (- 1)))
(fdo (k l (+ k 1))
((> k mm1) nil)
(let (*tag-hack1*)
(tagbody (multiple-value-setq (f g cs sn)
(drotg-hook f g cs sn))
(if (/= k l) (setf (fref e (- k 1)) f))
(setf f (+ (* cs (fref s k)) (* sn (fref e k))))
(setf (fref e k) (- (* cs (fref e k)) (* sn (fref s k))))
(setf g (* sn (fref s (+ k 1))))
(setf (fref s (+ k 1)) (* cs (fref s (+ k 1))))
(if wantv
(drot-hook p (vec-ref v 1 k) 1 (vec-ref v 1 (+ k 1)) 1 cs
sn))
(multiple-value-setq (f g cs sn)
(drotg-hook f g cs sn))
(setf (fref s k) f)
(setf f (+ (* cs (fref e k)) (* sn (fref s (+ k 1)))))
(setf (fref s (+ k 1)) (+ (* (- sn) (fref e k))
(* cs (fref s (+ k 1)))))
(setf g (* sn (fref e (+ k 1))))
(setf (fref e (+ k 1)) (* cs (fref e (+ k 1))))
(if (and wantu (< k n))
(drot-hook n (vec-ref u 1 k) 1 (vec-ref u 1 (+ k 1)) 1 cs
sn))))
)
(setf (fref e (- m 1)) f)
(setf iter (+ iter 1))
(go label610)
label570 (if (>= (fref s l) 0.0) (go label580))
(setf (fref s l) (- (fref s l)))
(if wantv
(dscal-hook p (- 1.0) (vec-ref v 1 l) 1))
label580 label590 (if (= l mm) (go label600))
(if (>= (fref s l) (fref s (+ l 1))) (go label600))
(setf t_ (fref s l))
(setf (fref s l) (fref s (+ l 1)))
(setf (fref s (+ l 1)) t_)
(if (and wantv (< l p))
(dswap-hook p (vec-ref v 1 l) 1 (vec-ref v 1 (+ l 1)) 1))
(if (and wantu (< l n))
(dswap-hook n (vec-ref u 1 l) 1 (vec-ref u 1 (+ l 1)) 1))
(setf l (+ l 1))
(go label590)
label600 (setf iter 0)
(setf m (+ m (- 1)))
label610 (go label360)
label620 (return (values x ldx n p s e u ldu v ldv work job info))))
| 17,735 | Common Lisp | .l | 384 | 27 | 94 | 0.350089 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 949adc33eb3b0b159ec0cc6c17b47f7048d016b23a6fcf90909e402fd29e65f6 | 33,295 | [
-1
] |
33,296 | trace.lsp | rwoldford_Quail/source/linear/trace.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; trace.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(trace-of)))
(defgeneric trace-of (A)
(:documentation "Returns the trace of the square matrix A. ~
Simply sums the diagonal elements."))
(defmethod trace-of ((A T))
(let ((first-dim (or (first (dimensions-of A)) 1))
(second-dim (or (second (dimensions-of A)) 1))
)
(cond
((= first-dim second-dim)
(if (= first-dim 1)
(eref A 0)
(loop for i from 0 below first-dim
sum (eref A i i)))
)
(T
(quail-error
"Matrix is ~s by ~s! Trace-of requires a square matrix; ~s is not."
first-dim second-dim A)))))
(defmethod trace-of ((A identity-matrix))
(nrows A))
| 1,242 | Common Lisp | .l | 38 | 27.289474 | 81 | 0.437919 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | ae0a69d8a8cd88b02a21c527a3398d1e0e57f20b5801948e090e262fc2757b2c | 33,296 | [
-1
] |
33,297 | condition-number.lsp | rwoldford_Quail/source/linear/condition-number.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; condition-number.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(condition-number-of)))
(defgeneric condition-number-of (thing)
(:documentation
"Returns the condition number of its argument; ~
That is the ratio of its largest singular value to its smallest.~
For some methods, this will be only a numerical approximation."
))
(defmethod condition-number-of ((X identity-matrix))
1
)
(defmethod condition-number-of ((X inverse-matrix))
(inverse (condition-number-of (inverse X)))
)
(defmethod condition-number-of ((X T))
"Returns the condition number of its argument; ~
That is the ratio of its largest singular value to its smallest.~
(:see-also (singular-values-of :generic-function) ~
(sv-decomposition :topic) )"
(let ((svs (singular-values-of X)))
(/ (max svs) (min svs)))
)
(defmethod condition-number-of ((lu lu-decomposition))
"Returns the condition number as estimated by the lu-decomposition ~
itself.~
(:see-also (singular-values-of :generic-function) ~
(sv-decomposition :topic) )"
(cond
((q::rcond-of lu) (/ (q::rcond-of lu)))
(T (warn "This LU decomposition has no condition number information.~&~
NaN returned.")
NaN)
))
(defmethod condition-number-of ((c cholesky-decomposition))
"Returns the condition number as estimated by the cholesky-decomposition ~
itself.~
(:see-also (singular-values-of :generic-function) ~
(sv-decomposition :topic) )"
(cond
((q::rcond-of c)
(/ (q::rcond-of c)))
(T (warn "This cholesky decomposition has no condition number information.~&~
Try an unpivoted version.~&~
NaN returned.")
NaN)
))
| 2,243 | Common Lisp | .l | 62 | 31.354839 | 88 | 0.574271 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 70170fa8bc96452cf9bc3112b7e09901998b452e0718ca0efc793cb6b9c13d34 | 33,297 | [
-1
] |
33,298 | dpbdi.lsp | rwoldford_Quail/source/linear/dpbdi.lsp | (in-package :q)
(defun dpbdi-hook (abd lda n m det)
;; (declare (type (simple-array double-float (*)) det))
(declare (type fixnum m))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((s 0.0d0) (i 0))
(declare (type fixnum i))
(declare (type double-float s))
;;
;; dpbdi computes the determinant
;; of a double precision symmetric positive definite band matrix
;; using the factors computed by dpbco or dpbfa.
;; if the inverse is needed, use dpbsl n times.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; the output from dpbco or dpbfa.
;;
;; lda integer
;; the leading dimension of the array abd .
;;
;; n integer
;; the order of the matrix a .
;;
;; m integer
;; the number of diagonals above the main diagonal.
;;
;; on return
;;
;; det double precision(2)
;; determinant of original matrix in the form
;; determinant = det(1) * 10.0**det(2)
;; with 1.0 .le. det(1) .lt. 10.0
;; or det(1) .eq. 0.0 .
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;;
;; internal variables
;;
;;
;; compute determinant
;;
(setf (fref det 1) 1.0)
(setf (fref det 2) 0.0)
(setf s 10.0d0)
(fdo (i 1 (1+ i))
((> i n) nil)
(tagbody (setf (fref det 1)
(* (expt (fref abd (1+ m) i) 2) (fref det 1)))
;; ...exit
(if (= (fref det 1) 0.0) (go label60))
label10 (if (>= (fref det 1) 1.0) (go label20))
(setf (fref det 1) (* s (fref det 1)))
(setf (fref det 2) (- (fref det 2) 1.0))
(go label10)
label20
label30 (if (< (fref det 1) s) (go label40))
(setf (fref det 1) (f2cl/ (fref det 1) s))
(setf (fref det 2) (+ (fref det 2) 1.0))
(go label30)
label40))
label60 (return (values abd lda n m det))))
| 2,753 | Common Lisp | .l | 69 | 28.043478 | 78 | 0.414179 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 5f9ccb8eaac8418380ad83306c2c4628695dc5a4105ae212817ffca08203b285 | 33,298 | [
-1
] |
33,299 | inverse.lsp | rwoldford_Quail/source/linear/inverse.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; inverse.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(inverse-matrix inverse inverse-object-of)))
(defgeneric inverse-object-of (thing)
(:documentation
"Returns the cached inverse of thing. Cannot be used with setf to ~
set the cache if one exists."))
(defmethod inverse-object-of ((thing t))
(if (quail-y-or-n-p "INVERSE-OBJECT-OF: No inverse-object cache exists for ~s, ~
perhaps you meant to take the inverse?" thing)
(inverse thing)
(quail-error
"INVERSE-OBJECT-OF: No inverse-object cache exists for ~s."
thing)
))
(defmethod (setf inverse-object-of) (new-value (thing t))
(declare (ignore new-value))
(quail-error
"Cannot directly set the cached inverse-object of thing."
thing))
(defclass inverse (quail-object)
((inverse-object :initarg :inverse-object
:reader inverse-object-of
:initform :NONE)
(inverse-calculated? :initarg :inverse-calculated?
:initform NIL
:reader inverse-calculated-p))
(:documentation "A general class representing the mathematical ~
inverse of something. It's primary use is to delay ~
evaluation of the actual inverse and to provide ~
programmatic opportunity to use the inverse in ~
a numerically reliable fashion.~
(:see-also (inverse :generic-function)~
)")
)
(defclass inverse-matrix (inverse matrix)
()
(:documentation "The matrix inverse of another matrix. ~
(:see-also (inverse :generic-function))")
)
;;;
;;; Make sure that matrix is the returned class type when inverse-matrix
;;; is combined with any of the list
;;;
(qk::put-return-class 'matrix
'inverse-matrix
'(inverse-matrix matrix num-array ref-array
vector cons sequence list array
integer fixnum rational float complex
symbol))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; The inverse function
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric inverse (object)
(:documentation
"Returns the mathematical inverse of the object.~
It may suppress explicit determination of the inverse for numerical ~
reasons until the result is actually needed in calculation. ~
(:see-also (inverse :generic-function)~
(solve :function))"))
(defmethod inverse ((object t))
"Not defined in general; missing-method invoked."
(missing-method 'inverse object))
(defmethod inverse ((self inverse))
"Returns inverse-object-of self."
(inverse-object-of self))
(defmethod inverse ((x number))
(cl:/ x))
(defmethod-multi inverse ((x ((eql infinity)
(eql +infinity)
(eql -infinity)
(eql NaN))))
(/ x))
(defmethod inverse :around ((x matrix))
"Checks dimensions of x to make sure that it is square."
(let*
((dims (dimensions-of x))
(p (length dims)))
(cond
((null dims) (inverse (eref x)))
((and (= p 1) (= 1 (first dims)))
(inverse (eref x 0)))
((and (= p 2) (apply #'cl::= dims))
(call-next-method))
(T (quail-error "INVERSE: Matrix ~s not square." x)))
))
(defmethod inverse ((x matrix))
"Returns the inverse-matrix of the square matrix x. ~
If x is non-square it calculates and returns the Moore-Penrose ~
generalized inverse of x. ~
(:see-also (solve :function) (qr-solution :topic))~
"
(if (cl:= (nrows x) (ncols x))
(let ((result (make-instance
'inverse-matrix
:inverse-object x)))
(setf (dimensions-of result) (dimensions-of x))
result)
(inverse (qrd-of x))))
(defmethod inverse ((lu lu-decomposition))
(if (cl::=
1.0
(cl::+ 1.0 (eref (rcond-of lu))))
(quail-error "Matrix is singular to working precision.")
(let* ((a (sel (lu-of lu)))
(n (first (dimensions-of a)))
(ipvt (ipvt-of lu))
(det (array 0.0D0 :dimensions (list 2)))
(work (array 0.0D0 :dimensions (list n)))
(job 1))
(dgedi a n ipvt det work job)
a)))
(defmethod inverse ((c cholesky-decomposition))
(cond
((jpvt-of c)
;; a pivoted cholesky
(quail-error
"Inverse not yet implemented for a pivoted Cholesky decomposition.~
~&Try using an unpivoted decomposition first.")
)
(T
;; an unpivoted cholesky
(if (or (not (zerop (info-of c)))
(cl::=
1.0
(cl::+ 1.0 (eref (rcond-of c)))))
(quail-error "Inverse of Cholesky: ~
Matrix is singular to working precision.")
(let* ((a (sel (upper-triangle-of c)))
(n (first (dimensions-of a)))
(det (array 0.0D0 :dimensions (list 2)))
(job 1))
;; calculate the inverse from LINPACK
(dpodi a n det job)
;; copy the top into the bottom.
(loop
for i from 0 below n
do
(loop
for j from 0 below i
do
(setf (eref a i j) (eref a j i))
)
)
a)))
)
)
(defmethod inverse ((e eigen-decomposition))
(let* ((V (eigen-vectors-of e))
(D (eigen-values-of e))
(p (nrows V))
(result (array 0.0 :dimensions (list p p)))
tmp)
(do ((i 0 (incf i)))
((= i p))
(do ((j i (incf j)))
((= j p))
(setf tmp 0)
(do ((k 0 (incf k)))
((= k p))
(setf tmp (+ tmp (/ (* (eref V i k) (eref V j k))
(eref D k))))
)
(setf (eref result i j) tmp)
(setf (eref result j i) tmp)
)
)
result))
;;;
;;; request-inverse-evaluation
;;;
(defgeneric request-inverse-evaluation (inverse)
(:documentation "Force inverse to actually calculate itself if it hasn't ~
already done so. (:see-also (inverse :generic-function))")
)
;;; Add do-nothing primary FEB 04 1998
(defmethod request-inverse-evaluation ((self inverse))
(declare (ignorable self)) ;(declare (ignore self)) ; 31JUL2023
(call-next-method))
(defmethod request-inverse-evaluation :around ((self inverse))
"Checks to see whether the evaluation has already been done.~
If it has then it returns self, if it has not then it calls the ~
next method."
(if (inverse-calculated-p self)
self
(call-next-method)))
(defmethod request-inverse-evaluation ((self t))
"In general does nothing but return self."
self)
(defmethod request-inverse-evaluation ((self inverse-matrix))
(unless (eq (inverse-object-of self) :NONE)
(let ((inv (inverse
(lud-of
(inverse-object-of self)))))
(with-slots ((self-proto qk::proto)
(self-ref-obj qk::ref-obj)
(self-specs-mask qk::specs-mask)
(self-specs qk::specs)
(self-dimensions qk::dimensions)
(self-ref-contents qk::ref-contents)
(self-decomposition decomposition)
(self-inverse-calculated? inverse-calculated?))
self
(with-slots ((inv-proto qk::proto)
(inv-ref-obj qk::ref-obj)
(inv-specs-mask qk::specs-mask)
(inv-specs qk::specs)
(inv-dimensions qk::dimensions)
(inv-ref-contents qk::ref-contents)
(inv-decomposition decomposition))
inv
(setf self-proto inv-proto
self-ref-obj inv-ref-obj
self-specs-mask inv-specs-mask
self-specs inv-specs
self-dimensions inv-dimensions
self-ref-contents inv-ref-contents
self-decomposition inv-decomposition
self-inverse-calculated? t)))
self))
)
;;; Add do-nothing primary FEB 04 1998
(defmethod fill-unbound-slots ((self inverse-matrix))
(declare (ignorable self)) ;(declare (ignore self)) ; 31JUL2023
(call-next-method))
(defmethod fill-unbound-slots :after ((self inverse-matrix))
(labels
((best-inverse-object (protos)
(if protos
(inverse-object-of (first protos))
nil))
(best-inverse-calculated (protos)
(let ((best-one (best-inverse-object protos)))
(and best-one (inverse-calculated-p best-one))))
)
(with-slots ((protos qk::proto))
self
(setf protos
(remove-if-not
#'(lambda (proto)
(typep proto 'inverse-matrix))
protos))
(if (qk::fill-slot-p self 'inverse-object)
(setf (slot-value self 'inverse-object)
(best-inverse-object protos)))
(if (qk::fill-slot-p self 'inverse-calculated?)
(setf (slot-value self 'inverse-calculated?)
(best-inverse-calculated protos)))))
)
;-----
(defmethod ref ((self inverse-matrix) &rest args)
(declare (ignore args))
(request-inverse-evaluation self)
(let ((result (call-next-method)))
(change-class result 'matrix)
result))
;-----
(defmethod sel ((self inverse-matrix) &rest args)
(declare (ignore args))
(request-inverse-evaluation self)
(let ((result (call-next-method)))
(change-class result 'matrix)
result))
;-----
(defmethod eref ((self inverse-matrix) &rest args)
(declare (ignore args))
(request-inverse-evaluation self)
(call-next-method))
;-----
(defmethod (setf ref) (new-value (self inverse-matrix) &rest args)
(declare (ignore args new-value))
(request-inverse-evaluation self)
(let ((result (call-next-method)))
(change-class self 'matrix)
result))
;-----
(defmethod (setf eref) (new-value (self inverse-matrix) &rest args)
(declare (ignore args new-value))
(request-inverse-evaluation self)
(let ((result (call-next-method)))
(change-class self 'matrix)
result))
;-----
(defmethod print-object ((self inverse-matrix) stream)
(if (inverse-calculated-p self)
(call-next-method)
(format stream "#<Matrix inverse of ~A>" (inverse-object-of self))))
| 11,499 | Common Lisp | .l | 305 | 28.534426 | 109 | 0.537491 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | d95ebb85b647acfa36b0f512049e6cd76963437d75dc5ce554731d9031fe243b | 33,299 | [
-1
] |
33,300 | dswap.lsp | rwoldford_Quail/source/linear/dswap.lsp | (in-package :q)
(defun dswap-hook (n dx incx dy incy)
(declare (type fixnum incy))
;;(declare (type (simple-array double-float (*)) dy))
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((dtemp 0.0d0) (mp1 0) (m 0) (iy 0) (ix 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum ix))
(declare (type fixnum iy))
(declare (type fixnum m))
(declare (type fixnum mp1))
(declare (type double-float dtemp))
(if (<= n 0) (go end_label))
(if (and (= incx 1) (= incy 1)) (go label20))
(setf ix 1)
(setf iy 1)
(if (< incx 0) (setf ix (+ (* (+ (- n) 1) incx) 1)))
(if (< incy 0) (setf iy (+ (* (+ (- n) 1) incy) 1)))
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf dtemp (fref dx ix))
(setf (fref dx ix) (fref dy iy))
(setf (fref dy iy) dtemp)
(setf ix (+ ix incx))
(setf iy (+ iy incy))))
(go end_label)
label20 (setf m (mod n 3))
(if (= m 0) (go label40))
(fdo (i 1 (+ i 1))
((> i m) nil)
(tagbody (setf dtemp (fref dx i))
(setf (fref dx i) (fref dy i))
(setf (fref dy i) dtemp)))
(if (< n 3) (go end_label))
label40 (setf mp1 (+ m 1))
(fdo (i mp1 (+ i 3))
((> i n) nil)
(tagbody (setf dtemp (fref dx i))
(setf (fref dx i) (fref dy i))
(setf (fref dy i) dtemp)
(setf dtemp (fref dx (+ i 1)))
(setf (fref dx (+ i 1)) (fref dy (+ i 1)))
(setf (fref dy (+ i 1)) dtemp)
(setf dtemp (fref dx (+ i 2)))
(setf (fref dx (+ i 2)) (fref dy (+ i 2)))
(setf (fref dy (+ i 2)) dtemp)))
(go end_label)
end_label (return (values n dx incx dy incy))))
| 1,958 | Common Lisp | .l | 50 | 28.96 | 61 | 0.454307 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | b8da2badba556c971aba47021cbdc5ef2c81039f06da65206e8947989cb0404e | 33,300 | [
-1
] |
33,301 | dgefa.lsp | rwoldford_Quail/source/linear/dgefa.lsp | (in-package :q)
(defun dgefa-hook (a lda n ipvt info)
;;(declare (type fixnum info))
;;(declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (nm1 0) (l 0) (kp1 0) (k 0) (j 0))
(declare (type fixnum j))
(declare (type fixnum k))
(declare (type fixnum kp1))
(declare (type fixnum l))
(declare (type fixnum nm1))
(declare (type double-float t_))
(setf (fref info 1) 0)
(setf nm1 (- n 1))
(if (< nm1 1) (go label70))
(fdo (k 1 (+ k 1))
((> k nm1) nil)
(tagbody (setf kp1 (+ k 1))
(setf l (- (+ (idamax-hook (+ (- n k) 1) (vec-ref a k k) 1) k) 1))
(setf (fref ipvt k) l)
(if (= (fref a l k) 0.0) (go label40))
(if (= l k) (go label10))
(setf t_ (fref a l k))
(setf (fref a l k) (fref a k k))
(setf (fref a k k) t_)
label10 (setf t_ (f2cl/ -1.0 (fref a k k)))
(dscal-hook (- n k) t_ (vec-ref a (+ k 1) k) 1)
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf t_ (fref a l j))
(if (= l k) (go label20))
(setf (fref a l j) (fref a k j))
(setf (fref a k j) t_)
label20 (daxpy-hook (- n k) t_ (vec-ref a (+ k 1) k)
1 (vec-ref a (+ k 1) j) 1)))
(go label50)
label40 (setf (fref info 1) k)
label50))
label70 (setf (fref ipvt n) n)
(if (= (fref a n n) 0.0) (setf (fref info 1) n))
(return (values a lda n ipvt info))))
| 1,915 | Common Lisp | .l | 43 | 29.837209 | 85 | 0.407923 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 534ac808584d305fe0fcb6dbf25386cacae10521dd7e6325c26d8ec1e83bf68c | 33,301 | [
-1
] |
33,302 | drot.lsp | rwoldford_Quail/source/linear/drot.lsp | (in-package :q)
(defun drot-hook (n dx incx dy incy c s)
(declare (type double-float s))
(declare (type double-float c))
(declare (type fixnum incy))
;;(declare (type (simple-array double-float (*)) dy))
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((dtemp 0.0d0) (iy 0) (ix 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum ix))
(declare (type fixnum iy))
(declare (type double-float dtemp))
(if (<= n 0) (go end_label))
(if (and (= incx 1) (= incy 1)) (go label20))
(setf ix 1)
(setf iy 1)
(if (< incx 0) (setf ix (+ (* (- 1 n) incx) 1)))
(if (< incy 0) (setf iy (+ (* (- 1 n) incy) 1)))
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf dtemp (+ (* c (fref dx ix)) (* s (fref dy iy))))
(setf (fref dy iy) (- (* c (fref dy iy)) (* s (fref dx ix))))
(setf (fref dx ix) dtemp)
(setf ix (+ ix incx))
(setf iy (+ iy incy))))
(go end_label)
label20 (fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf dtemp (+ (* c (fref dx i)) (* s (fref dy i))))
(setf (fref dy i) (- (* c (fref dy i)) (* s (fref dx i))))
(setf (fref dx i) dtemp)
))
(go end_label)
end_label (return (values n dx incx dy incy c s))))
| 1,549 | Common Lisp | .l | 36 | 31.527778 | 84 | 0.447979 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | eb9f048a2253a66dd8e8c7393d6e7893f77df9a62a3ef61c1336a975addc9f2b | 33,302 | [
-1
] |
33,303 | dpoco.lsp | rwoldford_Quail/source/linear/dpoco.lsp | (in-package :q)
(defun dpoco-hook (a lda n rcond z info)
;;(declare (type fixnum info))
;;(declare (type (simple-array double-float (*)) z))
;;(declare (type double-float rcond))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (wkm 0.0d0) (wk 0.0d0) (ek 0.0d0) (ynorm 0.0d0)
(sm 0.0d0) (s 0.0d0) (anorm 0.0d0) (kp1 0) (kb 0) (k 0) (jm1 0)
(j 0) (i 0))
;(declare (type single-float t_)) ;; declared double-float below and in other files where it is used
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum jm1))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum kp1))
(declare (type double-float anorm))
(declare (type double-float s))
(declare (type double-float sm))
(declare (type double-float ynorm))
(declare (type double-float ek))
(declare (type double-float t_))
(declare (type double-float wk))
(declare (type double-float wkm))
(declare (special *dummy_var*))
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) (dasum-hook j (vec-ref a 1 j) 1))
(setf jm1 (- j 1))
(if (< jm1 1) (go label20))
(fdo (i 1 (+ i 1))
((> i jm1) nil)
(tagbody (setf (fref z i) (+ (fref z i) (dabs (fref a i j))))))
label20))
(setf anorm 0.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf anorm (dmax1 anorm (fref z j)))))
(dpofa-hook a lda n info)
(if (/= (fref info 1) 0) (go label180))
(setf ek 1.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) 0.0d0)))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody
(if (/= (fref z k) 0.0)
(setf ek (dsign ek (- (fref z k)))))
(if (<= (dabs (- ek (fref z k))) (fref a k k))
(go label60))
(setf s
(f2cl/ (fref a k k) (dabs (- ek (fref z k)))))
(dscal-hook n s z 1)
(setf ek (* s ek))
label60 (setf wk (- ek (fref z k)))
(setf wkm (- (- ek) (fref z k)))
(setf s (dabs wk))
(setf sm (dabs wkm))
(setf wk (f2cl/ wk (fref a k k)))
(setf wkm (f2cl/ wkm (fref a k k)))
(setf kp1 (+ k 1))
(if (> kp1 n) (go label100))
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf sm (+ sm (dabs
(+ (fref z j)
(* wkm (fref a k j))))))
(setf (fref z j)
(+ (fref z j) (* wk (fref a k j))))
(setf s (+ s (dabs (fref z j))))))
(if (>= s sm) (go label90))
(setf t_ (- wkm wk))
(setf wk wkm)
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j)
(+ (fref z j)
(* t_ (fref a k j))))))
label90 label100 (setf (fref z k) wk)))
(setf s (f2cl/ 1.0
(dasum-hook n z 1)))
(dscal-hook n s z 1)
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (- (+ n 1) kb))
(if (<= (dabs (fref z k)) (fref a k k)) (go label120))
(setf s (f2cl/ (fref a k k) (dabs (fref z k))))
(dscal-hook n s z 1)
label120 (setf (fref z k) (f2cl/ (fref z k) (fref a k k)))
(setf t_ (- (fref z k)))
(daxpy-hook (- k 1) t_ (vec-ref a 1 k) 1 (vec-ref z 1) 1)))
(setf s (f2cl/ 1.0
(dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm 1.0d0)
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf (fref z k)
(- (fref z k)
(ddot-hook (- k 1) (vec-ref a 1 k) 1 (vec-ref z 1) 1)))
(if (<= (dabs (fref z k)) (fref a k k)) (go label140))
(setf s (f2cl/ (fref a k k) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label140 (setf (fref z k) (f2cl/ (fref z k) (fref a k k)))))
(setf s (f2cl/ 1.0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (- (+ n 1) kb))
(if (<= (dabs (fref z k)) (fref a k k)) (go label160))
(setf s (f2cl/ (fref a k k) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label160 (setf (fref z k) (f2cl/ (fref z k) (fref a k k)))
(setf t_ (- (fref z k)))
(daxpy-hook (- k 1) t_ (vec-ref a 1 k) 1 (vec-ref z 1) 1)))
(setf s (f2cl/ 1.0
(dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(if (/= anorm 0.0) (setf (fref rcond 1) (f2cl/ ynorm anorm)))
(if (= anorm 0.0) (setf (fref rcond 1) 0.0))
label180 (return (values a lda n rcond z info))))
| 6,091 | Common Lisp | .l | 128 | 29.335938 | 109 | 0.373049 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | c0c1b62cd0ac76360d4c7465cb941a7b19eb46a92bbe75978bacda3bf878ab9f | 33,303 | [
-1
] |
33,304 | dpbsl.lsp | rwoldford_Quail/source/linear/dpbsl.lsp | (in-package :q)
(defun dpbsl-hook (abd lda n m b)
;; (declare (type (simple-array double-float (*)) b))
(declare (type fixnum m))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((t_ 0.0d0) (lm 0) (lb 0) (la 0) (kb 0) (k 0))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum la))
(declare (type fixnum lb))
(declare (type fixnum lm))
(declare (type double-float t_))
(declare (special *dummy_var*))
;;
;; dpbsl solves the double precision symmetric positive definite
;; band system a*x = b
;; using the factors computed by dpbco or dpbfa.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; the output from dpbco or dpbfa.
;;
;; lda integer
;; the leading dimension of the array abd .
;;
;; n integer
;; the order of the matrix a .
;;
;; m integer
;; the number of diagonals above the main diagonal.
;;
;; b double precision(n)
;; the right hand side vector.
;;
;; on return
;;
;; b the solution vector x .
;;
;; error condition
;;
;; a division by zero will occur if the input factor contains
;; a zero on the diagonal. technically this indicates
;; singularity but it is usually caused by improper subroutine
;; arguments. it will not occur if the subroutines are called
;; correctly and info .eq. 0 .
;;
;; to compute inverse(a) * c where c is a matrix
;; with p columns
;; call dpbco(abd,lda,n,rcond,z,info)
;; if (rcond is too small .or. info .ne. 0) go to ...
;; do 10 j = 1, p
;; call dpbsl(abd,lda,n,c(1,j))
;; 10 continue
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; blas daxpy,ddot
;; fortran min0
;;
;; internal variables
;;
;;
;; solve trans(r)*y = b
;;
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf lm (min0 (1- k) m))
(setf la (- (1+ m) lm))
(setf lb (- k lm))
(setf t_ (ddot-hook lm (vec-ref abd la k) 1 (vec-ref b lb) 1))
(setf (fref b k)
(f2cl/ (- (fref b k) t_)
(fref abd (1+ m) k)))))
;;
;; solve r*x = y
;;
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (- (1+ n) kb))
(setf lm (min0 (1- k) m))
(setf la (- (1+ m) lm))
(setf lb (- k lm))
(setf (fref b k) (f2cl/ (fref b k) (fref abd (1+ m) k)))
(setf t_ (- (fref b k)))
(daxpy-hook lm t_ (vec-ref abd la k) 1 (vec-ref b lb) 1)))
(return (values abd lda n m b))))
| 3,696 | Common Lisp | .l | 92 | 28.217391 | 85 | 0.406944 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 21f8bff019ae712730ac11b2fe78d863f0f725b8dbc502f51b8f3a0737892331 | 33,304 | [
-1
] |
33,305 | dgedi.lsp | rwoldford_Quail/source/linear/dgedi.lsp | (in-package :q)
(defun dgedi-hook (a lda n ipvt det work job)
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) work))
;;(declare (type (simple-array double-float (*)) det))
;;(declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (ten 0.0d0) (nm1 0) (l 0) (kp1 0) (kb 0) (k 0) (j 0)
(i 0))
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum kp1))
(declare (type fixnum l))
(declare (type fixnum nm1))
(declare (type double-float ten))
(declare (type double-float t_))
(if (= (f2cl/ job 10) 0) (go label70))
(setf (fref det 1) 1.0)
(setf (fref det 2) 0.0)
(setf ten 10.0d0)
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (if (/= (fref ipvt i) i) (setf (fref det 1) (- (fref det 1))))
(setf (fref det 1) (* (fref a i i) (fref det 1)))
(if (= (fref det 1) 0.0) (go label60))
label10 (if (>= (dabs (fref det 1)) 1.0) (go label20))
(setf (fref det 1) (* ten (fref det 1)))
(setf (fref det 2) (- (fref det 2) 1.0))
(go label10)
label20 label30 (if (< (dabs (fref det 1)) ten) (go label40))
(setf (fref det 1) (f2cl/ (fref det 1) ten))
(setf (fref det 2) (+ (fref det 2) 1.0))
(go label30)
label40))
label60 label70 (if (= (mod job 10) 0) (go label150))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf (fref a k k) (f2cl/ 1.0 (fref a k k)))
(setf t_ (- (fref a k k)))
(dscal-hook (- k 1) t_ (vec-ref a 1 k) 1)
(setf kp1 (+ k 1))
(if (< n kp1) (go label90))
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf t_ (fref a k j))
(setf (fref a k j) 0.0)
(daxpy-hook k t_ (vec-ref a 1 k) 1 (vec-ref a 1 j)
1)))
label90))
(setf nm1 (+ n (- 1)))
(if (< nm1 1) (go label140))
(fdo (kb 1 (+ kb 1))
((> kb nm1) nil)
(tagbody (setf k (- n kb))
(setf kp1 (+ k 1))
(fdo (i kp1 (+ i 1))
((> i n) nil)
(tagbody (setf (fref work i) (fref a i k))
(setf (fref a i k) 0.0)))
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf t_ (fref work j))
(daxpy-hook n t_ (vec-ref a 1 j) 1 (vec-ref a 1 k)
1)))
(setf l (fref ipvt k))
(if (/= l k)
(dswap-hook n (vec-ref a 1 k) 1 (vec-ref a 1 l) 1))))
label140 label150 (return (values a lda n ipvt det work job))))
| 3,459 | Common Lisp | .l | 72 | 30.166667 | 87 | 0.386048 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 0a823d4e13ceb433f00f5d46e7aa71631f824226caa3e8e6c535b2f0dc080594 | 33,305 | [
-1
] |
33,306 | dsifa.lsp | rwoldford_Quail/source/linear/dsifa.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dsifa-hook (a lda n kpvt info)
;(declare (type fixnum info))
;(declare (type (simple-array fixnum (*)) kpvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (mulkm1 0.0d0) (mulk 0.0d0) (denom 0.0d0) (bkm1 0.0d0)
(bk 0.0d0) (akm1 0.0d0) (ak 0.0d0) (rowmax 0.0d0) (colmax 0.0d0) (alpha 0.0d0)
(absakk 0.0d0) (kstep 0) (km2 0) (km1 0) (k 0) (jmax 0)
(jj 0) (j 0) (imaxp1 0) (imax 0) (swap nil))
(declare (type t swap))
(declare (type fixnum imax))
(declare (type fixnum imaxp1))
(declare (type fixnum j))
(declare (type fixnum jj))
(declare (type fixnum jmax))
(declare (type fixnum k))
(declare (type fixnum km1))
(declare (type fixnum km2))
(declare (type fixnum kstep))
(declare (type double-float absakk))
(declare (type double-float alpha))
(declare (type double-float colmax))
(declare (type double-float rowmax))
(declare (type double-float ak))
(declare (type double-float akm1))
(declare (type double-float bk))
(declare (type double-float bkm1))
(declare (type double-float denom))
(declare (type double-float mulk))
(declare (type double-float mulkm1))
(declare (type double-float t_))
(setf alpha (f2cl/ (+ 1.0d0 (dsqrt 17d0)) 8.0d0))
(setf (fref info 1) 0)
(setf k n)
label10 (if (= k 0) (go label200))
(if (> k 1) (go label20))
(setf (fref kpvt 1) 1)
(if (= (fref a 1 1) 0.0) (setf (fref info 1) 1))
(go label200)
label20 (setf km1 (+ k (- 1)))
(setf absakk (dabs (fref a k k)))
(setf imax (idamax (- k 1) (vec-ref a 1 k) 1))
(setf colmax (dabs (fref a imax k)))
(if (< absakk (* alpha colmax)) (go label30))
(setf kstep 1)
(setf swap nil)
(go label90)
label30 (setf rowmax 0.0d0)
(setf imaxp1 (+ imax 1))
(fdo (j imaxp1 (+ j 1))
((> j k) nil)
(tagbody (setf rowmax (dmax1 rowmax (dabs (fref a imax j))))))
(if (= imax 1) (go label50))
(setf jmax (idamax (- imax 1) (vec-ref a 1 imax) 1))
(setf rowmax (dmax1 rowmax (dabs (fref a jmax imax))))
label50 (if (< (dabs (fref a imax imax)) (* alpha rowmax)) (go label60))
(setf kstep 1)
(setf swap t)
(go label80)
label60 (if (< absakk (* alpha colmax (f2cl/ colmax rowmax)))
(go label70))
(setf kstep 1)
(setf swap nil)
(go label80)
label70 (setf kstep 2)
(setf swap (/= imax km1))
label80 label90 (if (/= (dmax1 absakk colmax) 0.0) (go label100))
(setf (fref kpvt k) k)
(setf (fref info 1) k)
(go label190)
label100 (if (= kstep 2) (go label140))
(if (not swap) (go label120))
(dswap-hook imax (vec-ref a 1 imax) 1 (vec-ref a 1 k) 1)
(fdo (jj imax (+ jj 1))
((> jj k) nil)
(tagbody (setf j (+ k imax (- jj)))
(setf t_ (fref a j k))
(setf (fref a j k) (fref a imax j))
(setf (fref a imax j) t_)))
label120 (fdo (jj 1 (+ jj 1))
((> jj km1) nil)
(tagbody (setf j (+ k (- jj)))
(setf mulk (f2cl/ (* -1 (fref a j k)) (fref a k k)))
(setf t_ mulk)
(daxpy-hook j t_ (vec-ref a 1 k) 1 (vec-ref a 1 j) 1)
(setf (fref a j k) mulk)))
(setf (fref kpvt k) k)
(if swap (setf (fref kpvt k) imax))
(go label190)
label140 (if (not swap) (go label160))
(dswap-hook imax (vec-ref a 1 imax) 1 (vec-ref a 1 (+ k (- 1))) 1)
(fdo (jj imax (+ jj 1))
((> jj km1) nil)
(tagbody (setf j (+ (+ km1 imax) (- jj)))
(setf t_ (fref a j (- k 1)))
(setf (fref a j (- k 1)) (fref a imax j))
(setf (fref a imax j) t_)))
(setf t_ (fref a (- k 1) k))
(setf (fref a (- k 1) k) (fref a imax k))
(setf (fref a imax k) t_)
label160 (setf km2 (- k 2))
(if (= km2 0) (go label180))
(setf ak (f2cl/ (fref a k k) (fref a (- k 1) k)))
(setf akm1
(f2cl/ (fref a (- k 1) (- k 1)) (fref a (- k 1) k)))
(setf denom (+ 1.0d0 (* (* -1 ak) akm1)))
(fdo (jj 1 (+ jj 1))
((> jj km2) nil)
(tagbody (setf j (+ km1 (- jj)))
(setf bk (f2cl/ (fref a j k) (fref a (- k 1) k)))
(setf bkm1
(f2cl/ (fref a j (+ k (- 1)))
(fref a (+ k (- 1)) k)))
(setf mulk (f2cl/ (- (* akm1 bk) bkm1) denom))
(setf mulkm1 (f2cl/ (- (* ak bkm1) bk) denom))
(setf t_ mulk)
(daxpy-hook j t_ (vec-ref a 1 k) 1 (vec-ref a 1 j) 1)
(setf t_ mulkm1)
(daxpy-hook j t_ (vec-ref a 1 (- k 1)) 1 (vec-ref a 1 j) 1)
(setf (fref a j k) mulk)
(setf (fref a j (- k 1)) mulkm1)))
label180 (setf (fref kpvt k) (- 1 k))
(if swap (setf (fref kpvt k) (- imax)))
(setf (fref kpvt (- k 1)) (fref kpvt k))
label190 (setf k (- k kstep))
(go label10)
label200 (return (values a lda n kpvt info))))
| 5,747 | Common Lisp | .l | 130 | 31.876923 | 88 | 0.463541 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 4d1db3781ba40d5b19b985b741b9ff6c81884b39633e88ca2a9fcc326b91a2bc | 33,306 | [
-1
] |
33,307 | linpack-envs.lsp | rwoldford_Quail/source/linear/linpack-envs.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; linpack-envs.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; copyright (c) 1990 statistical computing laboratory, university of waterloo
;;;
;;;
;;; authors:
;;; greg anglin, michael lewis 1991.
;;; Carsten Whimster, 1996
;;;
;;; NOTE: This file is no longer used, since moving Linpack to Lisp.
;;;
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
;----------------------------------------------------------------------------------
(mapcar #'make::add-object-directory
(make::linear-foreign-directories))
;;; unfortunately we have to split up linpack into 3 foreign function environments
;;; otherwise ff-load complains that an offset gets too big to fit into a word.
(defparameter *linpack-entry-names-1*
(list "dposl" "dpodi" "dgesl" "dgedi" "dpoco" "dpofa" "dgeco"
"dgefa" "dsico" "dscal" "dsifa" "daxpy" "dswap" "idamax"
"dasum" "ddot" "dgels"))
(defparameter *linpack-entry-names-2*
(list "dtrsl" "dtrdi" "dsisl" "dtrco" "dscal" "dasum" "dsidi"
"dswap" "daxpy" "dcopy" "ddot" "dtrls"))
(defparameter *linpack-entry-names-3*
(list "dchdc" "dqrsl" "dcopy" "dqrdc" "dsvdc" "dswap" "drot"
"drotg" "daxpy" "dscal" "dnrm2" "ddot" "dqrls"))
(defparameter *linpack-object-files-1*
#+:apple (apply #'make::object-files
:fortran *linpack-entry-names-1*)
#+(and :aclunix (not :aclpc)) (make::object-files :fortran "linpack-env-1"))
(defparameter *linpack-object-files-2*
#+:apple (apply #'make::object-files
:fortran *linpack-entry-names-2*)
#+(and :aclunix (not :aclpc)) (make::object-files :fortran "linpack-env-2"))
(defparameter *linpack-object-files-3*
#+:apple (apply #'make::object-files
:fortran *linpack-entry-names-3*)
#+(and :aclunix (not :aclpc)) (make::object-files :fortran "linpack-env-3" "dqrls"))
(defparameter *linpack-blas-and-fortran-libraries-object-files*
(make::object-files :library
#+(and :aclunix (not :aclpc)) "liblin_dG0"))
;----------------------------------------------------------------------------------
(def-ffenv 'linpack-env-1
:files *linpack-object-files-1*
:entry-names *linpack-entry-names-1*
:libraries *linpack-blas-and-fortran-libraries-object-files*
:standard-libraries (list :fortran)
:library-entry-names nil)
(pushnew 'linpack-env-1 *standard-quail-ffenvs*)
(def-ffenv 'linpack-env-2
:files *linpack-object-files-2*
:entry-names *linpack-entry-names-2*
:libraries *linpack-blas-and-fortran-libraries-object-files*
:standard-libraries (list :fortran)
:library-entry-names nil)
(pushnew 'linpack-env-2 *standard-quail-ffenvs*)
(def-ffenv 'linpack-env-3
:files *linpack-object-files-3*
:entry-names *linpack-entry-names-3*
:libraries *linpack-blas-and-fortran-libraries-object-files*
:standard-libraries (list :fortran)
:library-entry-names nil)
(pushnew 'linpack-env-3 *standard-quail-ffenvs*)
| 3,311 | Common Lisp | .l | 71 | 40.84507 | 87 | 0.564823 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | be1ce7db6611fc2744ef4adf96dd382b071f86df83cca63e1bbe6ddc66b53519 | 33,307 | [
-1
] |
33,308 | daxpy.lsp | rwoldford_Quail/source/linear/daxpy.lsp | (in-package :q)
(defun daxpy-hook (n da dx incx dy incy)
(declare (type fixnum incy))
;;(declare (type (simple-array double-float (*)) dy))
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type double-float da))
(declare (type fixnum n))
(prog ((mp1 0) (m 0) (iy 0) (ix 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum ix))
(declare (type fixnum iy))
(declare (type fixnum m))
(declare (type fixnum mp1))
(if (<= n 0) (go end_label))
(if (= da 0.0) (go end_label))
(if (and (= incx 1) (= incy 1)) (go label20))
(setf ix 1)
(setf iy 1)
(if (< incx 0) (setf ix (+ (* (- 1 n) incx) 1)))
(if (< incy 0) (setf iy (+ (* (- 1 n) incy) 1)))
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf (fref dy iy) (+ (fref dy iy) (* da (fref dx ix))))
(setf ix (+ ix incx))
(setf iy (+ iy incy))))
(go end_label)
label20 (setf m (mod n 4))
(if (= m 0) (go label40))
(fdo (i 1 (+ i 1))
((> i m) nil)
(tagbody (setf (fref dy i) (+ (fref dy i) (* da (fref dx i))))))
(if (< n 4) (go end_label))
label40 (setf mp1 (+ m 1))
(fdo (i mp1 (+ i 4))
((> i n) nil)
(tagbody
(setf (fref dy i) (+ (fref dy i) (* da (fref dx i))))
(setf (fref dy (+ i 1)) (+ (fref dy (+ i 1)) (* da (fref dx (+ i 1)))))
(setf (fref dy (+ i 2)) (+ (fref dy (+ i 2)) (* da (fref dx (+ i 2)))))
(setf (fref dy (+ i 3)) (+ (fref dy (+ i 3)) (* da (fref dx (+ i 3)))))))
(go end_label)
end_label (return (values n da dx incx dy incy))))
| 1,803 | Common Lisp | .l | 43 | 32.348837 | 84 | 0.447039 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 590a463e1d45fed3c4ff6b7b7522b5c09812d0d3df8819633d181c732c975d4c | 33,308 | [
-1
] |
33,309 | dtrsl.lsp | rwoldford_Quail/source/linear/dtrsl.lsp | (in-package :q)
(defun dtrsl-hook (t_ ldt n b job info)
;;(declare (type fixnum info))
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) b))
(declare (type fixnum n))
(declare (type fixnum ldt))
;;(declare (type (simple-array double-float (* *)) t_))
(prog ((temp 0.0d0) (jj 0) (j 0) (case_ 0) (tmpinfo 0))
;(ddot 0.0d0)) ; 31JUL2023
(declare (type fixnum tmpinfo))
(declare (type fixnum j))
(declare (type fixnum j))
(declare (type fixnum jj))
;(declare (type double-float ddot))
(declare (type double-float temp))
(fdo (tmpinfo 1 (+ tmpinfo 1))
((> tmpinfo n) nil)
(tagbody (if (= (fref t_ tmpinfo tmpinfo) 0.0)
(prog ()
(setf (fref info 1) tmpinfo)
(go label150)))))
(setf (fref info 1) 0)
(setf case_ 1)
(if (/= (mod job 10) 0) (setf case_ 2))
(if (/= (f2cl/ (mod job 100) 10) 0) (setf case_ (+ case_ 2)))
(case case_
(1 (go label20))
(2 (go label50))
(3 (go label80))
(4 (go label110)))
label20 (setf (fref b 1) (f2cl/ (fref b 1) (fref t_ 1 1)))
(if (< n 2) (go label40))
(fdo (j 2 (+ j 1))
((> j n) nil)
(tagbody (setf temp (- (fref b (- j 1))))
(daxpy-hook (+ (- n j) 1) temp (vec-ref t_ j (- j 1)) 1
(vec-ref b j) 1)
(setf (fref b j) (f2cl/ (fref b j) (fref t_ j j)))))
label40 (go label140)
label50 (setf (fref b n) (f2cl/ (fref b n) (fref t_ n n)))
(if (< n 2) (go label70))
(fdo (jj 2 (+ jj 1))
((> jj n) nil)
(tagbody (setf j (+ (- n jj) 1))
(setf temp (- (fref b (+ j 1))))
(daxpy-hook j temp (vec-ref t_ 1 (+ j 1)) 1 (vec-ref b 1) 1)
(setf (fref b j) (f2cl/ (fref b j) (fref t_ j j)))))
label70 (go label140)
label80 (setf (fref b n) (f2cl/ (fref b n) (fref t_ n n)))
(if (< n 2) (go label100))
(fdo (jj 2 (+ jj 1))
((> jj n) nil)
(tagbody (setf j (+ (- n jj) 1))
(setf (fref b j)
(- (fref b j)
(ddot-hook (- jj 1) (vec-ref t_ (+ j 1) j) 1 (vec-ref b (+ j 1)) 1)))
(setf (fref b j) (f2cl/ (fref b j) (fref t_ j j)))))
label100 (go label140)
label110 (setf (fref b 1) (f2cl/ (fref b 1) (fref t_ 1 1)))
(if (< n 2) (go label130))
(fdo (j 2 (+ j 1)) ((> j n) nil)
(tagbody (setf (fref b j)
(- (fref b j)
(ddot-hook (- j 1) (vec-ref t_ 1 j) 1 (vec-ref b 1) 1)))
(setf (fref b j) (f2cl/ (fref b j) (fref t_ j j)))))
label130 label140 label150 (return (values t_ ldt n b job info))))
| 2,867 | Common Lisp | .l | 67 | 32.119403 | 97 | 0.454936 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | fb8aabbd76afb3b00245162b68a54d2fd512bddbde94d2ea8ffaabdf2df0c29f | 33,309 | [
-1
] |
33,310 | dtrco.lsp | rwoldford_Quail/source/linear/dtrco.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dtrco-hook (t_ ldt n rcond z job)
(declare (type fixnum job))
;(declare (type (simple-array double-float (*)) z))
;(declare (type double-float rcond))
(declare (type fixnum n))
(declare (type fixnum ldt))
;(declare (type (simple-array double-float (* *)) t_))
(prog ((ek 0.0d0) (wkm 0.0d0) (wk 0.0d0) (w 0.0d0) (sm 0.0d0) (s 0.0d0)
(ynorm 0.0d0) (tnorm 0.0d0) (l 0) (kk 0) (k 0) (j2 0) (j1 0) (j 0) (i1 0)
(lower nil))
(declare (type t lower))
(declare (type fixnum i1))
(declare (type fixnum j))
(declare (type fixnum j1))
(declare (type fixnum j2))
(declare (type fixnum k))
(declare (type fixnum kk))
(declare (type fixnum l))
(declare (type double-float tnorm))
(declare (type double-float ynorm))
(declare (type double-float s))
(declare (type double-float sm))
(declare (type double-float w))
(declare (type double-float wk))
(declare (type double-float wkm))
(declare (type double-float ek))
(setf lower (= job 0))
(setf tnorm 0.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf l j)
(if lower (setf l (+ n 1 (- j))))
(setf i1 1)
(if lower (setf i1 j))
(setf tnorm (dmax1 tnorm (dasum-hook l (vec-ref t_ i1 j) 1)))))
(setf ek 1.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) 0.0)))
(fdo (kk 1 (+ kk 1))
((> kk n) nil)
(tagbody (setf k kk)
(if lower (setf k (+ n 1 (- kk))))
(if (/= (fref z k) 0.0)
(setf ek (dsign ek (- (fref z k)))))
(if (<= (dabs (+ ek (- (fref z k)))) (dabs (fref t_ k k)))
(go label30))
(setf s
(f2cl/ (dabs (fref t_ k k))
(dabs (- ek (fref z k)))))
(dscal-hook n s z 1)
(setf ek (* s ek))
label30 (setf wk (- ek (fref z k)))
(setf wkm (- (- ek) (fref z k)))
(setf s (dabs wk))
(setf sm (dabs wkm))
(if (= (fref t_ k k) 0.0) (go label40))
(setf wk (f2cl/ wk (fref t_ k k)))
(setf wkm (f2cl/ wkm (fref t_ k k)))
(go label50)
label40 (setf wk 1.0d0)
(setf wkm 1.0d0)
label50 (if (= kk n) (go label90))
(setf j1 (+ k 1))
(if lower (setf j1 1))
(setf j2 n)
(if lower (setf j2 (- k 1)))
(fdo (j j1 (+ j 1))
((> j j2) nil)
(tagbody (setf sm
(+ sm (dabs (+ (fref z j)
(* wkm (fref t_ k j))))))
(setf (fref z j) (+ (fref z j) (* wk (fref t_ k j))))
(setf s (+ s (dabs (fref z j))))))
(if (>= s sm) (go label80))
(setf w (- wkm wk))
(setf wk wkm)
(fdo (j j1 (+ j 1))
((> j j2) nil)
(tagbody (setf (fref z j) (+ (fref z j) (* w (fref t_ k j))))))
label80 label90 (setf (fref z k) wk)))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm 1.0d0)
(fdo (kk 1 (+ kk 1))
((> kk n) nil)
(tagbody (setf k (+ n 1 (- kk)))
(if lower (setf k kk))
(if (<= (dabs (fref z k)) (dabs (fref t_ k k)))
(go label110))
(setf s (f2cl/ (dabs (fref t_ k k)) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label110 (if (/= (fref t_ k k) 0.0) (setf (fref z k) (/ (fref z k) (fref t_ k k))))
(if (= (fref t_ k k) 0.0) (setf (fref z k) 1.0))
(setf i1 1)
(if lower (setf i1 (+ k 1)))
(if (>= kk n) (go label120))
(setf w (- (fref z k)))
(daxpy-hook (- n kk) w (vec-ref t_ i1 k) 1 (vec-ref z i1) 1)
label120))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(if (/= tnorm 0.0d0) (setf (fref rcond 1) (f2cl/ ynorm tnorm)))
(if (= tnorm 0.0d0) (setf (fref rcond 1) 0.0))
(return (values t_ ldt n rcond z job))))
| 5,088 | Common Lisp | .l | 109 | 28.807339 | 98 | 0.374874 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 5d9d0392438a56a6bb400450a1942794e4669266e4f212b197146a38f26416ce | 33,310 | [
-1
] |
33,311 | qr-decomposition.lsp | rwoldford_Quail/source/linear/qr-decomposition.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; qr-decomposition.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; Greg Anglin 1992.
;;; R.W. Oldford 1993, 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(qr-decomposition qrd-of qr-of qraux-of jpvt-of
q-matrix-of
;;qy-of qty-of coef-of resid-of pred-of
)))
;--------------------------------------------------------------------------
; CLASS: qr-decomposition
;--------------------------------------------------------------------------
(defclass qr-decomposition (matrix-decomposition)
((qr :initarg :qr
:reader qr-of
:initform '()
:documentation
"QR contains in its upper triangle the upper triangular matrix R of
the QR factorization. Below its diagonal, x contains information
from which the orthogonal part of the decomposition can be recovered.")
(qraux :initarg :qraux
:reader qraux-of
:initform '()
:documentation
"qraux is a singly subscripted array of dimension P that ~
contains further informations required to recover the orthogonal part ~
of the decomposition.")
(jpvt :initarg :jpvt
:reader jpvt-of
:initform '()
:documentation
"jpvt(j) contains the index of the column that was moved into column ~
j , provided pivoting has been requested. Thus, on return, the ~
QR decomposition is not of X, but of the matrix whose columns are ~
X(jpvt(1)),X(jpvt(2)),...,X(jpvt(p)).")
(pivot :initarg :pivot
:reader pivoted-p
:initform '()
:documentation
"Pivot is non-null if pivoting was requested, null otherwise.")
(initial :initarg :initial
:initform '()
:reader initial-of
:documentation
"Initial identifies columns which were constrained to occupy leading ~
positions during pivoting.")
(final :initarg :final
:initform '()
:reader final-of
:documentation
"Final identifies columns which were constrained to occupy trailing ~
positions during pivoting.")
;;(tolerance :initarg :tolerance
;; :initform '()
;; :documentation
;;
;; "Not used so commented out. Should indicate numerical tolerance ~
;; below which linear dependencies are declared.")
)
(:documentation
"Return class for QR decomposition. Slot documentation is mostly from ~
the Linpack manual."))
;;; export slot names
;;;
(push-extension-class 'qr-decomposition)
;---------------------------------------------------------------------------
; GENERIC-FUNCTION: qrd-of
;---------------------------------------------------------------------------
(defgeneric qrd-of (x &rest keyword-args
&key pivot initial final
&allow-other-keys)
(:documentation
"Determines the QR decomposition of the matrix X. ~
That is, X is decomposed into the product of an orthogonal matrix Q ~
and an upper triangular matrix R. ~
It is calculated using the LINPACK routine DQRDC which uses Householder ~
transformations to achieve this end. ~
Once calculated, the decomposition is cached on X so that it ~
need not be recalculated on subsequent calls. ~
(:required X A matrix having only strictly numerical non-complex elements.)
(:key ~
(:arg pivot NIL ~
Pivot is non-null if pivoting was requested, null otherwise.)~
(:arg initial NIL ~
If pivot is non-NIL, then initial can be a list of the indices ~
of those columns which are to be constrained to occupy the leading ~
positions of X during pivoting.If NIL, then there is no restriction ~
on the initial columns.)~
(:arg final NIL ~
If pivot is non-NIL, then final can be a list of the indices ~
of those columns which are to be constrained to occupy the trailing ~
positions of X during pivoting. If NIL, then there is no restriction ~
on the last columns.)~
)~
(:rest (:arg keyword-args NIL For some methods there may be ~
further keywords allowed.)~
)~
(:returns An instance of the class qr-decomposition.)~
(:see-also (qr-decomposition :topic) (matrix-decomposition :topic)~
(lsfit :generic-function) (dqrdc :function) (dqrsl :function))~
(:examples (:files (QR decompositions ~
q:examples;arrays;matrices;decompositions;qr.lisp) )~
)~
"))
(defmethod qrd-of ((x matrix)
&rest keyword-args
&key
(pivot nil pivot-supplied-p)
(initial nil initial-supplied-p)
(final nil final-supplied-p)
;;(tolerance nil tolerance-supplied-p)
&allow-other-keys)
"Determines the QR decomposition of the matrix X. ~
That is, X is decomposed into the product of an orthogonal matrix Q ~
and an upper triangular matrix R. ~
It is calculated using the LINPACK routine DQRDC which uses Householder ~
transformations to achieve this end. ~
Once calculated, the decomposition is cached on X so that it ~
need not be recalculated on subsequent calls. ~
(:required X A matrix having only strictly numerical non-complex elements.)
(:key ~
(:arg pivot NIL ~
Pivot is non-null if pivoting was requested, null otherwise.)~
(:arg initial NIL ~
If pivot is non-NIL, then initial can be a list of the indices ~
of those columns which are to be constrained to occupy the leading ~
positions of X during pivoting.If NIL, then there is no restriction ~
on the initial columns.)~
(:arg final NIL ~
If pivot is non-NIL, then final can be a list of the indices ~
of those columns which are to be constrained to occupy the trailing ~
positions of X during pivoting. If NIL, then there is no restriction ~
on the last columns.)~
)~
(:rest (:arg keyword-args NIL For some methods there may be ~
further keywords allowed.)~
)~
(:returns An instance of the class qr-decomposition.)~
(:see-also (qr-decomposition :topic) (qr-solution :topic) ~
(matrix-decomposition :topic) (solve :generic-function)~
(lsfit :generic-function) (dqrdc :function) (dqrsl :function))~
(:examples (:files (QR decompositions ~
q:examples;arrays;matrices;decompositions;qr.lisp) )~
)~
"
;; tolerance not supported above. Would require change to LINPACK code.
;; (:arg tolerance NIL ~
;; Tolerance for detecting linear dependence amongst columns columns ~
;; of X. Smaller values indicate stricter limits before exact dependence ~
;; is inferred.)~
(declare (ignore keyword-args))
(let* ((table-key (cons 'qrd
(list :pivot (if pivot T)
:initial initial
:final final)))
(current-decomposition
(find-table-entry x 'decomposition table-key)))
(if (and current-decomposition
(with-slots ((qrd-pivot pivot)
(qrd-initial initial)
(qrd-final final)
;;(qrd-tolerance tolerance)
)
current-decomposition
(and
(or (not pivot-supplied-p)
(eql pivot qrd-pivot))
(or (not initial-supplied-p)
(eql initial qrd-initial))
(or (not final-supplied-p)
(eql final qrd-final))
;;(or (not tolerance-supplied-p)
;; (> tolerance qrd-tolerance))
)))
current-decomposition
(let* ((qr (sel x))
(n (first (dimensions-of qr)))
(p (or (second (dimensions-of qr)) 1))
(qraux (array 0
:dimensions (list p)))
(jpvt (array 0
:dimensions (list p)))
(work (array 0
:dimensions (list p)))
job)
(cond ((or pivot initial final)
(progn
(setf pivot t)
(setf job 1)
(anchor-columns jpvt initial 1)
(anchor-columns jpvt final -1)))
(t (setf job 0)))
(dqrdc qr n p qraux jpvt work job)
(add-table-entry x 'decomposition table-key
(make-instance 'qr-decomposition
:qr qr :qraux qraux :jpvt jpvt :pivot pivot
:initial initial :final final
;;:tolerance tolerance
)
)))))
;;;-------------------------------------------------------------------------
(defun anchor-columns (pivot-vector fixed-columns fixing-code)
(if fixed-columns
(loop for i in fixed-columns
do (setf (eref pivot-vector i) fixing-code))))
;;;
;;; upper-triangle-of
;;;
(defmethod upper-triangle-of ((qrd qr-decomposition))
"Returns the upper triangular matrix R from the qr decomposition."
(upper-triangle-of (qr-of qrd)))
(defgeneric q-matrix-of (thing)
(:documentation "Returns the orthogonal Q matrix corresponding to a ~%~
QR (or Gram-Schmidt) orthogonalization of thing (a matrix ~%~
or a qr-decomposition). ~%~
Note: 1. contains only as many columns as the original ~%~
matrix, and 2. the column ordering of the Q matrix may not directly ~%~
correspond to that of the original thing due to possible ~%~
pivoting operations."))
(defmethod q-matrix-of ((x matrix))
(q-matrix-of (qrd-of x)))
(defmethod q-matrix-of ((qrd qr-decomposition))
(let ((x (original-matrix-of qrd))
(R (upper-triangle-of qrd))
)
(when (pivoted-p qrd)
(let* ((pivoted (sel x))
(pivots (jpvt-of qrd))
(cols (first (dimensions-of pivots))))
(loop for i from 0 to (- cols 1)
do (setf (ref-variable pivoted i)
(ref-variable x (- (eref pivots i) 1))))
(setf x pivoted)))
;; Need to do the following inline more efficiently ... rwo
(tp (solve (tp R) (tp x)))
)
)
| 11,270 | Common Lisp | .l | 251 | 34.031873 | 112 | 0.549366 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | ebbe5cbc82e66ae2814710bddfa2e3a7331431d5e33d9900fb35920c9489cede | 33,311 | [
-1
] |
33,312 | linpack.lsp | rwoldford_Quail/source/linear/linpack.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; linpack.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; copyright (c) 1991 statistical computing laboratory, university of waterloo
;;;
;;;
;;; authors:
;;; greg anglin, michael lewis 1991.
;;; Carsten Whimster 1996-97.
;;;
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(dasum daxpy dchdc dcopy ddot dgeco
dgedi dgefa dgels dgesl dpoco dpodi
dpofa dposl dnrm2 dqrdc dqrls dqrsl
drot drotg dscal dsico dsifa dsidi
dsisl dsvdc dswap dtrdi dtrco dtrls
dtrsl idamax jacobi)))
(defun dasum (n dx incx)
(let ()
(dasum-hook n dx incx)))
(defun daxpy (n da dx incx dy incy)
(let ()
(daxpy-hook n da dx incx dy incy)))
(defun dchdc (a p work jpvt job info)
(let ((lda (nth 0 (dimensions-of a))))
(dchdc-hook a lda p work jpvt job info)))
(defun dcopy (n dx incx dy incy)
(let ()
(dcopy-hook n dx incx dy incy)))
(defun ddot (n dx incx dy incy)
(let ()
(ddot-hook n dx incx dy incy)))
(defun dgeco (a n ipvt rcond z)
(let ((lda (nth 0 (dimensions-of a))))
(dgeco-hook a lda n ipvt rcond z)))
(defun dgefa (a n ipvt info)
(let ((lda (nth 0 (dimensions-of a))))
(dgefa-hook a lda n ipvt info)))
(defun dgedi (a n ipvt det work job)
(let ((lda (nth 0 (dimensions-of a))))
(dgedi-hook a lda n ipvt det work job)))
(defun dgels (a ipvt b job)
(let* ((n (first (dimensions-of a)))
(dim-b (dimensions-of b))
(m (if (= (length dim-b) 1) 1 (second dim-b))))
(dgels-hook a n n ipvt b m job)
b))
(defun dgesl (a n ipvt b job)
(let ((lda (nth 0 (dimensions-of a))))
(dgesl-hook a lda n ipvt b job)))
(defun dnrm2 (n dx incx)
(let ()
(dnrm2-hook n dx incx)))
(defun dpoco (a n rcond z info)
(let ((lda (nth 0 (dimensions-of a))))
(dpoco-hook a lda n rcond z info)))
(defun dpodi (a n det job)
(let ((lda (nth 0 (dimensions-of a))))
(dpodi-hook a lda n det job)))
(defun dpofa (a n info)
(let ((lda (nth 0 (dimensions-of a))))
(dpofa-hook a lda n info)))
(defun dposl (a n b)
(let ((lda (nth 0 (dimensions-of a))))
(dposl-hook a lda n b)))
(defun dqrdc (x n p qraux jpvt work job)
(let ((ldx (nth 0 (dimensions-of x))))
(dqrdc-hook x ldx n p qraux jpvt work job)))
(defun dqrls (qr qraux y &key rank qy qty coef resid pred job info)
(let* ((dim-qr (dimensions-of qr))
(n (first dim-qr))
(p (or (second dim-qr) 1))
(k (or rank (min n p)))
(dim-y (dimensions-of y))
(m (or (second dim-y) 1)))
(dqrls-hook qr n n k qraux y p m qy qty coef resid pred job info)
(eref info)))
(defun dqrsl (x n k qraux y qy qty b rsd xb job info)
(let ((ldx (nth 0 (dimensions-of x))))
(dqrsl-hook x ldx n k qraux y qy qty b rsd xb job info)))
(defun drot (n dx incx dy incy c s)
(let ()
(drot-hook n dx incx dy incy c s)))
(defun drotg (da db c s)
(let ()
(drotg-hook da db c s)))
(defun dscal (n da dx incx)
(let ()
(dscal-hook n da dx incx)))
(defun dsico (a n kpvt rcond z)
(let ((lda (nth 0 (dimensions-of a))))
(dsico-hook a lda n kpvt rcond z)))
(defun dsifa (a n kpvt info)
(let ((lda (nth 0 (dimensions-of a))))
(dsifa-hook a lda n kpvt info)))
(defun dsidi (a n kpvt det inert work job)
(let ((lda (nth 0 (dimensions-of a))))
(dsidi-hook a lda n kpvt det inert work job)))
(defun dsisl (a n kpvt b)
(let ((lda (nth 0 (dimensions-of a))))
(dsisl-hook a lda n kpvt b)))
(defun dsvdc (x n p s e u v work job info)
(let ((ldx (nth 0 (dimensions-of x)))
(ldu (nth 0 (dimensions-of u)))
(ldv (nth 0 (dimensions-of v))))
(dsvdc-hook x ldx n p s e u ldu v ldv work job info)))
(defun dswap (n dx incx dy incy)
(let ()
(dswap-hook n dx incx dy incy)))
(defun dtrco (tt n rcond z job)
(let ((ldt (nth 0 (dimensions-of tt))))
(dtrco-hook tt ldt n rcond z job)))
(defun dtrdi (tt n det job info)
(let ((ldt (nth 0 (dimensions-of tt))))
(dtrdi-hook tt ldt n det job info)))
(defun dtrls (a b job)
(let* ((dim-a (dimensions-of a))
(dim-b (dimensions-of b))
(lda (first dim-a))
(n (second dim-a))
(m (if (= (length dim-b) 1) 1 (second dim-b)))
(info (array 0 :dimensions 'nil)))
(dtrls-hook a lda n b m job info)))
(defun dtrsl (tt n b job info)
(let ((ldt (nth 0 (dimensions-of tt))))
(dtrsl-hook tt ldt n b job info)))
(defun idamax (n dx incx)
(let ()
(idamax-hook n dx incx)))
(defun jacobi (a d v &optional nrot)
(if nrot
(jacobi-hook a d v nrot)
(jacobi-hook a d v)))
;;;
;;; The following four functions manipulate positive definite banded matrices.
;;;
(defun dpbco (abd lda n m rcond z info)
(let ()
(dpbco-hook abd lda n m rcond z info)))
(defun dpbfa (abd lda n m info)
(let ()
(dpbfa-hook abd lda n m info)))
(defun dpbdi (abd lda n m det)
(let ()
(dpbdi-hook abd lda n m det)))
(defun dpbsl (abd lda n m b)
(let ()
(dpbsl-hook abd lda n m b)))
;;;
;;; The following four functions manipulate banded matrices.
;;;
(defun dgbco (abd lda n ml mu ipvt rcond z)
(let ()
(dgbco-hook abd lda n ml mu ipvt rcond z)))
(defun dgbfa (abd lda n ml mu ipvt info)
(let ()
(dgbfa-hook abd lda n ml mu ipvt info)))
(defun dgbdi (abd lda n ml mu ipvt det)
(let ()
(dgbdi-hook abd lda n ml mu ipvt det)))
(defun dgbsl (abd lda n ml mu ipvt b job)
(let ()
(dgbsl-hook abd lda n ml mu ipvt b job)))
| 5,979 | Common Lisp | .l | 169 | 30.065089 | 101 | 0.56451 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e0f749a27343cd6c40bf6ae8fcbe5481b271c0bea672ac3b0776e7fb3d4593c7 | 33,312 | [
-1
] |
33,313 | cholesky-decomposition.lsp | rwoldford_Quail/source/linear/cholesky-decomposition.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; cholesky-decomposition.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; Greg Anglin 1992.
;;; R.W. Oldford 1993, 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(cholesky-of cholesky-decomposition)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; CLASS: Cholesky-decomposition
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass cholesky-decomposition (matrix-decomposition)
((a :initarg :a :accessor upper-triangle-of :initform '()
:documentation
"A is an upper triangular matrix representing ~
the Cholesky factor of the matrix ~
as it has been permuted by pivoting.")
(jpvt :initarg :jpvt :reader jpvt-of :initform '()
:documentation
"If pivoting was requested, JPVT(J) contains the index of the ~
diagonal element of A that was moved into the J-th position.")
(rcond :initarg :rcond :initform NIL
:accessor rcond-of
:documentation
"This is the estimated inverse of the condition number of the original ~
matrix. If RCOND is so small that the logical expression ~
1.0 + RCOND .EQ. 1.0 is true, then the matrix can ~
usually be regarded as singular to working precision.")
(null-vector
:initarg :null-vector :initform NIL
:reader null-vector-of
:documentation
"If the original matrix, A, is close to a singular matrix, ~
then this will contain an approximate null-vector, z, in the ~
sense that ||Az|| = rcond*||A||*||z||.")
(info :initarg :info :reader info-of :initform '()
:documentation
"Value depends upon whether pivoting was chosen or not. ~
If pivoting, info contains the index of the last positive diagonal ~
element of the Cholesky factor. ~
Otherwise, it contains the order of the leading sub-matrix found ~
not to be positive definite."))
(:documentation
"Return class for Cholesky decomposition. Slot value ~
documentation from the Linpack manual."))
;;;
;;; export slots
;;;
(qk::push-extension-class 'cholesky-decomposition)
;---------------------------------------------------------------------------
; METHOD: cholesky-of
;---------------------------------------------------------------------------
(defgeneric cholesky-of (A &key pivot initial final prompt-if-fail?)
(:documentation
"If A is positive definite, A can ~
be factored uniquely in the form A = tp(R)R, where R ~
is an upper triangular matrix with positive diagonal ~
elements. This is the Cholesky decomposition of A, and ~
R is its Cholesky factor (Linpack manual). ~
Once calculated, the decomposition is cached on A so that it ~
need not be recalculated on subsequent calls. ~
(:required A A positive definite symmetric square matrix having only ~
strictly numerical non-complex elements. No check is made for symmetry.)
(:key ~
(:arg pivot NIL ~
Pivot is non-null if pivoting is requested, null otherwise.)~
(:arg initial NIL ~
If pivot is non-NIL, then initial can be a list of the indices ~
of those diagonal elements which are to be moved the leading ~
positions of A during pivoting.If NIL, then there is no restriction ~
on the initial columns.)~
(:arg final NIL ~
If pivot is non-NIL, then final can be a list of the indices ~
of those diagonal elements which are to be moved to the trailing ~
positions of A during pivoting. If NIL, then there is no restriction ~
on the last columns.)~
(:arg prompt-if-fail? T Only relevant if no pivoting is allowed. ~
If the algorithm fails, should the ~
user be offered the opportunity to continue? ~
If NIL, it is assumed that continuation is preferred. ~
Continuation will produce a ~
cholesky-decomposition object containing only a partial decomposition ~
together with the order of the leading submatrix found to not be ~
positive definite and a vector z such that Az = 0 approx. ~
These are stored as the slots info and null-vector, respectively.)~
)~
(:returns An instance of the class cholesky-decomposition.)~
(:see-also ~
(cholesky-decomposition :topic) ~
(upper-triangle-of :generic-function) ~
(lu-decomposition :topic) ~
(matrix-decomposition :topic)~
(lsfit :generic-function) ~
(backsolve :function))~
(:examples (:files (Cholesky decomposition ~
q:examples;arrays;matrices;decompositions;cholesky.lisp) )~
)~
")
)
(defmethod cholesky-of ((A matrix)
&key
(pivot NIL)
initial
final
(prompt-if-fail? T)
)
"If A is positive definite, A can ~
be factored uniquely in the form A = tp(R)R, where R ~
is an upper triangular matrix with positive diagonal ~
elements. This is the Cholesky decomposition of A, and ~
R is its Cholesky factor (Linpack manual). ~
Once calculated, the decomposition is cached on A so that it ~
need not be recalculated on subsequent calls. ~
(:required A A positive definite symmetric matrix having only ~
strictly numerical non-complex elements.) ~
(:key ~
(:arg pivot NIL ~
Pivot is non-null if pivoting is requested, null otherwise. ~
If pivoting is requested LINPACK dchdc is used, otherwise dpoco.)~
(:arg initial NIL ~
If pivot is non-NIL, then initial can be a list of the indices ~
of those diagonal elements which are to be moved the leading ~
positions of A during pivoting.If NIL, then there is no restriction ~
on the initial columns.)~
(:arg final NIL ~
If pivot is non-NIL, then final can be a list of the indices ~
of those diagonal elements which are to be moved to the trailing ~
positions of A during pivoting. If NIL, then there is no restriction ~
on the last columns.)~
(:arg prompt-if-fail? T Only relevant if no pivoting is allowed. ~
If the algorithm fails, should the ~
user be offered the opportunity to continue? ~
If NIL, it is assumed that continuation is preferred. ~
Continuation will produce a ~
cholesky-decomposition object containing only a partial decomposition ~
together with the order of the leading submatrix found to not be ~
positive definite and a vector z such that Az = 0 approx. ~
These are stored as the slots info and null-vector, respectively.) ~
)~
(:returns An instance of the class cholesky-decomposition.)~
(:see-also (cholesky-decomposition :topic) ~
(upper-triangle-of :generic-function) ~
(lu-decomposition :topic) ~
(matrix-decomposition :topic) ~
(lsfit :generic-function) ~
(backsolve :function) ~
(q::dchdc :function) ~
(q::dpoco :function))~
(:examples (:files (Cholesky decomposition ~
q:examples;arrays;matrices;decompositions;cholesky.lisp) )~
)~
"
(let ((table-key (list 'cholesky
:pivot (if pivot T)
:initial initial
:final final)))
(or (find-table-entry A 'decomposition table-key)
(if pivot
(let* ((n (nrows A))
(p (ncols A))
(aa (sel A))
(work (array 0
:dimensions (list p)))
(jpvt (array 0
:dimensions (list n)))
(job 1)
(info (array 0 :dimensions 'nil)))
(if initial
(loop for i in initial do (setf (eref jpvt i) 1)))
(if final
(loop for i in final do (setf (eref jpvt i) -1)))
;; call linpack
(dchdc aa p work jpvt job info)
;;; Zero out the bottom of aa
(loop
for i from 0 below n
do
(loop
for j from 0 below i
do
(setf (eref aa i j) 0)))
(setf info (eref info 0))
(add-table-entry A 'decomposition table-key
(make-instance
'cholesky-decomposition
:a aa
:jpvt jpvt
:info info)
))
(let* ((n (nrows A))
(aa (sel A))
(z (array 0 :dimensions (list n)))
(rcond (array 0 :dimensions 'nil))
(info (array 0 :dimensions 'nil)))
(dpoco aa n rcond z info)
;;; Zero out the bottom of aa
(loop
for i from 0 below n
do
(loop
for j from 0 below i
do
(setf (eref aa i j) 0)))
(setf info (eref info 0))
(setf rcond (eref rcond 0))
(cond
((zerop info)
(add-table-entry A 'decomposition table-key
(make-instance
'cholesky-decomposition
:a aa
:rcond rcond
:null-vector z
:info info)
)
)
(prompt-if-fail?
(unless
(quail-yes-or-no-p
"Possibly non positive definite matrix of order ~s. ~
Cholesky failed to converge. ~&~
Continue?"
(eref info 0))
(quail-error "Cholesky failed to converge for ~s ~&~
Matrix not positive definite."
A))
(if (quail-yes-or-no-p "Try pivoting?")
(cholesky-of A :pivot T)
(add-table-entry A 'decomposition table-key
(make-instance
'cholesky-decomposition
:a aa
:rcond rcond
:null-vector z
:info info)
)))
(T
(warn "Cholesky failed to converge for ~s ~&~
Matrix not positive definite. ~&~
Partial decomposition returned."
A)
(add-table-entry A 'decomposition table-key
(make-instance
'cholesky-decomposition
:a aa
:rcond rcond
:null-vector z
:info info)
))
)
)
)
)
)
)
(defmethod cholesky-of :around ((A matrix)
&key
(pivot NIL)
initial
final
(prompt-if-fail? T)
)
(declare (ignore pivot initial final prompt-if-fail?))
(if (= (nrows A)
(ncols A))
(call-next-method)
(quail-error "Cholesky-of: Matrix is not square!")))
| 12,236 | Common Lisp | .l | 281 | 30.672598 | 103 | 0.514467 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 0e9e3c8ed54299a736429e294458f031ab53557cd8efa08ec1c3bbaa28dabc19 | 33,313 | [
-1
] |
33,314 | table-mixin.lsp | rwoldford_Quail/source/linear/table-mixin.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; table-mixin.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; Greg Anglin 1992.
;;; R.W. Oldford 1993, 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(table-mixin ensure-table clear-table add-table-entry find-table-entry
remove-table-entry hash-table-mixin)))
;---------------------------------------------------------------------------
;Mixin adds tables to an object.
;---------------------------------------------------------------------------
(defclass table-mixin (quail-object)
()
(:documentation
"This mixin class allows a slot ~
containing a table to be added ~
to an object. Table-mixin has no ~
slots, only methods. The slots are ~
defined by subclasses."))
;---------------------------------------------------------------------------
;Generic methods for accessing the table.
;---------------------------------------------------------------------------
(defgeneric ensure-table (self slot-name &rest inits)
(:documentation
"Args: self, an object with tables, a ~
slot-name, and additional initialization info for ~
creating an empty table. If slot-name does not contain ~
a table, an empty one is instantiated there. ~
Returns the table."))
(defgeneric clear-table (self slot-name)
(:documentation
"Args: self, an object with tables, and ~
slot-name, the slot containing the particular ~
table to clear."))
(defgeneric add-table-entry (self slot-name key datum)
(:documentation
"Args: self, an object with tables; ~
slot-name, the slot containing the particular ~
table; and the key to create or change an ~
entry in the table."))
(defgeneric find-table-entry (self slot-name key)
(:documentation
"Args: self, an object with tables; ~
slot-name, the slot containing the particular ~
table; and the key to find an ~
entry in the table."))
(defgeneric remove-table-entry (self slot-name key)
(:documentation
"Args: self, an object with tables; ~
slot-name, the slot containing the particular ~
table; and the key to erase an ~
entry in the table."))
;---------------------------------------------------------------------------
;Mixin adds hash-tables to an object.
;---------------------------------------------------------------------------
(defclass hash-table-mixin (table-mixin)
()
(:documentation
"This mixin class allows a slot ~
containing a hash table to be added ~
to an object. Hash-table-mixin has no ~
slots, only methods. The slots are ~
defined by subclasses."))
;---------------------------------------------------------------------------
;Methods for accessing the hash table.
;---------------------------------------------------------------------------
(defmethod ensure-table ((self hash-table-mixin) slot-name &rest list-test)
(or (slot-value self slot-name)
(setf (slot-value self slot-name)
(if list-test
(make-hash-table :test (first list-test) :size 10)
(make-hash-table :test #'equal :size 10)))))
(defmethod clear-table ((self hash-table-mixin) slot-name)
(clrhash (ensure-table self slot-name)))
(defmethod add-table-entry ((self hash-table-mixin) slot-name key datum)
(setf (gethash key (ensure-table self slot-name)) datum))
(defmethod find-table-entry ((self hash-table-mixin) slot-name key)
(gethash key (ensure-table self slot-name)))
(defmethod remove-table-entry ((self hash-table-mixin) slot-name key)
(remhash key (ensure-table self slot-name)))
| 4,101 | Common Lisp | .l | 93 | 39.311828 | 135 | 0.526036 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 7c949b7ed235daebc47b8aa4dd1261dcda2f611635d9aa283ca2f56c8ac89b3e | 33,314 | [
-1
] |
33,315 | dasum.lsp | rwoldford_Quail/source/linear/dasum.lsp | (in-package :q)
(defun dasum-hook (n dx incx)
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((dasum_ 0.0d0) (dtemp 0.0d0) (nincx 0) (mp1 0) (m 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum m))
(declare (type fixnum mp1))
(declare (type fixnum nincx))
(declare (type double-float dtemp))
(declare (type double-float dasum_))
(setf dasum_ 0.0d0)
(setf dtemp 0.0d0)
(if (<= n 0) (go end_label))
(if (= incx 1) (go label20))
(setf nincx (* n incx))
(fdo (i 1 (+ i incx))
((> i nincx) nil)
(tagbody (setf dtemp (+ dtemp (dabs (fref dx i))))))
(setf dasum_ dtemp)
(go end_label)
label20 (setf m (mod n 6))
(if (= m 0) (go label40))
(fdo (i 1 (+ i 1))
((> i m) nil)
(tagbody (setf dtemp (+ dtemp (dabs (fref dx i))))))
(if (< n 6) (go label60))
label40 (setf mp1 (+ m 1))
(fdo (i mp1 (+ i 6))
((> i n) nil)
(tagbody (setf dtemp
(+ dtemp
(dabs (fref dx i))
(dabs (fref dx (+ i 1)))
(dabs (fref dx (+ i 2)))
(dabs (fref dx (+ i 3)))
(dabs (fref dx (+ i 4)))
(dabs (fref dx (+ i 5)))))))
label60 (setf dasum_ dtemp)
(go end_label)
end_label (return dasum_)))
| 1,517 | Common Lisp | .l | 42 | 25.904762 | 69 | 0.460231 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | c23e48d71e02457904ab53cc0087398151cb3b0418f9399c51cca3e92707da5d | 33,315 | [
-1
] |
33,316 | lu-decomposition.lsp | rwoldford_Quail/source/linear/lu-decomposition.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; lu-decomposition.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; Greg Anglin 1992.
;;; R.W. Oldford 1993, 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(lud-of lu-of ipvt-of lu-decomposition rcond-of)))
(defgeneric lud-of (A)
(:documentation
"Determines the LU decomposition of the matrix A. ~
That is, A is decomposed into the product of a ~
matrix L and an upper triangular matrix U. ~
L is the product of elementary lower triangular and permutation matrices. ~
Both are calculated using the LINPACK routine DGECO. ~
DGECO uses Gaussian elimination with partial pivoting to compute ~
the LU decomposition and estimate the condition number of A. ~
Once calculated, the decompostion is cached on A so that it ~
need not be recalculated on subsequent calls. ~
(:required A A square matrix having only strictly numerical non-complex elements.)
(:returns An instance of the class lu-decomposition.)~
(:see-also (lu-decomposition :topic) (matrix-decomposition :topic)~
(lsfit :generic-function) (solve :generic-function) ~
(dgeco :function) (dgedi :function) (dgefa :function) (dgesl :function))~
(:examples (:files (LU decompositions ~
q:examples;arrays;matrices;decompositions;lu.lisp) )~
)~
"))
(defgeneric lu-of (A)
(:documentation
"Returns the matrix LU whose upper triangular is the upper ~
triangular matrix U of the LU-decomposition A. Below diagonal ~
elements contain the information necessary to construct the lower ~
triangular matrix L. ~
(:see-also (lu-decomposition :topic) (matrix-decomposition :topic)~
(solve :generic-function) ~
(lud-of :generic-function))~
(:examples (:files (LU decompositions ~
q:examples;arrays;matrices;decompositions;lu.lisp) )~
)~
"))
;--------------------------------------------------------------------------
; CLASS: lu-decomposition
;--------------------------------------------------------------------------
(defclass lu-decomposition (matrix-decomposition)
((a
:initarg :a :reader lu-of :initform '()
:documentation
"A contains in its upper triangle an upper triangular matrix U ~
and in its strict lower triangle the multipliers necessary ~
to construct a matrix L so that A=LU.")
(ipvt
:initarg :ipvt :reader ipvt-of :initform '()
:documentation
"IPVT is a singly subscripted integer array of dimension N ~
which contains the pivot information necessary to construct ~
the permutations in L. Specifically, IPVT(K) is the ~
index of the K-th pivot row.")
(rcond
:initarg :rcond :reader rcond-of :initform '()
:documentation
"This is the estimated inverse of the condition number of the original ~
matrix. If RCOND is so small that the logical expression ~
1.0 + RCOND .EQ. 1.0 is true, then the matrix can ~
usually be regarded as singular to working precision."))
(:documentation
"Return class for LU decomposition. Slot documentation is from ~
the Linpack manual."))
;;;
;;; export slot names
;;;
(push-extension-class 'lu-decomposition)
;---------------------------------------------------------------------------
; METHOD: lud-of
;---------------------------------------------------------------------------
(defmethod lud-of ((x matrix))
(or (find-table-entry x 'decomposition 'lu)
(let* ((a (sel x))
(n (first (dimensions-of a)))
(ipvt (array 0
:dimensions (list n)))
(rcond (array 0 :dimensions nil))
(z (array 0 :dimensions (list n))))
(dgeco a n ipvt rcond z)
(add-table-entry
x 'decomposition 'lu
(make-instance 'lu-decomposition :a a :ipvt ipvt :rcond (eref rcond 0))
))))
;---------------------------------------------------------------------------
; METHOD: lu-of
;---------------------------------------------------------------------------
(defmethod lu-of ((X matrix))
(lu-of (lud-of X)))
;;;
;;; upper-triangle-of
;;;
(defmethod upper-triangle-of ((lud lu-decomposition))
"Returns the matrix U from the LU decomposition."
(upper-triangle-of (lu-of lud)))
| 4,811 | Common Lisp | .l | 111 | 37.441441 | 115 | 0.555293 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 735418227d53a5209f9c70673d31038925c857436cd1e3d1949b866fb94241c3 | 33,316 | [
-1
] |
33,317 | dgels.lsp | rwoldford_Quail/source/linear/dgels.lsp | (in-package :q)
(defun dgels-hook (a lda n ipvt b m job)
(declare (type fixnum job))
(declare (type fixnum m))
;;(declare (type (simple-array single-float (* *)) b))
;;(declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array single-float (* *)) a))
(prog ((j 0))
(declare (type fixnum j))
(fdo (j 1 (+ j 1))
((> j m) nil)
(tagbody (dgesl-hook a lda n ipvt (vec-ref b 1 j) job)))
(return (values a lda n ipvt b m job))))
| 581 | Common Lisp | .l | 15 | 32.066667 | 70 | 0.55694 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 228634f10854bfef73b9b674dceafb52f6ac9a88848a9d87b25bb733744819a7 | 33,317 | [
-1
] |
33,318 | dpofa.lsp | rwoldford_Quail/source/linear/dpofa.lsp | (in-package :q)
(defun dpofa-hook (a lda n info)
;;(declare (type fixnum info))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (s 0.0d0) (k 0) (jm1 0) (j 0))
;(ddot 0.0d0) (ddot-hook 0.0d0)) ; 31JUL2023
(declare (type fixnum j))
(declare (type fixnum jm1))
(declare (type fixnum k))
(declare (type double-float s))
(declare (type double-float ddot))
(declare (type double-float t_))
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref info 1) j)
(setf s 0.0d0)
(setf jm1 (- j 1))
(if (< jm1 1) (go label20))
(fdo (k 1 (+ k 1))
((> k jm1) nil)
(tagbody
(setf t_
(- (fref a k j)
(ddot-hook (- k 1) (vec-ref a 1 k)
1 (vec-ref a 1 j) 1)))
(setf t_ (f2cl/ t_ (fref a k k)))
(setf (fref a k j) t_)
(setf s (+ s (* t_ t_)))
))
label20
(setf s (- (fref a j j) s))
(if (<= s 0.0d0) (go label40))
(setf (fref a j j) (dsqrt s))))
(setf (fref info 1) 0)
label40 (return (values a lda n info))))
| 1,505 | Common Lisp | .l | 37 | 25.081081 | 69 | 0.386085 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 297054ca046464979acdf6c827384a7027238bb8164177aa9ee7998f5455751a | 33,318 | [
-1
] |
33,319 | dgbfa.lsp | rwoldford_Quail/source/linear/dgbfa.lsp | (in-package :q)
(defun dgbfa-hook (abd lda n ml mu ipvt info)
(declare (type fixnum info))
;; (declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum mu))
(declare (type fixnum ml))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((t_ 0.0d0) (nm1 0) (mm 0) (m 0) (lm 0) (l 0) (kp1 0) (k 0)
(j1 0) (j0 0) (jz 0) (ju 0) (j 0) (i0 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum i0))
(declare (type fixnum j))
(declare (type fixnum ju))
(declare (type fixnum jz))
(declare (type fixnum j0))
(declare (type fixnum j1))
(declare (type fixnum k))
(declare (type fixnum kp1))
(declare (type fixnum l))
(declare (type fixnum lm))
(declare (type fixnum m))
(declare (type fixnum mm))
(declare (type fixnum nm1))
(declare (type double-float t_))
(declare (special *dummy_var*))
;;
;; dgbfa factors a double precision band matrix by elimination.
;;
;; dgbfa is usually called by dgbco, but it can be called
;; directly with a saving in time if rcond is not needed.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; contains the matrix in band storage. the columns
;; of the matrix are stored in the columns of abd and
;; the diagonals of the matrix are stored in rows
;; ml+1 through 2*ml+mu+1 of abd .
;; see the comments below for details.
;;
;; lda integer
;; the leading dimension of the array abd .
;; lda must be .ge. 2*ml + mu + 1 .
;;
;; n integer
;; the order of the original matrix.
;;
;; ml integer
;; number of diagonals below the main diagonal.
;; 0 .le. ml .lt. n .
;;
;; mu integer
;; number of diagonals above the main diagonal.
;; 0 .le. mu .lt. n .
;; more efficient if ml .le. mu .
;; on return
;;
;; abd an upper triangular matrix in band storage and
;; the multipliers which were used to obtain it.
;; the factorization can be written a = l*u where
;; l is a product of permutation and unit lower
;; triangular matrices and u is upper triangular.
;;
;; ipvt integer(n)
;; an integer vector of pivot indices.
;;
;; info integer
;; = 0 normal value.
;; = k if u(k,k) .eq. 0.0 . this is not an error
;; condition for this subroutine, but it does
;; indicate that dgbsl will divide by zero if
;; called. use rcond in dgbco for a reliable
;; indication of singularity.
;;
;; band storage
;;
;; if a is a band matrix, the following program segment
;; will set up the input.
;;
;; ml = (band width below the diagonal)
;; mu = (band width above the diagonal)
;; m = ml + mu + 1
;; do 20 j = 1, n
;; i1 = max0(1, j-mu)
;; i2 = min0(n, j+ml)
;; do 10 i = i1, i2
;; k = i - j + m
;; abd(k,j) = a(i,j)
;; 10 continue
;; 20 continue
;;
;; this uses rows ml+1 through 2*ml+mu+1 of abd .
;; in addition, the first ml rows in abd are used for
;; elements generated during the triangularization.
;; the total number of rows needed in abd is 2*ml+mu+1 .
;; the ml+mu by ml+mu upper left triangle and the
;; ml by ml lower right triangle are not referenced.
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; blas daxpy,dscal,idamax
;; fortran max0,min0
;;
;; internal variables
;;
;;
;;
(setf m (+ ml mu 1))
(setf info 0)
;;
;; zero initial fill-in columns
;;
(setf j0 (+ mu 2))
(setf j1 (1- (min0 n m)))
(if (< j1 j0) (go label30))
(fdo (jz j0 (1+ jz))
((> jz j1) nil)
(tagbody (setf i0 (- (1+ m) jz))
(fdo (i i0 (1+ i))
((> i ml) nil)
(tagbody (setf (fref abd i jz) 0.0)))))
label30 (setf jz j1)
(setf ju 0)
;;
;; gaussian elimination with partial pivoting
;;
(setf nm1 (1- n))
(if (< nm1 1) (go label130))
(fdo (k 1 (1+ k))
((> k nm1) nil)
(tagbody (setf kp1 (1+ k))
;;
;; zero next fill-in column
;;
(setf jz (1+ jz))
(if (> jz n) (go label50))
(if (< ml 1) (go label50))
(fdo (i 1 (1+ i))
((> i ml) nil)
(tagbody (setf (fref abd i jz) 0.0)))
label50 ;;
;; find l = pivot index
;;
(setf lm (min0 ml (- n k)))
(setf l (1- (+ (idamax (1+ lm) (fref abd m k) 1) m)))
(setf (fref ipvt k) (- (+ l k) m))
;;
;; zero pivot implies this column already triangularized
;;
(if (= (fref abd l k) 0.0) (go label100))
;;
;; interchange if necessary
;;
(if (= l m) (go label60))
(setf t_ (fref abd l k))
(setf (fref abd l k) (fref abd m k))
(setf (fref abd m k) t_)
label60 ;;
;; compute multipliers
;;
(setf t_ (f2cl/ -1.0d0 (fref abd m k)))
(dscal-hook lm t_ (vec-ref abd (1+ m) k) 1)
;;
;; row elimination with column indexing
;;
(setf ju (min0 (max0 ju (+ mu (fref ipvt k))) n))
(setf mm m)
(if (< ju kp1) (go label90))
(fdo (j kp1 (1+ j))
((> j ju) nil)
(tagbody (setf l (1- l))
(setf mm (1- mm))
(setf t_ (fref abd l j))
(if (= l mm) (go label70))
(setf (fref abd l j) (fref abd mm j))
(setf (fref abd mm j) t_)
label70 (daxpy-hook lm t_ (vec-ref abd (1+ m) k) 1
(vec-ref abd (1+ mm) j) 1)))
label90 (go label110)
label100 (setf info k)
label110))
label130 (setf (fref ipvt n) n)
(if (= (fref abd m n) 0.0) (setf info n))
(return (values abd lda n ml mu ipvt info))))
| 8,440 | Common Lisp | .l | 189 | 30.365079 | 87 | 0.379532 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 4cd7bfabedd0703422024d20a97292cfd330cfcd400bb2bdc0183c2d69ae4cda | 33,319 | [
-1
] |
33,320 | idamax.lsp | rwoldford_Quail/source/linear/idamax.lsp | (in-package :q)
(defun idamax-hook (n dx incx)
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((idamax 0) (dmax 0.0d0) (ix 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum ix))
(declare (type double-float dmax))
(declare (type fixnum idamax))
(setf idamax 0)
(if (< n 1) (go end_label))
(setf idamax 1)
(if (= n 1) (go end_label))
(if (= incx 1) (go label20))
(setf ix 1)
(setf dmax (dabs (fref dx 1)))
(setf ix (+ ix incx))
(fdo (i 2 (+ i 1))
((> i n) nil)
(tagbody (if (<= (dabs (fref dx ix)) dmax) (go label5))
(setf idamax i)
(setf dmax (dabs (fref dx ix)))
label5 (setf ix (+ ix incx))))
(go end_label)
label20 (setf dmax (dabs (fref dx 1)))
(fdo (i 2 (+ i 1))
((> i n) nil)
(tagbody (if (<= (dabs (fref dx i)) dmax) (go label30))
(setf idamax i)
(setf dmax (dabs (fref dx i)))
label30))
(go end_label)
end_label (return idamax)))
| 1,262 | Common Lisp | .l | 34 | 25.882353 | 69 | 0.45915 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 5363595c8d4d640b0b8b0706586d5cfd4ec2537d96844985560ff241ff0bcc2d | 33,320 | [
-1
] |
33,321 | linpack-macros.lsp | rwoldford_Quail/source/linear/linpack-macros.lsp | ; macros.l - all the basic macros
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;Copyright (c) University of Waikato;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;Hamilton, New Zeland 1992-95 - all rights reserved;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(in-package :q)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(do1 do! map-defvar double-cdr double-mapcar push
fexport fproclaim fuse-package fin-package fdo arithmetic-if
computed-goto assigned-goto)))
; macros:
; rexpt
; fexport
; fproclaim
; fuse-package
; fin-package
; map-defvar
; do1
; do!
; double-cdr
; putproperty
; defprop
; array-cl
; store-cl
; apply!
; rfref
; rfset
; fref
; new-fset
; while
; fdo
; reset-vble - a defun
; arithmetic-if
; computed-goto
; assigned-goto
; eqv
; constant-list
; Fortran intrinsic functions imax, dabs,...
;----------------------------------------------------------------------------
(eval-when (:compile-toplevel :load-toplevel :execute) (proclaim '(special *verbose*)))
;----------------------------------------------------------------------------
#+aclpc (defmacro rexpt (x y) `(realpart (expt ,x ,y)))
#-aclpc (defmacro rexpt (x y) `(expt ,x ,y))
(defmacro fexport (x) `(eval-when (:compile-toplevel :load-toplevel :execute) (export ,x)))
(defmacro fproclaim (x) `(eval-when (:compile-toplevel :load -toplevel :execute) (proclaim ,x)))
(defmacro fin-package (x)
`(prog nil
(defpackage ,x)
(in-package ,x)))
(defmacro fuse-package (x) `(eval-when (:compile-toplevel :load-toplevel :execute) ,x))
;-------------------------------------------------------------------------
(defmacro apply! (fun args) (eval `(cons ,fun ,args)))
;-----------------------------------------------------------------------------
(defmacro do! (var init step end &rest body)
`(do ((,var ,init ,step)) (,end) ,@body))
; the body is an unquoted list of the terms of the actual body
(defmacro do1 (var end body)
`(do ((,var 1 (1+ i))) ((> ,var ,end)) ,@body))
(defmacro double-cdr (lis)
`(mapcar #'cdr (cdr ,lis)))
(defun putproperty (a b c) (setf (get a c) b))
(defmacro defprop (sym prop ind)
`(putproperty ',sym ',prop ',ind))
(defmacro def (name body) `(defun ,name ,(cadr body) ,(caddr body)))
(defmacro array-cl (name type &rest dims)
`(set ',name
(make-array ',(mapcar #'eval dims)
:element-type ,(cond ((equal type 'fixnum-block) ''integer)
((equal type 'flonum-block) ''flonum) ;###
((equal type t) t)))))
(defmacro store-cl (name-indices val)
`(setf (eref ,(car name-indices) ,@(cdr name-indices)) ,val))
;-----------------------------------------------------------------------------
(defmacro fref (arr &rest indices)
`(eref ,arr ,@(mapcar #'(lambda (x) (list '1- x)) indices)))
(defmacro new-fset (a b)
`(setf (fref ,(second a) ,@(cddr a)) ,b))
(defmacro rfref (arr &rest indices)
`(eref ,arr ,@(mapcar #'(lambda (x) (list '1- x)) (reverse indices))))
(defmacro rfset (a b)
`(setf (rfref ,(second a) ,@(cddr a)) ,b))
;----------------------------------------------------------------------------
#-aclpc (defmacro while (con &rest body)
`(loop (if (not ,con) (return t)) ,@body))
;------------------------------------------------------------------
(defun comment (s) (when *verbose* (princ s) (terpri)))
;----------------------------------------------------------------------------
(defun reset-vble (pred-clause) ; ((> i 4) nil)
`(,(first pred-clause)
(setq ,(second (first pred-clause)) ,(third (first pred-clause)))
,(second pred-clause)))
; fdo has similar syntax as do except there will only be one do_vble
(defmacro fdo (do_vble_clause predicate_clause &rest body)
`(prog* ((step ,(third (third do_vble_clause)))
(iteration_count
(max (truncate (+ (- ,(third (first predicate_clause))
,(second do_vble_clause)) step) step) 0)))
; initialise loop variable
(setq ,(first do_vble_clause) ,(second do_vble_clause))
loop
(return
(cond ; all iterations done
((zerop iteration_count) nil)
; execute loop, in/de-crement loop vble and decrement cntr
,(cons 't
(append
(append body
`((setq ,(first do_vble_clause)
,(third do_vble_clause)
iteration_count
(1- iteration_count))))
'((go loop))))))))
;(defmacro fdo (do-vbles predicate-clause &rest body)
; `(prog nil
; (setq ,(caar do-vbles) ,(cadar do-vbles))
; loop
; (return
; (cond ,(reset-vble predicate-clause)
; ,(cons 't
; (append
; (append body `((setq ,(caar do-vbles) ,(caddar do-vbles))))
; '((go loop))))))))
;(defmacro fdo (do-vbles predicate-clause &rest body)
; `(prog (iteration-count)
; ,(append '(psetq)
; (do ((do-vars do-vbles (cdr do-vars))
; (ret nil (append ret (list (caar do-vars) (cadar do-vars)))))
; ((null do-vars) ret)))
; loop
; (return
; (cond ,predicate-clause
; ,(cons 't
; (append
; (append body
; (list
; (append '(psetq)
; (do ((do-vars do-vbles (cdr do-vars))
; (ret nil (append ret (if (null (caddar do-vars))
; nil
; (list (caar do-vars)
; (caddar do-vars))))))
; ((null do-vars) ret)))))
; '((go loop))))))))
;----------------------------------------------------------------------------
(defun constant-list (x n)
(do ((i 1 (1+ i))
(ret nil (cons x ret)))
((> i n) ret)))
;----------------------------------------------------------------------------
;; macro for division
(defmacro f2cl/ (x y)
`(if (and (typep ,x 'fixnum) (typep ,y 'fixnum))
(floor ,x ,y)
(/ ,x ,y)))
;; macro for a lisp equivalent of Fortran arithmetic IFs
(defmacro arithmetic-if (pred s1 s2 s3)
`(cond ((< ,pred 0) ,s1)
((= ,pred 0) ,s2)
(t ,s3)))
;; macro for a lisp equivalent of Fortran computed GOTOs
(defmacro computed-goto (tag-lst i)
`(let ((tag ,(nth (1- (eval i)) tag-lst)))
(if tag (go tag) nil)))
;; macro for a lisp equivalent of Fortran assigned GOTOs
(defmacro assigned-goto (i &optional tag-lst)
`(if ,tag-lst
(if (member ,i ,tag-lst)
(go ,i)
(error "bad statement number in assigned goto"))
(go ,i)))
;-----------------------------------------------------------------------------
; set up a list of intrinsic function names
;real xxx
(defvar intrinsic_function_names
'(int ifix idint real float sngl dble cmplx ichar char aint dint
anint dnint nint idnint iabs abs dabs cabs mod amod dmod isign sign dsign
idim dim ddim dprod max max0 amax1 dmax1 amax0 amax1 min min0 amini dmini
amini min1 len index lge lgt lle llt aimag conjg sqrt dsqrt csqrt
exp dexp cexp log alog dlog clog log10 alog10 dlog10 sin dsin csin
cos dcos ccos tan dtan asin dasin acos dacos atan datan atan2 datan2
sinh dsinh cosh dcosh tanh dtanh))
; some macros for intrinsic functions
(defmacro int (x)
`(floor ,x))
(defmacro ifix (x)
`(floor ,x))
(defmacro idfix (x)
`(floor ,x))
(defmacro real_ (x)
`(coerce ,x 'single-float))
(defmacro sngl (x)
`(coerce ,x 'single-float))
(defmacro cmplx (x &optional y)
`(complex ,x ,(if y y 0)))
(defmacro ichar (c)
`(char-int ,c))
(defmacro fchar (i) ;intrinsic function char
`(char-int ,i))
(defmacro aint (x)
`(float (truncate ,x)))
(defmacro dint (x)
`(coerce (truncate ,x) 'double-float))
(defmacro anint (x)
`(float (round ,x)))
(defmacro dnint (x)
`(coerce (round ,x) 'double-float))
(defmacro nint (x)
`(round ,x))
(defmacro idnint (x)
`(round ,x))
#-aclpc (defmacro iabs (x) `(abs ,x))
(defmacro dabs (x)
`(abs ,x))
(defmacro cabs (x)
`(abs ,x))
(defmacro amod (x y)
`(mod ,x ,y))
(defmacro dmod (x y)
`(mod ,x ,y))
(defmacro sign (x y)
`(if (>= ,y 0) (abs ,x) (- (abs ,x))))
(defmacro isign (x y)
`(if (>= ,y 0) (abs ,x) (- (abs ,x))))
(defmacro dsign (x y)
`(if (>= ,y 0) (abs ,x) (- (abs ,x))))
(defmacro idim (x y)
`(abs (- ,x ,y)))
(defmacro dim (x y)
`(abs (- ,x ,y)))
(defmacro ddim (x y)
`(abs (- ,x ,y)))
(defmacro dprod (x y)
`(coerce (* ,x ,y) `double-float))
(defmacro max0 (&rest x)
`(funcall #'max ,@x))
(defmacro amax1 (&rest x)
`(funcall #'max ,@x))
(defmacro dmax1 (&rest x)
`(funcall #'max ,@x))
(defmacro amax0 (&rest x)
`(round (funcall #'max ,@x)))
(defmacro max1 (&rest x)
`(float (funcall #'max ,@x)))
(defmacro min0 (&rest x)
`(funcall #'min ,@x))
(defmacro amin1 (&rest x)
`(funcall #'min ,@x))
(defmacro dmin1 (&rest x)
`(funcall #'min ,@x))
(defmacro amin0 (&rest x)
`(round (funcall #'min ,@x)))
(defmacro min1 (&rest x)
`(float (funcall #'min ,@x)))
(defmacro len (s)
`(length ,s))
(defmacro index (s1 s2)
(declare (ignore s1 s2))
`(error "macro for intrinsic INDEX not yet implemented"))
(defmacro lge (s1 s2)
`(string>= ,s1 ,s2))
(defmacro lgt (s1 s2)
`(string> ,s1 ,s2))
(defmacro lle (s1 s2)
`(string<= ,s1 ,s2))
(defmacro llt (s1 s2)
`(string< ,s1 ,s2))
(defmacro aimag (c)
`(imagpart ,c))
(defmacro conjg (c)
`(conjugate ,c))
(defmacro dsqrt (x)
`(sqrt ,x))
(defmacro csqrt (x)
`(sqrt ,x))
(defmacro dexp (x)
`(exp ,x))
(defmacro cexp (x)
`(exp ,x))
(defmacro alog (x)
`(log ,x))
(defmacro dlog (x)
`(log ,x))
(defmacro clog (x)
`(log ,x))
(defmacro alog10 (x)
`(log ,x 10))
(defmacro dlog10 (x)
`(log ,x 10))
(defmacro dsin (x)
`(sin ,x))
(defmacro csin (x)
`(sin ,x))
(defmacro dcos (x)
`(cos ,x))
(defmacro ccos (x)
`(cos ,x))
(defmacro dtan (x)
`(tan ,x))
(defmacro ctan (x)
`(tan ,x))
(defmacro dasin (x)
`(asin ,x))
(defmacro dacos (x)
`(acos ,x))
(defmacro datan (x)
`(atan ,x))
(defmacro atan2 (x y)
`(atan (/ ,x ,y)))
(defmacro datan2 (x y)
`(atan (/ ,x ,y)))
(defmacro dsinh (x)
`(sinh ,x))
(defmacro dcosh (x)
`(cosh ,x))
(defmacro dtanh (x)
`(tanh ,x))
;----------------------------------------------------------------------------- ; end of macros.l
; University of Waterloo Addition
; This macro allows "slices" of arrays to be passed by reference, a-la
; Fortran. This allows ddot etc. to remain mostly original, while working
; like the fortran versions.
;----------------------------------------------------------------------------- ; end of macros.l
(defmacro vec-ref (d i &optional (j NIL))
(let ((xrow-start (gensym "vec-ref"))
(xcol (gensym "vec-ref"))
(dx (gensym "vec-ref")))
`(let ((,xrow-start ,i)
(,xcol ,j)
(,dx ,d))
(cond
((and (numberp ,xrow-start) (numberp ,xcol))
(if (= 1 ,xrow-start)
(setf ,dx (ref ,dx T (- ,xcol 1)))
(setf ,dx (ref ,dx
(cons :c (iseq (- ,xrow-start 1)))
(- ,xcol 1)))))
((and (numberp ,xrow-start) (/= 1 ,xrow-start))
(setf ,dx (ref ,dx (cons :c (iseq (- ,xrow-start 1))))))
)
(when (numberp ,dx)
(setf ,dx (array ,dx :dimensions 1)))
,dx)
)
)
| 12,487 | Common Lisp | .l | 343 | 30.752187 | 118 | 0.480896 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 826c226660e58cc38bb2e4f7cda3b189a83ad1240cf27d200bfd8f30f65de696 | 33,321 | [
-1
] |
33,322 | jacobi.lsp | rwoldford_Quail/source/linear/jacobi.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; jacobi.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994-97 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Carsten Whimster 1997.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :q)
(defun jacobi-hook (a d v &optional (nrot 50))
"This function takes a real symmetric matrix, and returns eigenvalues
and eigenvectors. Taken virtually verbatum from 'Numerical Recipes in Fortran,
2nd Edition'.
The parameters are as follows:
A (input) The real symmetric matrix, n x n.
D (input/output) An array of dimension n. Will be overwritten with the
eigenvalues of A. These are in no particular order.
V (input/output) An array of dimension n x n which contains, on output,
the eigenvectors of A in its columns.
NROT (input/output) A limit on the number of rotations allowed. Defaults to
50 which may possibly never be exceeded in real life."
(prog* (;; parameters
;; integers
(i 0)
(n (nrows a))
;; reals
(c 0.0D0) (g 0.0D0) (h 0.0D0) (s 0.0D0) (sm 0.0D0) (t_ 0.0D0)
(tau 0.0D0) (theta 0.0D0) (tresh 0.0D0)
(b (array 0.0D0 :dimensions (list n)))
(z (array 0.0D0 :dimensions (list n)))
(rot-limit nrot))
;; initialize matrix to identity
;; and initialize b and d to the diagonal of a
(do ((ip 1 (incf ip)))
((> ip n))
(setf (fref v ip ip) 1.0D0)
(setf (fref b ip) (fref a ip ip))
(setf (fref d ip) (fref b ip))
(setf (fref z ip) 0.0D0))
(setf nrot 0)
(do ((i 1 (incf i)))
((> i rot-limit))
(setf sm 0.0D0)
(do ((ip 1 (incf ip)))
((= ip n))
(do ((iq (+ ip 1) (incf iq)))
((> iq n))
(setf sm (+ sm (abs (fref a ip iq))))))
(when (< sm 1D-5)
(return))
(if (< i 4)
(setf tresh (/ (* 0.2 sm) (* n n)))
(setf tresh 0.0D0))
(do ((ip 1 (incf ip)))
((= ip n))
(do ((iq (+ ip 1) (incf iq)))
((> iq n))
(setf g (* 100.0D0 (abs (fref a ip iq))))
(if (and (> i 4)
(= (+ (abs (fref d ip)) g) (abs (fref d ip)))
(= (+ (abs (fref d iq)) g) (abs (fref d iq))))
(setf (fref a ip iq) 0.0D0)
(when (> (abs (fref a ip iq)) tresh)
(setf h (- (fref d iq) (fref d ip)))
(cond ((= (+ (abs h) g) (abs h))
(setf t_ (/ (fref a ip iq) h)))
(t
(setf theta (/ (* 0.5D0 h) (fref a ip iq)))
(setf t_ (/ 1.0D0 (+ (abs theta)
(sqrt (+ 1.0D0 (* theta theta))))))
(when (< theta 0.0D0)
(setf t_ (- t_)))))
(setf c (/ 1.0D0 (sqrt (+ 1.0D0 (* t_ t_)))))
(setf s (* t_ c))
(setf tau (/ s (+ 1.0D0 c)))
(setf h (* t_ (fref a ip iq)))
(setf (fref z ip) (- (fref z ip) h))
(setf (fref z iq) (+ (fref z iq) h))
(setf (fref d ip) (- (fref d ip) h))
(setf (fref d iq) (+ (fref d iq) h))
(setf (fref a ip iq) 0.0D0)
(do ((j 1 (incf j)))
((= j ip))
(setf g (fref a j ip))
(setf h (fref a j iq))
(setf (fref a j ip) (- g (* s (+ h (* g tau)))))
(setf (fref a j iq) (+ h (* s (- g (* h tau))))))
(do ((j (+ ip 1) (incf j)))
((= j iq))
(setf g (fref a ip j))
(setf h (fref a j iq))
(setf (fref a ip j) (- g (* s (+ h (* g tau)))))
(setf (fref a j iq) (+ h (* s (- g (* h tau))))))
(do ((j (+ iq 1) (incf j)))
((> j n))
(setf g (fref a ip j))
(setf h (fref a iq j))
(setf (fref a ip j) (- g (* s (+ h (* g tau)))))
(setf (fref a iq j) (+ h (* s (- g (* h tau))))))
(do ((j 1 (incf j)))
((> j n))
(setf g (fref v j ip))
(setf h (fref v j iq))
(setf (fref v j ip) (- g (* s (+ h (* g tau)))))
(setf (fref v j iq) (+ h (* s (- g (* h tau))))))
(setf nrot (+ nrot 1)))
)
))
(do ((ip 1 (incf ip)))
((> ip n))
(setf (fref b ip) (+ (fref b ip) (fref z ip)))
(setf (fref d ip) (fref b ip))
(setf (fref z ip) 0.0D0))
)
;; return the modified values with an error message
(when (= i rot-limit)
(format *terminal-io* "~&jacobi: too many iterations~%"))
(return (values a d v)))
)
| 5,215 | Common Lisp | .l | 127 | 28.92126 | 83 | 0.387046 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 308ab4c510f821ad2e43e870bd5dc0f4c865d5ffed072b35c50ef4f8144dedd4 | 33,322 | [
-1
] |
33,323 | lin-binary-methods.lsp | rwoldford_Quail/source/linear/lin-binary-methods.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; binary-methods.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
;;;;;;;;;;;;;
;;;
;;; dot-times-object
(defmethod dot-times-object ((x-inv inverse-matrix) (y-inv inverse-matrix))
(let ((x (inverse-object-of x-inv))
(y (inverse-object-of y-inv))
)
(cond
((or (eql x y-inv) (eql y x-inv))
(identity-matrix (first (dimensions-of x-inv))))
(T
(inverse (dot-times-object y x))))))
(defmethod dot-times-object :around ((x matrix) (y-inv inverse-matrix))
(if (eql x (inverse-object-of y-inv))
(identity-matrix (first (dimensions-of x)))
(call-next-method)))
(defmethod dot-times-object :around ((x-inv inverse-matrix) (y matrix))
(if (eql y (inverse-object-of x-inv))
(identity-matrix (first (dimensions-of y)))
(call-next-method)))
(defmethod-multi dot-times-object
((x-inv inverse-matrix)
(y (sequence array dimensioned-ref-object)))
(solve (inverse-object-of x-inv) y))
(defmethod-multi dot-times-object
((y (sequence array dimensioned-ref-object))
(x-inv inverse-matrix))
(tp (solve (tp (inverse-object-of x-inv))
(tp y))))
;;;;;
;;; now for identity matrices
;;;
(defmethod-multi dot-times-object
((Ik identity-matrix)
(y (sequence array dimensioned-ref-object)))
(if (eq (first (dimensions-of y))
(second (dimensions-of Ik)))
y
(call-next-method)))
(defmethod-multi dot-times-object
((y (array dimensioned-ref-object))
(Ik identity-matrix))
(if (eq (second (dimensions-of y))
(first (dimensions-of Ik)))
y
(call-next-method)))
| 2,100 | Common Lisp | .l | 63 | 28.285714 | 84 | 0.524069 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | d9876d4eb69f9984a8f5f27d0cf557c9af46de1439610a4e99085ce8a8e531e3 | 33,323 | [
-1
] |
33,324 | qr-solution.lsp | rwoldford_Quail/source/linear/qr-solution.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; qr-solution.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(qr-solution solve)))
;;;--------------------------------------------------------------------------
;;; CLASS: qr-solution
;;;--------------------------------------------------------------------------
(defclass qr-solution ()
((coef
:initarg :coef :initform nil
:documentation
"The least-squares solution to a linear system of equations Xb = y ~
as found by first decomposing X into a QR decomposition and then ~
solving for b in QRb = y. These will be pivoted if the QR was.")
(resid
:initarg :resid :initform nil
:documentation
"Least squares residuals -- the difference between y and its fitted value.")
(fitted-values
:initarg :fitted-values :initform nil
:documentation
"The fitted values of y. For the linear system Xb = y, with solution ~
bhat, this is simply X.*bhat.")
(y
:initarg :y :initform nil
:documentation
"The matrix or vector y in the system Xb = y.")
(qrd
:initarg :qrd :initform nil
:documentation
"QR decomposition used in calculations.")
(qy
:initarg :qy :initform nil
:documentation
"QY is the vector: Q times y.")
(qty
:initarg :qty :initform nil
:documentation
"QTY is the vector: transpose(Q) times y.")
(rank
:initarg :rank :initform nil
:documentation
"The numerical rank of the X matrix. See the slot tolerance as well.")
(tolerance
:initarg :tolerance :initform 1.0E-4 :reader tolerance-of
:documentation
"Tolerance used to determine the rank if the rank is NIL. ~
Numerical rank will be the number of diagonal elements of the ~
triangular matrix R that are greater than tolerance * the maximum ~
diagonal element.") )
(:documentation
"The class returned by calling solve on a qr-decomposition object. ~
and a vector y."))
;;;
;;; export slots
;;;
(push-extension-class 'qr-solution)
;;;
;;; INVERSE
;;;
(defmethod inverse ((qrd qr-decomposition))
(solve qrd (identity-matrix (nrows (qr-of qrd))))
)
;;;
;;; SOLVE
;;;
(defmethod solve ((qrd qr-decomposition) y
&rest keyword-args
&key
(coef T)
qy qty resid fit
(rank NIL rank-supplied-p)
(tolerance NIL)
&allow-other-keys)
"Given a qr-decomposition qrd ~
and a matrix or vector y, solve returns b such that qrb = y. ~
Uses the linpack routine dqrls, to solve the system.~
If y is not given, then solve uses the y found on the qr-solution. ~
(:see-also qrd-of)~
(:required ~
(:arg qrd An instance of qr-decomposition.) ~
(:arg y The matrix or vector y. If NIL then qrs is queried for the value of y ~
stored there.)~
)~
(:key ~
(:arg coef T Flag indicating non-NIL if the coefficients are to be calculated. ~
Note that if the original qr-decomposition had things pivoted then the ~
coefficients returned here will also be pivoted.) ~
(:arg resid NIL Non-NIL if the residuals are to be calculated.) ~
(:arg fitted-values NIL Non-NIL if the fitted values are to be calculated.) ~
(:arg qy nil Non-NIL if the vector Q times y is to be calculated.) ~
(:arg qty nil Non-NIL if the vector tp(Q) times y is to be calculated. ) ~
(:arg rank nil If non-NIL, this must be the numerical rank of the X matrix. ~
Otherwise the rank will be determined from the data.) ~
(:arg tolerance 1.0E-4 The numerical value used to determine the rank ~
if the rank argument is NIL. ~
Numerical rank will be the number of diagonal elements of the ~
triangular matrix R that are greater than tolerance * the maximum ~
diagonal element. ~
) ~
)~
(:returns Two values. The first is the least squares solution if requested ~
and the second is a qr-solution object containing information as requested.) ~
(:see-also qrd-of qr-solution qr-decomposition multiple-value-list) ~
"
(declare (ignore tolerance rank rank-supplied-p))
(if (or (null y)
(notany #'identity (list qy qty coef resid fit)))
;;; if don't ask for anything, return NIL
(values NIL NIL)
;;; otherwise, do it.
(apply #'solve (make-instance 'qr-solution :qrd qrd :y y)
y keyword-args)
)
)
(defmethod solve ((qrs qr-solution) y
&rest keyword-args
&key
(coef T)
qy qty resid fit
(rank NIL rank-supplied-p)
(tolerance NIL)
&allow-other-keys)
"Given a qr-solution qrs and a matrix or ~
vector y, solve returns b such that qrb = y. ~
Uses the linpack routine dqrls, to solve the system.~
If y is not given, then solve uses the y found on the qr-solution. ~
(:see-also qrd-of)~
(:required ~
(:arg qrs An instance of qr-solution.) ~
(:arg y The matrix or vector y. If NIL then qrs is queried for the value of y ~
stored there.)~
)~
(:key ~
(:arg coef T Flag indicating non-NIL if the coefficients are to be calculated. ~
Note that if the original qr-decomposition had things pivoted then the ~
coefficients returned here will also be pivoted.) ~
(:arg resid NIL Non-NIL if the residuals are to be calculated.) ~
(:arg fitted-values NIL Non-NIL if the fitted values are to be calculated.) ~
(:arg qy nil Non-NIL if the vector Q times y is to be calculated.) ~
(:arg qty nil Non-NIL if the vector tp(Q) times y is to be calculated. ) ~
(:arg rank nil If non-NIL, this must be the numerical rank of the X matrix. ~
Otherwise the rank will be determined from the data.) ~
(:arg tolerance 1.0E-4 The numerical value used to determine the rank ~
if the rank argument is NIL. ~
Numerical rank will be the number of diagonal elements of the ~
triangular matrix R that are greater than tolerance * the maximum ~
diagonal element. ~
) ~
)~
(:returns Two values. The first is the least squares solution if requested ~
and the second is the qr-solution object updated as necessary.) ~
(:see-also qr-solution qr-decomposition multiple-value-list) ~
"
(declare (ignore keyword-args))
(with-slots
(qrd
(qrs-y y)
(qrs-qy qy)
(qrs-qty qty)
(qrs-coef coef)
(qrs-resid resid)
(qrs-fitted-values fitted-values)
(qrs-tolerance tolerance)
(qrs-rank rank))
qrs
(unless tolerance
(setf tolerance (or qrs-tolerance 1E-4)))
(setf qrs-tolerance tolerance)
(if (and (or (null y)
(null qrs-y)
(eq y qrs-y))
(notany #'identity (list qy qty coef resid fit))
(and (numberp tolerance) (= tolerance qrs-tolerance))
(or (not rank-supplied-p)
(= rank qrs-rank))
)
;;; if don't ask for anything, return appropriate info
(values NIL qrs)
;;; otherwise, calculate it.
(with-slots
(qr qraux)
qrd
(let*
(job
(n (first (dimensions-of qr)))
(p (or (second (dimensions-of qr)) 1))
(m (second (dimensions-of y)))
(n-by-m (if m (list n m) (list n)))
(p-by-m (if m (list p m) (list p)))
(info (array 0 :dimensions nil))
(qr-rank
(or rank
qrs-rank
(with-cl-functions (abs - / <)
(if (second (dimensions-of qr))
(let ((riimax
(loop for i from 0 below p
maximize (abs (eref qr i i)))))
(loop for i from 0 below p
count
(> (abs
(/ (eref qr i i) riimax))
tolerance)))
1))))
work-qy work-qty work-resid work-fit work-coef)
;; Initialize the slots if y is given and different.
(if y
(if (not (eq qrs-y y))
(setf qrs-y y
qrs-qty NIL
qrs-qy NIL
qrs-coef NIL
qrs-resid NIL
qrs-fitted-values NIL)
)
(setf y qrs-y))
;; The JOB parameter of DQRSL determines what is to be computed.
;; JOB has the decimal expansion ABCDE, where:
;; if A != 0 QY is to be computed
;; if B,C,D or E != 0 QTY is to be computed
;; if C != 0 COEF is to be computed
;; if D != 0 RESID is to be computed
;; if E != 0 PRED is to be computed
;; Note that a request to compute COEF, RESID, or PRED automatically
;; triggers the computation of QTY, for which storage must be provided
;; in the calling sequence.
;; Now get the correct decimal expansion for job
;; as determined by the keyword arguments.
(setf job 0)
(mapc #'(lambda (a1 a2) (if a1 (incf job a2)))
(list qy qty coef resid fit)
'(10000 1000 100 10 1))
;; Set up the work arrays
(flet ((conserve-space (indicator &optional (size n-by-m))
(if indicator
(array 0 :dimensions size)
(array 0 :dimensions 'nil)))
)
(setf work-qy (conserve-space qy))
(setf work-resid (conserve-space resid))
(setf work-fit (conserve-space fit))
(setf work-coef (conserve-space coef p-by-m))
(setf work-qty (conserve-space
(or qty
(some #'identity
(list coef resid fit)))))
)
;; Call the solver
(dqrls qr qraux y
:rank qr-rank
:qy work-qy :qty work-qty
:coef work-coef :resid work-resid :pred work-fit
:job job :info info)
;;
;; save the solution
(setf qrs-rank qr-rank)
(if qy (setf qrs-qy work-qy))
(if qty (setf qrs-qty work-qty))
(if resid (setf qrs-resid work-resid))
(if fit (setf qrs-fitted-values work-fit))
(when coef
(setf qrs-coef work-coef)
(flet ((extremely-small-p (x)
(cl:< (cl:abs x) tolerance))
)
(when (< qr-rank p)
(loop for i from 0 to (1- p)
do (if (extremely-small-p (eref qr i i))
(setf (ref qrs-coef i) nan))))
)
)
)
(values (if coef qrs-coef) qrs)
))))
;;;
;;; The various readers.
;;;
(defmethod qrd-of ((qrs qr-solution)
&rest keyword-args
&key
&allow-other-keys)
"Simply returns whatever is found on the qrd slot, whatever ~
the values of the remaining args."
(declare (ignore keyword-args))
(slot-value qrs 'qrd))
(defmethod (setf qrd-of) ((new-value qr-decomposition)
(qrs qr-solution))
"Sets the value of the qrd slot. If it is different from the ~
old value (not EQ), then the coefficients are recalculated."
(declare (ignore keyword-args))
(setf (slot-value qrs 'qrd) new-value)
(solve qrs NIL)
new-value)
(defmethod (setf qrd-of) ((new-value T)
(qrs qr-solution))
"Sets the value of the qrd slot."
(declare (ignore keyword-args))
(quail-error "Sorry, the new-value must be an instance of qr-decomposition.~&~
Not: ~s." new-value))
(defmethod coef-of ((qrs qr-solution))
"The least-squares solution to a linear system of equations Xb = y ~
as found from a QR solution and then ~
solving for b in QRb = y. These will be pivoted if the QR was."
(with-slots
(coef)
qrs
(when (not coef)
(solve qrs (slot-value qrs 'y) :coef t))
coef)
)
(defmethod resid-of ((qrs qr-solution))
"Least squares residuals -- the difference between y and its fitted value. ~
As determined from the qrs-solution."
(with-slots
(resid)
qrs
(when (not resid)
(solve qrs (slot-value qrs 'y) :resid t))
resid)
)
(defmethod pred-of ((qrs qr-solution))
"The fitted or predicted values of y as determined by the qr-solution qrs."
(with-slots
(fitted-values)
qrs
(when (not fitted-values)
(solve qrs (slot-value qrs 'y) :fit t))
fitted-values)
)
(defmethod qy-of ((qrs qr-solution))
"QY is Q times y as determined by the qr-solution qrs."
(with-slots
(qy)
qrs
(when (not qy)
(solve qrs (slot-value qrs 'y) :qy t))
qy)
)
(defmethod qty-of ((qrs qr-solution))
"QY is transpose(Q) times y as determined by the qr-solution qrs."
(with-slots
(qty)
qrs
(when (not qty)
(solve qrs (slot-value qrs 'y) :qty t))
qty)
)
(defmethod rank-of ((qrs qr-solution) &rest keyword-args
&key &allow-other-keys)
"The numerical rank of the X matrix used in calculating ~
this qr-solution. See the reader tolerance-of as well."
(declare (ignore keyword-args))
(slot-value qrs 'rank))
(defmethod tolerance-of ((qrs qr-solution))
"Tolerance used to determine the rank if the rank is NIL. ~
Numerical rank will be the number of diagonal elements of the ~
triangular matrix R that are greater than tolerance * the maximum ~
diagonal element."
(slot-value qrs 'tolerance))
| 14,819 | Common Lisp | .l | 374 | 29.794118 | 86 | 0.549688 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 2fcc6adef46d502b493500c553d597dbfa3a7bb0fd5667ec4789b28ae24f96b5 | 33,324 | [
-1
] |
33,325 | diagonal.lsp | rwoldford_Quail/source/linear/diagonal.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; diagonal.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(diagonal diagonal-of)))
(defun diagonal (elements)
"Returns a diagonal matrix having the specified ~
elements along its diagonal. The order is column major ~
over the contents of elements.~~
(:see-also (diagonal-of :function)~
)
(:required ~
(:arg elements Any ref'able object -- a sequence, an array, etc.))"
(let* ((n (number-of-elements elements))
(d (array 0 :dimensions (list n n)))
)
(loop for i from 0 to (- n 1)
do
(setf (eref d i i)
(column-major-eref elements i)))
d))
(defun diagonal-of (matrix)
"Returns an array of the (i,i) elements of the matrix.~
(:see-also (diagonal :function)~
)"
(array
(loop
for i from 0
below (min (nrows matrix) (ncols matrix))
collect (eref matrix i i)))
)
| 1,392 | Common Lisp | .l | 44 | 26.863636 | 89 | 0.479851 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | f16fc3c476c767b73f94300bb9cdf8f54845e4a66d7f8935cf7adaf396ecf68e | 33,325 | [
-1
] |
33,326 | dgeco.lsp | rwoldford_Quail/source/linear/dgeco.lsp | (in-package :q)
(defun dgeco-hook (a lda n ipvt rcond z)
;;(declare (type (simple-array double-float (*)) z))
;;(declare (type double-float rcond))
;;(declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (wkm 0.0d0) (wk 0.0d0) (ek 0.0d0) (ynorm 0.0d0)
(sm 0.0d0) (s 0.0d0) (anorm 0.0d0) (l 0) (kp1 0) (kb 0) (k 0)
(j 0) (info (array 0 :dimensions 'nil)))
;;(declare (type fixnum info))
(declare (type fixnum j))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum kp1))
(declare (type fixnum l))
(declare (type double-float anorm))
(declare (type double-float s))
(declare (type double-float sm))
(declare (type double-float ynorm))
(declare (type double-float ek))
(declare (type double-float t_))
(declare (type double-float wk))
(declare (type double-float wkm))
(setf anorm 0.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf anorm (dmax1 anorm (dasum-hook n (vec-ref a 1 j) 1)))))
(dgefa-hook a lda n ipvt info)
(setf ek 1.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) 0.0)))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (if (/= (fref z k) 0.0)
(setf ek (dsign ek (- (fref z k)))))
(if (<= (dabs (+ ek (- (fref z k)))) (dabs (fref a k k)))
(go label30))
(setf s
(f2cl/ (dabs (fref a k k))
(dabs (+ ek (- (fref z k))))))
(dscal-hook n s z 1)
(setf ek (* s ek))
label30 (setf wk (- ek (fref z k)))
(setf wkm (- (- ek) (fref z k)))
(setf s (dabs wk))
(setf sm (dabs wkm))
(if (= (fref a k k) 0.0) (go label40))
(setf wk (f2cl/ wk (fref a k k)))
(setf wkm (f2cl/ wkm (fref a k k)))
(go label50)
label40 (setf wk 1.0d0)
(setf wkm 1.0d0)
label50 (setf kp1 (+ k 1))
(if (> kp1 n) (go label90))
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf sm
(+
sm
(dabs
(+
(fref z j)
(* wkm (fref a k j))))))
(setf (fref z j) (+ (fref z j) (* wk (fref a k j))))
(setf s (+ s (dabs (fref z j))))))
(if (>= s sm) (go label80))
(setf t_ (+ wkm (- wk)))
(setf wk wkm)
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) (+ (fref z j) (* t_ (fref a k j))))))
label80 label90 (setf (fref z k) wk)))
(setf s (f2cl/ 1.0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (+ (+ n 1) (- kb)))
(if (< k n)
(setf (fref z k)
(+ (fref z k)
(ddot-hook (- n k) (vec-ref a (+ k 1) k) 1 (vec-ref z (+ 1 k)) 1))))
(if (<= (dabs (fref z k)) 1.0) (go label110))
(setf s (f2cl/ 1.0 (dabs (fref z k))))
(dscal-hook n s z 1)
label110 (setf l (fref ipvt k))
(setf t_ (fref z l))
(setf (fref z l) (fref z k))
(setf (fref z k) t_)))
(setf s (f2cl/ 1.0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm 1.0d0)
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf l (fref ipvt k))
(setf t_ (fref z l))
(setf (fref z l) (fref z k))
(setf (fref z k) t_)
(if (< k n)
(daxpy-hook (- n k) t_ (vec-ref a (+ k 1) k) 1
(vec-ref z (+ k 1)) 1))
(if (<= (dabs (fref z k)) 1.0) (go label130))
(setf s (f2cl/ 1.0 (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label130))
(setf s (f2cl/ 1.0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (+ (+ n 1) (- kb)))
(if (<= (dabs (fref z k)) (dabs (fref a k k)))
(go label150))
(setf s (f2cl/ (dabs (fref a k k)) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label150 (if (/= (fref a k k) 0.0) (setf (fref z k) (/ (fref z k)(fref a k k))))
(if (= (fref a k k) 0.0) (setf (fref z k) 1.0))
(setf t_ (- (fref z k)))
(daxpy-hook (+ k (- 1)) t_ (vec-ref a 1 k) 1 (vec-ref z 1) 1)))
(setf s (f2cl/ 1.0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
(if (/= anorm 0.0) (setf (fref rcond 1) (f2cl/ ynorm anorm)))
(if (= anorm 0.0) (setf (fref rcond 1) 0.0))
(return (values a lda n ipvt rcond z))))
| 5,727 | Common Lisp | .l | 129 | 28.635659 | 99 | 0.385055 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | bbca0cb0b1b2a97be427df0f7ebc674152e04b99a3a943f517e2fcaa1e5030d8 | 33,326 | [
-1
] |
33,327 | drotg.lsp | rwoldford_Quail/source/linear/drotg.lsp | (in-package :q)
(defun drotg-hook (da db c s)
(declare (type double-float s))
(declare (type double-float c))
(declare (type double-float db))
(declare (type double-float da))
(prog ((z 0.0d0) (r 0.0d0) (scale 0.0d0) (roe 0.0d0))
(declare (type double-float roe))
(declare (type double-float scale))
(declare (type double-float r))
(declare (type double-float z))
(setf roe db)
(if (> (dabs da) (dabs db)) (setf roe da))
(setf scale (+ (dabs da) (dabs db)))
(if (/= scale 0.0d0) (go label10))
(setf c 1.0d0)
(setf s 0.0d0)
(setf r 0.0d0)
(go label20)
label10 (setf r
(* scale
(dsqrt (+ (expt (f2cl/ da scale) 2)
(expt (f2cl/ db scale) 2)))))
(setf r (* (dsign 1.0 roe) r))
(setf c (f2cl/ da r))
(setf s (f2cl/ db r))
label20 (setf z s)
(if (and (> (dabs c) 0.0d0) (<= (dabs c) s)) (setf z (f2cl/ 1.0 c)))
(setf da r)
(setf db z)
(return (values da db c s))))
| 1,129 | Common Lisp | .l | 31 | 26.709677 | 77 | 0.486289 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 215623246eca2a2fe600d9e4e8e8649893cb1a8f3e5ab3e4694a769c05ebb781 | 33,327 | [
-1
] |
33,328 | determinant.lsp | rwoldford_Quail/source/linear/determinant.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; determinant.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(determinant)))
(defgeneric determinant (thing)
(:documentation
"Returns the determinant of its argument."
))
(defmethod determinant ((X identity-matrix))
(declare (ignorable X)) ;(declare (ignore X)) ; 31JUL2023
1)
(defmethod determinant ((X inverse-matrix))
(inverse (determinant (inverse x))))
(defmethod determinant ((X matrix))
"Returns the determinant of the square matrix X. ~
Depends on an lu decomposition of X, followed by ~
a call to the LINPACK routine dgedi."
(let ((first-dim (or (first (dimensions-of X)) 1))
(second-dim (or (second (dimensions-of X)) 1))
)
(cond
((= first-dim second-dim)
(let ((lu (lud-of X)))
(if (= 1.0 (+ 1.0 (eref (rcond-of lu))))
0
(let* ((a (lu-of lu))
(n (first (dimensions-of a)))
(ipvt (ipvt-of lu))
(det (array 0.0D0 :dimensions (list 2)))
(work (array 0.0D0 :dimensions (list n)))
(job 10))
(dgedi a n ipvt det work job)
(cl::* (eref det 0)
(cl:expt 10 (eref det 1))))))
)
(T
(quail-error
"Matrix is ~s by ~s! Determinant requires a square matrix; ~s is not."
first-dim second-dim X)))))
(defmethod determinant ((LU lu-decomposition))
"Returns the determinant from the lu decomposition, LU, by ~
a call to the LINPACK routine dgedi."
(if (= 1.0 (+ 1.0 (eref (rcond-of lu))))
0
(let* ((a (lu-of lu))
(n (first (dimensions-of a)))
(ipvt (ipvt-of lu))
(det (array 0.0D0 :dimensions (list 2)))
(work (array 0.0D0 :dimensions (list n)))
(job 10))
(dgedi a n ipvt det work job)
(cl::* (eref det 0)
(cl:expt 10 (eref det 1))))))
(defmethod determinant ((c cholesky-decomposition))
"Returns the determinant from the Cholesky decomposition, c, by ~
a call to the LINPACK routine dpodi, if necessary."
(let* ((a (upper-triangle-of c))
(n (nrows a)))
(if (or (and (null (jpvt-of c))
(zerop (info-of c)))
(and (jpvt-of c)
(= (info-of c) n)))
(let ((det (array 0.0D0 :dimensions (list 2)))
(job 10))
(dpodi a n det job)
(cl::* (eref det 0)
(cl:expt 10 (eref det 1))))
0)
)
)
(defmethod determinant ((svd sv-decomposition))
"Returns the determinant from the singular value decomposition, svd, ~
of a square matrix."
(let ((u (left-singular-vectors-of svd)))
(if (= (nrows u) (ncols u))
(reduce-slices #'* (singular-values-of svd)
:initial-value 1.0)
(quail-error
"Can't determine a determinant from the singular value ~
decomposition of a non-square matrix. svd = ~s"
svd))))
| 3,523 | Common Lisp | .l | 95 | 28.894737 | 81 | 0.502642 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | bc1c68c490a22c6138ba00f77feec681cb710c55506d69b6078b8ede8558ec51 | 33,328 | [
-1
] |
33,329 | dchdc.lsp | rwoldford_Quail/source/linear/dchdc.lsp | (in-package :q)
(defun dchdc-hook (a lda p work jpvt job info)
;;(declare (type fixnum info))
(declare (type fixnum job))
;;(declare (type (simple-array fixnum (*)) jpvt))
;;(declare (type (simple-array double-float (*)) work))
(declare (type fixnum p))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((maxl 0) (L 0) (kp1 0) (km1 0) (kb 0) (k 0) (jt 0) (jp 0) (j 0)
(plp1 0) (pl 0) (pu 0) (temp 0.0d0) (maxdia 0.0d0) (negk nil) (swapk nil))
(declare (type t swapk))
(declare (type t negk))
(declare (type double-float maxdia))
(declare (type double-float temp))
(declare (type fixnum pu))
(declare (type fixnum pl))
(declare (type fixnum plp1))
(declare (type fixnum j))
(declare (type fixnum jp))
(declare (type fixnum jt))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum km1))
(declare (type fixnum kp1))
(declare (type fixnum L))
(declare (type fixnum maxl))
(setf pl 1)
(setf pu 0)
(setf (fref info 1) p)
(if (= job 0) (go label160))
(fdo (k 1 (+ k 1))
((> k p) nil)
(tagbody (setf swapk (> (fref jpvt k) 0))
(setf negk (< (fref jpvt k) 0))
(setf (fref jpvt k) k)
(if negk (setf (fref jpvt k) (- (fref jpvt k))))
(if (not swapk) (go label60))
(if (= k pl) (go label50))
(dswap-hook (- pl 1) (vec-ref a 1 k) 1 (vec-ref a 1 pl) 1)
(setf temp (fref a k k))
(setf (fref a k k) (fref a pl pl))
(setf (fref a pl pl) temp)
(setf plp1 (+ pl 1))
(if (< p plp1) (go label40))
(fdo (j plp1 (+ j 1))
((> j p) nil)
(tagbody (if (>= j k) (go label10))
(setf temp (fref a pl j))
(setf (fref a pl j) (fref a j k))
(setf (fref a j k) temp)
(go label20)
label10 (if (= j k) (go label20))
(setf temp (fref a k j))
(setf (fref a k j) (fref a pl j))
(setf (fref a pl j) temp)
label20))
label40 (setf (fref jpvt k) (fref jpvt pl))
(setf (fref jpvt pl) k)
label50 (setf pl (+ pl 1))
label60))
(setf pu p)
(if (< p pl) (go label150))
(fdo (kb pl (+ kb 1))
((> kb p) nil)
(tagbody (setf k (+ (- p kb) pl))
(if (>= (fref jpvt k) 0) (go label130))
(setf (fref jpvt k) (- (fref jpvt k)))
(if (= pu k) (go label120))
(dswap-hook (- k 1) (vec-ref a 1 k) 1 (vec-ref a 1 pu) 1)
(setf temp (fref a k k))
(setf (fref a k k) (fref a pu pu))
(setf (fref a pu pu) temp)
(setf kp1 (+ k 1))
(if (< p kp1) (go label110))
(fdo (j kp1 (+ j 1))
((> j p) nil)
(tagbody (if (>= j pu) (go label80))
(setf temp (fref a k j))
(setf (fref a k j) (fref a j pu))
(setf (fref a j pu) temp)
(go label90)
label80 (if (= j pu) (go label90))
(setf temp (fref a k j))
(setf (fref a k j) (fref a pu j))
(setf (fref a pu j) temp)
label90))
label110 (setf jt (fref jpvt k))
(setf (fref jpvt k) (fref jpvt pu))
(setf (fref jpvt pu) jt)
label120 (setf pu (- pu 1))
label130))
label150
label160
(fdo (k 1 (+ k 1))
((> k p) nil)
(tagbody (setf maxdia (fref a k k))
(setf kp1 (+ k 1))
(setf maxl k)
(if (or (< k pl) (>= k pu)) (go label190))
(fdo (L kp1 (+ L 1))
((> L pu) nil)
(tagbody (if (> (fref a L L) maxdia)
(go label170))
(setf maxdia (fref a L L))
(setf maxl L)
label170))
label190 (if (> maxdia 0.0) (go label200))
(setf (fref info 1) (- k 1))
(go label280)
label200 (if (= k maxl) (go label210))
(setf km1 (- k 1))
(dswap-hook km1 (vec-ref a 1 k) 1 (vec-ref a 1 maxl) 1)
(setf (fref a maxl maxl) (fref a k k))
(setf (fref a k k) maxdia)
(setf jp (fref jpvt maxl))
(setf (fref jpvt maxl) (fref jpvt k))
(setf (fref jpvt k) jp)
label210 (setf (fref work k) (dsqrt (fref a k k)))
(setf (fref a k k) (fref work k))
(if (< p kp1) (go label260))
(fdo (j kp1 (+ j 1))
((> j p) nil)
(tagbody (if (= k maxl) (go label240))
(if (>= j maxl) (go label220))
(setf temp (fref a k j))
(setf (fref a k j) (fref a j maxl))
(setf (fref a j maxl) temp)
(go label230)
label220 (if (= j maxl) (go label230))
(setf temp (fref a k j))
(setf (fref a k j) (fref a maxl j))
(setf (fref a maxl j) temp)
label230 label240 (setf (fref a k j)
(f2cl/ (fref a k j)
(fref work k)))
(setf (fref work j) (fref a k j))
(setf temp (- (fref a k j)))
(daxpy-hook (- j k) temp
(vec-ref work kp1) 1
(vec-ref a kp1 j) 1)))
label260))
label280 (return (values a lda p work jpvt job info))))
| 7,297 | Common Lisp | .l | 143 | 27.440559 | 84 | 0.343776 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 113a71b6a0cfec938e5b04433b6e91451a72eb15a57d184afec15bd13e907a98 | 33,329 | [
-1
] |
33,330 | dposl.lsp | rwoldford_Quail/source/linear/dposl.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dposl-hook (a lda n b)
;(declare (type (simple-array double-float (*)) b))
(declare (type fixnum n))
(declare (type fixnum lda))
;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (kb 0) (k 0))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type double-float t_))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf t_ (ddot-hook (- k 1) (vec-ref a 1 k) 1 (vec-ref b 1) 1))
(setf (fref b k) (f2cl/ (- (fref b k) t_) (fref a k k)))))
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (+ n 1 (- kb)))
(setf (fref b k) (f2cl/ (fref b k) (fref a k k)))
(setf t_ (- (fref b k)))
(daxpy-hook (- k 1) t_ (vec-ref a 1 k) 1 (vec-ref b 1) 1)))
(return (values a lda n b))))
| 973 | Common Lisp | .l | 22 | 32.954545 | 86 | 0.447619 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | aff1e7e44b593884f064390feb90e1a74d042239644f2a498c168b863e9fd2da | 33,330 | [
-1
] |
33,331 | matrix-sqrt.lsp | rwoldford_Quail/source/linear/matrix-sqrt.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; matrix-sqrt.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '()))
;-------------------------------------------------------------------------------
; GENERIC FUNCTION: matrix-sqrt
;-------------------------------------------------------------------------------
(defgeneric matrix-sqrt (object)
(:documentation
"Returns the matrix-sqrt of object. Depending on the dimensions of ~
the object this will either be the simple square root ~
or a matrix S such that tp(S).*S will return the object. ~
At present, S is the Cholesky factor of object."))
(defmethod matrix-sqrt ((object t))
(sqrt object))
(defmethod matrix-sqrt ((object matrix))
(cond
((mat1dp object) (sqrt object))
((mat2dp object) (upper-triangle-of (cholesky-of object)))))
| 1,332 | Common Lisp | .l | 33 | 35.939394 | 84 | 0.422414 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | afe6161f694c13c2616fff3b1a2c1d3c78bd2fb578e1eb173b89bfd0c6b99ac9 | 33,331 | [
-1
] |
33,332 | eigen-decomposition.lsp | rwoldford_Quail/source/linear/eigen-decomposition.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; eigen-decomposition.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Carsten Whimster 1997.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(eigen-vectors-of
eigen-values-of
eigen-decomposition
eigen-of)))
(defgeneric eigen-vectors-of (thing)
(:documentation
"Returns the eigen vectors of its argument. ~
(:see-also (eigen-of :generic-function) ~
(eigen-decomposition :topic) ) ~
(:examples (:files (eigen decompositions ~
q:examples;arrays;matrices;decompositions;eigen.lisp) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp) )~
)"
)
)
(defgeneric eigen-values-of (thing)
(:documentation "Returns the eigen values of its argument. ~
(:see-also (eigen-of :generic-function) ~
(eigen-decomposition :topic) ) ~
(:examples (:files (eigen decompositions ~
q:examples;arrays;matrices;decompositions;eigen.lisp) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp) )~
)"
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; CLASS: eigen-decomposition
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass eigen-decomposition (matrix-decomposition)
((eigen-values
:initarg :eigen-values
:reader eigen-values-of
:initform NIL
:documentation
"Contains the vector of eigen values.")
(eigen-vectors
:initarg :eigen-vectors
:reader eigen-vectors-of
:initform NIL
:documentation
"The matrix of eigen vectors.")
)
(:documentation
"Return class for eigen decomposition. ~
Source: Numerical Recipes in Fortran."))
;;; export slot names
;;;
(push-extension-class 'eigen-decomposition)
;---------------------------------------------------------------------------
; GENERIC-FUNCTION: eigen-of
;---------------------------------------------------------------------------
(defgeneric eigen-of (A &optional sort?)
(:documentation
"Determines the eigen decomposition of the real symmetric matrix A. ~
It is calculated using the Jacobi method. ~
Once calculated, the decomposition is cached on A so that it ~
need not be recalculated on subsequent calls. Note that the decomposition ~
might be dangerously out of date if the elements of X are changed after ~
the initial call (see clear-decompositions). ~
(:required ~
(:arg A - Symmetric matrix having only real elements.) ~
)~
(:returns An instance of the class eigen-decomposition.)~
(:see-also (eigen-decomposition :topic) (matrix-decomposition :topic) ~
(clear-decompositions :function))~
(:examples (:files (eigen decompositions ~
q:examples;arrays;matrices;decompositions;eigen.lisp~
) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp~
) )~
)~
"
))
(defmethod eigen-of ((A matrix) &optional (sort? T))
"Determines the eigen decomposition of the matrix A. ~
It is calculated using the jacobi routine. ~
Once calculated, the decomposition is cached on A so that it ~
need not be recalculated on subsequent calls. Note that the decomposition ~
might be dangerously out of date if the elements of X are changed after ~
the initial call (see clear-decompositions). ~
(:required ~
(:arg A - Symmetric matrix having only real elements.) ~
(:arg sort? - Default T. Specifies whether or not to sort eigen values
and vectors.) ~
)~
(:returns an instance of the class eigen-decomposition.)~
(:see-also (eigen-decomposition :topic) (matrix-decomposition :topic) ~
(clear-decompositions :function))~
(:examples (:files (eigen decompositions ~
q:examples;arrays;matrices;decompositions;eigen.lisp~
) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp~
) )~
)~
"
(let ((key (list 'eigen)))
(or (find-table-entry A 'decomposition key)
(let* ((A-copy (sel A))
(rows (nrows A))
(D (array 0.0 :dimensions (list rows)))
(V (array 0.0 :dimensions (list rows rows))))
(jacobi A-copy D V)
(if sort?
(let ((sort-pos (qk::sort-position D #'>)))
(add-table-entry A 'decomposition
key
(make-instance 'eigen-decomposition
:eigen-values (ref D sort-pos)
:eigen-vectors (ref V T sort-pos)
)
)
)
(add-table-entry A 'decomposition
key
(make-instance 'eigen-decomposition
:eigen-values D
:eigen-vectors V
)
)
)
)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Methods for matrices
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod eigen-vectors-of ((thing matrix))
(eigen-vectors-of (eigen-of thing))
)
(defmethod eigen-values-of ((thing matrix))
(eigen-values-of (eigen-of thing))
)
| 6,056 | Common Lisp | .l | 158 | 29.898734 | 82 | 0.517988 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 68dbc1fad911e13b02608353acc73871049c6e48afe2c09f16eed0cda7336e73 | 33,332 | [
-1
] |
33,333 | dpbfa.lsp | rwoldford_Quail/source/linear/dpbfa.lsp | (in-package :q)
(defun dpbfa-hook (abd lda n m info)
(declare (type fixnum info))
(declare (type fixnum m))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((t_ 0.0d0) (s 0.0d0) (mu 0) (k 0) (jk 0) (j 0) (ik 0))
(declare (type fixnum ik))
(declare (type fixnum j))
(declare (type fixnum jk))
(declare (type fixnum k))
(declare (type fixnum mu))
(declare (type double-float s))
(declare (type double-float t_))
;;
;; dpbfa factors a double precision symmetric positive definite
;; matrix stored in band form.
;;
;; dpbfa is usually called by dpbco, but it can be called
;; directly with a saving in time if rcond is not needed.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; the matrix to be factored. the columns of the upper
;; triangle are stored in the columns of abd and the
;; diagonals of the upper triangle are stored in the
;; rows of abd . see the comments below for details.
;;
;; lda integer
;; the leading dimension of the array abd .
;; lda must be .ge. m + 1 .
;;
;; n integer
;; the order of the matrix a .
;;
;; m integer
;; the number of diagonals above the main diagonal.
;; 0 .le. m .lt. n .
;;
;; on return
;;
;; abd an upper triangular matrix r , stored in band
;; form, so that a = trans(r)*r .
;;
;; info integer
;; = 0 for normal return.
;; = k if the leading minor of order k is not
;; positive definite.
;;
;; band storage
;;
;; if a is a symmetric positive definite band matrix,
;; the following program segment will set up the input.
;;
;; m = (band width above diagonal)
;; do 20 j = 1, n
;; i1 = max0(1, j-m)
;; do 10 i = i1, j
;; k = i-j+m+1
;; abd(k,j) = a(i,j)
;; 10 continue
;; 20 continue
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; blas ddot
;; fortran max0,dsqrt
;;
;; internal variables
;;
;; begin block with ...exits to 40
;;
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf info j)
(setf s 0.0d0)
(setf ik (1+ m))
(setf jk (max0 (- j m) 1))
(setf mu (max0 (- (+ m 2) j) 1))
(if (< m mu) (go label20))
(fdo (k mu (1+ k))
((> k m) nil)
(tagbody (setf t_
(-
(fref abd k j)
(ddot-hook
(- k mu)
(vec-ref abd ik jk)
1
(vec-ref abd mu j)
1)))
(setf t_ (f2cl/ t_ (fref abd (1+ m) jk)))
(setf (fref abd k j) t_)
(setf s (+ s (* t_ t_)))
(setf ik (1- ik))
(setf jk (1+ jk))))
label20 (setf s (- (fref abd (1+ m) j) s))
;; ......exit
(if (<= s 0.0d0) (go label40))
(setf (fref abd (1+ m) j) (dsqrt s))))
(setf info 0)
label40 (return (values abd lda n m info))))
| 4,671 | Common Lisp | .l | 107 | 28.327103 | 80 | 0.351754 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | ae85bc26c66621a376bade6b6f39a1a11bdfbc084391752127af711ffb76ce2c | 33,333 | [
-1
] |
33,334 | dpbco.lsp | rwoldford_Quail/source/linear/dpbco.lsp | (in-package :q)
(defun dpbco-hook (abd lda n m rcond z info)
(declare (type fixnum info))
;; (declare (type (simple-array double-float (*)) z))
(declare (type double-float rcond))
(declare (type fixnum m))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((t_ 0.0d0) (wkm 0.0d0) (wk 0.0d0) (ek 0.0d0) (ynorm 0.0d0) (sm 0.0d0)
(s 0.0d0) (anorm 0.0d0) (mu 0) (lm 0) (lb 0) (la 0) (l 0) (kp1 0) (kb 0)
(k 0) (j2 0) (j 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum j2))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum kp1))
(declare (type fixnum l))
(declare (type fixnum la))
(declare (type fixnum lb))
(declare (type fixnum lm))
(declare (type fixnum mu))
(declare (type double-float anorm))
(declare (type double-float s))
(declare (type double-float sm))
(declare (type double-float ynorm))
(declare (type double-float ek))
(declare (type double-float t_))
(declare (type double-float wk))
(declare (type double-float wkm))
(declare (special *dummy_var*))
;;
;; dpbco factors a double precision symmetric positive definite
;; matrix stored in band form and estimates the condition of the
;; matrix.
;;
;; if rcond is not needed, dpbfa is slightly faster.
;; to solve a*x = b , follow dpbco by dpbsl.
;; to compute inverse(a)*c , follow dpbco by dpbsl.
;; to compute determinant(a) , follow dpbco by dpbdi.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; the matrix to be factored. the columns of the upper
;; triangle are stored in the columns of abd and the
;; diagonals of the upper triangle are stored in the
;; rows of abd . see the comments below for details.
;;
;; lda integer
;; the leading dimension of the array abd .
;; lda must be .ge. m + 1 .
;;
;; n integer
;; the order of the matrix a .
;;
;; m integer
;; the number of diagonals above the main diagonal.
;; 0 .le. m .lt. n .
;;
;; on return
;;
;; abd an upper triangular matrix r , stored in band
;; form, so that a = trans(r)*r .
;; if info .ne. 0 , the factorization is not complete.
;;
;; rcond double precision
;; an estimate of the reciprocal condition of a .
;; for the system a*x = b , relative perturbations
;; in a and b of size epsilon may cause
;; relative perturbations in x of size epsilon/rcond .
;; if rcond is so small that the logical expression
;; 1.0 + rcond .eq. 1.0
;; is true, then a may be singular to working
;; precision. in particular, rcond is zero if
;; exact singularity is detected or the estimate
;; underflows. if info .ne. 0 , rcond is unchanged.
;;
;; z double precision(n)
;; a work vector whose contents are usually unimportant.
;; if a is singular to working precision, then z is
;; an approximate null vector in the sense that
;; norm(a*z) = rcond*norm(a)*norm(z) .
;; if info .ne. 0 , z is unchanged.
;;
;; info integer
;; = 0 for normal return.
;; = k signals an error condition. the leading minor
;; of order k is not positive definite.
;;
;; band storage
;;
;; if a is a symmetric positive definite band matrix,
;; the following program segment will set up the input.
;;
;; m = (band width above diagonal)
;; do 20 j = 1, n
;; i1 = max0(1, j-m)
;; do 10 i = i1, j
;; k = i-j+m+1
;; abd(k,j) = a(i,j)
;; 10 continue
;; 20 continue
;;
;; this uses m + 1 rows of a , except for the m by m
;; upper left triangle, which is ignored.
;;
;; example.. if the original matrix is
;;
;; 11 12 13 0 0 0
;; 12 22 23 24 0 0
;; 13 23 33 34 35 0
;; 0 24 34 44 45 46
;; 0 0 35 45 55 56
;; 0 0 0 46 56 66
;;
;; then n = 6 , m = 2 and abd should contain
;;
;; * * 13 24 35 46
;; * 12 23 34 45 56
;; 11 22 33 44 55 66
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; linpack dpbfa
;; blas daxpy,ddot,dscal,dasum
;; fortran dabs,dmax1,max0,min0,dreal,dsign
;;
;; internal variables
;;
;;
;;
;; find norm of a
;;
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody
(setf l (min0 j (1+ m)))
(setf mu (max0 (- (+ m 2) j) 1))
(setf (fref z j) (dasum-hook l (vec-ref abd mu j) 1))
(setf k (- j l))
(if (< m mu) (go label20))
(fdo (i mu (+ i 1))
((> i m) nil)
(tagbody
(setf k (1+ k))
(setf (fref z k)
(+
(fref z k)
(dabs (fref abd i j))))))
label20))
(setf anorm 0.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf anorm (dmax1 anorm (fref z j)))))
;;
;; factor
;;
(multiple-value-setq (*dummy_var* lda n m info)
(dpbfa-hook abd lda n m info))
(if (/= info 0) (go label180))
;;
;; rcond = 1/(norm(a)*(estimate of norm(inverse(a)))) .
;; estimate = norm(z)/norm(y) where a*z = y and a*y = e .
;; the components of e are chosen to cause maximum local
;; growth in the elements of w where trans(r)*w = e .
;; the vectors are frequently rescaled to avoid overflow.
;;
;; solve trans(r)*w = e
;;
(setf ek 1.0d0)
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody (setf (fref z j) 0.0)))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (if (/= (fref z k) 0.0)
(setf ek (dsign ek (- (fref z k)))))
(if (<= (dabs (- ek (fref z k)))
(fref abd (+ m 1) k))
(go label60))
(setf s
(f2cl/ (fref abd (+ m 1) k)
(dabs (- ek (fref z k)))))
(dscal-hook n s z 1)
(setf ek (* s ek))
label60 (setf wk (- ek (fref z k)))
(setf wkm (- (- ek) (fref z k)))
(setf s (dabs wk))
(setf sm (dabs wkm))
(setf wk (f2cl/ wk (fref abd (+ m 1) k)))
(setf wkm (f2cl/ wkm (fref abd (+ m 1) k)))
(setf kp1 (1+ k))
(setf j2 (min0 (+ k m) n))
(setf i (+ m 1))
(if (> kp1 j2) (go label100))
(fdo (j kp1 (+ j 1))
((> j j2) nil)
(tagbody (setf i (1- i))
(setf sm
(+ sm (dabs
(+ (fref z j) (* wkm (fref abd i j))))))
(setf (fref z j)
(+ (fref z j) (* wk (fref abd i j))))
(setf s (+ s (dabs (fref z j))))))
(if (>= s sm) (go label90))
(setf t_ (- wkm wk))
(setf wk wkm)
(setf i (1+ m))
(fdo (j kp1 (+ j 1))
((> j j2) nil)
(tagbody (setf i (1- i))
(setf (fref z j)
(+
(fref z j)
(* t_ (fref abd i j))))))
label90 label100 (setf (fref z k) wk)))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
;;
;; solve r*y = w
;;
(fdo (kb 1 (1+ kb))
((> kb n) nil)
(tagbody (setf k (- (1+ n) kb))
(if (<= (dabs (fref z k)) (fref abd (1+ m) k))
(go label120))
(setf s (f2cl/ (fref abd (1+ m) k) (dabs (fref z k))))
(dscal-hook n s z 1)
label120 (setf (fref z k)
(f2cl/ (fref z k) (fref abd (1+ m) k)))
(setf lm (min0 (1- k) m))
(setf la (- (+ m 1) lm))
(setf lb (- k lm))
(setf t_ (- (fref z k)))
(daxpy-hook lm t_ (vec-ref abd la k) 1 (vec-ref z lb) 1)))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
;;
(setf ynorm 1.0d0)
;;
;; solve trans(r)*v = y
;;
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf lm (min0 (1- k) m))
(setf la (- (1+ m) lm))
(setf lb (- k lm))
(setf (fref z k)
(- (fref z k)
(ddot-hook lm (vec-ref abd la k) 1 (vec-ref z lb) 1)))
(if (<= (dabs (fref z k)) (fref abd (+ m 1) k))
(go label140))
(setf s (f2cl/ (fref abd (1+ m) k) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label140 (setf (fref z k)
(f2cl/ (fref z k) (fref abd (1+ m) k)))))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
;;
;; solve r*z = w
;;
(fdo (kb 1 (1+ kb))
((> kb n) nil)
(tagbody (setf k (- (1+ n) kb))
(if (<= (dabs (fref z k)) (fref abd (1+ m) k))
(go label160))
(setf s (f2cl/ (fref abd (1+ m) k) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label160 (setf (fref z k)
(f2cl/ (fref z k) (fref abd (1+ m) k)))
(setf lm (min0 (1- k) m))
(setf la (- (1+ m) lm))
(setf lb (- k lm))
(setf t_ (- (fref z k)))
(daxpy-hook lm t_ (vec-ref abd la k) 1 (vec-ref z lb) 1)))
;; make znorm = 1.0
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
;;
(if (/= anorm 0.0d0)
(setf rcond (f2cl/ ynorm anorm))
(setf rcond 0.0d0))
label180 (return (values abd lda n m rcond z info))))
| 13,041 | Common Lisp | .l | 292 | 29.493151 | 90 | 0.366831 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 6c20dbb593120cef85e622e09207ad40f0d6c48092f255949bdc0c6dd7336fb9 | 33,334 | [
-1
] |
33,335 | matrix-decomposition.lsp | rwoldford_Quail/source/linear/matrix-decomposition.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; matrix-decomposition.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; Greg Anglin 1992.
;;; R.W. Oldford 1993, 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(matrix-decomposition decomposition-mixin clear-decompositions
qr-decomposition lu-decomposition cholesky-decomposition
singular-value-decomposition)))
;;;
;;; Mixin separates out matrix-decompositions. .... rwo
;;;-------------------------------------------------------------------------
(defclass matrix-decomposition (quail-object)
((original-matrix :initarg :original-matrix
:reader original-matrix-of
:initform '()
:documentation
"Contains a pointer to the original matrix that was decomposed."))
(:documentation
"A class that defines the decomposition of a matrix. Purely an ~
organizational class."))
;---------------------------------------------------------------------------
;Mixin adds decompositions to matrix
;---------------------------------------------------------------------------
(defclass decomposition-mixin (hash-table-mixin)
((decomposition :initarg :decomposition
:accessor decomposition-of
:initform nil
:documentation
"Hash table of decompositions, or nil"))
(:documentation
"Mixin for slot to store decompositions of a matrix."))
(defun clear-decompositions (thing)
"Clears all decompositions cached on this thing. ~
This is important if the contents of thing have been changed after ~
decompositions of it were calculated."
(clear-table thing 'decomposition))
;---------------------------------------------------------------------------
;redefinition of matrix class
;---------------------------------------------------------------------------
(defclass matrix (decomposition-mixin num-array)
())
#+:aclpc(acl-mop::finalize-inheritance (find-class 'qk::matrix))
| 2,489 | Common Lisp | .l | 56 | 38.214286 | 127 | 0.481497 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | f70f9e7a5d03a8fc168df5832675124daf7691e3c0abb5bd4a6c97246e83315c | 33,335 | [
-1
] |
33,336 | dcopy.lsp | rwoldford_Quail/source/linear/dcopy.lsp | (in-package :q)
(defun dcopy-hook (n dx incx dy incy)
(declare (type fixnum incy))
;;(declare (type (simple-array double-float (*)) dy))
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((mp1 0) (m 0) (iy 0) (ix 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum ix))
(declare (type fixnum iy))
(declare (type fixnum m))
(declare (type fixnum mp1))
(if (<= n 0) (go end_label))
(if (and (= incx 1) (= incy 1)) (go label20))
(setf ix 1)
(setf iy 1)
(if (< incx 0) (setf ix (+ (* (- 1 n) incx) 1)))
(if (< incy 0) (setf iy (+ (* (- 1 n) incy) 1)))
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody
(setf (fref dy iy) (fref dx ix))
(setf ix (+ ix incx))
(setf iy (+ iy incy))))
(go end_label)
label20 (setf m (mod n 7))
(if (= m 0) (go label40))
(fdo (i 1 (+ i 1))
((> i m) nil)
(tagbody
(setf (fref dy i) (fref dx i))))
(if (< n 7) (go end_label))
label40 (setf mp1 (+ m 1))
(fdo (i mp1 (+ i 7)) ((> i n) nil)
(tagbody
(setf (fref dy i) (fref dx i))
(setf (fref dy (+ i 1)) (fref dx (+ i 1)))
(setf (fref dy (+ i 2)) (fref dx (+ i 2)))
(setf (fref dy (+ i 3)) (fref dx (+ i 3)))
(setf (fref dy (+ i 4)) (fref dx (+ i 4)))
(setf (fref dy (+ i 5)) (fref dx (+ i 5)))
(setf (fref dy (+ i 6)) (fref dx (+ i 6)))))
(go end_label)
end_label (return (values n dx incx dy incy))))
| 1,781 | Common Lisp | .l | 45 | 28.688889 | 60 | 0.428984 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 0028fb87427932600246d247fb3ff73ef420a712c3e4de728d948609f183e049 | 33,336 | [
-1
] |
33,337 | dpodi.lsp | rwoldford_Quail/source/linear/dpodi.lsp | (in-package :q)
(defun dpodi-hook (a lda n det job)
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) det))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (s 0.0d0) (kp1 0) (k 0) (jm1 0) (j 0) (i 0))
;(declare (type single-float t_)) ;double-float declaration below
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum jm1))
(declare (type fixnum k))
(declare (type fixnum kp1))
(declare (type double-float s))
(declare (type double-float t_))
(if (= (f2cl/ job 10) 0) (go label70))
(setf (fref det 1) 1.0)
(setf (fref det 2) 0.0)
(setf s 10.0d0)
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody
(setf (fref det 1) (* (fref a i i) (fref a i i) (fref det 1)))
(if (= (fref det 1) 0.0) (go label60))
label10 (if (>= (fref det 1) 1.0) (go label20))
(setf (fref det 1) (* s (fref det 1)))
(setf (fref det 2) (- (fref det 2) 1.0))
(go label10)
label20
label30 (if (< (fref det 1) s) (go label40))
(setf (fref det 1) (f2cl/ (fref det 1) s))
(setf (fref det 2) (+ (fref det 2) 1.0))
(go label30)
label40))
label60
label70 (if (= (mod job 10) 0) (go label140))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody
(setf (fref a k k) (f2cl/ 1.0 (fref a k k)))
(setf t_ (- (fref a k k)))
(dscal-hook (- k 1) t_ (vec-ref a 1 k) 1)
(setf kp1 (+ k 1))
(if (< n kp1) (go label90))
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody
(setf t_ (fref a k j))
(setf (fref a k j) 0.0)
(daxpy k t_ (vec-ref a 1 k) 1 (vec-ref a 1 j) 1)))
label90))
(fdo (j 1 (+ j 1))
((> j n) nil)
(tagbody
(setf jm1 (- j 1))
(if (< jm1 1) (go label120))
(fdo (k 1 (+ k 1))
((> k jm1) nil)
(tagbody
(setf t_ (fref a k j))
(daxpy k t_ (vec-ref a 1 j) 1 (vec-ref a 1 k) 1)))
label120 (setf t_ (fref a j j))
(dscal-hook j t_ (vec-ref a 1 j) 1)))
label140 (return (values a lda n det job))))
| 2,479 | Common Lisp | .l | 65 | 27.492308 | 74 | 0.449378 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e4afcac3fc628fc09934b8bdf32a6a4041ef1dbb3ae496969259a1044c48f252 | 33,337 | [
-1
] |
33,338 | dqrdc.lsp | rwoldford_Quail/source/linear/dqrdc.lsp | (in-package :q)
(defun dqrdc-hook (x ldx n p qraux jpvt work job)
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) work))
;;(declare (type (simple-array fixnum (*)) jpvt))
;;(declare (type (simple-array double-float (*)) qraux))
(declare (type fixnum p))
(declare (type fixnum n))
(declare (type fixnum ldx))
;;(declare (type (simple-array double-float (* *)) x))
(prog ((t_ 0.0d0) (jj 0) (pu 0) (pl 0) (maxj 0) (lup 0) (lp1 0) (l 0) (jp 0)
(j 0) (tt 0.0d0) (maxnrm 0.0d0) (nrmxl 0.0d0) (swapj nil) (negj nil))
;(dnrm2 0.0d0) (ddot 0.0d0)) ; 31JUL2023
(declare (type fixnum jj))
(declare (type t negj))
(declare (type t swapj))
;(declare (type double-float ddot))
(declare (type double-float nrmxl))
(declare (type double-float t_))
(declare (type double-float maxnrm))
;(declare (type double-float dnrm2))
(declare (type double-float tt))
(declare (type fixnum j))
(declare (type fixnum jp))
(declare (type fixnum l))
(declare (type fixnum lp1))
(declare (type fixnum lup))
(declare (type fixnum maxj))
(declare (type fixnum pl))
(declare (type fixnum pu))
(setf pl 1)
(setf pu 0)
(if (= job 0) (go label60))
(fdo (j 1 (+ j 1))
((> j p) nil)
(tagbody (setf swapj (> (fref jpvt j) 0))
(setf negj (< (fref jpvt j) 0))
(setf (fref jpvt j) j)
(if negj (setf (fref jpvt j) (- j)))
(if (not swapj) (go label10))
(if (/= j pl)
(dswap-hook n (vec-ref x 1 pl) 1 (vec-ref x 1 j) 1))
(setf (fref jpvt j) (fref jpvt pl))
(setf (fref jpvt pl) j)
(setf pl (+ pl 1))
label10))
(setf pu p)
(fdo (jj 1 (+ jj 1))
((> jj p) nil)
(tagbody (setf j (+ (- p jj) 1))
(if (>= (fref jpvt j) 0) (go label40))
(setf (fref jpvt j) (- (fref jpvt j)))
(if (= j pu) (go label30))
(dswap-hook n (vec-ref x 1 pu) 1 (vec-ref x 1 j) 1)
(setf jp (fref jpvt pu))
(setf (fref jpvt pu) (fref jpvt j))
(setf (fref jpvt j) jp)
label30 (setf pu (- pu 1))
label40))
label60 (if (< pu pl) (go label80))
(fdo (j pl (+ j 1))
((> j pu) nil)
(tagbody (setf (fref qraux j) (dnrm2 n (vec-ref x 1 j) 1))
(setf (fref work j) (fref qraux j))))
label80 (setf lup (min0 n p))
(fdo (l 1 (+ l 1))
((> l lup) nil)
(tagbody (if (or (< l pl) (>= l pu)) (go label120))
(setf maxnrm 0.0d0)
(setf maxj l)
(fdo (j l (+ j 1))
((> j pu) nil)
(tagbody (if (<= (fref qraux j) maxnrm)
(go label90))
(setf maxnrm (fref qraux j))
(setf maxj j)
label90))
(if (= maxj l) (go label110))
(dswap-hook n (vec-ref x 1 l) 1 (vec-ref x 1 maxj) 1)
(setf (fref qraux maxj) (fref qraux l))
(setf (fref work maxj) (fref work l))
(setf jp (fref jpvt maxj))
(setf (fref jpvt maxj) (fref jpvt l))
(setf (fref jpvt l) jp)
label110 label120 (setf (fref qraux l) 0.0)
(if (= l n) (go label190))
(setf nrmxl (dnrm2-hook (+ (- n l) 1) (vec-ref x l l) 1))
(if (= nrmxl 0.0d0) (go label180))
(if (/= (fref x l l) 0.0)
(setf nrmxl (dsign nrmxl (fref x l l))))
(dscal-hook (+ (- n l) 1) (f2cl/ 1.0 nrmxl) (vec-ref x l l)
1)
(setf (fref x l l) (+ 1.0 (fref x l l)))
(setf lp1 (+ l 1))
(if (< p lp1) (go label170))
(fdo (j lp1 (+ j 1))
((> j p) nil)
(tagbody (setf t_
(f2cl/
(-
(ddot-hook
(+ (- n l) 1)
(vec-ref x l l)
1
(vec-ref x l j)
1))
(fref x l l)))
(daxpy-hook (+ (- n l) 1) t_ (vec-ref x l l)
1 (vec-ref x l j) 1)
(if (or (< j pl) (> j pu)) (go label150))
(if (= (fref qraux j) 0.0) (go label150))
(setf tt
(-
1.0
(expt
(f2cl/
(dabs (fref x l j))
(fref qraux j))
2)))
(setf tt (dmax1 tt 0.0d0))
(setf t_ tt)
(setf tt
(+
1.0d0
(*
0.05d0
tt
(expt
(f2cl/
(fref qraux j)
(fref work j))
2))))
(if (= tt 1.0d0) (go label130))
(setf (fref qraux j) (* (fref qraux j) (dsqrt t_)))
(go label140)
label130 (setf (fref qraux j)
(dnrm2 (- n l) (vec-ref x (+ l 1) j) 1))
(setf (fref work j) (fref qraux j))
label140 label150))
label170 (setf (fref qraux l) (fref x l l))
(setf (fref x l l) (- nrmxl))
label180 label190))
(return (values x ldx n p qraux jpvt work job))))
| 7,182 | Common Lisp | .l | 143 | 25.538462 | 88 | 0.323952 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e5d0156b076a9ea3b118b2b402ce350b3067b9d9ee9adba080b43ef598c44cbc | 33,338 | [
-1
] |
33,339 | dgbsl.lsp | rwoldford_Quail/source/linear/dgbsl.lsp | (in-package :q)
(defun dgbsl-hook (abd lda n ml mu ipvt b job)
(declare (type fixnum job))
;; (declare (type (simple-array double-float (*)) b))
;; (declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum mu))
(declare (type fixnum ml))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((t_ 0.0d0) (nm1 0) (m 0) (lm 0) (lb 0) (la 0) (l 0)
(kb 0) (k 0))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum l))
(declare (type fixnum la))
(declare (type fixnum lb))
(declare (type fixnum lm))
(declare (type fixnum m))
(declare (type fixnum nm1))
(declare (type double-float t_))
(declare (special *dummy_var*))
;;
;; dgbsl solves the double precision band system
;; a * x = b or trans(a) * x = b
;; using the factors computed by dgbco or dgbfa.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; the output from dgbco or dgbfa.
;;
;; lda integer
;; the leading dimension of the array abd .
;;
;; n integer
;; the order of the original matrix.
;;
;; ml integer
;; number of diagonals below the main diagonal.
;;
;; mu integer
;; number of diagonals above the main diagonal.
;;
;; ipvt integer(n)
;; the pivot vector from dgbco or dgbfa.
;;
;; b double precision(n)
;; the right hand side vector.
;;
;; job integer
;; = 0 to solve a*x = b ,
;; = nonzero to solve trans(a)*x = b , where
;; trans(a) is the transpose.
;;
;; on return
;;
;; b the solution vector x .
;;
;; error condition
;;
;; a division by zero will occur if the input factor contains a
;; zero on the diagonal. technically this indicates singularity
;; but it is often caused by improper arguments or improper
;; setting of lda . it will not occur if the subroutines are
;; called correctly and if dgbco has set rcond .gt. 0.0
;; or dgbfa has set info .eq. 0 .
;;
;; to compute inverse(a) * c where c is a matrix
;; with p columns
;; call dgbco(abd,lda,n,ml,mu,ipvt,rcond,z)
;; if (rcond is too small) go to ...
;; do 10 j = 1, p
;; call dgbsl(abd,lda,n,ml,mu,ipvt,c(1,j),0)
;; 10 continue
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; blas daxpy,ddot
;; fortran min0
;;
;; internal variables
;;
;;
(setf m (+ mu ml 1))
(setf nm1 (1- n))
(if (/= job 0) (go label50))
;;
;; job = 0 , solve a * x = b
;; first solve l*y = b
;;
(if (= ml 0) (go label30))
(if (< nm1 1) (go label30))
(fdo (k 1 (1+ k))
((> k nm1) nil)
(tagbody (setf lm (min0 ml (- n k)))
(setf l (fref ipvt k))
(setf t_ (fref b l))
(if (= l k) (go label10))
(setf (fref b l) (fref b k))
(setf (fref b k) t_)
label10 (daxpy-hook lm t_ (vec-ref abd (1+ m) k) 1 (vec-ref b (1+ k))
1)))
label30 ;;
;; now solve u*x = y
;;
(fdo (kb 1 (1+ kb))
((> kb n) nil)
(tagbody (setf k (- (1+ n) kb))
(setf (fref b k) (f2cl/ (fref b k) (fref abd m k)))
(setf lm (1- (min0 k m)))
(setf la (- m lm))
(setf lb (- k lm))
(setf t_ (- (fref b k)))
(daxpy-hook lm t_ (vec-ref abd la k) 1 (vec-ref b lb) 1)))
(go label100)
label50 ;;
;; job = nonzero, solve trans(a) * x = b
;; first solve trans(u)*y = b
;;
(fdo (k 1 (1+ k))
((> k n) nil)
(tagbody (setf lm (1- (min0 k m)))
(setf la (- m lm))
(setf lb (- k lm))
(setf t_ (ddot-hook lm (vec-ref abd la k) 1 (vec-ref b lb) 1))
(setf (fref b k)
(f2cl/ (- (fref b k) t_) (fref abd m k)))))
;;
;; now solve trans(l)*x = y
;;
(if (= ml 0) (go label90))
(if (< nm1 1) (go label90))
(fdo (kb 1 (1+ kb))
((> kb nm1) nil)
(tagbody (setf k (- n kb))
(setf lm (min0 ml (- n k)))
(setf (fref b k)
(+ (fref b k)
(ddot-hook lm (vec-ref abd (1+ m) k) 1 (vec-ref b (1+ k))
1)))
(setf l (fref ipvt k))
(if (= l k) (go label70))
(setf t_ (fref b l))
(setf (fref b l) (fref b k))
(setf (fref b k) t_)
label70))
label90 label100 (return (values abd lda n ml mu ipvt b job))))
| 6,119 | Common Lisp | .l | 151 | 27.827815 | 89 | 0.389671 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 90fa0e6308cd63c1129de5f2141e56ecd6b1d7c79f40811a1d821397694f8475 | 33,339 | [
-1
] |
33,340 | ddot.lsp | rwoldford_Quail/source/linear/ddot.lsp | (in-package :q)
(defun ddot-hook (n dx incx dy incy)
(declare (type fixnum incy))
;;(declare (type (simple-array double-float (*)) dy))
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((ddot 0.0d0) (dtemp 0.0d0) (mp1 0) (m 0) (iy 0) (ix 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum ix))
(declare (type fixnum iy))
(declare (type fixnum m))
(declare (type fixnum mp1))
(declare (type double-float dtemp))
(declare (type double-float ddot))
(setf ddot 0.0d0)
(setf dtemp 0.0d0)
(if (<= n 0) (go end_label))
(if (and (= incx 1) (= incy 1)) (go label20))
(setf ix 1)
(setf iy 1)
(if (< incx 0) (setf ix (+ (* (+ (- n) 1) incx) 1)))
(if (< incy 0) (setf iy (+ (* (+ (- n) 1) incy) 1)))
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf dtemp (+ dtemp (* (fref dx ix) (fref dy iy))))
(setf ix (+ ix incx))
(setf iy (+ iy incy))))
(setf ddot dtemp)
(go end_label)
label20 (setf m (mod n 5))
(if (= m 0) (go label40))
(fdo (i 1 (+ i 1))
((> i m) nil)
(tagbody (setf dtemp (+ dtemp (* (fref dx i) (fref dy i))))))
(if (< n 5) (go label60))
label40 (setf mp1 (+ m 1))
(fdo (i mp1 (+ i 5))
((> i n) nil)
(tagbody (setf dtemp
(+ dtemp
(* (fref dx i) (fref dy i))
(* (fref dx (+ i 1)) (fref dy (+ i 1)))
(* (fref dx (+ i 2)) (fref dy (+ i 2)))
(* (fref dx (+ i 3)) (fref dy (+ i 3)))
(* (fref dx (+ i 4)) (fref dy (+ i 4)))))))
label60 (setf ddot dtemp)
(go end_label)
end_label (return ddot)))
| 2,026 | Common Lisp | .l | 49 | 28.795918 | 75 | 0.419665 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 0bda6e65835f0c38e8e14817c8377ab3b162192c2392c13e20ae006b36fd1cd0 | 33,340 | [
-1
] |
33,341 | identity-matrix.lsp | rwoldford_Quail/source/linear/identity-matrix.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; identity-matrix.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(identity-matrix)))
;;;-------------------------------------------------------------------------
;;; DEFCLASS: identity-matrix
;;;-------------------------------------------------------------------------
(defclass identity-matrix (matrix)
((identity-filled? :initform NIL
:reader identity-filled-p))
(:documentation "The identity matrix. ~
(:see-also ~
(identity-matrix :function)~
(inverse :generic-function))"))
(defun identity-matrix (extent)
"Creates and returns an extent by extent identity matrix."
(make-instance 'identity-matrix :dimensions (list extent extent)))
(defgeneric request-identity-filled (identity-matrix)
(:documentation "Force identity to actually fill itself if it hasn't ~
already done so.")
)
(defmethod request-identity-filled ((self identity-matrix))
(let*
((extent (or (first (dimensions-of self)) 1))
(iden
(array (loop for i from 1 to extent
collect
(loop for j from 1 to extent
collect
(if (= i j) 1 0)))
:dimensions (list extent extent)
:class 'identity-matrix))
)
(with-slots ((self-proto qk::proto)
(self-ref-obj qk::ref-obj)
(self-specs-mask qk::specs-mask)
(self-specs qk::specs)
(self-dimensions qk::dimensions)
(self-ref-contents qk::ref-contents)
(self-identity-filled? identity-filled?))
self
(with-slots ((iden-proto qk::proto)
(iden-ref-obj qk::ref-obj)
(iden-specs-mask qk::specs-mask)
(iden-specs qk::specs)
(iden-dimensions qk::dimensions)
(iden-ref-contents qk::ref-contents))
iden
(setf self-proto iden-proto
self-ref-obj iden-ref-obj
self-specs-mask iden-specs-mask
self-specs iden-specs
self-dimensions iden-dimensions
self-ref-contents iden-ref-contents
self-identity-filled? t)))
self)
)
(defmethod request-identity-filled :around ((self identity-matrix))
"Checks to see whether the filling has already been done.~
If it has then it returns self, if it has not then it calls the ~
next method."
(if (identity-filled-p self)
self
(call-next-method)))
(defmethod request-identity-filled ((self t))
"In general does nothing but return self."
self)
(defmethod ref ((x identity-matrix) &rest args)
(let ((result (call-next-method))
(num-args (length args))
(arg-1 (first args))
(old-extent (or (first (dimensions-of x)) 1)))
(unless
(or (zerop num-args)
(and (= num-args 1)
(or (eq (first args) T)
(equal (iseq old-extent) arg-1)
))
(and (= num-args 2)
(equal arg-1 (second args))
(or (eq arg-1 T)
(numberp arg-1)
(and (listp arg-1)
(= (length arg-1)
(length (remove-duplicates arg-1 :test #'eq))))))
)
(change-class result 'matrix))
result)
)
(defmethod sel ((x identity-matrix) &rest args)
(let ((result NIL)
(num-args (length args))
(old-extent (or (first (dimensions-of x)) 1)))
(cond
((zerop num-args)
(setf result (identity-matrix old-extent)))
((and (= num-args 1)
(or (eq (first args) T)
(equal (iseq old-extent) (first args))
)
)
(setf result (identity-matrix old-extent)))
((= num-args 2)
(let ((arg-1 (first args))
(arg-2 (second args)))
(when (equal arg-1 arg-2)
(cond
((eq arg-1 T) (setf result (identity-matrix old-extent)))
((numberp arg-1) (identity-matrix 1))
((and (listp arg-1)
(= (length arg-1)
(length (remove-duplicates arg-1 :test #'eq))))
(if (eq (first arg-1) :c)
(setf result
(identity-matrix (- old-extent
(length (rest arg-1)))))
(setf result
(identity-matrix (length arg-1)))
))
)
)
)
))
(unless result
(let ((extent (or (first (dimensions-of x)) 1)))
(setf result
(array (loop for i from 1 to extent
collect
(loop for j from 1 to extent
collect
(if (= i j) 1 0)))
:dimensions (list extent extent)))
(setf result (apply #'sel result args))))
result))
(defmethod eref ((x identity-matrix) &rest args)
(if (not (= (length args) 2))
(quail-error "Referencing elements of ~s requires 2 subscripts; ~
eref called with ~s."
x
args))
(let* ((i (first args))
(j (second args))
(dims (dimensions-of x))
(n (if dims
(first dims)
1)))
(cond
((or (>= i n) (< i 0))
(quail-error "eref: Index ~s out of bounds for ~s."
i
x))
((or (>= j n) (< j 0))
(quail-error "eref: Index ~s out of bounds for ~s."
j
x))
(T
(if (apply #'cl:= args)
1
0)))))
(defmethod print-object ((self identity-matrix) stream)
(let*
((dims (dimensions-of self))
(n (if dims
(first dims)
1))
)
(format stream "#<~a by ~a Identity Matrix>" n n)))
;-----
(defmethod (setf ref) (new-value (self identity-matrix) &rest args)
(declare (ignore args new-value))
(request-identity-filled self)
(change-class (call-next-method) 'matrix))
;-----
(defmethod (setf eref) (new-value (self identity-matrix) &rest args)
;;(declare (ignore args new-value))
(when (or (null args)
(and (= (length args) 2)
(if (apply #'= args)
(/= new-value 1)
(/= new-value 0)))
)
(Quail-error "Cannot set the ~s element of an identity matrix to ~s."
args new-value))
new-value)
(qk::put-return-class 'matrix
'identity-matrix
'(inverse-matrix matrix num-array ref-array
vector sequence list array number
;;integer fixnum rational float complex
symbol))
(defmethod inverse ((self identity-matrix))
self)
(defmethod tp ((self identity-matrix) &key perm)
(declare (ignore perm))
self)
| 7,880 | Common Lisp | .l | 209 | 26.110048 | 84 | 0.461417 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 35f8091675357b8c3544adaff9deddc8b12a285a4eda42b7d361fa3d5aa6d225 | 33,341 | [
-1
] |
33,342 | dgbco.lsp | rwoldford_Quail/source/linear/dgbco.lsp | (in-package :q)
(defun dgbco-hook (abd lda n ml mu ipvt rcond z)
;; (declare (type (simple-array double-float (*)) z))
(declare (type double-float rcond))
;; (declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum mu))
(declare (type fixnum ml))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((wkm 0.0d0) (wk 0.0d0) (t_ 0.0d0) (ek 0.0d0) (ynorm 0.0d0)
(sm 0.0d0) (s 0.0d0) (anorm 0.0d0) (mm 0d0) (m 0) (lz 0) (lm 0)
(la 0) (l 0) (kp1 0) (kb 0) (k 0) (ju 0) (j 0) (info 0) (is 0))
(declare (type fixnum is))
(declare (type fixnum info))
(declare (type fixnum j))
(declare (type fixnum ju))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum kp1))
(declare (type fixnum l))
(declare (type fixnum la))
(declare (type fixnum lm))
(declare (type fixnum lz))
(declare (type fixnum m))
(declare (type fixnum mm))
(declare (type double-float anorm))
(declare (type double-float s))
(declare (type double-float sm))
(declare (type double-float ynorm))
(declare (type double-float ek))
(declare (type double-float t_))
(declare (type double-float wk))
(declare (type double-float wkm))
(declare (special *dummy_var*))
;;
;; dgbco factors a double precision band matrix by gaussian
;; elimination and estimates the condition of the matrix.
;;
;; if rcond is not needed, dgbfa is slightly faster.
;; to solve a*x = b , follow dgbco by dgbsl.
;; to compute inverse(a)*c , follow dgbco by dgbsl.
;; to compute determinant(a) , follow dgbco by dgbdi.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; contains the matrix in band storage. the columns
;; of the matrix are stored in the columns of abd and
;; the diagonals of the matrix are stored in rows
;; ml+1 through 2*ml+mu+1 of abd .
;; see the comments below for details.
;;
;; lda integer
;; the leading dimension of the array abd .
;; lda must be .ge. 2*ml + mu + 1 .
;;
;; n integer
;; the order of the original matrix.
;;
;; ml integer
;; number of diagonals below the main diagonal.
;; 0 .le. ml .lt. n .
;;
;; mu integer
;; number of diagonals above the main diagonal.
;; 0 .le. mu .lt. n .
;; more efficient if ml .le. mu .
;;
;; on return
;;
;; abd an upper triangular matrix in band storage and
;; the multipliers which were used to obtain it.
;; the factorization can be written a = l*u where
;; l is a product of permutation and unit lower
;; triangular matrices and u is upper triangular.
;;
;; ipvt integer(n)
;; an integer vector of pivot indices.
;;
;; rcond double precision
;; an estimate of the reciprocal condition of a .
;; for the system a*x = b , relative perturbations
;; in a and b of size epsilon may cause
;; relative perturbations in x of size epsilon/rcond .
;; if rcond is so small that the logical expression
;; 1.0 + rcond .eq. 1.0
;; is true, then a may be singular to working
;; precision. in particular, rcond is zero if
;; exact singularity is detected or the estimate
;; underflows.
;;
;; z double precision(n)
;; a work vector whose contents are usually unimportant.
;; if a is close to a singular matrix, then z is
;; an approximate null vector in the sense that
;; norm(a*z) = rcond*norm(a)*norm(z) .
;;
;; band storage
;;
;; if a is a band matrix, the following program segment
;; will set up the input.
;;
;; ml = (band width below the diagonal)
;; mu = (band width above the diagonal)
;; m = ml + mu + 1
;; do 20 j = 1, n
;; i1 = max0(1, j-mu)
;; i2 = min0(n, j+ml)
;; do 10 i = i1, i2
;; k = i - j + m
;; abd(k,j) = a(i,j)
;; 10 continue
;; 20 continue
;;
;; this uses rows ml+1 through 2*ml+mu+1 of abd .
;; in addition, the first ml rows in abd are used for
;; elements generated during the triangularization.
;; the total number of rows needed in abd is 2*ml+mu+1 .
;; the ml+mu by ml+mu upper left triangle and the
;; ml by ml lower right triangle are not referenced.
;;
;; example.. if the original matrix is
;;
;; 11 12 13 0 0 0
;; 21 22 23 24 0 0
;; 0 32 33 34 35 0
;; 0 0 43 44 45 46
;; 0 0 0 54 55 56
;; 0 0 0 0 65 66
;;
;; then n = 6, ml = 1, mu = 2, lda .ge. 5 and abd should contain
;;
;; * * * + + + , * = not used
;; * * 13 24 35 46 , + = used for pivoting
;; * 12 23 34 45 56
;; 11 22 33 44 55 66
;; 21 32 43 54 65 *
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; linpack dgbfa
;; blas daxpy,ddot,dscal,dasum
;; fortran dabs,dmax1,max0,min0,dsign
;;
;; internal variables
;;
;;
;;
;; compute 1-norm of a
;;
(setf anorm 0.0d0)
(setf l (1+ ml))
(setf is (+ l mu))
(fdo (j 1 (1+ j))
((> j n) nil)
(tagbody (setf anorm (dmax1 anorm (dasum-hook l (vec-ref abd is j) 1)))
(if (> is (1+ ml)) (setf is (1- is)))
(if (<= j mu) (setf l (1+ l)))
(if (>= j (- n ml)) (setf l (1- l)))))
;;
;; factor
;;
(multiple-value-setq (*dummy_var* lda n ml mu *dummy_var* info)
(dgbfa-hook abd lda n ml mu ipvt info))
;;
;; rcond = 1/(norm(a)*(estimate of norm(inverse(a)))) .
;; estimate = norm(z)/norm(y) where a*z = y and trans(a)*y = e .
;; trans(a) is the transpose of a . the components of e are
;; chosen to cause maximum local growth in the elements of w where
;; trans(u)*w = e . the vectors are frequently rescaled to avoid
;; overflow.
;;
;; solve trans(u)*w = e
;;
(setf ek 1.0d0)
(fdo (j 1 (1+ j)) ((> j n) nil)
(tagbody (setf (fref z j) 0.0)))
(setf m (+ ml mu 1))
(setf ju 0)
(fdo (k 1 (1+ k))
((> k n) nil)
(tagbody (if (/= (fref z k) 0.0)
(setf ek (dsign ek (- (fref z k)))))
(if (<= (dabs (- ek (fref z k)))
(dabs (fref abd m k)))
(go label30))
(setf s
(f2cl/ (dabs (fref abd m k))
(dabs (- ek (fref z k)))))
(dscal-hook n s z 1)
(setf ek (* s ek))
label30 (setf wk (- ek (fref z k)))
(setf wkm (- (- ek) (fref z k)))
(setf s (dabs wk))
(setf sm (dabs wkm))
(if (= (fref abd m k) 0.0) (go label40))
(setf wk (f2cl/ wk (fref abd m k)))
(setf wkm (f2cl/ wkm (fref abd m k)))
(go label50)
label40 (setf wk 1.0d0)
(setf wkm 1.0d0)
label50 (setf kp1 (1+ k))
(setf ju (min0 (max0 ju (+ mu (fref ipvt k))) n))
(setf mm m)
(if (> kp1 ju) (go label90))
(fdo (j kp1 (1+ j))
((> j ju) nil)
(tagbody (setf mm (1- mm))
(setf sm
(+
sm
(dabs
(+
(fref z j)
(* wkm (fref abd mm j))))))
(setf (fref z j)
(+
(fref z j)
(* wk (fref abd mm j))))
(setf s (+ s (dabs (fref z j))))))
(if (>= s sm) (go label80))
(setf t_ (- wkm wk))
(setf wk wkm)
(setf mm m)
(fdo (j kp1 (1+ j))
((> j ju) nil)
(tagbody (setf mm (1- mm))
(setf (fref z j)
(+
(fref z j)
(* t_ (fref abd mm j))))))
label80 label90 (setf (fref z k) wk)))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
;;
;; solve trans(l)*y = w
;;
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (+ n 1 (- kb)))
(setf lm (min0 ml (- n k)))
(if (< k n)
(setf (fref z k)
(+ (fref z k)
(ddot-hook lm (vec-ref abd (1+ m) k) 1
(vec-ref z (1+ k)) 1))))
(if (<= (dabs (fref z k)) 1.0) (go label110))
(setf s (f2cl/ 1.0 (dabs (fref z k))))
(dscal-hook n s z 1)
label110 (setf l (fref ipvt k))
(setf t_ (fref z l))
(setf (fref z l) (fref z k))
(setf (fref z k) t_)))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
;;
(setf ynorm 1.0d0)
;;
;; solve l*v = y
;;
(fdo (k 1 (1+ k))
((> k n) nil)
(tagbody (setf l (fref ipvt k))
(setf t_ (fref z l))
(setf (fref z l) (fref z k))
(setf (fref z k) t_)
(setf lm (min0 ml (- n k)))
(if (< k n)
(daxpy-hook lm t_ (vec-ref abd (1+ m) k) 1
(fref z (1+ k)) 1))
(if (<= (dabs (fref z k)) 1.0) (go label130))
(setf s (f2cl/ 1.0d0 (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label130))
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
;;
;; solve u*z = w
;;
(fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (+ n 1 (- kb)))
(if (<= (dabs (fref z k)) (dabs (fref abd m k)))
(go label150))
(setf s (f2cl/ (dabs (fref abd m k)) (dabs (fref z k))))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
label150 (if (/= (fref abd m k) 0.0)
(setf (fref z k) (f2cl/ (fref z k) (fref abd m k))))
(if (= (fref abd m k) 0.0) (setf (fref z k) 1.0))
(setf lm (1- (min0 k m)))
(setf la (- m lm))
(setf lz (- k lm))
(setf t_ (- (fref z k)))
(daxpy-hook lm t_ (vec-ref abd la k) 1 (vec-ref z lz) 1)))
;; make znorm = 1.0
(setf s (f2cl/ 1.0d0 (dasum-hook n z 1)))
(dscal-hook n s z 1)
(setf ynorm (* s ynorm))
;;
(if (/= anorm 0.0d0)
(setf rcond (f2cl/ ynorm anorm))
(setf rcond 0.0d0))
(return (values abd lda n ml mu ipvt rcond z))))
| 14,162 | Common Lisp | .l | 310 | 30.258065 | 85 | 0.369223 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 8b882eef31ede17539f2688ee7ed20e40456537f8a60cde9f62c2ac14ab79f9d | 33,342 | [
-1
] |
33,343 | rank.lsp | rwoldford_Quail/source/linear/rank.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; rank.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(rank-of)))
(defgeneric rank-of (thing &key &allow-other-keys)
(:documentation "Determines and returns the rank of its argument. ~
For some methods different keywords may be applicable."
))
(defmethod rank-of ((X T) &key &allow-other-keys)
(missing-method 'rank-of X))
(defmethod rank-of ((x identity-matrix) &key &allow-other-keys)
(nrows x))
(defmethod rank-of ((X matrix) &key (tolerance NIL))
"Returns the numerical rank of X as determined by the number of~
its non-zero singular-values. If a positive number tolerance is given, ~
then the ~
rank is defined to be the number of singular-values greater than ~
tolerance. ~
(:see-also (singular-values-of :generic-function) ~
)"
(unless (and (numberp tolerance) (cl:> tolerance 0))
(setf tolerance 0))
(let ((rank 0)
(svs (singular-values-of X)))
(loop
for i
from 0 below (number-of-elements svs)
when (cl:> (eref svs i) tolerance)
do (incf rank))
rank))
(defmethod rank-of ((X sv-decomposition) &key (tolerance NIL))
"Returns the numerical rank of X as determined by the number of~
its non-zero singular-values. If a positive number tolerance is given, ~
then the ~
rank is defined to be the number of singular-values greater than ~
tolerance. ~
(:see-also (singular-values-of :generic-function) ~
)"
(unless (and (numberp tolerance) (cl:> tolerance 0))
(setf tolerance 0))
(let ((rank 0)
(svs (singular-values-of X)))
(loop
for i
from 0 below (number-of-elements svs)
when (cl:> (eref svs i) tolerance)
do (incf rank))
rank)
)
(defmethod rank-of ((qrd qr-decomposition) &key (tolerance NIL))
"Returns the numerical rank of the original matrix ~
from its QR decomposition. It does this by counting the number ~
of diagonal elements of the triangular R matrix ~
that are greater than 0. ~
If a positive number tolerance is given, ~
then the rank is defined to be the number greater than ~
tolerance. "
(unless (and (numberp tolerance)
(cl:> tolerance 0))
(setf tolerance 0))
(with-slots (qr) qrd
(let ((p (second (dimensions-of qr))))
(if p
(loop
for i from 0 to (1- p)
count (cl:>
(cl:abs (eref qr i i))
tolerance))
1))))
(defmethod rank-of ((lu lu-decomposition) &key (tolerance NIL))
"Returns the numerical rank of the original matrix ~
from its lu decomposition. It does this by counting the number ~
of diagonal elements of the upper triangular matrix U ~
that are greater than 0. ~
If a positive number tolerance is given, ~
then the rank is defined to be the number greater than ~
tolerance. "
(unless (and (numberp tolerance)
(cl:> tolerance 0))
(setf tolerance 0))
(let* ((u (lu-of lu))
(p (second (dimensions-of u))))
(if p
(loop
for i from 0 below p
count (cl:>
(cl:abs (eref u i i))
tolerance))
1)
))
(defmethod rank-of ((c cholesky-decomposition) &key (tolerance NIL))
"Returns the numerical rank of the original matrix ~
from its Cholesky decomposition. It does this by querying the ~
info on the decomposition when the tolerance is zero. ~
When the tolerance is > 0, it tries to determine the rank ~
by counting the number ~
of diagonal elements of the upper triangular matrix R ~
that are greater than the tolerance where this is legitimate. ~
If the operation is known to be illegitimate then NaN is returned and ~
the user warned. "
(unless (and (numberp tolerance)
(cl:> tolerance 0))
(setf tolerance 0))
(cond
((jpvt-of c)
;; have a pivoted cholesky
(if (zerop tolerance)
(info-of c)
(let ((r (upper-triangle-of c))
(count 0))
(loop for i from 0 below (nrows r)
when (cl::> (eref r i i) tolerance)
do (incf count))
(min (info-of c) count)))
)
;; else an unpivoted cholesky
((zerop (info-of c))
(if (zerop tolerance)
(nrows (upper-triangle-of c))
(let ((r (upper-triangle-of c)))
(loop for i from 0 below (nrows r)
count (cl::> (eref r i i) tolerance))
))
)
(T (warn "Could not determine the rank from this Cholesky ~
decomposition. ~&Returning NaN.")
NaN)
)
)
| 5,183 | Common Lisp | .l | 143 | 29.545455 | 81 | 0.579094 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | aede12ba4304714ddb4cca6faaa13a83d85d380cc6d645e73c12e286b8b074ca | 33,343 | [
-1
] |
33,344 | dtrdi.lsp | rwoldford_Quail/source/linear/dtrdi.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dtrdi-hook (t_ ldt n det job info)
;(declare (type fixnum info))
(declare (type fixnum job))
;(declare (type (simple-array double-float (*)) det))
(declare (type fixnum n))
(declare (type fixnum ldt))
;(declare (type (simple-array double-float (* *)) t_))
(prog ((temp 0.0d0) (kp1 0) (km1 0) (kb 0) (k 0) (j 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum j))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum km1))
(declare (type fixnum kp1))
(declare (type double-float temp))
(if (= (f2cl/ job 100) 0) (go label70))
(setf (fref det 1) 1.0)
(setf (fref det 2) 0.0)
(fdo (i 1 (+ i 1))
((> i n) nil)
(tagbody (setf (fref det 1) (* (fref t i i) (fref det 1)))
(if (= (fref det 1) 0.0) (go label60))
label10 (if (>= (dabs (fref det 1)) 1.0) (go label20))
(setf (fref det 1) (* 10.0 (fref det 1)))
(setf (fref det 2) (- (fref det 2) 1.0))
(go label10)
label20 label30 (if (< (dabs (fref det 1)) 10.0) (go label40))
(setf (fref det 1) (f2cl/ (fref det 1) 10.0))
(setf (fref det 2) (+ (fref det 2) 1.0))
(go label30)
label40))
label60
label70 (if (= (mod (f2cl/ job 10) 10) 0) (go label170))
(if (= (mod job 10) 0) (go label120))
(fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf (fref info 1) k)
(if (= (fref t_ k k) 0.0) (go label110))
(setf (fref t k k) (f2cl/ 1.0 (fref t k k)))
(setf temp (- (fref t_ k k)))
(dscal-hook (- k 1) temp (vec-ref t_ 1 k) 1)
(setf kp1 (+ k 1))
(if (< n kp1) (go label90))
(fdo (j kp1 (+ j 1))
((> j n) nil)
(tagbody (setf temp (fref t_ k j))
(setf (fref t k j) 0.0)
(daxpy-hook k temp (vec-ref t_ 1 k) 1 (vec-ref t_ 1 j) 1)))
label90))
(setf (fref info 1) 0)
label110 (go label160)
label120 (fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (+ n 1 (- kb)))
(setf (fref info 1) k)
(if (= (fref t_ k k) 0.0) (go label180))
(setf (fref t k k) (f2cl/ 1.0 (fref t k k)))
(setf temp (- (fref t_ k k)))
(if (/= k n)
(dscal-hook (- n k) temp (vec-ref t_ (+ k 1) k) 1))
(setf km1 (+ k (- 1)))
(if (< km1 1) (go label140))
(fdo (j 1 (+ j 1))
((> j km1) nil)
(tagbody (setf temp (fref t_ k j))
(setf (fref t k j) 0.0)
(daxpy-hook (+ n (- k) 1) temp
(vec-ref t_ k k) 1
(vec-ref t_ k j) 1)))
label140))
(setf (fref info 1) 0)
label160 label170 label180 (return (values t_ ldt n det job info))))
| 3,600 | Common Lisp | .l | 74 | 29.986486 | 96 | 0.377841 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | fcd0970c26c7d329a94a5bf98b81050400819874bfc78208ba6cbcf81a87174f | 33,344 | [
-1
] |
33,345 | pivot.lsp | rwoldford_Quail/source/linear/pivot.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; pivot.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(pivot-in-place unpivot-in-place)))
(defgeneric pivot-in-place (unpivoted-matrix pivots)
(:documentation
"Returns a matrix whose columns are selected
from unpivoted-matrix in the order given by
pivots. The column numbers in pivots
start with 1 for the first column, not 0.
The computations are done in place, i.e.
the unpivoted-matrix is modified to become pivoted."))
(defgeneric unpivot-in-place (pivoted-matrix pivots)
(:documentation
"The inverse of pivot-in-place.
The column numbers in pivots
start with 1 for the first column, not 0.
The computations are done in place, i.e.
the pivoted-matrix is modified to become unpivoted."))
;;; should try this using with-ref !!
(defmethod-multi-one-body pivot-in-place
((the-matrix (vector array matrix)) pivots)
(let ((unpivoted (sel the-matrix))
(cols (first (dimensions-of pivots))))
(loop for i from 0 to (- cols 1)
do (setf (ref-variable the-matrix i)
(ref-variable unpivoted (- (eref pivots i) 1))))
the-matrix))
(defmethod-multi-one-body unpivot-in-place
((the-matrix (vector array matrix)) pivots)
(let ((pivoted (sel the-matrix))
(cols (first (dimensions-of pivots))))
(loop for i from 0 to (- cols 1)
do (setf (ref-variable the-matrix (- (eref pivots i) 1))
(ref-variable pivoted i)))
the-matrix))
| 2,007 | Common Lisp | .l | 50 | 34.9 | 100 | 0.559959 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | c2bb24867f17cc6c156b449da2b618326f35671190e391da41a7121b2f54b7ba | 33,345 | [
-1
] |
33,346 | triangular.lsp | rwoldford_Quail/source/linear/triangular.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; triangular.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(upper-triangle-of backsolve)))
(defgeneric upper-triangle-of (X)
(:documentation "Returns an upper triangular square matrix whose ~
non-zero elements have been copied from the upper ~
triangular portion of X.")
)
(defmethod upper-triangle-of ((X matrix))
(let* ((size (ncols X))
(result (sel X (iseq size) (iseq size))))
(loop
for i from 0 below size
do
(loop
for j from 0 below i
do
(setf (eref result i j) 0)))
result))
(defun backsolve (x y &key transpose upper)
"Solves triangular linear systems of the form xb = y or zb = y where ~
z is the transpose of x. Returns b. ~&~
By default, x is lower triangular and is not ~
transposed. If transpose is non-nil, the transpose of x is used. If ~
upper is non-nil, x is taken to be upper triangular. Elements of x ~
outside of the triangular portion of interest are ASSUMED to be zero, ~
regardless of their actual values."
(let* ((job 00)
(n (first (dimensions-of x)))
(b (sel y))
(info (array 0 :dimensions '(1))))
(if transpose (incf job 10))
(if upper (incf job 1))
(dtrsl x n b job info)
b))
#|
;-----
(defclass upper-triangular-matrix (matrix)
())
(put-return-class 'matrix
'upper-triangular-matrix
'(matrix array vector cons integer rational float symbol))
(defmethod make-upper-triangular-matrix ((self matrix))
(change-class self 'upper-triangular-matrix))
;-----
(defmethod eref :around ((self upper-triangular-matrix) &rest index)
(let ((i (first index))
(j (second index)))
(if (> i j) 0 (call-next-method))))
(defmethod (setf eref) :around
(new-value (self upper-triangular-matrix) &rest index)
(let ((i (first index))
(j (second index)))
(if (> i j) 0 (call-next-method))))
;-----
(defmethod ref :around ((self dimensioned-ref-object) &rest args)
(multiple-value-bind (subscripts shape)
(interpret args '(:shape))
(if (null subscripts)
self
(call-next-method))))
|#
| 2,864 | Common Lisp | .l | 78 | 29.769231 | 96 | 0.537698 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 8d5cfea01d9f17a95445a5425ca2828e66f01d269cb22da80eabca77ad82b277 | 33,346 | [
-1
] |
33,347 | dgbdi.lsp | rwoldford_Quail/source/linear/dgbdi.lsp | (in-package :q)
(defun dgbdi-hook (abd lda n ml mu ipvt det)
;; (declare (type (simple-array double-float (*)) det))
;; (declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum mu))
(declare (type fixnum ml))
(declare (type fixnum n))
(declare (type fixnum lda))
;; (declare (type (simple-array double-float (* *)) abd))
(prog ((m 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum m))
;;
;; dgbdi computes the determinant of a band matrix
;; using the factors computed by dgbco or dgbfa.
;; if the inverse is needed, use dgbsl n times.
;;
;; on entry
;;
;; abd double precision(lda, n)
;; the output from dgbco or dgbfa.
;;
;; lda integer
;; the leading dimension of the array abd .
;;
;; n integer
;; the order of the original matrix.
;;
;; ml integer
;; number of diagonals below the main diagonal.
;;
;; mu integer
;; number of diagonals above the main diagonal.
;;
;; ipvt integer(n)
;; the pivot vector from dgbco or dgbfa.
;;
;; on return
;;
;; det double precision(2)
;; determinant of original matrix.
;; determinant = det(1) * 10.0**det(2)
;; with 1.0 .le. dabs(det(1)) .lt. 10.0
;; or det(1) = 0.0 .
;;
;; linpack. this version dated 08/14/78 .
;; cleve moler, university of new mexico, argonne national lab.
;;
;; subroutines and functions
;;
;; fortran dabs
;;
;; internal variables
;;
;;
;;
(setf m (+ ml mu 1))
(setf (fref det 1) 1.0)
(setf (fref det 2) 0.0)
(fdo (i 1 (1+ i))
((> i n) nil)
(tagbody (if (/= (fref ipvt i) i)
(setf (fref det 1) (- (fref det 1))))
(setf (fref det 1) (* (fref abd m i) (fref det 1)))
;; ...exit
(if (= (fref det 1) 0.0) (go label60))
label10 (if (>= (dabs (fref det 1)) 1.0) (go label20))
(setf (fref det 1) (* 10.0 (fref det 1)))
(setf (fref det 2) (1- (fref det 2)))
(go label10)
label20 label30 (if (< (dabs (fref det 1)) 10.0) (go label40))
(setf (fref det 1) (f2cl/ (fref det 1) 10.0))
(setf (fref det 2) (1+ (fref det 2)))
(go label30)
label40))
label60 (return (values abd lda n ml mu ipvt det))))
| 3,086 | Common Lisp | .l | 76 | 28.973684 | 77 | 0.414172 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 3fdbef846aa182ea970c01b429c25a3d247787d5b5c46554e2d75ebf26cfdf2f | 33,347 | [
-1
] |
33,348 | solve.lsp | rwoldford_Quail/source/linear/solve.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; solve.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(solve)))
;-------------------------------------------------------------------------------
; GENERIC FUNCTION: solve
;-------------------------------------------------------------------------------
(defgeneric solve (x y &key &allow-other-keys)
(:documentation
"Consider the linear system Xb = y. ~
Given both X and y, solve calculates and returns the solution b. ~
If X is given, but y is null or an identity matrix, ~
then solve returns the inverse of X. ~
(:see-also (inverse :generic-function) (backsolve :function) ~
(matrix-decompositions :topic))"
))
(defmethod solve ((x t) y &key &allow-other-keys)
(missing-method 'solve x y))
(defmethod solve :before ((x matrix) y &key &allow-other-keys)
(if y
(unless (= (nrows X) (nrows y))
(quail-error "Number of rows of ~s does not equal number of ~
rows of ~s." x y))
)
)
(defmethod solve :around ((x lu-decomposition) (y identity-matrix)
&key &allow-other-keys)
(if (= (nrows (lu-of x))
(nrows y))
(inverse x)
(quail-error "Solve: Dimensions don't match ~&~
~5Tx = ~s ~&~
~5Ty = ~s."
x y)))
(defmethod solve :around ((x lu-decomposition) (y (eql NIL)) &key &allow-other-keys)
(inverse x))
(defmethod solve ((lu lu-decomposition) y &key &allow-other-keys)
"Given an lu-decomposition lu and y, solve returns b such that LUb = y. ~
If y is not given, then solve calls inverse on lu. ~
(:see-also lud-of inverse)"
(if (= 1.0 (+ 1.0 (eref (rcond-of lu))))
(quail-error "Matrix is singular to working precision.")
(let* ((a (lu-of lu))
(ipvt (ipvt-of lu))
(b (sel y))
(job 0))
(dgels a ipvt b job)
b))
)
(defmethod solve ((chol cholesky-decomposition) y &key &allow-other-keys)
"Given a Cholesky-decomposition chol and y, solve returns b such that ~
A .* tp(A) b = y. ~
If y is not given, then solve calls inverse on chol. ~
(:see-also cholesky-of inverse)"
(if (and (rcond-of chol)
(= 1.0 (+ 1.0 (eref (rcond-of chol)))))
(quail-error "Matrix is singular to working precision.")
(if (jpvt-of chol)
;; a pivoted cholesky
(quail-error
"Solve not yet implemented for a pivoted Cholesky decomposition.~
~&Try using an unpivoted decomposition first.")
(let* ((a (upper-triangle-of chol)))
(if y
(backsolve a (backsolve a y :upper T)
:upper T
:transpose T)
(inverse chol)))
)))
(defmethod solve :around ((x matrix) (y identity-matrix)
&key
&allow-other-keys)
(if (= (nrows x)
(nrows y))
(inverse x)
(quail-error "Solve: Dimensions don't match ~&~
~5Tx = ~s ~&~
~5Ty = ~s."
x y)))
(defmethod solve :around ((x matrix) (y (eql NIL))
&key
&allow-other-keys)
(inverse x))
(defmethod solve ((x matrix) y &rest keyword-args &key (qr? NIL) &allow-other-keys)
"Given X and y, solve returns two values, the first of which is ~
b such that Xb = y. ~
First if x is square and qr? NIL, ~
an lu-decomposition is used to solve the system ~
and the second value returned is NIL.~
In the non-square case, the least squares solution (unpivoted) is found ~
via a QR decomposition of X and returned as the first value. ~
The second value will be an instance of qr-solution which contains other ~
information such as the residuals, etc. ~
(:key ~
(:arg qr? NIL If non-NIL, the solution is forced to be via a QR ~
decomposition. In this case the keyword arguments from qrd-of and ~
solve from a qr-solution will be relevant.) ~
)~
(:rest (:arg keyword-args These are keyword arguments that might be ~
used in the non-square case and are passed directly on to both ~
qrd-of and solve with a qr-decomposition. ) ~
)~
(:see-also (solve :generic-function) (lud-of :generic-function) ~
(qrd-of :generic-function) (qr-solution :class))"
(if (and (not qr?) (= (nrows x) (ncols x)))
(values (solve (lud-of x) y) NIL)
(let* ((qrd (apply #'qrd-of X keyword-args))
(pivot (pivoted-p qrd))
(jpvt (jpvt-of qrd))
coef
qrs)
(multiple-value-setq (coef qrs)
(apply #'solve qrd y keyword-args))
(if (and coef pivot)
(setf coef (unpivot-in-place (sel coef) jpvt)))
(values coef qrs)
)
)
)
| 5,339 | Common Lisp | .l | 134 | 32.201493 | 85 | 0.529878 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | aec29564b40bdcad72b170ae3f1d9e40b8956daa796957c9bbd0929159f51a6c | 33,348 | [
-1
] |
33,349 | dgesl.lsp | rwoldford_Quail/source/linear/dgesl.lsp | (in-package :q)
(defun dgesl-hook (a lda n ipvt b job)
(declare (type fixnum job))
;;(declare (type (simple-array double-float (*)) b))
;;(declare (type (simple-array fixnum (*)) ipvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;;(declare (type (simple-array double-float (* *)) a))
(prog ((t_ 0.0d0) (nm1 0) (l 0) (kb 0) (k 0))
(declare (type fixnum k))
(declare (type fixnum kb))
(declare (type fixnum l))
(declare (type fixnum nm1))
(declare (type double-float t_))
(setf nm1 (- n 1))
(if (/= job 0) (go label50))
(if (< nm1 1) (go label30))
(fdo (k 1 (+ k 1))
((> k nm1) nil)
(tagbody (setf l (fref ipvt k))
(setf t_ (fref b l))
(if (= l k) (go label10))
(setf (fref b l) (fref b k))
(setf (fref b k) t_)
label10 (daxpy-hook (- n k) t_ (vec-ref a (+ k 1) k) 1
(vec-ref b (+ k 1)) 1)))
label30 (fdo (kb 1 (+ kb 1))
((> kb n) nil)
(tagbody (setf k (- (+ n 1) kb))
(setf (fref b k) (f2cl/ (fref b k) (fref a k k)))
(setf t_ (- (fref b k)))
(daxpy-hook (- k 1) t_ (vec-ref a 1 k) 1 (vec-ref b 1)
1)))
(go label100)
label50 (fdo (k 1 (+ k 1))
((> k n) nil)
(tagbody (setf t_
(ddot-hook (- k 1) (vec-ref a 1 k) 1 (vec-ref b 1)
1))
(setf (fref b k) (f2cl/ (- (fref b k) t_) (fref a k k)))))
(if (< nm1 1) (go label90))
(fdo (kb 1 (+ kb 1))
((> kb nm1) nil)
(tagbody (setf k (- n kb))
(setf (fref b k)
(+ (fref b k)
(ddot-hook (- n k) (vec-ref a (+ k 1) k) 1 (vec-ref b (+ k 1))
1)))
(setf l (fref ipvt k))
(if (= l k) (go label70))
(setf t_ (fref b l))
(setf (fref b l) (fref b k))
(setf (fref b k) t_)
label70))
label90 label100 (return (values a lda n ipvt b job))))
| 2,375 | Common Lisp | .l | 55 | 27.690909 | 90 | 0.383851 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 4a62179fbe14ec2f4119b177d6716b5284ce70147f168ecb7e0b0b79304199bb | 33,349 | [
-1
] |
33,350 | dscal.lsp | rwoldford_Quail/source/linear/dscal.lsp | (in-package :q)
(defun dscal-hook (n da dx incx)
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type double-float da))
(declare (type fixnum n))
(prog ((nincx 0) (mp1 0) (m 0) (i 0))
(declare (type fixnum i))
(declare (type fixnum m))
(declare (type fixnum mp1))
(declare (type fixnum nincx))
(if (<= n 0) (go end_label))
(if (= incx 1) (go label20))
(setf nincx (* n incx))
(fdo (i 1 (+ i incx))
((> i nincx) nil)
(tagbody (setf (fref dx i) (* da (fref dx i)))))
(go end_label)
label20 (setf m (mod n 5))
(if (= m 0) (go label40))
(fdo (i 1 (+ i 1))
((> i m) nil)
(tagbody (setf (fref dx i) (* da (fref dx i)))))
(if (< n 5) (go end_label))
label40 (setf mp1 (+ m 1))
(fdo (i mp1 (+ i 5))
((> i n) nil)
(tagbody
(setf (fref dx i) (* da (fref dx i)))
(setf (fref dx (+ i 1)) (* da (fref dx (+ i 1))))
(setf (fref dx (+ i 2)) (* da (fref dx (+ i 2))))
(setf (fref dx (+ i 3)) (* da (fref dx (+ i 3))))
(setf (fref dx (+ i 4)) (* da (fref dx (+ i 4))))))
(go end_label)
end_label (return (values n da dx incx))))
| 1,346 | Common Lisp | .l | 35 | 29.371429 | 62 | 0.454476 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 6b9cb035f5bc6d2b253990c1ded1898011f369187a16ae1a535edb616c6c5359 | 33,350 | [
-1
] |
33,351 | dqrls.lsp | rwoldford_Quail/source/linear/dqrls.lsp | (in-package :q)
(defun dqrls-hook (x ldx n k qraux y p m qy qty b rsd xb job info)
;;(declare (type fixnum info))
(declare (type fixnum job))
;;(declare (type (simple-array single-float (* *)) xb))
;;(declare (type (simple-array single-float (* *)) rsd))
;;(declare (type (simple-array single-float (* *)) b))
;;(declare (type (simple-array single-float (* *)) qty))
;;(declare (type (simple-array single-float (* *)) qy))
(declare (type fixnum m))
(declare (type fixnum p))
;;(declare (type (simple-array single-float (* *)) y))
;;(declare (type (simple-array single-float (*)) qraux))
(declare (type fixnum k))
(declare (type fixnum n))
(declare (type fixnum ldx))
;;(declare (type (simple-array single-float (* *)) x))
(prog ((j 0))
(declare (type fixnum j))
(fdo (j 1 (+ j 1))
((> j m) nil)
(tagbody (dqrsl-hook x ldx n k qraux (vec-ref y 1 j) (vec-ref qy 1 j)
(vec-ref qty 1 j) (vec-ref b 1 j) (vec-ref rsd 1 j)
(vec-ref xb 1 j) job info)
(if (/= (fref info 1) 0.0) (go label20))))
label20 (return (values x ldx n k qraux y p m qy qty b rsd xb job info))))
| 1,241 | Common Lisp | .l | 26 | 39.846154 | 83 | 0.556565 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | d50d5d170c1fd3ec7784d2100779413520a17929799642632c2569949424aa09 | 33,351 | [
-1
] |
33,352 | dsisl.lsp | rwoldford_Quail/source/linear/dsisl.lsp | ;;; not yet tested. CW.
(in-package :q)
(defun dsisl-hook (a lda n kpvt b)
;(declare (type (simple-array double-float (*)) b))
;(declare (type (simple-array fixnum (*)) kpvt))
(declare (type fixnum n))
(declare (type fixnum lda))
;(declare (type (simple-array double-float (* *)) a))
(prog ((temp 0.0d0) (denom 0.0d0) (bkm1 0.0d0) (bk 0.0d0) (akm1 0.0d0)
(ak 0.0d0) (kp 0) (k 0))
(declare (type fixnum k))
(declare (type fixnum kp))
(declare (type double-float ak))
(declare (type double-float akm1))
(declare (type double-float bk))
(declare (type double-float bkm1))
(declare (type double-float denom))
(declare (type double-float temp))
(setf k n)
label10 (if (= k 0) (go label80))
(if (< (fref kpvt k) 0) (go label40))
(if (= k 1) (go label30))
(setf kp (fref kpvt k))
(if (= kp k) (go label20))
(setf temp (fref b k))
(setf (fref b k) (fref b kp))
(setf (fref b kp) temp)
label20 (daxpy-hook (- k 1) (fref b k) (vec-ref a 1 k) 1 (vec-ref b 1) 1)
(setf (fref b k) (f2cl/ (fref b k) (fref a k k)))
label30 (setf k (- k 1))
(go label70)
label40 (if (= k 2) (go label60))
(setf kp (iabs (fref kpvt k)))
(if (= kp (- k 1)) (go label50))
(setf temp (fref b (- k 1)))
(setf (fref b (- k 1)) (fref b kp))
(setf (fref b kp) temp)
label50 (daxpy-hook (- k 2) (fref b k) (vec-ref a 1 k) 1 (vec-ref b 1) 1)
(daxpy-hook (- k 2) (fref b (- k 1)) (vec-ref a 1 (- k 1)) 1
(vec-ref b 1) 1)
label60 (setf ak (f2cl/ (fref a k k) (fref a (- k 1) k)))
(setf akm1
(f2cl/ (fref a (- k 1) (- k 1)) (fref a (- k 1) k)))
(setf bk (f2cl/ (fref b k) (fref a (- k 1) k)))
(setf bkm1 (f2cl/ (fref b (- k 1)) (fref a (- k 1) k)))
(setf denom (- (* ak akm1) 1.0d0))
(setf (fref b k) (f2cl/ (- (* akm1 bk) bkm1) denom))
(setf (fref b (- k 1)) (f2cl/ (- (* ak bkm1) bk) denom))
(setf k (- k 2))
label70 (go label10)
label80 (setf k 1)
label90 (if (> k n) (go label160))
(if (< (fref kpvt k) 0) (go label120))
(if (= k 1) (go label110))
(setf (fref b k) (+ (fref b k)
(ddot (- k 1) (vec-ref a 1 k) 1 (vec-ref b 1) 1)))
(setf kp (fref kpvt k))
(if (= kp k) (go label100))
(setf temp (fref b k))
(setf (fref b k) (fref b kp))
(setf (fref b kp) temp)
label100 label110 (setf k (+ k 1))
(go label150)
label120 (if (= k 1) (go label140))
(setf (fref b k) (+ (fref b k)
(ddot (- k 1) (vec-ref a 1 k) 1 (vec-ref b 1) 1)))
(setf (fref b (+ k 1)) (+ (fref b (+ k 1))
(ddot (- k 1) (vec-ref a 1 (+ k 1)) 1 (vec-ref b 1) 1)))
(setf kp (iabs (fref kpvt k)))
(if (= kp k) (go label130))
(setf temp (fref b k))
(setf (fref b k) (fref b kp))
(setf (fref b kp) temp)
label130 label140 (setf k (+ k 2))
label150 (go label90)
label160 (return (values a lda n kpvt b))))
| 3,261 | Common Lisp | .l | 76 | 33.5 | 91 | 0.480969 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 9a04ea0776d2862ff0a84878f9e08a4b2fef8b386602ebd28026ced375e2bd48 | 33,352 | [
-1
] |
33,353 | sv-decomposition.lsp | rwoldford_Quail/source/linear/sv-decomposition.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; sv-decomposition.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1994.
;;;
;;;
;;;-----------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(sv-decomposition
svd-of
left-singular-vectors-of
right-singular-vectors-of
singular-values-of)))
(defgeneric left-singular-vectors-of (thing)
(:documentation
"Returns the left singular vectors of its argument. ~
(:see-also (svd-of :generic-function) ~
(sv-decomposition :topic) ) ~
(:examples (:files (sv decompositions ~
q:examples;arrays;matrices;decompositions;svd.lisp) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp) )~
)"
)
)
(defgeneric right-singular-vectors-of (thing)
(:documentation "Returns the right singular vectors of its argument. ~
(:see-also (svd-of :generic-function) ~
(sv-decomposition :topic) ) ~
(:examples (:files (sv decompositions ~
q:examples;arrays;matrices;decompositions;svd.lisp) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp) )~
)"
)
)
(defgeneric singular-values-of (thing)
(:documentation "Returns the singular values of its argument. ~
(:see-also (svd-of :generic-function) ~
(sv-decomposition :topic) ) ~
(:examples (:files (sv decompositions ~
q:examples;arrays;matrices;decompositions;svd.lisp) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp) )~
)"
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; CLASS: sv-decomposition
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass sv-decomposition (matrix-decomposition)
((singular-values
:initarg :singular-values
:reader singular-values-of
:initform NIL
:documentation
"Contains the vector of singular values in descending order.")
(left-singular-vectors
:initarg :left
:reader left-singular-vectors-of
:initform NIL
:documentation
"The matrix of left singular vectors.")
(right-singular-vectors
:initarg :right
:reader right-singular-vectors-of
:initform NIL
:documentation
"The matrix of right singular vectors.")
(diagonal
:initarg :diag
:initform NIL
:documentation
"If info is non-zero, then this contains the diagonal ~
of a bidiagonal matrix having the same singular values as the original ~
matrix. The super diagonal of this matrix is stored as the ~
slot super-diagonal."
)
(super-diagonal
:initarg :super-diag
:initform NIL
:documentation
"If info is non-zero, then this contains the super-diagonal ~
of a bidiagonal matrix having the same singular values as the original ~
matrix. The diagonal of this matrix is stored on the slot diagonal."
)
(start-index
:initarg :start-index
:initform 0
:documentation
"This is the start index of the singular-values that have been ~
successfully computed. If non-zero, the diagonal and super-diagonal ~
slots become of interest.")
)
(:documentation
"Return class for singular value decomposition. ~
Slot documentation is mostly from ~
the Linpack manual."))
;;; export slot names
;;;
(push-extension-class 'sv-decomposition)
;---------------------------------------------------------------------------
; GENERIC-FUNCTION: svd-of
;---------------------------------------------------------------------------
(defgeneric svd-of (x &key prompt-if-fail?)
(:documentation
"Determines the singular value decomposition of the matrix X. ~
That is, X is decomposed into the product of an orthogonal matrix U, ~
diagonal matrix D and the transpose of the orthogonal matrix V. ~
It is calculated using the LINPACK routine DSVDC which uses Householder ~
transformations to achieve this end. ~
Once calculated, the decomposition is cached on X so that it ~
need not be recalculated on subsequent calls. Note that the decomposition ~
might be dangerously out of date if the elements of X are changed after ~
the initial call (see clear-decompositions). ~
(:required ~
(:arg X A matrix having only strictly numerical non-complex elements.) ~
)~
(:key ~
(:arg prompt-if-fail? T If the algorithm fails to converge, should the ~
user be offered the opportunity to continue? Continuation will produce an ~
sv-decomposition object containing some of the singular values ~
together with the diagonal and super-diagonal of a bidiagonal matrix that ~
has the same singular values as X. These are stored as the slots of the same ~
name. If NIL, it is assumed that continuation is preferred.) ~
)~
(:returns An instance of the class sv-decomposition.)~
(:see-also (sv-decomposition :topic) (matrix-decomposition :topic) ~
(dsvdc :function)(clear-decompositions :function))~
(:examples (:files (sv decompositions ~
q:examples;arrays;matrices;decompositions;svd.lisp~
) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp~
) )~
)~
"
))
(defmethod svd-of ((x matrix) &key (prompt-if-fail? T))
"Determines the singular value decomposition of the matrix X. ~
That is, X is decomposed into the product of an orthogonal matrix U, ~
diagonal matrix D and the transpose of the orthogonal matrix V. ~
It is calculated using the LINPACK routine DSVDC which uses Householder ~
transformations to achieve this end. ~
Once calculated, the decomposition is cached on X so that it ~
need not be recalculated on subsequent calls. Note that the decomposition ~
might be dangerously out of date if the elements of X are changed after ~
the initial call (see clear-decompositions). ~
(:required ~
(:arg X A matrix having only strictly numerical non-complex elements.) ~
)~
(:key ~
(:arg prompt-if-fail? T If the algorithm fails to converge, should the ~
user be offered the opportunity to continue? Continuation will produce an ~
sv-decomposition object containing some of the singular values ~
together with the diagonal and super-diagonal of a bidiagonal matrix that ~
has the same singular values as X. These are stored as the slots of the same ~
name. If NIL, it is assumed that continuation is preferred.) ~
)~
(:returns An instance of the class sv-decomposition.)~
(:see-also (sv-decomposition :topic) (matrix-decomposition :topic) ~
(dsvdc :function)(clear-decompositions :function))~
(:examples (:files (sv decompositions ~
q:examples;arrays;matrices;decompositions;svd.lisp~
) ~
(Other decompositions ~
q:examples;arrays;matrices;decompositions;intro.lisp~
) )~
)~
"
(let ((key (list 'svd
:prompt-if-fail?
(if prompt-if-fail? T))))
(or (find-table-entry x 'decomposition key)
(let* ((x-copy (sel x))
(n (or (first (dimensions-of x)) 1))
(p (or (second (dimensions-of x)) 1))
(m (min n p))
(s (array 0 :dimensions (list (min (1+ n) p))))
(e (array 0 :dimensions (list p)))
(u (array 0 :dimensions (list n m)))
(v (array 0 :dimensions (list p m)))
(work (array 0 :dimensions (list n)))
;; The following job number insures that the first m
;; left singular vectors are produced and that all the
;; right singular vectors are produced.
(job 21)
(info (array 0 :dimensions (list 1))))
(dsvdc x-copy n p s e u v work job info)
(let ((svs (array NaN :dimensions (list m)))
(start-index (eref info 0)))
(cond
((zerop start-index)
(loop for i from 0 to (- m 1)
do (setf (eref svs i)
(eref s i)))
(add-table-entry x 'decomposition
key
(make-instance 'sv-decomposition
:singular-values svs
:left u
:right v
:start-index 0
:diag NIL
:super-diag NIL
)
)
)
(T
(unless
(and prompt-if-fail?
(quail-yes-or-no-p
"Warning: SVD failed to converge. ~&~
~s singular values were obtained. ~&~
Continue with the rest set to NaN?"
(max 0 (- m start-index)))
)
(quail-error "SVD failed to converge for ~s ~&~
~s singular values were obtained."
x (max 0 (- m start-index))))
(loop for i from start-index
to (- m 1)
do (setf (eref svs i)
(eref s i)))
(add-table-entry x 'decomposition
key
(make-instance 'sv-decomposition
:singular-values svs
:left u
:right v
:start-index start-index
:diag s
:super-diag e
)
)))
)
)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Methods for matrices
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod left-singular-vectors-of ((thing matrix))
(left-singular-vectors-of (svd-of thing))
)
(defmethod right-singular-vectors-of ((thing matrix))
(right-singular-vectors-of (svd-of thing))
)
(defmethod singular-values-of ((thing matrix))
(singular-values-of (svd-of thing))
)
| 11,220 | Common Lisp | .l | 265 | 31.637736 | 82 | 0.537102 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 6237f9fb998efef28c20604aa8b02c0f8fe923f3daf074314c59573c777eb60f | 33,353 | [
-1
] |
33,354 | dnrm2.lsp | rwoldford_Quail/source/linear/dnrm2.lsp | (in-package :q)
(defun dnrm2-hook (n dx incx)
(declare (type fixnum incx))
;;(declare (type (simple-array double-float (*)) dx))
(declare (type fixnum n))
(prog ((j 0) (i 0) (nn 0) (dnrm2 0.0d0) (next 0) (one 0.0d0) (zero 0.0d0)
(xmax 0.0d0) (sum 0.0d0) (hitest 0.0d0) (cuthi 0.0d0) (cutlo 0.0d0))
(declare (type fixnum j))
(declare (type fixnum i))
(declare (type fixnum nn))
(declare (type fixnum next))
(declare (type double-float cutlo))
(declare (type double-float cuthi))
(declare (type double-float hitest))
(declare (type double-float sum))
(declare (type double-float xmax))
(declare (type double-float zero))
(declare (type double-float one))
(declare (type double-float dnrm2))
(setq zero 0.0d0)
(setq one 1.0d0)
(setq cutlo 4.441d-16)
(setq cuthi 1.304d19)
(if (> n 0) (go label10))
(setf dnrm2 zero)
(go label300)
label10 (setf next 30)
(setf sum zero)
(setf nn (* n incx))
(setf i 1)
label20 (case next
(30 (go label30))
(50 (go label50))
(70 (go label70))
(110 (go label110)))
label30 (if (> (dabs (fref dx i)) cutlo) (go label85))
(setf next 50)
(setf xmax zero)
label50 (if (= (fref dx i) zero) (go label200))
(if (> (dabs (fref dx i)) cutlo) (go label85))
(setf next 70)
(go label105)
label100 (setf i j)
(setf next 110)
(setf sum (f2cl/ (f2cl/ sum (fref dx i)) (fref dx i)))
label105 (setf xmax (dabs (fref dx i)))
(go label115)
label70 (if (> (dabs (fref dx i)) cutlo) (go label75))
label110 (if (<= (dabs (fref dx i)) xmax) (go label115))
(setf sum (+ one (* sum (expt (f2cl/ xmax (fref dx i)) 2))))
(setf xmax (dabs (fref dx i)))
(go label200)
label115 (setf sum (+ sum (expt (f2cl/ (fref dx i) xmax) 2)))
(go label200)
label75 (setf sum (* (* sum xmax) xmax))
label85 (setf hitest (f2cl/ cuthi (float n)))
(fdo (j i (+ j incx))
((> j nn) nil)
(tagbody (if (>= (dabs (fref dx j)) hitest) (go label100))
(setf sum (+ sum (expt (fref dx j) 2)))))
(setf dnrm2 (dsqrt sum))
(go label300)
label200 (setf i (+ i incx))
(if (<= i nn) (go label20))
(setf dnrm2 (* xmax (dsqrt sum)))
label300 (return dnrm2)))
| 2,561 | Common Lisp | .l | 66 | 29.651515 | 78 | 0.52509 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e686077ca75c2730031bc9b7bae92285dc3e55ba5a4fc9715e90fe32a98827c3 | 33,354 | [
-1
] |
33,355 | apply-weight.lsp | rwoldford_Quail/source/linear/apply-weight.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; apply-weight.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1994 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; Michael Lewis 1991.
;;; R.W. Oldford 1994.
;;;
;;;
;;;--------------------------------------------------------------------------------
;;;
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(apply-weight remove-weight)))
;-----------------------------------------------------------------------------
;METHOD: apply-weight
;-----------------------------------------------------------------------------
(defmethod apply-weight ((weight null) (x matrix))
x)
(defmethod-multi-one-body apply-weight ((weight (matrix sequence))
(x matrix))
(cond ((mat2dp weight)
(let ((weight (upper-triangle-of (cholesky-of weight)))
(result (array 0 :dimensions (dimensions-of x)))
(n (nrows x))
(p (ncols x))
)
(with-cl-functions (*)
(loop for i from 0 below n
do
(loop for j from 0 below p
do
(setf (eref result i j)
(loop for k from i below n
sum
(* (eref weight i k)
(eref x k j))))
)
))
result))
(t (* (sqrt weight) x)))
)
#|
(defmethod-multi-one-body apply-weight ((x matrix) (weight (vector sequence)))
(let ((weight (matrix-sqrt weight)))
(cond ((mat1dp weight) (* weight x))
((mat2dp weight) (.* weight x))
(t (quail-error "Weight is not of dimension 1 or 2.")))))
(defmethod-multi-one-body apply-weight :before ((x matrix)
(weight (matrix sequence)))
(cond ((null (dimensions-of weight)) nil)
((mat1dp weight)
(unless (= (first (dimensions-of x))
(first (dimensions-of weight)))
(quail-error "Weights do not match number of observations."))
)
((mat2dp weight)
(unless (= (first (dimensions-of x))
(first (dimensions-of weight)))
(quail-error "Weights do not match number of observations.")
(unless (apply #'= (dimensions-of weight))
(quail-error "Weight matrix not square.")))
(t (quail-error "Weight is not of dimension 1 or 2."))))
|#
;;;-----------------------------------------------------------------------------
;;; METHOD: remove-weight
;;;-----------------------------------------------------------------------------
(defmethod remove-weight ((weight null) (x matrix))
x)
(defmethod-multi-one-body remove-weight ((weight (matrix sequence))
(x matrix))
"Removes the sqrt or matrix sqrt of weight from x."
(let ((result (sel x)))
(cond
((mat2dp weight)
(with-slots
((cholesky-a a))
(cholesky-of weight)
(dtrls cholesky-a result 01)
result))
(T
(loop
for i from 0 below (nrows result)
do
(loop for j from 0 to (ncols result)
with div = (cl::sqrt (eref weight i))
do
(setf (eref result i j)
(/ (eref x i j) div))
)
)
result)))
)
| 3,796 | Common Lisp | .l | 98 | 27.642857 | 95 | 0.403322 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 5753b4eb89a0f80b9393df23291a603b2e0cd238c9fb7d7a5d7bab196a91077e | 33,355 | [
-1
] |
33,356 | infix.lsp | rwoldford_Quail/source/top-level/infix.lsp | ;;; -*- File: infix.lisp, Mode: LISP, Syntax: MCL 2.0, Package: "QUAIL"
(in-package :quail)
;; Alterations: M.E.Lewis.
;; My thanks to the author.
;; Some Lisp programers who have experienced FORTRAN or C programming
;; often complain that Lisp is weak at mathematical formula expression.
;; Here is a read macro program which accepts C-like infix formulae
;; and translates them into prefixed lisp forms.
;;
;; (1 + 2 * 3 / 4.0) is expanded to something like
;; (+ 1 (/ (* 2 3) 4.0) and 2.5 is resulted.
;;
;; Fuction call and array reference are also handled.
;; (sin(x) + a[1]) --> (+ (sin x) (sel a 1))
;;
;; Also, a simple optimization to reduce function call and array
;; reference is performed.
;; ((sin(x) + cos(x)) / (sin(x) - cos(x)))
;; --> (let* ((t1 (sin x)) (t2 (cos x))) (/ (+ t1 t2) (- t1 t2)))
;; For this optimization, all the expressions are assumed to have
;; no side-effect.
;;
;; Assignment and relative operator are also available.
;; (a != b) --> (/= a b)
;; (a <- x + 1) --> (setf a (+ x 1))
;; (a[0] <- (x + y + z) ) --> (setf (sel a 0) (+ x y z))
;;
;; Note that every factor or operator needs to be delimited by spaces,
;; since terms like '2*a' and 'a+pi' are valid symbols for Lisp although they
;; are recognized three different symbols by C.
;;
;; This program was developed on euslisp, which is a subset of CommonLisp
;; and has lots of extended features for three-dimensional solid modeling,
;; especially for robot programming. However, I have confirmed this program
;; correctly works in KCL environments both on our sun3 and sun4.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; mathtran.l
;;;; convert C-like arithmethic expressions into lisp notation.
;;;; 1987-Sep
;;;; Copyright (c) 1987,
;;;; Toshihiro MATSUI, Electrotechnical Laboratory
;;;; Tsukuba-city, Ibaraki, 305 JAPAN
;;;; matsui%[email protected]
(defmacro infix-while (cond &rest body)
`(do ()
((not ,cond))
. ,body))
(defun infix-memq (x l) (member x l :test #'eq))
(defun expression (exp &optional (lhs nil) &aux result letvar-alist)
(labels
(
(letvar (form)
(let ((v (assoc form letvar-alist :test #'equal)))
(cond (v (incf (third v)) (second v))
(t (setf v (gensym))
(push (list form v 1) letvar-alist)
v))))
(factor1 (exp)
(let* ((sy (pop exp)) (arglist) form)
(cond
((consp sy)
(multiple-value-setq (sy form) (expr sy))
(if form (error "illegal math expression for infix macro"))
(values sy exp))
((consp (first exp)) ;function call or array ref.
(setf arglist (pop exp))
(cond ((eq (first arglist) 'sel)
(setf arglist (expr-list (rest arglist)))
(setf form (cons 'sel (cons sy arglist)))
(unless lhs (setf form (letvar form)))
(values form exp))
(t
(values (letvar (cons sy (expr-list arglist))) exp) )) )
(t (values sy exp)))))
(factor2 (exp)
(let* ((left) (right) (form))
(multiple-value-setq (left exp) (factor1 exp))
(cond
((infix-memq (first exp) '(** ^))
(multiple-value-setq (right exp) (factor1 (rest exp)))
(cond
((and (integerp right) (< right 10))
(setf form (list '*))
(cond ((atom left)
(dotimes (i right) (nconc form (list left)))
(values (letvar form) exp))
(t
(dotimes (i right) (nconc form (list 'temp)))
(values `(let ((temp ,left)) ,form) exp))))
(t (values (list 'expt left right) exp))))
((numberp left) (values left exp))
(t (values left exp) ))))
(term (exp)
(let* ((left) (op) (right))
(multiple-value-setq (left exp) (factor2 exp))
(setf op (first exp))
(cond
(;;(infix-memq op '(* /))
;;(infix-while (infix-memq op '(* /))
(infix-memq op '(* / .*))
(infix-while (infix-memq op '(* / .*))
(setf left (list op left))
(infix-while (eq (first exp) op)
(multiple-value-setq (right exp) (factor2 (rest exp)))
(nconc left (list right)) )
(setf op (first exp)))
(values left exp))
(t (values left exp)))))
(expr (exp)
(let* ((op (first exp)) (left) (right))
(if (infix-memq op '(+ -)) ;+- as unary operator
(setf exp (rest exp)))
(multiple-value-setq (left exp) (term exp))
(if (eq op '-)
(setf left (list op left)))
(when (infix-memq (first exp) '(+ -))
(setf left (list '+ left))
(infix-while (infix-memq (setf op (first exp)) '(+ -))
(multiple-value-setq (right exp) (term (rest exp)))
(if (eq op '-) (setf right (list '- right)))
(nconc left (list right))))
(values left exp)))
(expr-list (exp)
(let (temp result)
(infix-while exp
(multiple-value-setq (temp exp) (expr exp))
(push temp result))
(nreverse result)))
(rel-expr (exp)
(let ((left) (op) (right))
(multiple-value-setq (left exp) (expr exp))
(setf op (pop exp))
(when (infix-memq op '(== != /= < > <= >=))
(multiple-value-setq (right exp) (expr exp))
(setf left
(list (second (assoc op '((== =) (!= /=) (/= /=) (< <)
(<= <=) (> >) (>= >=))))
left right)))
(values left exp)))
(reconstruct-form (exp)
(setf exp (list exp))
(let ((letpairs))
(dolist (lv letvar-alist)
(if (> (third lv) 1) ;referenced more than once
(push (list (second lv) (first lv)) letpairs)
(nsubst (first lv) (second lv) exp)))
(if letpairs
`(let* ,letpairs . ,exp)
(first exp)))))
(multiple-value-setq (result exp) (rel-expr exp))
(if exp (error "illegal expression in infix macro"))
(let ((reconstruction (reconstruct-form result)))
(if (and (symbolp reconstruction)
(function-information reconstruction))
(list reconstruction)
reconstruction)) ))
#|
(defun infix2prefix (file &optional char)
(let ((exp (read file)))
(cond
((symbolp exp) ;probably a left-hand-side array ref.
(expression (list exp (read file)) t))
((eq (second exp) '<-)
(list 'setf (car exp) (expression (cddr exp) nil)))
((eq (third exp) '<-)
(list 'setf (expression (list (first exp) (second exp)) t)
(expression (cdddr exp) nil)))
(t (expression exp nil)))) )
|#
(defun infix2prefix (form &optional subchar arg)
(declare (ignore subchar arg))
(with-input-from-string (stream (format nil "~a" form))
(unless (char= (read-char stream nil nil) #\()
(error "Bad syntax. Infix notation is (2 + 3)."))
(let ((exp (read-delimited-list #\) stream)))
(cond
((symbolp exp) exp)
((numberp exp) exp)
((eq (second exp) '<-)
(list 'setf (car exp) (expression (cddr exp) nil)))
((eq (third exp) '<-)
(list 'setf (expression (list (first exp) (second exp)) t)
(expression (cdddr exp) nil)))
(t (expression exp nil))))))
(defun read-sel (file &optional char)
(declare (ignore char))
(cons 'sel (read-delimited-list #\] file)))
#|
(set-macro-character #\% 'infix2prefix)
(set-dispatch-macro-character #\# #\% #'infix2prefix)
|#
(set-macro-character #\[ 'read-sel)
(set-syntax-from-char #\] #\))
;; --
;; [email protected] (domestic), matsui%[email protected] (overseas)
| 7,643 | Common Lisp | .l | 196 | 32.341837 | 78 | 0.561413 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | e8ef395b32f5ef14669582ebb3d6c5e6dd229d20d6d50b264972de44cb0d90c5 | 33,356 | [
-1
] |
33,357 | quail-top-level-read.lsp | rwoldford_Quail/source/top-level/quail-top-level-read.lsp |
(in-package :quail)
(defvar *forms-awaiting-evaluation* nil
"Remainder of last line read.")
(defun quail-toplevel-reader-function (&optional (stream *standard-input*))
"Reads a line of input from stream and returns the first ~
form to be evaluated. Stores any remaining forms in the ~
special variable *forms-awaiting-evaluation*. ~
Created for use in the Quail toplevel loop."
(declare (special *forms-awaiting-evaluation*))
(flet ((num-unmatched-left-parens (string)
(let ((count 0))
(dotimes (i (length string) count)
(let ((string-elt-i (elt string i)))
(cond
((string-equal string-elt-i "(")
(incf count))
((string-equal string-elt-i ")")
(decf count))
(t nil)))))))
(let ((input-line
(do* ((next-line (read-line stream nil nil)
(read-line stream nil nil))
(input-line next-line
(concatenate 'string
input-line
next-line))
(count (num-unmatched-left-parens next-line)
(incf count (num-unmatched-left-parens next-line))))
((= count 0) input-line))))
(with-input-from-string (str input-line)
(let ((first-form (read str nil nil)))
(if (listen str)
(do ((next-form (read str nil nil)
(read str nil nil))
(rest-of-forms nil))
((null next-form)
(if rest-of-forms
(setq *forms-awaiting-evaluation*
(append *forms-awaiting-evaluation*
(nreverse rest-of-forms)))))
(push next-form rest-of-forms)))
first-form)))))
#|
(defun quail-loop (&aux prompt-string)
"The Quail top-level loop function."
(declare (special -))
(fresh-line)
(setf prompt-string
(concatenate 'string
"Quail"
"> "))
(princ prompt-string)
(setf - (quail-read))
(quail-top-level-eval-current-form)
)
(defun quail-read ()
"Read the next Quail expression."
(get-next-form))
(defun get-next-form ()
"Retrieves the next form to be evaluated."
(declare (special *forms-awaiting-evaluation*))
(or (ccl:get-next-queued-form)
(pop *forms-awaiting-evaluation*)
(quail-toplevel-reader-function)))
(defun quail-top-level-eval-current-form ()
"Evaluates and prints the value of the current form (the value of the ~
- symbol)."
(declare (special -))
(eval-print))
(defun eval-print (&optional (stream *terminal-io*)
&aux result)
"Evaluates and prints the form supplied. Output to stream, ~
if supplied, otherwise to *terminal-io*."
(declare
(special *terminal-io*
+ ++ +++ * ** *** / // /// -))
(setf result (multiple-value-list
(eval -))
)
(setf +++ ++)
(setf ++ +)
(setf + -)
(setf *** **)
(setf ** *)
(setf /// //)
(setf // /)
(setf / (list (setf * (format stream "~&~a" (car result)))))
(if (> (length result) 1)
(setf / (append /
(loop for v in (cdr result)
collect
(format stream "~&~a" v)))))
*
)
(defun quail ()
(ccl::%set-toplevel #'quail-loop)
(ccl:toplevel))
(defun exit ()
(ccl::%set-toplevel #'ccl:toplevel-loop)
(ccl:toplevel))
|#
| 3,718 | Common Lisp | .l | 101 | 25.742574 | 77 | 0.5121 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 2ef710658c27c179b890077dd0253ab30a37e00d524fecb9abc0da6504e06e85 | 33,357 | [
-1
] |
33,358 | top-level-pc.lsp | rwoldford_Quail/source/top-level/top-level-pc.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; top-level-pc.lsp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; M.E. Lewis 1991.
;;; R.W. Oldford 1991.
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(*system-top-level-loop-function* install-top-level current-top-level
get-next-form get-function-name setup-system-top-level-loop-variable)))
(defvar *system-top-level-loop-function* NIL
"Variable containing the stack of top-level loop functions.")
(defun setup-system-top-level-loop-variable ()
(declare (special *system-top-level-loop-function*))
(setf *system-top-level-loop-function* NIL )) ;;#'ccl:toplevel-loop))
;;;----------
(eval-when (load eval)
(setup-system-top-level-loop-variable))
;;;;;;;;;;;;
;;;
;;;
(defun install-top-level (&optional
(top-level *system-top-level-loop-function*))
"Installs the top-level function, if provided. Default ~
is the one supplied with the system."
(declare (special *system-top-level-loop-function*) (ignore top-level))
(inform-user "New top level functions cannot be installed yet in ~
this system.")
;;(ccl:%set-toplevel top-level)
;;(ccl:toplevel)
)
(defun current-top-level ()
"Returns the current top-level loop function."
;;(ccl:%set-toplevel)
(inform-user "New top level functions cannot be installed yet in ~
this system.")
)
(defun get-next-form ()
"Retrieves the next form to be evaluated."
(declare (special *forms-awaiting-evaluation*))
(or ;; don't know how to do this yet
;; (ccl:get-next-queued-form)
(pop *forms-awaiting-evaluation*)
(quail-toplevel-reader-function)))
(defun get-function-name (function)
(qk::function-name function))
;;;(defun set-listener-package (&optional (package :cl-user))
;;; (ccl:eval-enqueue `(in-package ,package)))
(defun system-quit-lisp ()
"System dependent function that quits Lisp."
(excl::exit) ;(acl:quit) from help 15jun2004
)
| 2,441 | Common Lisp | .l | 60 | 35.45 | 134 | 0.573311 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 757c6f67318b9757c95bb5b5498d94d8ab2a21c5642c53ae02f9b3d675204434 | 33,358 | [
-1
] |
33,359 | pqr.lsp | rwoldford_Quail/source/top-level/pqr.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;
;;;
;;; quail-menu.lsp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1991.
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export
'(*quail-menu-items* add-to-quail-menu delete-from-quail-menu)))
(defun this-may-take-a-while ()
(inform-user (format NIL
"This may take a while. ~%~
There is a lot of information to collect and
load. ~%~
Patience please :-)."))
T)
(defvar *quail-menu-items* NIL
"The current menu items to be used to construct the Quail menu ~
to be used in the Quail menubar.")
(defun quail-menu ()
"Creates and returns the default Quail menu."
(wb::make-menu
:menu-type :title
:items *quail-menu-items*
:title "Quail")
)
(defun add-to-quail-menu (item &rest other-items)
"Adds one or more items to the list of items in the ~
quail-menu-items. Returns the new menu-items list. ~
Destructive to *quail-menu-items* ~
(:required (:arg item The menu item list to be added.) )~
(:rest (:arg other-items NIL Other item lists to be added.)) ~
(:see-also wb:make-menu delete-from-quail-menu *quail-menu-items* ~
install-default-quail-menubar) ~
"
(declare (special *quail-menu-items*))
(nconc *quail-menu-items* (list item) other-items)
*quail-menu-items*)
(defun delete-from-quail-menu (item &rest other-items)
"Deletes one or more items from the list of items in the ~
quail-menu-items. Returns the new menu-items list. ~
Destructive to *quail-menu-items* ~
(:required (:arg item The menu item list to be deleted.) )~
(:rest (:arg other-items NIL Other item lists to be deleted.)) ~
(:see-also wb:make-menu add-to-quail-menu *quail-menu-items* ~
install-default-quail-menubar) ~
"
(declare (special *quail-menu-items*))
(delete item *quail-menu-items* :test #'equal)
(when other-items
(dolist (item other-items)
(delete item *quail-menu-items* :test #'equal)))
*quail-menu-items*)
(<-
*quail-menu-items*
'(("About Quail"
(inform-user
(format NIL
"~&~a ~%~
~%~
Copyright ~%~
Statistical Computing Laboratory ~%~
University of Waterloo ~%~
~%~
From a cast of ones, including:~%~
R.W. Oldford, C.B. Hurley, D.G. Anglin, M.E. Lewis,~%~
G. Desvignes, H.A.Chipman, P. Poirier, N.G. Bennett, ~
G.W. Bennett, C. Whimster, and, of course, Bob White."
(qk::quail-release)))
"Some credit information on Quail.")
("-" () "")
("Information" (help) "Get general help information."
:sub-items
(("Help" (help)
"Get help on some symbol."
:sub-items
(("Help" (help)
"Get help on some symbol.")
("Organized by topic"
(help 'Quail :topic)
"Get the quail topic.")
("Symbol indices"
(view-doc-index :package :quail)
"View the most recent index of all the Quail symbols."
:sub-items
(("Quail external symbols"
(view-doc-index :package :quail)
"View the most recent index of all the Quail symbols.")
("Quail-Kernel external symbols"
(view-doc-index :package :quail-kernel)
"View the most recent index of all the Quail-Kernel symbols.")
("Views external symbols"
(view-doc-index :package :views)
"View the most recent index of all the views symbols.")
("Window Basics external symbols"
(view-doc-index :package :window-basics)
"View the most recent index of all the Window-basics
symbols."))
))
)
("Packages" (help (find-symbol "PACKAGES"
(find-package "Q-USER"))
:topic)
"General package information."
:sub-items
(("About packages"
(help (find-symbol "PACKAGES"
(find-package "Q-USER"))
:topic)
"General package information.")
("Quail-User" (and (this-may-take-a-while)
;; avoid interning 'quail-user in the :quail package
(help :q-user :package))
"Get help on the quail-user package.")
("Quail" (and (this-may-take-a-while)
(help :quail :package)) "Get help on the quail
package.")
("Quail-Kernel" (and (this-may-take-a-while)
(help :quail-kernel :package))
"Get help on the quail-kernel package.")
("Window-Basics" (and (this-may-take-a-while)
(help :window-basics :package))
"Get help on the window-basics package.")
("Views" (and (this-may-take-a-while)
(help :views :package))
"Get help on the views package.")
))
("Browser" (make-browser) "General class browser."
:sub-items
(("Class browser" (make-browser) "General class browser.")
("Class browse all of Quail"
(apply #'class-browse
(append
(qk::list-symbols :window-basics
:test
#'(lambda (s) (and (eq (symbol-package
s)
(find-package
:window-basics))
(find-class s
nil))))
(qk::list-symbols
:quail
:test
#'(lambda (s)
(and (or
(eq (symbol-package s)
(find-package :quail))
(eq (symbol-package s)
(find-package :quail-kernel))
(eq (symbol-package s)
(find-package :views)))
(find-class s nil))))))
"Browse all classes defined in Quail.")
("Class browse the Quail package"
(apply #'class-browse
(qk::list-symbols
:quail
:test
#'(lambda (s)
(and (or
(eq (symbol-package s)
(find-package :quail))
)
(find-class s nil)))))
"Browse all classes defined in Quail.")
("Class browse the Quail-kernel package"
(apply #'class-browse
(qk::list-symbols
:quail-kernel
:test
#'(lambda (s)
(and (or
(eq (symbol-package s)
(find-package :quail-kernel))
)
(find-class s nil)))))
"Browse all classes defined in the Quail-kernel package.")
("Class browse the views package"
(apply #'class-browse
(qk::list-symbols
:views
:test
#'(lambda (s)
(and (eq (symbol-package s)
(find-package :views))
(find-class s nil)))))
"Browse all classes in the views package.")
("Class browse window-basics"
(apply #'class-browse
(qk::list-symbols :window-basics
:test
#'(lambda (s) (and (eq (symbol-package
s)
(find-package
:window-basics))
(find-class s
nil)))))
"Browse all classes in the window-basics package.")
))
))
("Examples"
(inform-user
(format NIL
"Examples can be found in the directory eg: ~&~
There are more files there than are presented here."))
"Examples can be found in the directory eq:"
:sub-items
(("Where are the files?"
(inform-user
(format NIL
"Examples can be found in the directory ~a ~&~
or more simply \"eg:\". ~&~
There are more files there than are presented here."
(truename (pathname "eg:"))))
"Examples can be found in the directory eg:")
("-" () "")
("Arrays in Quail" (edit-file "eg:Arrays;overview.lsp")
"Overview and entry point into example files on arrays in Quail"
:sub-items
(("Overview" (edit-file "eg:Arrays;overview.lsp")
"Overview and entry point into example files on arrays in Quail")
("Introduction" (edit-file "eg:Arrays;intro.lsp")
"Introduction to array creation and array attributes.")
("-" () "")
("Advanced array creation" (edit-file "eg:Arrays;array.lsp")
"Advanced use of the array function.")
("Arithmetic operations" (edit-file "eg:Arrays;arith-ops.lsp")
"Arithmetic operations on arrays")
("Glueing operations"
(edit-file "eg:Arrays;glue.lsp")
"Putting arrays together with glue.")
("Iteration"
(edit-file "eg:Arrays;iter-elements.lsp")
"Macros useful in iterating over elements."
:sub-items
(("Elements"
(edit-file "eg:Arrays;iter-elements.lsp")
"Macros useful in iterating over elements.")
("General"
(edit-file "eg:Arrays;iter-general.lsp")
"General iteration macros.")
("Mapping functions"
(edit-file "eg:Arrays;iter-map.lsp")
"Mapping functions over arrays.")
("Modifying slices"
(edit-file "eg:Arrays;iter-modify.lsp")
"Removal and substitution of slices.")
("Slices"
(edit-file "eg:Arrays;iter-slices.lsp")
"Macros useful in iterating over slices.")
))
("Mathematical operations" (edit-file "eg:Arrays;math-funs.lsp")
"Mathematical operations on arrays")
("Matrices"
(edit-file "eg:Arrays;Matrices;overview.lsp")
"Focus on matrix arrays.")
("Numerical predicates" (edit-file "eg:Arrays;num-preds.lsp")
"Numerical predicates like =, <, <=, >, >=")
("Referencing and copying" (edit-file "eg:Arrays;ref.lsp")
"Referencing and setting blocks of an array.")
("Searching arrays"
(edit-file "eg:Arrays;search.lsp")
"Finding and counting slices; slice positions.")
("Selecting elements by test"
(edit-file "eg:Arrays;select-by-pred.lsp")
"Selecting elements by predicate testing.")
("Some handy arrays" (edit-file "eg:Arrays;handy-arrays.lsp")
"Some handy arrays.")
("Sorting, ranking, permuting"
(edit-file "eg:Arrays;sort.lsp")
"Sorting, ranking, permuting slices of an array.")
)
)
("Documentation"
(edit-file "eg:Documentation;doc-example.lsp")
"Quail's extended documentation facility.")
("Mathematics"
()
"Examples illustrating some mathematical functionality."
:sub-items
(("Arithmetic operations" (edit-file "eg:Arrays;arith-ops.lsp")
"Arithmetic operations on arrays")
("Calculus"
()
"Collection of tools from the differential calculus."
:sub-items
(("Derivatives"
(edit-file "eg:Mathematics;Calculus;deriv.lsp")
"Symbolic and numerical differentiation.")
;; ("Integration"
;; (edit-file "eg:Mathematics;Calculus;integrate.lsp")
;; "Numerical integration.")
)
)
("Combinatorics"
(edit-file "eg:Mathematics;Combinatorics;counting.lsp")
"Collection of some simple combinatorial tools."
:sub-items
(("Counting"
(edit-file "eg:Mathematics;Combinatorics;counting.lsp")
"Collection of some simple counting tools.")
("Factors"
(edit-file "eg:Mathematics;Combinatorics;factor.lsp")
"Collection of some simple tools related to factoring
integers."
)
)
)
("Extended arithmetic"
(edit-file "eg:Mathematics;extended-arithmetic.lsp")
"Quail's handling of extended arithmetic.")
("Mathematical operations (CL)"
(edit-file "eg:Arrays;math-funs.lsp")
"Mathematical operations on arrays")
("Matrices"
(edit-file "eg:Arrays;Matrices;overview.lsp")
"Focus on matrix arrays."
:sub-items
(("Overview"
(edit-file "eg:Arrays;Matrices;overview.lsp")
"Focus on matrix arrays.")
("Introduction"
(edit-file "eg:Arrays;Matrices;intro.lsp")
"Introduction to properties of Quail matrices.")
("-" () "")
("Decompositions"
(edit-file
"eg:Arrays;Matrices;Decompositions;overview.lsp")
"Various matrix decompositions."
:sub-items
(("Overview"
(edit-file
"eg:Arrays;Matrices;Decompositions;overview.lsp")
"Various matrix decompositions.")
("-" () "")
("Cholesky decomposition"
(edit-file
"eg:Arrays;Matrices;Decompositions;cholesky.lsp")
"The Cholesky decomposition of a symmetric matrix.")
("LU decomposition"
(edit-file
"eg:Arrays;Matrices;Decompositions;lu.lsp")
"The LU decomposition of a square matrix.")
("QR decomposition"
(edit-file
"eg:Arrays;Matrices;Decompositions;qr.lsp")
"The QR decomposition of a rectangular matrix.")
("Singular value decomposition"
(edit-file
"eg:Arrays;Matrices;Decompositions;svd.lsp")
"The Singular value decomposition of a rectangular matrix.")
)
)
("Matrix operations"
(edit-file "eg:Arrays;Matrices;operations.lsp")
"Focus on matrix operations, mostly mathematical.")
)
)
("Special functions"
(edit-file "eg:Mathematics;Special-Functions;overview.lsp")
"Special Mathematical functions."
:sub-items
(("Overview"
(edit-file "eg:Mathematics;Special-Functions;overview.lsp")
"Special mathematical functions.")
("-" () "")
("Beta functions"
(edit-file "eg:Mathematics;Special-Functions;beta.lsp")
"Beta and incomplete beta functions.")
("Continued fractions"
(edit-file
"eg:Mathematics;Special-Functions;continued-fraction.lsp")
"Approximating arbitrary continued fraction expansions.")
("Error functions"
(edit-file "eg:Mathematics;Special-Functions;error-fun.lsp")
"Error function and its complement.")
("Gamma functions"
(edit-file "eg:Mathematics;Special-Functions;gamma.lsp")
"Gamma and incomplete gamma functions."))
)
)
)
("Probability" ()
"Probability calculations and random variables."
:sub-items
(("Distributions"
(edit-file "eg:Probability;Distributions;overview.lsp")
"Overview and entry point into example files on statistical
distributions in Quail"
:sub-items
(("Overview"
(edit-file "eg:Probability;Distributions;overview.lsp")
"Overview and entry point into example files on statistical
distributions in Quail")
("-"
()
"")
("Introduction"
(edit-file "eg:Probability;Distributions;intro.lsp")
"Introduction to distributions in Quail.")
("Built in distributions."
(edit-file "eg:Probability;Distributions;stock.lsp")
"The built-in distributions in Quail."
:sub-items
(("Overview."
(edit-file "eg:Probability;Distributions;stock.lsp")
"The built-in distributions in Quail."
)
("-"
()
"")
("Continuous distributions."
(edit-file "eg:Probability;Distributions;stock-cts.lsp")
"The built-in continuous distributions in Quail."
)
("Beta"
(edit-file "eg:Probability;Distributions;beta.lsp")
"The beta distribution in Quail.")
("Cauchy"
(edit-file "eg:Probability;Distributions;cauchy.lsp")
"The Cauchy distribution in Quail.")
("Chi-squared"
(edit-file "eg:Probability;Distributions;chi-squared.lsp")
"The Chi-squared distribution in Quail.")
("Exponential"
(edit-file "eg:Probability;Distributions;exponential.lsp")
"The exponential distribution in Quail.")
("F"
(edit-file "eg:Probability;Distributions;F-dist.lsp")
"The F distribution in Quail.")
("Gamma"
(edit-file "eg:Probability;Distributions;gamma.lsp")
"The gamma distribution in Quail.")
("Gaussian (Normal)"
(edit-file "eg:Probability;Distributions;gaussian.lsp")
"The Gaussian distribution in Quail.")
("K"
(edit-file "eg:Probability;Distributions;K-dist.lsp")
"The K distribution in Quail.")
("Pareto"
(edit-file "eg:Probability;Distributions;pareto.lsp")
"The Pareto distribution in Quail.")
("Student's t"
(edit-file "eg:Probability;Distributions;student.lsp")
"The student distribution in Quail.")
("Uniform"
(edit-file "eg:Probability;Distributions;uniform.lsp")
"The uniform distribution in Quail.")
("Weibull"
(edit-file "eg:Probability;Distributions;weibull.lsp")
"The weibull distribution in Quail.")
("-"
()
"")
("Discrete distributions."
(edit-file "eg:Probability;Distributions;stock-disc.lsp")
"The built-in discrete distributions in Quail.")
("Bernoulli"
(edit-file "eg:Probability;Distributions;bernoulli.lsp")
"The Bernoulli distribution in Quail.")
("Binomial"
(edit-file "eg:Probability;Distributions;binomial.lsp")
"The Binomial distribution in Quail.")
("Geometric"
(edit-file "eg:Probability;Distributions;geometric.lsp")
"The geometric distribution in Quail.")
("Hypergeometric"
(edit-file "eg:Probability;Distributions;hypergeometric.lsp")
"The Hypergeometric distribution in Quail.")
("Negative binomial"
(edit-file
"eg:Probability;Distributions;negative-binomial.lsp")
"The negative binomial distribution in Quail.")
("Poisson"
(edit-file "eg:Probability;Distributions;poisson.lsp")
"The Poisson distribution in Quail.")
("Uniform (discrete)"
(edit-file
"eg:Probability;Distributions;discrete-uniform.lsp")
"The discrete uniform distribution in Quail.")
))
("Empirical distributions"
(edit-file "eg:Probability;Distributions;empirical.lsp")
"Interpreting data as empirical distributions in Quail.")
("Finite mixtures"
(edit-file "eg:Probability;Distributions;finite-mixture.lsp")
"Finite mixture distributions in Quail.")
("Adding new distributions"
(edit-file "eg:Probability;Distributions;extending.lsp")
"How to add new distributions to Quail.")
)
)
)
)
("Statistics" ()
"Statistical modelling and graphics"
:sub-items
(("Summary statistics"
(edit-file "eg:Statistics;summary-statistics.lsp")
"Summary statistics."
)
("Response Models" (edit-file "eg:Statistics;Models;overview.lsp")
"Overview and entry point into example files on statistical
models in Quail"
:sub-items
(("Overview" (edit-file "eg:Statistics;Models;overview.lsp")
"Overview of response models in Quail.")
("-" () "")
("binary/logit" (edit-file
"eg:Statistics;Models;eg-glm-kyphosis.lsp")
"Logistic regression models.")
("poisson/log" (edit-file
"eg:Statistics;Models;eg-glm-ship-data.lsp")
"Poisson regression (or log-linear) models.")
("gamma/reciprocal" (edit-file
"eg:Statistics;Models;eg-glm-car.lsp")
"Gamma regression models.")
)
)
("Analyses" () ;;(edit-file "eg:Statistics;Analyses;overview.lsp")
"Overview and entry point into example files on statistical
analyses in Quail"
:sub-items
(("Speed of light meta analysis"
(edit-file "eg:Statistics;Analyses;meta-analysis.lsp")
"A graphical meta analysis of the speed of light studies.")
)
)
)
)
("Views"
(edit-file "eg:Views;overview.lsp")
"Examples illustrating some Views functionality."
:sub-items
(("Overview"
(edit-file "eg:Views;overview.lsp")
"An overview of the Views philosophy and system.")
("-" () "")
("Plots"
(edit-file "eg:Views;Plots;general.lsp")
"An overview of the stock statistical graphics."
:sub-items
(("Plots"
(edit-file "eg:Views;Plots;general.lsp")
"Introduction to plots in general.")
("-" () "")
("Scatterplots"
(edit-file "eg:Views;Plots;scatterplot.lsp")
"Introduction to scatterplots.")
("Surface plots"
(edit-file "eg:Views;Plots;surface.lsp")
"Plotting surfaces.")
("Grid plots"
(edit-file "eg:Views;Plots;grid-plot.lsp")
"Introduction to laying views out in a grid plot.")
)
)
("Simple-Views"
();;(edit-file "eg:Views;Simple-Views;introduction.lsp")
"An overview of the simple views."
:sub-items
(("Bars"
(edit-file "eg:Views;Simple-Views;bar.lsp")
"Rectangular bars as in bar plots, histograms, etc.")
("Pies"
(edit-file "eg:Views;Simple-Views;pie.lsp")
"Pies as in pie charts")
("Labels"
(edit-file "eg:Views;Simple-Views;label.lsp")
"Text labels.")
)
)
("Basics"
(edit-file "eg:Views;Basics;introduction.lsp")
"An overview of the stock statistical graphics."
:sub-items
(("Introduction"
(edit-file "eg:Views;Basics;introduction.lsp")
"Introduction to basic design of views.")
("-" () "")
("Classes"
(edit-file "eg:Views;Basics;classes.lsp")
"Classes in the Views system.")
("Drawing styles"
(edit-file "eg:Views;Basics;drawing-styles.lsp")
"Introduction to drawing-styles of views.")
("Mouse interaction"
(edit-file "eg:Views;Basics;mouse.lsp")
"How the pointing device can be used to interact with views.")
("Moving and Copying"
(edit-file "eg:Views;Basics;move-copy.lsp")
"How views may be moved and copied.")
("Viewports and Windows"
(edit-file "eg:Views;Basics;vp-vw.lsp")
"Discussion of viewports and view-windows.")
("Selection of views"
(edit-file "eg:Views;Basics;selection.lsp")
"Discussion of selecting views with the mouse.")
("Dealing with data"
(edit-file "eg:Views;Basics;data.lsp")
"Discussion of the plot-data interface.")
)
)
("Graphical Layout"
(inform-user "Sorry no overview written yet.")
;;(edit-file "eg:Views;overview.lsp")
"Laying out graphics."
:sub-items
(("Grid plot"
(edit-file "eg:Views;Plots;grid-plot.lsp")
"Arranging plots in a rectangular grid.")
)
)
("Text"
(edit-file "eg:Views;Simple-Views;label.lsp")
"Labels as views of text.")
("Advanced"
(inform-user "Various advanced displays.")
;;(edit-file "eg:Views;Stat-graphics;overview.lsp")
"Various advanced displays."
:sub-items
(("Interaction plots"
(edit-file "eg:Views;Advanced;interaction-plots.lsp")
"Interacton plots for factorial data.")
("A trellis example"
(edit-file "eg:Views;Advanced;trellis.lsp")
"Using the views toolkit to build linked trellis displays.")
("Suicide data"
(edit-file "eg:Views;Advanced;suicide.lsp")
"Linking trellis displays and correspondence analysis plots.")
("Categorical data"
(edit-file "eg:Views;Advanced;categorical.lsp")
"Barcharts and tables for categorical data.")
("Mosaic displays"
(edit-file "eg:Views;Advanced;mosaic.lsp")
"Mosaic displays for categorical data.")
)
)
("Applications"
(inform-user "Sorry no overview written yet.")
;;(edit-file "eg:Views;Stat-graphics;overview.lsp")
"An overview of the stock statistical graphics."
:sub-items
(("Box-Cox plots"
(edit-file "eg:Views;Applications;boxcox.lsp")
"Building Box Cox plots that illustrate views functionality.")
("EU symbol"
(edit-file "eg:Views;Applications;euro.lsp")
"An example using basic methods to draw the European Union
symbol.")
("Smoker analysis"
(edit-file "eg:Views;Applications;smoke.lsp")
"An example using basic methods to analyze some data on
smokers.")
)
)
)
)
#|
("Interface to foreign code" (edit-file "eg:Quaff;overview.lsp")
"Quail's foreign function interface."
:sub-items
(("Overview of Quaff" (edit-file "eg:Quaff;overview.lsp")
"Quail's foreign function interface.")
("-" () "")
("Fortran example" (edit-file "eg:Quaff;fortran-example.lsp")
"Fortran example")
("C example" (edit-file "eg:Quaff;c-example.lsp")
"C example")
("Auto-generated access to fortran"
(edit-file "eg:Quaff;auto-cl-to-f.lsp")
"Routine for generating lisp code to attach fortran routines.")
)
)
|#
)
)
("Datasets"
(inform-user "Datasets can be found in the directory q:Data;")
"Datasets can be found in the directory q:Data;"
:sub-items
(("A.A. Michelson's 1879 speed of light"
(edit-file "q:Data;michelson-1879.lsp")
"A.A. Michelson's 1879 speed of light experiment.")
("Apple data"
(edit-file "q:Data;apple.lsp")
"Apple data.")
("Arms race"
(edit-file "q:Data;arms.lsp")
"Arms race.")
("Brain and Body average weights"
(edit-file "q:Data;bbwgt.lsp")
"Brain and Body average weights")
("Cigarette Chemicals"
(edit-file "q:Data;cigs.lsp")
"Cigarette Chemicals")
("Coal mine data"
(edit-file "q:Data;coal.lsp")
"Coal mine data.")
("Historical measures of speed of light"
(edit-file "q:Data;light-speeds.lsp")
"Historical measures of speed of light.")
("Nile river annual flow"
(edit-file "q:Data;nile-river.lsp")
"Nile river annual flow.")
("Reaction times"
(edit-file "q:Data;reaction-times.lsp")
"Reaction time data")
("Smoker data"
(edit-file "q:Data;smoker.lsp")
"Smoker data")
("Solar data"
(edit-file "q:Data;solar.lsp")
"Solar data")
("Squids eaten by sharks"
(edit-file "q:Data;squid.lsp")
"Squids eaten by sharks.")
("U.S. annual production"
(edit-file "q:Data;US-production.lsp")
"U.S. annual production")
))
("Environment"
(inform-user "Sub-items on this menu allow global Quail environment ~
parameters to be set.")
"Access to global Quail environment parameters."
:sub-items
(("Run Quail toplevel loop?" (quail)
"Run Quail's toplevel loop in the listener.")
("-" () "")
("Mouse behaviour" (edit-file
"eg:Window-Basics;mouse-behaviour.lsp")
"Information on the role of the mouse keys.")
("Help window"
(inform-user "You must select a sub-item on this menu!")
"Set background and pen color of the help window."
:sub-items
(("Help in windows"
(setf *help-in-windows* (not *help-in-windows*))
"Toggles whether help information is to appear in windows."
:sub-items
(("Yes ... in windows"
(setf *help-in-windows* T)
"Help information is to appear in windows.")
("No ... in the listener"
(setf *help-in-windows* NIL)
"Help information is to appear in the listener.")
)
)
("Background color"
(set-help-background-color
(wb:prompt-user-for-color))
"Set the default background colour for all help windows."
:sub-items
(("Black"
(set-help-background-color
wb:*black-color*)
"Set the default background colour to be black.")
("Gray"
(set-help-background-color
wb:*gray-color*)
"Set the default background colour to be gray.")
("White"
(set-help-background-color
wb:*white-color*)
"Set the default background colour to be white.")
("-"
()
"")
("User defined"
(set-help-background-color
(wb:prompt-user-for-color))
"Set the default background colour to one defined by the
user.")
("-"
()
"")
("Black"
(set-help-background-color
wb:*black-color*)
"Set the default background colour to be black.")
("Blue"
(set-help-background-color
wb:*blue-color*)
"Set the default background colour to be blue.")
("Blue (light)"
(set-help-background-color
wb:*light-blue-color*)
"Set the default background colour to be light blue.")
("Brown"
(set-help-background-color
wb:*brown-color*)
"Set the default background colour to be brown.")
("Brown (light)"
(set-help-background-color
wb:*tan-color*)
"Set the default background colour to be tan.")
("Gray"
(set-help-background-color
wb:*gray-color*)
"Set the default background colour to be gray.")
("Gray (dark)"
(set-help-background-color
wb:*dark-gray-color*)
"Set the default background colour to be dark gray.")
("Gray (light)"
(set-help-background-color
wb:*light-gray-color*)
"Set the default background colour to be light gray.")
("Green"
(set-help-background-color
wb:*green-color*)
"Set the default background colour to be green.")
("Green (dark)"
(set-help-background-color
wb:*dark-green-color*)
"Set the default background colour to be dark green.")
("Orange"
(set-help-background-color
wb:*orange-color*)
"Set the default background colour to be orange.")
("Pink"
(set-help-background-color
wb:*pink-color*)
"Set the default background colour to be pink.")
("Purple"
(set-help-background-color
wb:*purple-color*)
"Set the default background colour to be purple.")
("Red"
(set-help-background-color
wb:*red-color*)
"Set the default background colour to be red.")
("White"
(set-help-background-color
wb:*white-color*)
"Set the default background colour to be white.")
("Yellow"
(set-help-background-color
wb:*yellow-color*)
"Set the default background colour to be yellow.")
)
)
("Pen color"
(set-help-pen-color (wb:prompt-user-for-color))
"Set the default pen colour for the Help window."
:sub-items
(("Black"
(set-help-pen-color wb:*black-color*)
"Set the default pen colour to be black.")
("Gray"
(set-help-pen-color wb:*gray-color*)
"Set the default pen colour to be gray.")
("White"
(set-help-pen-color wb:*white-color*)
"Set the default pen colour to be white.")
("-"
()
"")
("User defined"
(set-help-pen-color (wb:prompt-user-for-color))
"Set the default pen colour to one defined by the user.")
("-"
()
"")
("Black"
(set-help-pen-color wb:*black-color*)
"Set the default pen colour to be black.")
("Blue"
(set-help-pen-color wb:*blue-color*)
"Set the default pen colour to be blue.")
("Blue (light)"
(set-help-pen-color wb:*light-blue-color*)
"Set the default pen colour to be light blue.")
("Brown"
(set-help-pen-color wb:*brown-color*)
"Set the default pen colour to be brown.")
("Brown (light)"
(set-help-pen-color wb:*tan-color*)
"Set the default pen colour to be tan.")
("Gray"
(set-help-pen-color wb:*gray-color*)
"Set the default pen colour to be gray.")
("Gray (dark)"
(set-help-pen-color wb:*dark-gray-color*)
"Set the default pen colour to be dark gray.")
("Gray (light)"
(set-help-pen-color wb:*light-gray-color*)
"Set the default pen colour to be light gray.")
("Green"
(set-help-pen-color wb:*green-color*)
"Set the default pen colour to be green.")
("Green (dark)"
(set-help-pen-color wb:*dark-green-color*)
"Set the default pen colour to be dark green.")
("Orange"
(set-help-pen-color wb:*orange-color*)
"Set the default pen colour to be orange.")
("Pink"
(set-help-pen-color wb:*pink-color*)
"Set the default pen colour to be pink.")
("Purple"
(set-help-pen-color wb:*purple-color*)
"Set the default pen colour to be purple.")
("Red"
(set-help-pen-color wb:*red-color*)
"Set the default pen colour to be red.")
("White"
(set-help-pen-color wb:*white-color*)
"Set the default pen colour to be white.")
("Yellow"
(set-help-pen-color wb:*yellow-color*)
"Set the default pen colour to be yellow.")
)
)
)
)
("Information window"
(inform-user "You must select a sub-item on this menu!")
"Set background and pen color of the information window."
:sub-items
(("Background color"
(set-info-background-color
(wb:prompt-user-for-color))
"Set the default background colour for the information window."
:sub-items
(("Black"
(set-info-background-color
wb:*black-color*)
"Set the default background colour to be black.")
("Gray"
(set-info-background-color
wb:*gray-color*)
"Set the default background colour to be gray.")
("White"
(set-info-background-color
wb:*white-color*)
"Set the default background colour to be white.")
("-"
()
"")
("User defined"
(set-info-background-color
(wb:prompt-user-for-color))
"Set the default background colour to one defined by the
user.")
("-"
()
"")
("Black"
(set-info-background-color
wb:*black-color*)
"Set the default background colour to be black.")
("Blue"
(set-info-background-color
wb:*blue-color*)
"Set the default background colour to be blue.")
("Blue (light)"
(set-info-background-color
wb:*light-blue-color*)
"Set the default background colour to be light blue.")
("Brown"
(set-info-background-color
wb:*brown-color*)
"Set the default background colour to be brown.")
("Brown (light)"
(set-info-background-color
wb:*tan-color*)
"Set the default background colour to be tan.")
("Gray"
(set-info-background-color
wb:*gray-color*)
"Set the default background colour to be gray.")
("Gray (dark)"
(set-info-background-color
wb:*dark-gray-color*)
"Set the default background colour to be dark gray.")
("Gray (light)"
(set-info-background-color
wb:*light-gray-color*)
"Set the default background colour to be light gray.")
("Green"
(set-info-background-color
wb:*green-color*)
"Set the default background colour to be green.")
("Green (dark)"
(set-info-background-color
wb:*dark-green-color*)
"Set the default background colour to be dark green.")
("Orange"
(set-info-background-color
wb:*orange-color*)
"Set the default background colour to be orange.")
("Pink"
(set-info-background-color
wb:*pink-color*)
"Set the default background colour to be pink.")
("Purple"
(set-info-background-color
wb:*purple-color*)
"Set the default background colour to be purple.")
("Red"
(set-info-background-color
wb:*red-color*)
"Set the default background colour to be red.")
("White"
(set-info-background-color
wb:*white-color*)
"Set the default background colour to be white.")
("Yellow"
(set-info-background-color
wb:*yellow-color*)
"Set the default background colour to be yellow.")
)
)
("Pen color"
(set-info-pen-color (wb:prompt-user-for-color))
"Set the default pen colour for the information window."
:sub-items
(("Black"
(set-info-pen-color wb:*black-color*)
"Set the default pen colour to be black.")
("Gray"
(set-info-pen-color wb:*gray-color*)
"Set the default pen colour to be gray.")
("White"
(set-info-pen-color wb:*white-color*)
"Set the default pen colour to be white.")
("-"
()
"")
("User defined"
(set-info-pen-color (wb:prompt-user-for-color))
"Set the default pen colour to one defined by the user.")
("-"
()
"")
("Black"
(set-info-pen-color wb:*black-color*)
"Set the default pen colour to be black.")
("Blue"
(set-info-pen-color wb:*blue-color*)
"Set the default pen colour to be blue.")
("Blue (light)"
(set-info-pen-color wb:*light-blue-color*)
"Set the default pen colour to be light blue.")
("Brown"
(set-info-pen-color wb:*brown-color*)
"Set the default pen colour to be brown.")
("Brown (light)"
(set-info-pen-color wb:*tan-color*)
"Set the default pen colour to be tan.")
("Gray"
(set-info-pen-color wb:*gray-color*)
"Set the default pen colour to be gray.")
("Gray (dark)"
(set-info-pen-color wb:*dark-gray-color*)
"Set the default pen colour to be dark gray.")
("Gray (light)"
(set-info-pen-color wb:*light-gray-color*)
"Set the default pen colour to be light gray.")
("Green"
(set-info-pen-color wb:*green-color*)
"Set the default pen colour to be green.")
("Green (dark)"
(set-info-pen-color wb:*dark-green-color*)
"Set the default pen colour to be dark green.")
("Orange"
(set-info-pen-color wb:*orange-color*)
"Set the default pen colour to be orange.")
("Pink"
(set-info-pen-color wb:*pink-color*)
"Set the default pen colour to be pink.")
("Purple"
(set-info-pen-color wb:*purple-color*)
"Set the default pen colour to be purple.")
("Red"
(set-info-pen-color wb:*red-color*)
"Set the default pen colour to be red.")
("White"
(set-info-pen-color wb:*white-color*)
"Set the default pen colour to be white.")
("Yellow"
(set-info-pen-color wb:*yellow-color*)
"Set the default pen colour to be yellow.")
)
)
)
)
("Canvas parameters"
(inform-user "You must select a sub-item on this menu!")
"Set some global parameters for canvases."
:sub-items
(("Default background color"
(setf wb:*default-canvas-background-color*
(wb:prompt-user-for-color))
"Set the default background colour for all canvases."
:sub-items
(("Black"
(setf wb:*default-canvas-background-color*
wb:*black-color*)
"Set the default background colour to be black.")
("Gray"
(setf wb:*default-canvas-background-color*
wb:*gray-color*)
"Set the default background colour to be gray.")
("White"
(setf wb:*default-canvas-background-color*
wb:*white-color*)
"Set the default background colour to be white.")
("-"
()
"")
("User defined"
(setf wb:*default-canvas-background-color*
(wb:prompt-user-for-color))
"Set the default background colour to one defined by the
user.")
("-"
()
"")
("Black"
(setf wb:*default-canvas-background-color*
wb:*black-color*)
"Set the default background colour to be black.")
("Blue"
(setf wb:*default-canvas-background-color*
wb:*blue-color*)
"Set the default background colour to be blue.")
("Blue (light)"
(setf wb:*default-canvas-background-color*
wb:*light-blue-color*)
"Set the default background colour to be light blue.")
("Brown"
(setf wb:*default-canvas-background-color*
wb:*brown-color*)
"Set the default background colour to be brown.")
("Brown (light)"
(setf wb:*default-canvas-background-color*
wb:*tan-color*)
"Set the default background colour to be tan.")
("Gray"
(setf wb:*default-canvas-background-color*
wb:*gray-color*)
"Set the default background colour to be gray.")
("Gray (dark)"
(setf wb:*default-canvas-background-color*
wb:*dark-gray-color*)
"Set the default background colour to be dark gray.")
("Gray (light)"
(setf wb:*default-canvas-background-color*
wb:*light-gray-color*)
"Set the default background colour to be light gray.")
("Green"
(setf wb:*default-canvas-background-color*
wb:*green-color*)
"Set the default background colour to be green.")
("Green (dark)"
(setf wb:*default-canvas-background-color*
wb:*dark-green-color*)
"Set the default background colour to be dark green.")
("Orange"
(setf wb:*default-canvas-background-color*
wb:*orange-color*)
"Set the default background colour to be orange.")
("Pink"
(setf wb:*default-canvas-background-color*
wb:*pink-color*)
"Set the default background colour to be pink.")
("Purple"
(setf wb:*default-canvas-background-color*
wb:*purple-color*)
"Set the default background colour to be purple.")
("Red"
(setf wb:*default-canvas-background-color*
wb:*red-color*)
"Set the default background colour to be red.")
("White"
(setf wb:*default-canvas-background-color*
wb:*white-color*)
"Set the default background colour to be white.")
("Yellow"
(setf wb:*default-canvas-background-color*
wb:*yellow-color*)
"Set the default background colour to be yellow.")
)
)
("Default pen color"
(setf wb:*default-canvas-pen-color*
(wb:prompt-user-for-color))
"Set the default pen colour for all canvases."
:sub-items
(("Black"
(setf wb:*default-canvas-pen-color*
wb:*black-color*)
"Set the default pen colour to be black.")
("Gray"
(setf wb:*default-canvas-pen-color*
wb:*gray-color*)
"Set the default pen colour to be gray.")
("White"
(setf wb:*default-canvas-pen-color*
wb:*white-color*)
"Set the default pen colour to be white.")
("-"
()
"")
("User defined"
(setf wb:*default-canvas-pen-color*
(wb:prompt-user-for-color))
"Set the default pen colour to one defined by the user.")
("-"
()
"")
("Black"
(setf wb:*default-canvas-pen-color*
wb:*black-color*)
"Set the default pen colour to be black.")
("Blue"
(setf wb:*default-canvas-pen-color*
wb:*blue-color*)
"Set the default pen colour to be blue.")
("Blue (light)"
(setf wb:*default-canvas-pen-color*
wb:*light-blue-color*)
"Set the default pen colour to be light blue.")
("Brown"
(setf wb:*default-canvas-pen-color*
wb:*brown-color*)
"Set the default pen colour to be brown.")
("Brown (light)"
(setf wb:*default-canvas-pen-color*
wb:*tan-color*)
"Set the default pen colour to be tan.")
("Gray"
(setf wb:*default-canvas-pen-color*
wb:*gray-color*)
"Set the default pen colour to be gray.")
("Gray (dark)"
(setf wb:*default-canvas-pen-color*
wb:*dark-gray-color*)
"Set the default pen colour to be dark gray.")
("Gray (light)"
(setf wb:*default-canvas-pen-color*
wb:*light-gray-color*)
"Set the default pen colour to be light gray.")
("Green"
(setf wb:*default-canvas-pen-color*
wb:*green-color*)
"Set the default pen colour to be green.")
("Green (dark)"
(setf wb:*default-canvas-pen-color*
wb:*dark-green-color*)
"Set the default pen colour to be dark green.")
("Orange"
(setf wb:*default-canvas-pen-color*
wb:*orange-color*)
"Set the default pen colour to be orange.")
("Pink"
(setf wb:*default-canvas-pen-color*
wb:*pink-color*)
"Set the default pen colour to be pink.")
("Purple"
(setf wb:*default-canvas-pen-color*
wb:*purple-color*)
"Set the default pen colour to be purple.")
("Red"
(setf wb:*default-canvas-pen-color*
wb:*red-color*)
"Set the default pen colour to be red.")
("White"
(setf wb:*default-canvas-pen-color*
wb:*white-color*)
"Set the default pen colour to be white.")
("Yellow"
(setf wb:*default-canvas-pen-color*
wb:*yellow-color*)
"Set the default pen colour to be yellow.")
)
)
("Device type" (wb::set-device-type
(wb::prompt-user
:prompt-string
"Enter one of :color, :gray-scale, or
:black&white."
:type 'symbol
:read-type :eval))
"Set the type of the current device."
:sub-items
(("Color" (wb::set-device-type :color)
"Set the type of the current device to :color.")
("Gray scale" (wb::set-device-type :gray-scale)
"Set the type of the current device to :gray-scale.")
("Black and White" (wb::set-device-type :black&white)
"Set the type of the current device to :black&white.")
("Other" (wb::set-device-type
(wb::prompt-user
:prompt-string
(format NIL
"Enter one of ~s."
wb::*device-types*)
:type 'symbol
:read-type :eval))
"Set the type of the current device to :black&white.")))
("Default canvas position"
(quail-print "You must select a sub-item on this menu!")
"Set the default canvas position."
:sub-items
(("Bottom left corner"
(wb::set-up-default-canvas-region 10 10 400 300)
"All new canvases will appear for the first time in the bottom
left corner ~
of the display.")
("Top left corner"
(wb::set-up-default-canvas-region
10
(- (wb::screen-height) 300)
400 300)
"All new canvases will appear for the first time in the top
left corner ~
of the display.")
("Top right corner"
(wb::set-up-default-canvas-region
(- (wb::screen-width) 400)
(- (wb::screen-height) 300)
400 300)
"All new canvases will appear for the first time in the top
right corner ~
of the display.")
("Bottom right corner"
(wb::set-up-default-canvas-region
(- (wb::screen-width) 400)
10
400 300)
"All new canvases will appear for the first time in the bottom
right corner ~
of the display.")
("Center of display"
(wb::set-up-default-canvas-region
(- (round (/ (wb::screen-width) 2)) 200)
(- (round (/ (wb::screen-height) 2)) 150)
400 300)
"All new canvases will appear for the first time in the bottom
right corner ~
of the display.")
("Choose at creation"
(setf wb::*default-canvas-region* NIL)
"All new canvases will appear for the first time in the bottom
right corner ~
of the display.")
))
))
("-" () "")
("Default colors for Views"
(inform-user "You must select a sub-item on this menu!")
"Set background and pen color of the help window."
:sub-items
(
("Highlighting"
(setf *default-highlight-color* (wb:prompt-user-for-color))
"Set the default highlight colour for all views."
:sub-items
(("Black"
(setf *default-highlight-color* wb:*black-color*)
"Set the default highlight colour to be black.")
("Gray"
(setf *default-highlight-color* wb:*gray-color*)
"Set the default highlight colour to be gray.")
("White"
(setf *default-highlight-color* wb:*white-color*)
"Set the default highlight colour to be white.")
("-"
()
"")
("User defined"
(setf *default-highlight-color* (wb:prompt-user-for-color))
"Set the default highlight colour to one defined by the user.")
("-"
()
"")
("Black"
(setf *default-highlight-color* wb:*black-color*)
"Set the default highlight colour to be black.")
("Blue"
(setf *default-highlight-color* wb:*blue-color*)
"Set the default highlight colour to be blue.")
("Blue (light)"
(setf *default-highlight-color* wb:*light-blue-color*)
"Set the default highlight colour to be light blue.")
("Brown"
(setf *default-highlight-color* wb:*brown-color*)
"Set the default highlight colour to be brown.")
("Brown (light)"
(setf *default-highlight-color* wb:*tan-color*)
"Set the default highlight colour to be tan.")
("Gray"
(setf *default-highlight-color* wb:*gray-color*)
"Set the default highlight colour to be gray.")
("Gray (dark)"
(setf *default-highlight-color* wb:*dark-gray-color*)
"Set the default highlight colour to be dark gray.")
("Gray (light)"
(setf *default-highlight-color* wb:*light-gray-color*)
"Set the default highlight colour to be light gray.")
("Green"
(setf *default-highlight-color* wb:*green-color*)
"Set the default highlight colour to be green.")
("Green (dark)"
(setf *default-highlight-color* wb:*dark-green-color*)
"Set the default highlight colour to be dark green.")
("Orange"
(setf *default-highlight-color* wb:*orange-color*)
"Set the default highlight colour to be orange.")
("Pink"
(setf *default-highlight-color* wb:*pink-color*)
"Set the default highlight colour to be pink.")
("Purple"
(setf *default-highlight-color* wb:*purple-color*)
"Set the default highlight colour to be purple.")
("Red"
(setf *default-highlight-color* wb:*red-color*)
"Set the default highlight colour to be red.")
("White"
(setf *default-highlight-color* wb:*white-color*)
"Set the default highlight colour to be white.")
("Yellow"
(setf *default-highlight-color* wb:*yellow-color*)
"Set the default highlight colour to be yellow.")
)
)
("Point symbols"
(setf *default-point-color* (wb:prompt-user-for-color))
"Set the default point colour for all views."
:sub-items
(("Black"
(setf *default-point-color* wb:*black-color*)
"Set the default point colour to be black.")
("Gray"
(setf *default-point-color* wb:*gray-color*)
"Set the default point colour to be gray.")
("White"
(setf *default-point-color* wb:*white-color*)
"Set the default point colour to be white.")
("-"
()
"")
("User defined"
(setf *default-point-color* (wb:prompt-user-for-color))
"Set the default point colour to one defined by the user.")
("-"
()
"")
("Black"
(setf *default-point-color* wb:*black-color*)
"Set the default point colour to be black.")
("Blue"
(setf *default-point-color* wb:*blue-color*)
"Set the default point colour to be blue.")
("Blue (light)"
(setf *default-point-color* wb:*light-blue-color*)
"Set the default point colour to be light blue.")
("Brown"
(setf *default-point-color* wb:*brown-color*)
"Set the default point colour to be brown.")
("Brown (light)"
(setf *default-point-color* wb:*tan-color*)
"Set the default point colour to be tan.")
("Gray"
(setf *default-point-color* wb:*gray-color*)
"Set the default point colour to be gray.")
("Gray (dark)"
(setf *default-point-color* wb:*dark-gray-color*)
"Set the default point colour to be dark gray.")
("Gray (light)"
(setf *default-point-color* wb:*light-gray-color*)
"Set the default point colour to be light gray.")
("Green"
(setf *default-point-color* wb:*green-color*)
"Set the default point colour to be green.")
("Green (dark)"
(setf *default-point-color* wb:*dark-green-color*)
"Set the default point colour to be dark green.")
("Orange"
(setf *default-point-color* wb:*orange-color*)
"Set the default point colour to be orange.")
("Pink"
(setf *default-point-color* wb:*pink-color*)
"Set the default point colour to be pink.")
("Purple"
(setf *default-point-color* wb:*purple-color*)
"Set the default point colour to be purple.")
("Red"
(setf *default-point-color* wb:*red-color*)
"Set the default point colour to be red.")
("White"
(setf *default-point-color* wb:*white-color*)
"Set the default point colour to be white.")
("Yellow"
(setf *default-point-color* wb:*yellow-color*)
"Set the default point colour to be yellow.")
)
)
("Curves"
(setf *default-curve-color* (wb:prompt-user-for-color))
"Set the default curve colour for all views."
:sub-items
(("Black"
(setf *default-curve-color* wb:*black-color*)
"Set the default curve colour to be black.")
("Gray"
(setf *default-curve-color* wb:*gray-color*)
"Set the default curve colour to be gray.")
("White"
(setf *default-curve-color* wb:*white-color*)
"Set the default curve colour to be white.")
("-"
()
"")
("User defined"
(setf *default-curve-color* (wb:prompt-user-for-color))
"Set the default curve colour to one defined by the user.")
("-"
()
"")
("Black"
(setf *default-curve-color* wb:*black-color*)
"Set the default curve colour to be black.")
("Blue"
(setf *default-curve-color* wb:*blue-color*)
"Set the default curve colour to be blue.")
("Blue (light)"
(setf *default-curve-color* wb:*light-blue-color*)
"Set the default curve colour to be light blue.")
("Brown"
(setf *default-curve-color* wb:*brown-color*)
"Set the default curve colour to be brown.")
("Brown (light)"
(setf *default-curve-color* wb:*tan-color*)
"Set the default curve colour to be tan.")
("Gray"
(setf *default-curve-color* wb:*gray-color*)
"Set the default curve colour to be gray.")
("Gray (dark)"
(setf *default-curve-color* wb:*dark-gray-color*)
"Set the default curve colour to be dark gray.")
("Gray (light)"
(setf *default-curve-color* wb:*light-gray-color*)
"Set the default curve colour to be light gray.")
("Green"
(setf *default-curve-color* wb:*green-color*)
"Set the default curve colour to be green.")
("Green (dark)"
(setf *default-curve-color* wb:*dark-green-color*)
"Set the default curve colour to be dark green.")
("Orange"
(setf *default-curve-color* wb:*orange-color*)
"Set the default curve colour to be orange.")
("Pink"
(setf *default-curve-color* wb:*pink-color*)
"Set the default curve colour to be pink.")
("Purple"
(setf *default-curve-color* wb:*purple-color*)
"Set the default curve colour to be purple.")
("Red"
(setf *default-curve-color* wb:*red-color*)
"Set the default curve colour to be red.")
("White"
(setf *default-curve-color* wb:*white-color*)
"Set the default curve colour to be white.")
("Yellow"
(setf *default-curve-color* wb:*yellow-color*)
"Set the default curve colour to be yellow.")
)
)
("Labels"
(setf *default-label-color* (wb:prompt-user-for-color))
"Set the default label colour for all views."
:sub-items
(("Black"
(setf *default-label-color* wb:*black-color*)
"Set the default label colour to be black.")
("Gray"
(setf *default-label-color* wb:*gray-color*)
"Set the default label colour to be gray.")
("White"
(setf *default-label-color* wb:*white-color*)
"Set the default label colour to be white.")
("-"
()
"")
("User defined"
(setf *default-label-color* (wb:prompt-user-for-color))
"Set the default label colour to one defined by the user.")
("-"
()
"")
("Black"
(setf *default-label-color* wb:*black-color*)
"Set the default label colour to be black.")
("Blue"
(setf *default-label-color* wb:*blue-color*)
"Set the default label colour to be blue.")
("Blue (light)"
(setf *default-label-color* wb:*light-blue-color*)
"Set the default label colour to be light blue.")
("Brown"
(setf *default-label-color* wb:*brown-color*)
"Set the default label colour to be brown.")
("Brown (light)"
(setf *default-label-color* wb:*tan-color*)
"Set the default label colour to be tan.")
("Gray"
(setf *default-label-color* wb:*gray-color*)
"Set the default label colour to be gray.")
("Gray (dark)"
(setf *default-label-color* wb:*dark-gray-color*)
"Set the default label colour to be dark gray.")
("Gray (light)"
(setf *default-label-color* wb:*light-gray-color*)
"Set the default label colour to be light gray.")
("Green"
(setf *default-label-color* wb:*green-color*)
"Set the default label colour to be green.")
("Green (dark)"
(setf *default-label-color* wb:*dark-green-color*)
"Set the default label colour to be dark green.")
("Orange"
(setf *default-label-color* wb:*orange-color*)
"Set the default label colour to be orange.")
("Pink"
(setf *default-label-color* wb:*pink-color*)
"Set the default label colour to be pink.")
("Purple"
(setf *default-label-color* wb:*purple-color*)
"Set the default label colour to be purple.")
("Red"
(setf *default-label-color* wb:*red-color*)
"Set the default label colour to be red.")
("White"
(setf *default-label-color* wb:*white-color*)
"Set the default label colour to be white.")
("Yellow"
(setf *default-label-color* wb:*yellow-color*)
"Set the default label colour to be yellow.")
)
)
)
)
)
)
)
)
| 64,305 | Common Lisp | .l | 1,662 | 27.808063 | 83 | 0.5471 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 69f81dcdd5ca34a1d8649c9f435af009d8a39f444ae038d631d1c9b524fdd756 | 33,359 | [
-1
] |
33,361 | init-menubar-pc.lsp | rwoldford_Quail/source/top-level/init-menubar-pc.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; init-menubar-pc.lsp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; R.W. Oldford 1992.
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
(eval-when (load eval)
(setf *quail-menu* (quail-menu))
(setf *quail-plot-menu* (quail-plot-menu))
(add-menu-in-quail-menubar *quail-menu*)
| 671 | Common Lisp | .l | 19 | 31.105263 | 84 | 0.32716 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | a8604a882b96c2e455e60b020ac6ea75a56a7f3cf05b735dccd51a12e285abef | 33,361 | [
-1
] |
33,362 | top-level.lsp | rwoldford_Quail/source/top-level/top-level.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; top-level.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; M.E. Lewis 1991.
;;; R.W. Oldford 1991.
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
(eval-when (:compile-toplevel :load-toplevel :execute) (export '(*legal-top-level-loop-functions*
install-legal-top-level-loop top-level-loop-p
? *pending-top-levels* pop-level pop-to-top-level push-level
*pending-packages* pop-package push-package
eval-print quail-loop quail increment-quail-level
decrement-quail-level reset-quail-level quail-running-p quit-lisp
add-quail-command delete-quail-command)))
#|
;;;----------------------------------------------------------------------
;;;
;;; Make the toplevel quail available in the cl package.
;;;
;;;----------------------------------------------------------------------
(eval-when (:compile-toplevel :load-toplevel :execute) (import 'quail:quail :cl))
(eval-when (:compile-toplevel :load-toplevel :execute) (export 'quail :cl))
|#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Defining the legal top-level loop functions.
;;;
(defvar *legal-top-level-loop-functions* nil
"Variable containing a list of the legal top-level loop functions." )
(defun setup-legal-top-level-loop-functions ()
(declare (special *system-top-level-loop-function*
*legal-top-level-loop-functions*))
(setf *legal-top-level-loop-functions*
(list *system-top-level-loop-function*)))
(eval-when (load eval)
(setup-legal-top-level-loop-functions))
(defun top-level-loop-p (fun)
"T if the function is a legal top-level loop function,
NIL otherwise."
(declare (special *legal-top-level-loop-functions*))
(find fun *legal-top-level-loop-functions*))
(defun install-legal-top-level-loop (fun)
"Installs the argument as a legal top-level loop function.
Need only be done once."
(declare (special *legal-top-level-loop-functions*))
(if (not (top-level-loop-p fun))
(push fun *legal-top-level-loop-functions*)))
;;;;;;;;;;;
;;;
;;;
;;; Pushing and popping levels in quail's top-level loop.
;;;
(defvar *pending-top-levels* nil
"Variable containing the stack of top-level loop functions." )
(defun pop-level (&aux next-level)
"Pops the next pending level off the stack of top-level loop functions."
(declare
(special *pending-top-levels*
*system-top-level-loop-function*
*quail-terminal-io*))
(setq next-level (or (top-level-loop-p (pop *pending-top-levels*))
*system-top-level-loop-function*))
(format *quail-terminal-io* "~&popping levels from ~s to ~s."
(get-function-name (current-top-level))
(get-function-name next-level))
(install-top-level next-level))
(defun pop-to-top-level ()
"Pops the next pending levels off the stack of top-level loop functions
until the system top-level loop function is reached."
(declare
(special *pending-top-levels*
*pending-packages*
*system-top-level-loop-function*
*quail-terminal-io*))
(setf *pending-top-levels* NIL)
(format *quail-terminal-io* "~&popping levels from ~s to ~s."
(get-function-name (current-top-level))
(get-function-name *system-top-level-loop-function*))
(let ((top-package (last *pending-packages*)))
(set-listener-package (package-name (first top-package)))
(setf *pending-packages* NIL))
(install-top-level *system-top-level-loop-function*))
(defun push-level (top-level-fn)
"Pushes the given pending level onto the stack of top-level loop functions."
(declare
(special *pending-top-levels*))
(push top-level-fn *pending-top-levels*))
;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Ensure that the quail-loop is running in quail-user when first
;;; installed.
;;;
(defvar *pending-packages* nil
"Variable containing the stack of listener in-packages.")
(defun set-listener-package (package)
"Sets the listener's package to package."
(eval `(eval (in-package ,package))))
(defun pop-package (&aux next-package)
"Pops the next pending package off the stack of listener in-packages."
(declare
(special *pending-packages*))
(setq next-package (pop *pending-packages*))
(set-listener-package (package-name next-package)))
(defun push-package (package)
"Pushes the given pending package onto the stack of listener in-packages."
(declare
(special *pending-packages*))
(push package *pending-packages*))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Common Lisp variables
;;; that should behave equivalently in the
;;; quail loop.
;;;
;;;
(defvar + nil "See Common Lisp documentation.")
(defvar ++ nil "See Common Lisp documentation.")
(defvar +++ nil "See Common Lisp documentation.")
(defvar * nil "See Common Lisp documentation.")
(defvar ** nil "See Common Lisp documentation.")
(defvar *** nil "See Common Lisp documentation.")
(defvar / nil "See Common Lisp documentation.")
(defvar // nil "See Common Lisp documentation.")
(defvar /// nil "See Common Lisp documentation.")
(defvar - nil "See Common Lisp documentation.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Monitor the number of levels of quail's top-level loop are running.
;;;
(defvar *quail-levels* 0
"Variable containing the number of quail top-level loop functions pending." )
(defun quail-running-p ()
"True if a quail top-level loop is pending, nil otherwise."
(if (> *quail-levels* 0) T))
(defun increment-quail-level ()
"Increments the counter of quail top-level loop functions pending."
(declare (special *quail-levels*))
(incf *quail-levels* 1))
(defun decrement-quail-level ()
"Decrements the counter of quail top-level loop functions pending."
(declare (special *quail-levels*))
(if (quail-running-p) (decf *quail-levels* 1)))
(defun reset-quail-level ()
"Resets the counter of quail top-level loop functions pending to
its original value."
(declare (special *quail-levels*))
(setf *quail-levels* 0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Establish Quail top-level loop commands
;;;
(defvar *quail-top-level-commands* NIL
"A hash table containing the commands that are special to the
quail top-level loop.")
(defun pop-quail ()
"Pops one level of quail."
(decrement-quail-level)
(pop-package)
(pop-level))
(defun exit-quail ()
"Exits from the present and all pending Quail top-level loops."
(declare (special *quail-terminal-io*))
(reset-quail-level)
(format *quail-terminal-io* "~&Bye ~%")
(pop-to-top-level))
(defun quit-lisp ()
"Politely quits lisp."
(when (quail-yes-or-no-p "Really quit LISP?")
(if (quail-yes-or-no-p "Save your quail objects?")
(save-quail-objects))
(system-quit-lisp)))
;;;;;;;;;;;;;;;;;
;;;
;;; Making infix available
;;;
(defvar *read-as-infix* NIL)
(defun infix ()
(declare (special *read-as-infix*
*extra-prompt-info*))
(push "INFIX" *extra-prompt-info*)
(setf *read-as-infix* T))
(defun prefix ()
(declare (special *read-as-infix*
*extra-prompt-info*))
(setf *extra-prompt-info*
(loop for s in *extra-prompt-info* when (not (string-equal s "INFIX"))
collect s))
(setf *read-as-infix* NIL))
(defun infix-p ()
(declare (special *read-as-infix*))
*read-as-infix*)
(defun show-quail-commands ()
"Shows the non-LISP commands understood by the Quail top-level loop."
(declare (special *quail-top-level-commands*
*quail-terminal-io*))
(format *quail-terminal-io*
"~&~%
Besides any legal LISP expression, Quail provides a collection of ~%
top-level commands. These are usually keywords. ~%
Currently available quail top-level commands are: ~2%"
)
(maphash
#'(lambda (key value)
(declare (special *quail-terminal-io*))
(fresh-line *quail-terminal-io*)
(format *quail-terminal-io*
"~&~15@<~s~>~A" key (second value)))
*quail-top-level-commands*)
(fresh-line *quail-terminal-io*)
(terpri *quail-terminal-io*)
(values))
(defun quail-command-p (command-name)
"Returns true if the argument names a Quail top-level command, NIL otherwise."
(declare (special *quail-top-level-commands*))
(multiple-value-bind (command-info found?)
(gethash command-name *quail-top-level-commands*)
(declare (ignore command-info))
found?))
(defun add-quail-command
(command-name command-fn
&optional (doc-string "No documentation available."))
"Adds a command to Quail's set of top-level commands.
First argument is a symbol representing the command name
(typically a keyword symbol); second is a function of no arguments
to be funcalled when the command is executed.
Optionally, a documentation string may be given."
(declare (special *quail-top-level-commands*))
(if (quail-command-p command-name)
(if (quail-yes-or-no-p "The command ~s already exists. ~%
Replace it anyway?" command-name)
(setf (gethash command-name *quail-top-level-commands*)
(list command-fn doc-string)))
(setf (gethash command-name *quail-top-level-commands*)
(list command-fn doc-string))))
(defun delete-quail-command (command-name)
"Removes the Quail top-level command named by the argument.
Returns T if command was present, NIL otherwise."
(declare (special *quail-top-level-commands*))
(remhash command-name *quail-top-level-commands*))
(defun do-quail-command (command-name)
"Executes the named top-level Quail command if it exists.
Error otherwise."
(declare (special *quail-top-level-commands*))
(multiple-value-bind (command-fn-info exists?)
(gethash command-name *quail-top-level-commands*)
(if exists?
(funcall (car command-fn-info))
(quail-error
"~&Sorry, ~s is not a top-level Quail command." command-name))))
(defun setup-quail-top-level-commands ()
"Sets up Quail's basic set of top-level commands."
(declare (special *quail-top-level-commands*))
(setf *quail-top-level-commands*
(make-hash-table :size 10))
(add-quail-command '? #'show-quail-commands
"Displays all available Quail top-level commands.")
(add-quail-command :infix
#'infix "Read ALL top-level expressions in infix notation.")
(add-quail-command :prefix
#'prefix
"Read ALL top-level expressions in the usual prefix notation.")
(add-quail-command :pop #'pop-quail
"Pop to the next pending top-level loop.")
(add-quail-command :exit #'exit-quail
"Exit completely from Quail.")
(add-quail-command :quit #'exit-quail
"Exit completely from Quail.")
(add-quail-command :bye #'exit-quail
"Exit completely from Quail.")
(add-quail-command :quit! #'quit-lisp
"Quit from LISP.")
(add-quail-command :help #'(lambda ()
(show-quail-commands)
(help))
"Invokes the general help facility.")
(add-quail-command :topics #'(lambda ()
;;(ensure-loaded-topics :package :quail)
(help 'Quail :topic)
;;(delete-quail-command :load-topics)
)
"General information on quail organized by topic.")
(add-quail-command 'help
#'(lambda ()
(format *quail-terminal-io*
"With the exception of ? all quail toplevel commands
are keyword symbols. ~&
That is, the first character is a colon.~&
If you would like general help information type :help. ~&
If you would only like to see the set of available quail toplevel commands
type ?. ~%
N.B. This message will appear only once. ~&
From now on you must use :help or ?.")
(delete-quail-command 'help)
(show-quail-commands))
"A one shot look at the available quail-commands.")
)
(eval-when (eval load) (setup-quail-top-level-commands))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Evaluating and printing in the quail loop
;;;
;;;
#| ;;The old one.
(defun eval-print (&optional (stream *quail-terminal-io*)
&aux result)
"Evaluates and prints the form supplied. Output to stream, ~
if supplied, otherwise to *quail-terminal-io*."
(declare
(special *quail-terminal-io*
+ ++ +++ * ** *** / // /// -))
(setf result (multiple-value-list (eval -)))
(setf +++ ++)
(setf ++ +)
(setf + -)
(setf *** **)
(setf ** *)
(setf /// //)
(setf // /)
(setf / (list (setf * (print (car result) stream))))
(if (> (length result) 1)
(setf / (append /
(loop for v in (cdr result) collect (print v stream)))))
*
)
|#
(defun eval-print (&optional (stream *quail-terminal-io*)
&aux result)
"Evaluates and prints the form supplied. Output to stream,
if supplied, otherwise to *quail-terminal-io*."
(declare
(special *quail-terminal-io*
+ ++ +++ * ** *** / // /// -))
(setf result (multiple-value-list
(eval
(if (infix-p)
(setf -
(infix2prefix -))
-)))
)
(setf +++ ++)
(setf ++ +)
(setf + -)
(setf *** **)
(setf ** *)
(setf /// //)
(setf // /)
(setf / (list (setf * (format stream "~&~a" (car result)))))
(if (> (length result) 1)
(setf / (append /
(loop for v in (cdr result)
collect
(format stream "~&~a" (car result))))))
*
)
(defun quail-top-level-eval-current-form ()
"Evaluates and prints the value of the current form (the value of the
- symbol). Accepts quail commands as well."
(declare (special -))
(if (quail-command-p -)
(do-quail-command -)
(eval-print)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Quail top-level loop
;;;
(defun quail-read ()
"Read the next Quail expression."
(quail:get-next-form))
(defun quail-loop (&aux prompt-string)
"The Quail top-level loop function."
(declare (special - *quail-levels*))
(fresh-line)
(setf prompt-string
(concatenate 'string
"Quail"
(extra-prompt-info)
(if (> *quail-levels* 1)
(format nil "(~s)" (- *quail-levels* 1))
(values))
"> "))
(princ prompt-string)
(setf - (quail-read))
(quail-top-level-eval-current-form)
)
(defvar *extra-prompt-info* NIL)
(defun extra-prompt-info ()
(declare (special *extra-prompt-info*))
(if *extra-prompt-info*
(apply #'concatenate 'string "{" (append *extra-prompt-info* (list "}")))
(values)))
(defun quail::setup-legal-quail-loop ()
(install-legal-top-level-loop #'quail-loop))
(eval-when (eval load)
(setup-legal-quail-loop))
(defun quail ()
"Starts the Quail top-level loop."
(declare (special *package* *quail-terminal-io* *quail-levels*))
(if (zerop *quail-levels*)
(format *quail-terminal-io*
"~%Welcome to ~a! ~%
Several keyword commands are available at Quail's top-level loop. ~&
To see these, type ? at the Quail prompt. ~&
If you exit Quail, you can always reinvoke it by typing (quail). ~%"
(qk::quail-release)))
(increment-quail-level)
(push-level (current-top-level))
(push-package *package*)
(set-listener-package :quail-user)
(install-top-level #'quail-loop)
)
| 17,381 | Common Lisp | .l | 420 | 33.228571 | 111 | 0.568647 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | d367893bb4265f4ca859787cfdc3f04207389d2dc8d1784c13794eebc80a9078 | 33,362 | [
-1
] |
33,364 | editor-pc.lsp | rwoldford_Quail/source/top-level/editor-pc.lsp | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; editor-pc.lisp
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;
;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo
;;;
;;;
;;; Authors:
;;; M.E. Lewis 1991.
;;; R.W. Oldford 1991.
;;;
;;;--------------------------------------------------------------------------------
(in-package :quail)
;;; Just tries to ensure that expressions can be evaluated from a Fred
;;; window when the the top-level Quail loop is running.
#|
(defmethod ccl::ed-eval-or-compile-current-sexp :around ((w ccl::fred-mixin))
(when (quail-running-p)
(ccl::eval-enqueue (ccl::ed-current-sexp w))
(ccl::toplevel)
)
(call-next-method))
|#
| 900 | Common Lisp | .l | 26 | 30.346154 | 84 | 0.403712 | rwoldford/Quail | 0 | 1 | 0 | GPL-3.0 | 9/19/2024, 11:43:28 AM (Europe/Amsterdam) | 284b18fa30b18041eaf6c36e652253e26e52a9f870df8244fe4c2fb99b691440 | 33,364 | [
-1
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.