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,365
quail-menu.lsp
rwoldford_Quail/source/top-level/quail-menu.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.") ) ) ) ; outer (("Help in windows" ) ; end ("Help window" ("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.") ) ) ) ; end outer (("Highlighting" ) ; ("Default colors for views" ) ; outer (( Run Quail toplevel loop ) ; end ("Environment" ) ; outer (( "About Quail" )(<- *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.") ) ) ) ; outer (("Help in windows" ) ; end ("Help window" ("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.") ) ) ) ; end outer (("Highlighting" ) ; ("Default colors for views" ) ; outer (( Run Quail toplevel loop ) ; end ("Environment" ) ; outer (( "About Quail" )
126,801
Common Lisp
.l
3,260
27.817485
83
0.546821
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
cec0dfe169012fe8374c7b20a9b1e3c500dea02d1c07398e98f01a6647f744e8
33,365
[ -1 ]
33,367
quail-menubar-pc.lsp
rwoldford_Quail/source/top-level/quail-menubar-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; quail-menubar-pc.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; G.W. Bennett 1997. ;;; ;;; was new-qmb-pc.lsp but became qmb-pc.lsp May 19 1998 ;;; to test the building of Quail menubar ... gwb 051998 ;;;-------------------------------------------------------------------------------- ;;; See also Q/Q/S/Top-Level/quail-menubar-pc-log.lsp (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*quail-menubar* add-menu-in-quail-menubar remove-menu-from-quail-menubar install-quail-menubar ))) #| Replaced March 25 1998 ;; Nov 11+ 1997 redefined *q-mnb* to be cg::*lisp-menu-bar* (defvar *quail-menubar* (if (typep wb::*system-default-menubar* 'cg::closed-stream) (wb::set-system-default-menubar) wb::*system-default-menubar*) "The default menubar put up for the Quail system.~ This is to be the main menubar for ACL.") |# (defvar *quail-menubar* NIL "The default menubar put up for the Quail system.") #| 06JUL2023 not used in this file! (defvar *system-default-menubar-items* (cg::menu-items wb::*system-default-menubar*) "The default menubar items of the system.") |# ;; Added 042098 gwb (defun add-menu-in-quail-menubar (menu) "Adds the menu to Quail's menubar. ~ if it is not already there. Adjusts the width of the menubar if necessary.~ menu may be a menu or a menu-item (:see-also install-quail-menubar remove-menu-from-quail-menubar)" (declare (special *quail-menubar* wb::*system-default-menubar*)) ;; (if (typep *quail-menubar* 'cg::closed-stream) ;; (setf *quail-menubar* wb::*system-default-menubar*)) (cond (*quail-menubar* (wb::add-menu-in-menubar menu *quail-menubar*) ) (T (install-quail-menubar) (add-menu-in-quail-menubar menu)) )) (defun remove-menu-from-quail-menubar (menu) "Removes the menu from Quail's menubar. ~ if it is there. Adjusts the width of the menubar after removal. (:see-also install-quail-menubar add-menu-in-quail-menubar)" (declare (special *quail-menubar*)) (wb::remove-menu-from-menubar menu *quail-menubar*) (unless (cg::menu-items *quail-menubar*) (if (quail-yes-or-no-p "~&You have just stripped the menubar bare!! ~%Is that OK?") (warn "To get the default one back type ~%(install-default-quail-menubar). ") (install-quail-menubar))) ) ;; Nov 11+ changed wb::*sy-def-mnb-its* to *sy-def-mnb-its* ;; since that variable is defined at the top of this file! (defun install-default-quail-menubar () "Creates and installs the default top level Quail menubar." (declare (special *quail-menubar* wb::*system-default-menubar*)) #| (when (and *quail-menubar* (cg::streamp *quail-menubar*)) (cg::close *quail-menubar*) (cg::close (cg::parent *quail-menubar*))) |# (when (or (null wb::*system-default-menubar*) ;; (typep wb::*system-default-menubar* 'cg::closed-stream) (not (cg::open-stream-p (cg::parent wb::*system-default-menubar*))) ) (wb::set-system-default-menubar)) (setf *quail-menubar* wb::*system-default-menubar*) (add-menu-in-quail-menubar (quail-menu)) (add-menu-in-quail-menubar (quail-plot-menu)) ) (defun install-quail-menubar () "Installs the top-level Quail's menubar according to the ~ value of *quail-menubar*." ;; Carry over MCL implementation where this would have to set the ;; menubar on top of the Mac menubar. Pay no attention to the ;; man behind the curtain! (install-default-quail-menubar)) (eval-when (:load-toplevel :execute) (add-restore-lisp-functions #'wb::set-system-default-menubar #'q::install-default-quail-menubar)) ;;; ;;; Spot to get rid of pop-up menus when a view-window is closed ;;; (excl::without-package-locks (defmethod cg::device-close :around ((w vw::view-window) abort) (declare (ignore abort)) (let ((vps-vws (vw::viewports-and-views-of w)) ;(viewports-and-views-of w)) ; 30JUL2030 vws (result (call-next-method))) (when vps-vws (setf vws (loop for vp-vw in vps-vws collect (cdr vp-vw))) (labels ((doit (a-view) (loop for m in '(vw::left-menu vw::middle-menu vw::right-menu vw::ctrl-left-menu vw::ctrl-middle-menu vw::ctrl-right-menu ) when (and (slot-exists-p a-view m) (wb::menu-p (slot-value a-view m))) do (wb::release-menu-space (slot-value a-view m)) (setf (slot-value a-view m) NIL)) (when (slot-exists-p a-view 'vw::subviews) (loop for sv in (vw::subviews-of a-view) ;(subviews-of a-view) ; 30JUL2023 do (doit sv)))) ) (loop for vw in vws do (doit vw))) ) result) ) )
5,369
Common Lisp
.l
131
34.305344
137
0.58518
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f7ef7debe5cbe7873b0065e528931117f9deca424946727ce4dda530a3a4aacf
33,367
[ -1 ]
33,368
gwb1-28jan15.lsp
rwoldford_Quail/source/top-level/gwb1-28jan15.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; ;;; ;;; gwb1-28Jan15.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,420
Common Lisp
.l
1,663
27.791942
79
0.547088
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
01ca2b8cc1778000c2a20407684f2d9956e0c4f0df7ebcb1198e58fb5b5845de
33,368
[ -1 ]
33,371
quail-menubar-sblx.lsp
rwoldford_Quail/source/top-level/quail-menubar-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; quail-menubar-sblx.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; G.W. Bennett 1997. ;;; ;;; was new-qmb-pc.lsp but became qmb-pc.lsp May 19 1998 ;;; to test the building of Quail menubar ... gwb 051998 ;;;-------------------------------------------------------------------------------- ;;; See also Q/Q/S/Top-Level/quail-menubar-pc-log.lsp (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*quail-menubar* add-menu-in-quail-menubar remove-menu-from-quail-menubar install-quail-menubar ))) #| Replaced March 25 1998 ;; Nov 11+ 1997 redefined *q-mnb* to be cg::*lisp-menu-bar* (defvar *quail-menubar* (if (typep wb::*system-default-menubar* 'cg::closed-stream) (wb::set-system-default-menubar) wb::*system-default-menubar*) "The default menubar put up for the Quail system.~ This is to be the main menubar for ACL.") |# (defvar *quail-menubar* NIL "The default menubar put up for the Quail system.") (defvar *system-default-menubar-items* (cg::menu-items wb::*system-default-menubar*) "The default menubar items of the system.") ;; Added 042098 gwb (defun add-menu-in-quail-menubar (menu) "Adds the menu to Quail's menubar. ~ if it is not already there. Adjusts the width of the menubar if necessary.~ menu may be a menu or a menu-item (:see-also install-quail-menubar remove-menu-from-quail-menubar)" (declare (special *quail-menubar* wb::*system-default-menubar*)) ;; (if (typep *quail-menubar* 'cg::closed-stream) ;; (setf *quail-menubar* wb::*system-default-menubar*)) (cond (*quail-menubar* (wb::add-menu-in-menubar menu *quail-menubar*) ) (T (install-quail-menubar) (add-menu-in-quail-menubar menu)) )) (defun remove-menu-from-quail-menubar (menu) "Removes the menu from Quail's menubar. ~ if it is there. Adjusts the width of the menubar after removal. (:see-also install-quail-menubar add-menu-in-quail-menubar)" (declare (special *quail-menubar*)) (wb::remove-menu-from-menubar menu *quail-menubar*) (unless (cg::menu-items *quail-menubar*) (if (quail-yes-or-no-p "~&You have just stripped the menubar bare!! ~%Is that OK?") (warn "To get the default one back type ~%(install-default-quail-menubar). ") (install-quail-menubar))) ) ;; Nov 11+ changed wb::*sy-def-mnb-its* to *sy-def-mnb-its* ;; since that variable is defined at the top of this file! (defun install-default-quail-menubar () "Creates and installs the default top level Quail menubar." (declare (special *quail-menubar* wb::*system-default-menubar*)) ;; #| (when (and *quail-menubar* (cg::streamp *quail-menubar*)) (cg::close *quail-menubar*) (cg::close (cg::parent *quail-menubar*))) ;; |# (when (or (null wb::*system-default-menubar*) ;; (typep wb::*system-default-menubar* 'cg::closed-stream) (not (cg::open-stream-p (cg::parent wb::*system-default-menubar*))) ) (wb::set-system-default-menubar)) (setf *quail-menubar* wb::*system-default-menubar*) (add-menu-in-quail-menubar (quail-menu)) (add-menu-in-quail-menubar (quail-plot-menu)) ) (defun install-quail-menubar () "Installs the top-level Quail's menubar according to the ~ value of *quail-menubar*." ;; Carry over MCL implementation where this would have to set the ;; menubar on top of the Mac menubar. Pay no attention to the ;; man behind the curtain! (install-default-quail-menubar)) (eval-when (:load-toplevel :execute) (add-restore-lisp-functions #'wb::set-system-default-menubar #'q::install-default-quail-menubar)) ;;; ;;; Spot to get rid of pop-up menus when a view-window is closed ;;; (defmethod cg::device-close :around ((w vw::view-window) abort) (declare (ignore abort)) (let ((vps-vws (viewports-and-views-of w)) vws (result (call-next-method))) (when vps-vws (setf vws (loop for vp-vw in vps-vws collect (cdr vp-vw))) (labels ((doit (a-view) (loop for m in '(vw::left-menu vw::middle-menu vw::right-menu vw::ctrl-left-menu vw::ctrl-middle-menu vw::ctrl-right-menu ) when (and (slot-exists-p a-view m) (wb::menu-p (slot-value a-view m))) do (wb::release-menu-space (slot-value a-view m)) (setf (slot-value a-view m) NIL)) (when (slot-exists-p a-view 'vw::subviews) (loop for sv in (subviews-of a-view) do (doit sv)))) ) (loop for vw in vws do (doit vw))) ) result) )
5,225
Common Lisp
.l
127
34.275591
137
0.582219
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
2a01dc1aff0b6628f5bf5eb1007f7db057e51332005758cef122065645fb6c66
33,371
[ -1 ]
33,372
top-level-sblx.lsp
rwoldford_Quail/source/top-level/top-level-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; top-level-sblx.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-toplevel :execute) ;eval) 18MAR2022 gwb (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*)) (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,386
Common Lisp
.l
60
35.766667
133
0.589965
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
0084d112c217a2124b6ac268921b33c21f0297f6c42e69a1f8884c8bcbfd32c6
33,372
[ -1 ]
33,373
quail-plot-menu.lsp
rwoldford_Quail/source/top-level/quail-plot-menu.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; quail-plot-menu.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992. ;;; ;;;-------------------------------------------------------------------------------- (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*quail-plot-menu-items* add-to-plot-menu delete-from-plot-menu))) (defvar *quail-plot-menu-items* NIL "The menu items to appear in the default plot menu.") (setq *quail-plot-menu-items* (vw:plot-menu-items)) (defmethod vw::single-plot-by-dim :around ((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")) (list "Scatterplot Matrix" "Plot matrix" "Side by side" "Andrews' Trace" "Tukey's Trace")))) (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 "Andrews' Trace") (apply #'prompt-projection-trace :andrews :vars v args)) ((string-equal plot-fn "Tukey's Trace") (apply #'prompt-projection-trace :tukey :vars v 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)) ) (call-next-method))) (defun quail-plot-menu () "Creates and returns the default plot menu for the Quail menubar." (wb:make-menu :items *quail-plot-menu-items* :title "Plots" :menu-type :title )) (defun add-to-plot-menu (item &rest other-items) "Adds one or more items to the list of items in the ~ quail-plot-menu-items. Returns the new plot-menu-items list. ~ Destructive to *quail-plot-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-plot-menu *quail-plot-menu-items* ~ remake-quail-menubar) ~ " (declare (special *quail-plot-menu-items*)) (nconc *quail-plot-menu-items* (list item) other-items) *quail-plot-menu-items*) (defun delete-from-plot-menu (item &rest other-items) "Deletes one or more items from the list of items in the ~ quail-plot-menu-items. Returns the new menu-items list. ~ Destructive to *quail-plot-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-plot-menu-items* ~ remake-quail-menubar) ~ " (declare (special *quail-plot-menu-items*)) (delete item *quail-plot-menu-items* :test #'equal) (when other-items (dolist (item other-items) (delete item *quail-plot-menu-items* :test #'equal))) *quail-plot-menu-items*)
4,291
Common Lisp
.l
93
36.526882
131
0.538981
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
8becf9faca4e6c21b197a660fa335a1de5e23bc90ba2001b899411f9758e0e42
33,373
[ -1 ]
33,375
re-enable-menus.lsp
rwoldford_Quail/source/top-level/re-enable-menus.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; re-enable-menus.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; Authors: ;;; R.W. Oldford 1996 ;;; ;;; ;;; (in-package :q-user) (setf wb::*all-menus* (append wb::*all-menus* (list (q::quail-menu) (q::quail-plot-menu))))
593
Common Lisp
.l
22
22.5
81
0.308642
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
d7eb5e87caca7e21c067be520bb941028f2e4c7a42435c8634854576660f0bfb
33,375
[ -1 ]
33,378
editor-sblx.lsp
rwoldford_Quail/source/top-level/editor-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; editor-sblx.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)) |#
870
Common Lisp
.l
26
30.423077
83
0.417661
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f4ace4309278f480bc8b895258276d9d3de04f2deb90f02f224ffb4f3dd8f401
33,378
[ -1 ]
33,381
syn-stream-bug.lsp
rwoldford_Quail/source/top-level/bugs/syn-stream-bug.lsp
;;;********* bug in MCL 2.0b1 ;;; ;;; Do synonym streams really work? ;;; ;;; Consider the following: ;;; (defun my-read () (read)) (defun si-read () (declare (special *standard-input*)) (read *standard-input*)) (defvar *syn-standard-input*) (setf *syn-standard-input* (make-synonym-stream '*standard-input*)) (defun syn-read () (declare (special *syn-standard-input*)) (read *syn-standard-input*)) ;;; ;;; ;;; ANd in the listener: ;;; ? (my-read) (+ 2 3) ;<--- as typed (+ 2 3) ;<--- as returned ? (my-read) (+ 2 3) ;<--- typed as (+ 2 300000000000000 & 14 backspaces) (+ 2 3) ;<--- as returned ? (si-read) (+ 2 3) ;<--- as typed (+ 2 3) ;<--- as returned ? (si-read) (+ 2 3) ;<--- typed as (+ 2 300000000000000 & 14 backspaces) (+ 2 3) ;<--- as returned ? (syn-read) (+ 2 3) ;<--- as typed (+ 2 3) ;<--- as returned ? (syn-read) (+ 2 3) ;<--- typed as (+ 2 300000000000000 & 14 backspaces) (+ 2 300000000000000) ;<--- as returned ;;; ;;; ;;;;;;;;;;;;;; Argggggggggggggggggggggh!!!!!!!!!!!!! ;;; ;;; ;;; Explanations anyone? MCL folk?
1,368
Common Lisp
.l
44
28.318182
83
0.453426
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
7982a9b3ea150657f0e3851685fdfdeae007e06fe0899ff7a38e740dec0ee6b5
33,381
[ -1 ]
33,382
history.lsp
rwoldford_Quail/source/top-level/misc/history.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; history.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; ;;; ;;;---------------------------------------------------------------------------- (in-package :quail) ;;;------------------------------------------------------------------------------- ;;; ;;; an eval that takes a history ;;; ;;;------------------------------------------------------------------------------- (defmacro history-eval (form &optional (history '*current-history*)) (declare (special *current-history*)) `(let ((result (eval , form)) (event (make-instance 'history-event :form (quote , form)))) (record-event , history event) result)) ;;;-------------------------------------------------------------------------------- ;;; ;;; History structure ;;; ;;;-------------------------------------------------------------------------------- (defclass history () ((contents :accessor contents-of) (size :initarg :size :initform 25 :reader size-of) (saved-events :initarg :saved-cmds :initform () :accessor saved-events-of) (current-line-no :initform 1 :accessor current-line-no-of) (current-line :initform 0 :initarg :current-line :accessor current-line-of))) (defmethod initialize-instance :after ((self history) &key) (setf (contents-of self ) (make-list (size-of self))) self) ;;;;;;;;;;;;; ;;; ;;; Record an event on the history ;;; (defmethod record-event ((self history) event) (setf (elt (contents-of self) (current-line-of self)) event) (setf (current-line-of self) (mod (+ (current-line-of self) 1) (size-of self))) (setf (current-line-no-of self) (+ (current-line-no-of self) 1))) ;;;;;;;;;;;; ;;; ;;; Change the size of the history ;;; (defmethod (setf size-of) (new-value (self history)) (if (not (and (integerp new-value) (> new-value 0))) (error "Size must be a positive integer. Not ~s !" new-value) (labels ((insert-list (list at size) (append (subseq list 0 at) (make-list size) (subseq list at))) (delete-list (list at amount) (if (> at 0) (append (subseq list 0 at) (subseq list (+ at amount))) (subseq list amount)))) (let ((num-events-to-add (- new-value (size-of self)))) (cond ((> num-events-to-add 0) (setf (contents-of self) (insert-list (contents-of self) (current-line-of self) num-events-to-add))) ((< num-events-to-add 0) (setf (contents-of self) (delete-list (contents-of self) (current-line-of self) (- num-events-to-add)))))) (setf (slot-value self 'size) new-value)))) ;;;-------------------------------------------------------------------------- ;;; ;;; History-events ;;; ;;;-------------------------------------------------------------------------- (defclass history-event () ((form :reader form-of :initarg :form) (time-stamp :reader time-stamp-of :initform (get-universal-time)) (creator :accessor creator-of :initform 'User))) ;;;;;;;; ;;; ;;; Some silly methods for interacting with the time-stamp of an event ;;; (defmethod date-of ((self history-event)) (multiple-value-bind (second minute hour day month year day-of-week) (decode-universal-time (time-stamp-of self)) (setf month (case month (1 "January") (2 "February") (3 "March") (4 "April") (5 "May") (6 "June") (7 "July") (8 "August") (9 "September") (10 "October") (11 "November") (12 "December"))) (setf day-of-week (case day-of-week (0 "Monday") (1 "Tuesday") (2 "Wednesday") (3 "Thursday") (4 "Friday") (5 "Saturday") (6 "Sunday"))) (concatenate 'string (format NIL "~S:~S:~S " hour minute second) day-of-week " " month (format NIL " ~S ~S" day year)))) ;;;-------------------------------------------------------------------------- ;;; ;;; Redo selected event ;;; ;;;-------------------------------------------------------------------------- #| Fancy redo below is not finished (defun redo (&rest args) (cond ((null args) (redo-event (get-last-history-event))) ((= 1 (length args)) (redo-event (car args))) (T (let* ((history (position :history args)) (from (position :from args)) (to (position :to args)) (with (position :with args)) (for (position :for args))) (cond ((and with for) "replacing") ((and from to) "range") (from "to current-line less one") ) ) ) ) ) |# ;;; Instead the following one works: (defun redo (&rest args) (apply #'redo-event args)) (defmethod redo-event ((self history-event) &key) (eval `(history-eval , (form-of self)))) (defmethod redo-event ((self t) &key (history *current-history*)) (declare (special *current-history*)) (redo-event (get-event history self))) (defmethod get-last-history-event (&optional (history *current-history*)) (get-event history (- (current-line-no-of history) 1))) (defmethod get-event ((self history) (line-no integer)) (let ((c-l-n (current-line-no-of self))) (cond ((<= line-no 0) (cond ((< (size-of self) (abs line-no)) (print (format nil "Sorry, event numbered ~a has dropped off the history." line-no)) (values)) (T (elt (contents-of self) (mod (+ (current-line-of self) line-no) (size-of self)))))) ((>= line-no c-l-n) (print (format nil "Redo? I haven't even done that one yet!~ ~%Current line is ~A, you asked for ~A" c-l-n line-no)) (values)) ((< (size-of self) (- c-l-n line-no)) (print (format nil "Sorry, event numbered ~a has dropped off the history." line-no)) (values)) (T (elt (contents-of self) (mod (+ (current-line-of self) (- line-no c-l-n)) (size-of self))))))) (defmethod get-event ((self history) (symbol symbol)) (let* ((current-line (current-line-of self)) (one-piece (= 0 current-line)) (contents (contents-of self)) the-event) (labels ((test-event (event) (member symbol (form-of event)))) (setf the-event (if one-piece (find-if #'test-event contents :from-end T) (or (find-if #'test-event contents :from-end T :start 0 :end (- current-line 1)) (find-if #'test-event contents :from-end T :start current-line)))) the-event))) ;;;-------------------------------------------------------------------------- ;;; ;;; Permanent events that don't drop off the history stack ;;; are stored on the slot saved-events. ;;; the following functions are used to interact with this slot. ;;; ;;;-------------------------------------------------------------------------- (defmethod save-event ((self history) event) (setf (saved-events-of self) (push event (saved-events-of self))) event) (defmethod rm-saved-event ((self history) event) (setf (saved-events-of self) (remove event (saved-events-of self))) event)
8,385
Common Lisp
.l
231
27.354978
84
0.458809
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
6790e9f322f1ae6874914ebf32980e50c9ddab37df30e1e5629c0cab0135c944
33,382
[ -1 ]
33,383
history-loop.lsp
rwoldford_Quail/source/top-level/misc/history-loop.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; history.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; M.E. Lewis ;;; R.W. Oldford 1991. ;;; ;;;-------------------------------------------------------------------------------- (defclass foo () ((form :initarg :form :accessor form-of) (back-links :initarg :back-links :accessor back-links-of :initform NIL) (to-links :initarg :to-links :accessor to-links-of :initform NIL))) (defmethod link ((a foo) (b foo)) (push a (back-links-of b)) (push b (to-links-of a))) (defmethod link (a b) ) (defmethod set-spawning-expression (thing expression) ) (defmethod set-spawning-expression ((thing foo) expression) (setf (form-of thing) expression)) (defun map-top (&aux f) (print 'map?) (setq f (read)) (cond ((eq f :end-map) (%set-toplevel #'quail-top)) ((listp f) (let* ((args (loop for a in (cdr f) collect (eval a))) (result (eval `(,(car f) ,@args)))) (loop for a in args do (link a result)) (set-spawning-expression result (append (list (car f)) args)) (setf +++ ++) (setf ++ +) (setf + f) (setf *** **) (setf ** *) (setf * (eval f)) (print * *terminal-io*))) (T "?"))) (defun my-map () (format *terminal-io* "history on") (%set-toplevel #'map-top) (toplevel))
1,652
Common Lisp
.l
51
27.313725
84
0.460908
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
9ff72aee4933baeb643476b418697e26e63e3d78b44cfab4a553d510cdc7199e
33,383
[ -1 ]
33,384
choose.lsp
rwoldford_Quail/source/mathematics/combinatorics/choose.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; choose.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of the binomial coefficient ;;; ;;; n! ;;; (choose n k) <=> ------------ . ;;; k! (n-k)! ;;; ;;;------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(choose))) ;;;------------------------------------------------------------------------------ ;;; ;;; Choose n k ;;; ;;; The binomial coefficient. ;;; ;;;------------------------------------------------------------------------------ (defun choose (n k) "Returns the binomial coefficient nCk or n!/(k! (n-k)!). ~ For small values it returns an integer, otherwise a floating point." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline log-n!)) (if (or (not (integerp n)) (minusp n)) (quail-error "Argument must be a non-negative integer: ~s" n)) (if (or (not (integerp k)) (minusp k) (> k n)) (error "Second argument, ~s , must be a non-negative integer <= ~s" k n)) (let ((result (exp (- (log-n! n) (log-n! k) (log-n! (- n k)))))) (if (<= result most-positive-fixnum) (setf result (round result))) result))
1,831
Common Lisp
.l
47
34.148936
84
0.375143
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
5da49019daf795521cf18c0bbce9ac29422fc017e72f00b5ecaea76e4e62ff29
33,384
[ -1 ]
33,385
factorial.lsp
rwoldford_Quail/source/mathematics/combinatorics/factorial.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; factorial.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of some special functions: ;;; factorial, log-n! ;;; ;;; Code is a hand-coded translation of fortran code from Numerical Recipes ;;; Chapter 6, by Press, Flannery, Teukolsky, and Vetterling (1986). ;;; ;;;------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(factorial log-n!))) ;;;------------------------------------------------------------------------------- ;;; ;;; Factorial ;;; ;;; Sets up a global-table to cache results <- not implemented yet! ;;; ;;;------------------------------------------------------------------------------- #-:sbcl-linux(defconstant *table-of-factorials* (make-array 33 :initial-element 1)) #+:sbcl-linux(qk::define-constant *table-of-factorials* (make-array 33 :initial-element 1)) (defun factorial (n &key (integer-arithmetic? nil) (max-for-integers 32)) "Returns the integer n! This is calculated using integers by ~ forming the multiplication. ~ The answer will be exact and will not overflow. ~ Alternatively, the log-gamma function ~ is called and exponentiated giving only an approximate answer.~ (:required (:arg n A positive integer.)) ~ (:key ~ (:arg integer-arithmetic? NIL If non-NIL integer-arithmetic will ~ be used and because of bignums will not overflow.) ~ (:arg max-for-integers 32 If the argument n exceeds this value and ~ integer-arithmetic? is NIL then the floating point approximation will be ~ used. Otherwise exact integer arithmetic is used.) ~ )~ (:see-also log-gamma log-n! choose)~ " (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline log-gamma)) (if (or (not (integerp n)) (minusp n)) (quail-error "Argument must be a non-negative integer: ~s" n) (labels ((int-arith-fact (k) (let ((result 1)) (loop for i from 1 to k do (setf result (* i result))) result))) (if (or integer-arithmetic? (<= n max-for-integers)) (int-arith-fact n) (exp (log-gamma (+ n 1))))))) ;;;------------------------------------------------------------------------------- ;;; ;;; Log-Factorial ;;; ;;; Sets up a table to cache results. ;;; ;;;------------------------------------------------------------------------------- #-:sbcl-linux(defconstant *table-of-log-factorials* (make-array 100 :initial-element -1)) #+:sbcl-linux(qk::define-constant *table-of-log-factorials* (make-array 100 :initial-element -1)) (defun log-n! (n) "Returns log(n!) Source: Numerical Recipes. ~ (:see-also log-gamma n!)" (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline log-gamma)) (if (or (not (integerp n)) (minusp n)) (quail-error "Argument must be a non-negative integer: ~s" n)) (if (< n (length *table-of-log-factorials*)) (let ((table-value (aref *table-of-log-factorials* n))) (if (< table-value 0) (setf (aref *table-of-log-factorials* n) (log-gamma (+ n 1)))) (aref *table-of-log-factorials* n)) (log-gamma (+ n 1))))
3,891
Common Lisp
.l
92
36.271739
85
0.50093
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
adc78c73cc83cff116fb7ccc6b3212b78d127afd3f5a4c738f897e9e7b738e35
33,385
[ -1 ]
33,386
factorial-test.lsp
rwoldford_Quail/source/mathematics/combinatorics/factorial-test.lsp
;;; factorial-test.lsp ;;; trying to check on the defconstant form (defconstant *a-table-of-factorials* (make-array 33 :initial-element 1)) (defun show-it () (format t "*a-table-of-factorials* is ~s" *a-table-of-factorials*)) (compile-file factorial-test.lsp) (load factorial-test.fasl) The constant *A-TABLE-OF-FACTORIALS* is being redefined (from #(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) to #(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)) [Condition of type DEFCONSTANT-UNEQL]
541
Common Lisp
.l
15
34.266667
68
0.681298
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
9c6e6248376a8e3660cc7e5fee3a76b69261a92dc74df5f6f44d4acf1b583360
33,386
[ -1 ]
33,387
factor.lsp
rwoldford_Quail/source/mathematics/combinatorics/factor.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; factor.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; ;;;-------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(smallest-divisor dividesp factor coprimep))) (defun smallest-divisor (n &key (from 2)) "Returns the smallest divisor of the integer n that is ~ greater than the value of the keyword argument from (default 2)." (declare (integer n) (optimize (speed 3) )) (if (and (integerp n) (> n 0)) (if (= n 1) 1 (if (or (not (integerp from)) (< from 2)) (quail-error "Keyword argument :from must be integer > 1: ~s" from) (find-divisor n from))) (quail-error "~s is not a postive integer!" n))) (defun find-divisor (n test-divisor) (cond ((>= test-divisor ;;(* test-divisor test-divisor) n) n) ((dividesp test-divisor n) test-divisor) (t (find-divisor n (+ test-divisor 1))))) (defun dividesp (a b) "Tests whether the integer a divides the integer b." (declare (type integer a b) (optimize (speed 3) )) (= (mod b a) 0)) (defun factor (n) "Returns a list of the prime factors of the integer n." (declare (type integer n) (optimize (speed 3) )) (cond ((= 0 n) '()) ((= 1 n) '()) ((< n 0) (let ((result (factor (abs n)))) (setf (first result) (- (first result))) result)) (t (let ((whats-left n) (next-value 2)) (declare (type integer whats-left next-value)) (loop while (> whats-left 1) collect (let () (setf next-value (smallest-divisor whats-left :from next-value)) (setf whats-left (/ whats-left next-value)) next-value)))))) #| A clearer but slower version: (defun factor (n) (cond ((not (integerp n)) (quail-error "~s is not an integer!" n)) ((= 0 n) '()) ((= 1 n) '()) ((< n 0) (let ((result (factor (abs n)))) (setf (first result) (- (first result))) result)) (t (let ((first-factor (smallest-divisor n))) (append (list first-factor) (factor (/ n first-factor))))))) |# (defun coprimep (a b) (= (gcd a b) 1))
2,941
Common Lisp
.l
78
27.717949
110
0.445266
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
8c3634ac848d14f70b4adb45bcaf495a748f8d9af445ba08863aecdf9e07c6af
33,387
[ -1 ]
33,388
error-function.lsp
rwoldford_Quail/source/mathematics/special-functions/error-function.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; error-function.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 '(error-function error-function-complement))) ;;;--------------------------------------------------------------------------------- ;;; ;;; The Error Function ;;; ;;;--------------------------------------------------------------------------------- ;;; x 2 ;;; 2 / -t ;;; erf(x) = -------- / e dt ;;; sqrt(pi) / ;;; 0 ;;; ;;; Some properties: ;;; ;;; erf(0) = 0 erfc(0) = 1 ;;; erf(infinity) = 1 erfc(infinity) = 0 ;;; erf(-x) = -erf(x) erfc(-x) = 2 - erfc(x) ;;; ;;; ;;; These are related to the incomplete gamma functions as ;;; ;;; erf(x) = P(1/2, x^2) x >= 0 ;;; erfc(x) = Q(1/2, x^2) x >= 0 ;;; ;;; and to Gaussian or Normal(0,1) probabilities as ;;; ;;; Prob(|z| < a) = erf(a / sqrt(2)) where z ~ N(0,1) ;;; (defun error-function (x &key (max-iterations 100) (epsilon 1.0D-7)) "Returns the error function erf(x). Calculated by incomplete-gamma.~ (:required (:arg x A real valued number)) ~ (:key ~ (:arg max-iterations 100 Maximum number of iterations before ~ divergence of the incomplete-gamma is declared.) ~ (:arg epsilon 1.0D-7 Convergence criterion for incomplete gamma calculation.) ~ ) ~ (:see-also (error-function-complement :function) ~ (incomplete-gamma :function) ~ ) ~ (:examples ~ (:files (Error function ~ eg:Mathematics;Special-Functions;error-fun.lisp ~ ) ~ ) ~ )" (declare (type number x) (type fixnum max-iterations) (type float epsilon) (optimize (speed 3) (safety 3))) (cond ((= x 0) 0) ((< x 0) (- (incomplete-gamma 0.5 (* x x) :epsilon epsilon :max-iterations max-iterations))) (T (values (incomplete-gamma 0.5 (* x x) :epsilon epsilon :max-iterations max-iterations))))) (defun error-function-complement (x &key (max-iterations 100) (epsilon 1.0D-7)) "Returns the error function erfc(x) = 1 - erf(x). ~ Calculated by incomplete-gamma.~ (:required (:arg x A real valued number)) ~ (:key ~ (:arg max-iterations 100 Maximum number of iterations before ~ divergence of the incomplete-gamma is declared.) ~ (:arg epsilon 1.0D-7 Convergence criterion for incomplete gamma calculation.) ~ ) ~ (:see-also (error-function :function) ~ (incomplete-gamma :function) ~ (incomplete-gamma-complement :function) ~ ) ~ (:examples ~ (:files (Error function ~ eg:Mathematics;Special-Functions;error-fun.lisp ~ ) ~ ) ~ )" (declare (type number x) (type fixnum max-iterations) (type float epsilon) (optimize (speed 3) (safety 3))) (cond ((= x 0) 1) ((< x 0) (+ 1.0 (incomplete-gamma 0.5 (* x x) :epsilon epsilon :max-iterations max-iterations))) (T (values (incomplete-gamma-complement 0.5 (* x x) :epsilon epsilon :max-iterations max-iterations)))))
3,968
Common Lisp
.l
110
28.8
109
0.454214
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
1ef06e0120a2f2e9376db776e235b1641ae8b6d0fd768922e7b979ecb73f5511
33,388
[ -1 ]
33,389
incomplete-beta.lsp
rwoldford_Quail/source/mathematics/special-functions/incomplete-beta.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; incomplete-beta.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; Dan ;;; R.W. Oldford 1992. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of the special function: ;;; incomplete beta. ;;; ;;; Code is a hand-coded translation of fortran code from Numerical Recipes ;;; Chapter 6, by Press, Flannery, Teukolsky, and Vetterling (1986). ;;; ;;;------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(incomplete-beta))) ;;;---------------------------------------------------------------------------------- ;;; ;;; Incomplete beta function I(a,b,x) is the value of the cumulative distribution ;;; function of a beta(a,b) random variable evaluated at the point x. ;;; ;;; x ;;; 1 / a-1 b-1 ;;; I(a,b,x) = -------- / t (1-t) dt (a,b > 0) ;;; B(a,b) / ;;; 0 ;;; ;;;----------------------------------------------------------------------------------- (defun incomplete-beta (a b x &key (max-iterations 100) (epsilon 3.0D-7)) "Returns the value of the cumulative distribution ~ function of a beta(a,b) random variable evaluated at the point x. ~ That is the value of the incomplete beta function Ix(a,b)." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline log-gamma incomplete-beta-cf)) (cond ((= x 0) 0.0) ((= x 1) 1.0) ((or (< x 0) (> x 1)) (error "Argument X = ~s is out of range = [0.0 1.0]" x)) ((or (<= a 0.0) (<= b 0.0)) (error "Arguments a and b must be greater than 0.0. Here (a, b) = (~s, ~s)." a b)) (T (let ((factor ;; Factor in front of the continued fraction. (exp (- (+ (* a (log x)) (* b (log (- 1.0 x))) (log-gamma (+ a b))) (log-gamma a) (log-gamma b))))) (if (< x (/ (+ a 1) (+ a b 2))) ;; then use continued fraction directly (/ (* factor (incomplete-beta-cf a b x :epsilon epsilon :max-iterations max-iterations)) a) ;; Else use the continued fraction after ;; making the symmetry transformation. (- 1 (/ (* factor (incomplete-beta-cf b a (- 1.0 x) :epsilon epsilon :max-iterations max-iterations)) b))))))) (defun incomplete-beta-cf (a b x &key (max-iterations 100) (epsilon 3.0D-7)) "Continued fraction for incomplete-beta function." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline incomplete-beta)) (let* ((am 1.0) (bm 1.0) (az 1.0) ;; These q's will be used in factors which occur in the ;; coefficients. (qab (+ a b)) (qap (+ a 1.0)) (qam (- a 1.0)) (bz (- 1.0 (/ (* qab x) qap)))) ;; Now the continued fraction evaluation by the recurrence method. (let (2m d ap bp app bpp a-old ) (loop for m from 1 by 1 do (setf 2m (+ m m)) (setf d (/ (* m (- b m) x) (* (+ qam 2m) (+ a 2m)))) ;; One step (the even one) of the recurrence (setf ap (+ az (* d am))) (setf bp (+ bz (* d bm))) (setf d (- (/ (* (+ a m) (+ qab m) x) (* (+ a 2m) (+ qap 2m))))) ;; Next step of the recurrence (the odd one). (setf app (+ ap (* d az))) (setf bpp (+ bp (* d bz))) ;; Save the old answer. (setf a-old az) ;; Renormalize to prevent overflows. (setf am (/ ap bpp)) (setf bm (/ bp bpp)) (setf az (/ app bpp)) (setf bz 1.0) #|(print (format NIL "M = ~S ~% 2M = ~S ~% D = ~S ~% Ap = ~S ~%~ bp = ~S ~% app = ~S ~% bpp = ~S ~%~ a-old = ~S ~%~ approximant (az) = ~s ~%" m 2m d ap bp app bpp a-old az)) |# ;; Determine exit criteria ;; First has it converged? (if (< (abs (- az a-old)) (* epsilon (abs az))) ;; Then return the final result, az. (return az)) ;; Second have we reached the max-iterations? (if (> m max-iterations) (return az) #|(error "Failed to converge: One of beta parameters a or b ~ is too large (a = ~s, b = ~s), or the max-iterations ~ (= ~s) is too small." a b max-iterations)|# ) ) ) ) ) #| (defun incomplete-beta-continued-fraction (a b x &key (max-iterations 100) (epsilon 1.0D-7)) "Continued fraction for incomplete-beta function (a b x) <=> Ix(a,b)." (flet ((den-fun (y j) (declare (ignore y) (type integer j)) (cond ((= j 0) 0.0) (T 1.0))) (num-fun (y j) (declare (type number y) (type integer j)) (cond ((= j 1) 1.0) ((oddp j) ;; Corresponds to 2m = (j-1) (let* ((2m (- j 1)) (m (/ 2m 2))) (/ (* m (- b m) y) (* (+ a 2m -1.0) (+ a 2m))))) ((evenp j) ;; Corresponds to 2m+1 = (j-1) (let* ((2m (- j 2)) (m (/ 2m 2))) (- (/ (* (+ a m) (+ a b m) y) (* (+ a 2m) (+ a 2m 1.0))))))))) (funcall (continued-fraction-eval #'num-fun #'den-fun) x :max-iterations max-iterations :epsilon epsilon) )) (defun test-incomplete-beta (a b x &key (max-iterations 100) (epsilon 3.0D-7)) "Returns the value of the cumulative distribution ~ function of a beta(a,b) random variable evaluated at the point x. ~ That is the value of the incomplete beta function Ix(a,b)." ;;(cerror "a = ~s ~% b = ~s ~% x = ~s ~%" "Inside incomplete-beta" a b x) (cond ((= x 0) 0.0) ((= x 1) 1.0) ((or (< x 0) (> x 1)) (error "Argument X = ~s is out of range = [0.0 1.0]" x)) ((or (<= a 0.0) (<= b 0.0)) (error "Arguments a and b must be greater than 0.0. Here (a, b) = (~s, ~s)." a b)) (T (let ((factor ;; Factor in front of the continued fraction. (exp (- (+ (* a (log x)) (* b (log (- 1.0 x))) (log-gamma (+ a b))) (log-gamma a) (log-gamma b))))) (if (< x (/ (+ a 1) (+ a b 2))) ;; then use continued fraction directly (/ (* factor (incomplete-beta-continued-fraction a b x :epsilon epsilon :max-iterations max-iterations)) a) ;; Else use the continued fraction after ;; making the symmetry transformation. (- 1 (/ (* factor (incomplete-beta-continued-fraction b a (- 1.0 x) :epsilon epsilon :max-iterations max-iterations)) b))))))) |#
8,587
Common Lisp
.l
207
27.937198
87
0.393599
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
22dd96db7826455074de05710d0c3f9bde70bc0ba7725947156b9d8242fee301
33,389
[ -1 ]
33,390
log-gamma.lsp
rwoldford_Quail/source/mathematics/special-functions/log-gamma.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; log-gamma.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of log-gamma function ;;; (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(log-gamma gamma))) ;;;------------------------------------------------------------------------------ ;;; ;;; LOG-GAMMA ;;; ;;;------------------------------------------------------------------------------ (defun log-gamma (x) ;(declare (special pi) ;) "Returns the natural logarithm of the gamma function evaluated at x>0. ~ If 0<x<1, the reflection formula is used. Source: Numerical Recipes." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) ) (cond ((not (numberp x)) (quail-error "~s is not a number!" x)) ((<= x 0) (quail-error "Argument must be positive: ~s" x)) ((< x 1) (- (+ (log pi) (log (- 1 x))) ; Reflection formula (+ (log (sin (* pi (- 1 x)))) ; Eqn (6.1.4) in NR (log-gamma (- 2 x))))) (t (let* ((coefs (make-array 6 :element-type 'double-float :initial-contents '(76.18009173D0 -86.50532033D0 24.01409822D0 -1.231739516D0 0.120858003D-2 -0.536382D-5))) (stp 2.50662827465D0) (z (- x 1D0)) (temp1 (+ z 5.5D0)) (temp (- (* (+ z 0.5D0) (log temp1)) temp1))) (+ temp (log (* stp (+ 1D0 (loop for i from 0 to 5 sum (progn () (setf z (+ z 1D0)) (/ (aref coefs i) z))))))))))) (defun gamma (x) "Returns the gamma function evaluated at x > 0." (exp (log-gamma x)))
2,354
Common Lisp
.l
62
28.790323
84
0.376646
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
5b52135cd0e2f83192525e32a8823d5b83a5b4da2e484660b1b67abdb459adcf
33,390
[ -1 ]
33,391
incomplete-gamma.lsp
rwoldford_Quail/source/mathematics/special-functions/incomplete-gamma.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; incomplete-gamma.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; Dan ;;; R.W. Oldford 1992. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of the special function: ;;; incomplete gamma. ;;; ;;; Code is a hand-coded translation of fortran code from Numerical Recipes ;;; Chapter 6, by Press, Flannery, Teukolsky, and Vetterling (1986). ;;; ;;;------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(incomplete-gamma incomplete-gamma-complement))) ;;;------------------------------------------------------------------------------ ;;; ;;; Incomplete Gamma Function ;;; ;;; Implementation relies on both a series expansion and a continued ;;; fraction expansion for the incomplete gamma and its complement, ;;; respectively. ;;; ;;; Here (as in NR) we call ;;; x ;;; 1 / ;;; P(a,x) = -------- / exp(-t) t^(a-1) dt ;;; gamma(a) / ;;; 0 ;;; ;;; the incomplete gamma function. This is just the cumulative ;;; distribution function of a gamma random variable with parameter a. ;;; ;;; The complement of P is Q(a,x) = 1 - P(a,x) ;;; ;;; There exists a series expansion for P(a,x)*gamma(a) ;;; And a continued-fraction expansion for Q(a,x)*gamma(a) ;;; ;;; Most importantly, their regions of convergence are complementary ;;; so an accurate incomplete gamma function can be had by using ;;; each where appropriate. ;;; ;;;--------------------------------------------------------------------------------- (defun incomplete-gamma (a x &key (epsilon 1.0D-7) (max-iterations 100)) "Returns two values. The first is the incomplete gamma function P(a,x) ~ defined to be the cumulative ~ distribution function of a gamma random variable with shape parameter a. ~ The second is log-gamma(a) + log (P(a,x)) and is ~ sometimes denoted as the natural log of lower-case-gamma(a,x)." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (cond ((or (not (numberp x)) (< x 0.0)) (error "The value of the second argument, x, must be a number greater than or ~ equal to 0, not ~s!" x)) ((or (not (numberp a)) (<= a 0.0)) (error "The parameter gamma shape-parameter, a, must be a number greater than 0, ~ not ~s!" a))) (if (= x 0.0) (values 0.0 q::-infinity) (if (< x (+ a 1)) ;; Use the series representation. (let ((results (multiple-value-list (gamma-series-approximation a x :epsilon epsilon :max-iterations max-iterations)))) (values (first results) (+ (log (first results)) (second results)) )) ;; Else use the continued-fraction representation of the complementary gamma. (let* ((results (multiple-value-list (gamma-continued-fraction-approximation a x :epsilon epsilon :max-iterations max-iterations))) (inc-gamma-1 (- 1.0 (first results))) (inc-gamma-2 (+ (log inc-gamma-1) (second results)) ) ) (values inc-gamma-1 inc-gamma-2))))) (defun incomplete-gamma-complement (a x &key (epsilon 1.0D-7) (max-iterations 100)) "Returns two values. The first is the complement of the incomplete gamma function, ~ namely 1 - P(a,x), where P(a,x) is the incomplete gamma function that is ~ defined to be the same as the cumulative ~ distribution function of a gamma random variable with shape parameter a. ~ The second is gamma(a) * (1 - P(a,x)) and is ~ sometimes denoted as upper-case-gamma(a,x)." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (cond ((or (not (numberp x)) (< x 0.0)) (error "The value of the second argument, x, must be a number greater than or ~ equal to 0, not ~s!" x)) ((or (not (numberp a)) (<= a 0.0)) (error "The parameter gamma shape-parameter, a, must be a number greater than 0, ~ not ~s!" a))) (if (< x (+ a 1)) ;; Use the series representation for the incomplete gamma and complement. (let* ((results (multiple-value-list (gamma-series-approximation a x :epsilon epsilon :max-iterations max-iterations))) (gamma-1 (- 1.0 (first results))) (gamma-2 (* gamma-1 (exp (second results))))) (values gamma-1 gamma-2)) ;; Else use the continued-fraction representation of the complementary gamma. (let ((results (multiple-value-list (gamma-continued-fraction-approximation a x :epsilon epsilon :max-iterations max-iterations)))) (values (first results) (* (first results) (exp (second results))))))) (defun gamma-series-approximation (a x &key (max-iterations 100) (epsilon 3.0D-7)) "Returns two values. The first is the incomplete gamma function, ~ defined to be the same as the cumulative ~ distribution function of a gamma random variable with shape parameter a. ~ Evaluation is via its series representation. Converges rapidly ~ when x < a + 1. ~ The second is the natural log of gamma(a)." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) ) (let ((ln-gamma-a (log-gamma a)) (gamma-series 0.0)) (if (or (not (numberp x)) (< x 0)) (error "The value of the second argument, x, must be a number greater than or ~ equal to 0, not ~s!" x)) (if (not (zerop x)) (let* ((sum (/ 1.0 a)) (delta sum) (ap a)) (loop for iteration-no from 1 by 1 until (< (abs delta) (* epsilon (abs sum))) do (setf ap (+ ap 1)) (setf delta (/ (* delta x) ap)) (setf sum (+ sum delta)) (when (> iteration-no max-iterations) (error "Either the first argument, a = ~s is too large ~ or the max-iterations = ~s is too small." a max-iterations))) (setf gamma-series (* sum (exp (- (* a (log x)) x ln-gamma-a)))))) (values gamma-series ln-gamma-a))) (defun gamma-continued-fraction-approximation (a x &key (max-iterations 100) (epsilon 3.0D-7)) "Returns two values. The first is the complement of the incomplete gamma function, ~ 1 - P(a,x), where P(a,x) is defined to be the same as the cumulative ~ distribution function of a gamma random variable with shape parameter a. ~ Evaluation is via a continued fraction expansion. Converges rapidly when ~ x > a + 1. ~ The second is the natural log of gamma(a)." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (let ((ln-gamma-a (log-gamma a)) (gamma-cf 1.0)) ;; Error checking (if (or (not (numberp x)) (< x 0)) (error "The value of the second argument, x, must be a number greater than or ~ equal to 0, not ~s!" x)) ;; Now the approximation. (if (not (zerop x)) ;; otherwise we do the continued fraction expansion. (let* ;; First a parameter to denote the standard to test against for convergence ((gold 0.0) ;; Successive approximants, gn in the continued fraction expansion ;; are evaluated by using two 3 term recurrence relations (see num recipes) (gn gold) (a0 1.0) (a1 x) (b0 0.0) (b1 1.0) ;; the renormalization factor that prevents overflow of the partial ;; numerators and partial denominators. (factor 1.0)) (let (n-a n*fac) (loop for n from 1 by 1 do ;; Check on iteration count. (if (> n max-iterations) (error "Either the first argument, a = ~s is too large ~ or the max-iterations = ~s is too small." a max-iterations)) ;; One step of the recurrence (setf n-a (- n a)) (setf a0 (* (+ a1 (* a0 n-a)) factor)) (setf b0 (* (+ b1 (* b0 n-a)) factor)) ;; Next step of recurrence (setf n*fac (* n factor)) (setf a1 (+ (* x a0) (* n*fac a1))) (setf b1 (+ (* x b0) (* n*fac b1))) ;; Should we renormalize? (when (not (zerop a1)) (setf factor (/ 1.0 a1)) (setf gn (* b1 factor)) ;; Check convergence (when (< (abs (/ (- gn gold) gn)) epsilon) ;; Converged, so put factors in front (setf gamma-cf (* (exp (- (* a (log x)) x ln-gamma-a)) gn)) ;; Return from loop (return)) ;; Not converged, so update the gold standard. (setf gold gn)) ) ) ) ) ;; we're done (values gamma-cf ln-gamma-a) ) ) #| (defun incomplete-gamma-cf (alpha x &key (max-iterations 100) (epsilon 1.0D-7)) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (flet ((den-fun (y j) (declare (type number y) (type integer j)) (cond ((= j 0) 0.0) ((oddp j) y) ((evenp j) 1))) (num-fun (y j) (declare (ignore y) (type integer j)) (cond ((= j 1) 1.0) ((oddp j) (/ (- j 1) 2)) ) ((evenp j) (- (+ 1 (/ (- j 2) 2)) alpha) ))) (funcall (continued-fraction-eval (function num-fun) (function den-fun)) x :max-iterations max-iterations :epsilon epsilon))) (defun incomplete-gamma (alpha x &key (max-iterations 100) (epsilon 1.0D-7)) "The incomplete gamma function. This is just the cumulative ~ distribution function of a gamma random variable with parameter alpha." (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (let((ans 0) (old-ans 0)) (cond ((< x 0) 0.0) ((< x (+ 1 alpha)) (/ (* (exp (- 0 x)) (expt x alpha) (loop for n from 0 by 1 do (setf ans (+ old-ans (/ (* (exp (log-gamma alpha)) (expt x n)) (exp (log-gamma (+ alpha 1 n)))))) (if (< (abs (- ans old-ans)) epsilon ) (return ans)) (if (> n max-iterations) (error "Failed to converge")) (setf old-ans ans))) (exp (log-gamma alpha)))) ((>= x (+ 1 alpha)) (- 1 (/ (* (incomplete-gamma-cf alpha x :epsilon epsilon :max-iterations max-iterations) (exp (- 0 x)) (expt x alpha)) (exp (log-gamma alpha))))) ))) |#
13,072
Common Lisp
.l
301
30.328904
130
0.470945
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
073f2219dce155101e4661f13d20ea8694b8d760c070625dd2547d4afe60ff9b
33,391
[ -1 ]
33,392
complete-beta.lsp
rwoldford_Quail/source/mathematics/special-functions/complete-beta.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; complete-beta.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of some special functions: ;;; log-gamma, factorial, gamma, beta, incomplete beta ;;; ;;; Code is a hand-coded translation of fortran code from Numerical Recipes ;;; Chapter 6, by Press, Flannery, Teukolsky, and Vetterling (1986). ;;; ;;;------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(beta))) ;;;------------------------------------------------------------------------------ ;;; ;;; Complete Beta Function ;;; ;;; Beta(a,b) = Gamma(a) * Gamma(b) / Gamma(a+b) ;;; ;;;------------------------------------------------------------------------------ (defun beta (a b) "Returns the value of the complete beta function B(a,b)." (exp (- (+ (log-gamma a) (log-gamma b)) (log-gamma (+ a b)))))
1,421
Common Lisp
.l
36
35.75
84
0.371617
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
4775685c2be4bb0a1afa4c24e6367c0a279d6a5f945f0933dc33d4eabfe8bd52
33,392
[ -1 ]
33,393
continued-fraction.lsp
rwoldford_Quail/source/mathematics/special-functions/continued-fraction.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; continued-fraction.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 '(continued-fraction-eval))) (defun continued-fraction-eval (numerator-fun denominator-fun) "Given two functions numerator-fun denominator-fun this function ~ returns a function which will calculated the continued fraction ~ expansion whose succesive numeratores are defined by numerator-fun ~ and whose successive denominators are defined by denominator-fun. ~ The continued fraction is d_0(x) + [n_1(x) / [d_1(x) + [n_2(x) / [d_2(x) + ~ ... ]]]] ~ where d_i(x) is the i'th denominator evaluated at x and n_i is the ~ i'th numerator evaluated at x. (:required ~ (:arg numerator-fun A function of two arguments which when applied ~ to two numbers x and i returns the value of the i'th (i = 1, 2, ~ 3, ... ) numerator ~ in the continued fraction evaluated at x.) (:arg denominator-fun A function of two arguments which when applied ~ to two numbers x and i returns the value of the i'th (i = 0, 1, ~ 2, ... ) denominator ~ in the continued fraction evaluated at x.))~ (:returns A function which will calculate the continued fraction ~ expansion d_0(x) + [n_1(x) / [d_1(x) + [n_2(x) / [d_2(x) + ~ ... ]]]] ~ at arbitrary argument x to a tolerance determined ~ by the keyword epsilon, and to a maximum number of iterations ~ given by the keyword max-iterations. The method of calculation ~ employs the well-known forward recurrence relations.)" (flet ;; Set up a convergence test function. ((close-enough-p (old new eps) (if (and old new) (< (abs (- old new)) (* eps (abs old))))) ) (function (lambda (x &key (epsilon 1.0D-7) (max-iterations 100)) "This function calculates a continued fraction expansion at the ~ value of its argument by approximating the continued fraction ~ by a rational function. It uses forward recurrence relations ~ for this calculation and convergence control is given by use of ~ keyword arguments. ~ (:required (:arg x The value at which the fraction is to be evaluated.)) ~ (:key ~ (:arg epsilon 1.0D-7 The minimal relative difference between successive ~ iterations to declare convergence.) ~ (:arg max-iterations 100 The maximum number of iterations to ~ perform before divergence is declared.)) ~ (:returns Returns multiple-values: the approximation, the number ~ of iterations j, the partial numerator at j-1, the partial numerator ~ at j, the partial denominator at j-1, and the partial denominator ~ at j.)" (let ;; Set up of values for the case j = 0 ((partial-numerator-j-2 NIL) (partial-numerator-j-1 1) (partial-numerator-j NIL) (partial-denominator-j-2 NIL) (partial-denominator-j-1 0) (partial-denominator-j 1) (approximant-j-1 NIL) (approximant-j NIL)) ;; Set up starting values. (setf partial-numerator-j (funcall denominator-fun x 0)) (setf approximant-j partial-numerator-j) ;; Begin iterative evaluation (loop for j from 1 do ;; Set the partial numerators' and denominators' ;; indices back 1. (setf partial-numerator-j-2 partial-numerator-j-1) (setf partial-numerator-j-1 partial-numerator-j) (setf partial-denominator-j-2 partial-denominator-j-1) (setf partial-denominator-j-1 partial-denominator-j) ;; Get the new partial numerator (setf partial-numerator-j (+ (* partial-numerator-j-1 (funcall denominator-fun x j)) (* partial-numerator-j-2 (funcall numerator-fun x j)))) ;; Get the new partial denominator (setf partial-denominator-j (+ (* partial-denominator-j-1 (funcall denominator-fun x j)) (* partial-denominator-j-2 (funcall numerator-fun x j)))) ;; Set the approximant's index back 1 (setf approximant-j-1 approximant-j) (unless (zerop partial-denominator-j) ;; Normalize to prevent overflow (setf partial-numerator-j (/ partial-numerator-j partial-denominator-j)) (setf partial-numerator-j-1 (/ partial-numerator-j-1 partial-denominator-j)) (setf partial-denominator-j-1 (/ partial-denominator-j-1 partial-denominator-j)) (setf partial-denominator-j 1.0) ;; Approximant is now simply partial-numerator-j (setf approximant-j partial-numerator-j) ;; Check for convergence (cond ((> j max-iterations) (return approximant-j) (error "Failure to converge! ~%~ Increase max-iterations (now ~s) or ~ increase epsilon (the convergence tolerance, now ~s)." max-iterations epsilon)) ((close-enough-p approximant-j-1 approximant-j epsilon) (return (values approximant-j j partial-numerator-j-1 partial-numerator-j partial-numerator-j-1 partial-denominator-j)))) ) ) ) ) ) ) )
6,831
Common Lisp
.l
136
34.889706
92
0.518587
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f3bd637ffcef27f5303456e8140251744e1dc5a95afdf74632f9913218c14a5c
33,393
[ -1 ]
33,394
other_Special-functions.lsp
rwoldford_Quail/source/mathematics/special-functions/other_Special-functions.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; special-functions.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; ;;; This file contains the CL implementation of some special functions: ;;; log-gamma, factorial, gamma, beta, incomplete beta ;;; ;;; Code is a hand-coded translation of fortran code from Numerical Recipes ;;; Chapter 6, by Press, Flannery, Teukolsky, and Vetterling (1986). ;;; ;;;------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(log-gamma fact log-n! choose beta gamma-inc))) ;;;------------------------------------------------------------------------------ ;;; ;;; LOG-GAMMA ;;; ;;;------------------------------------------------------------------------------ (defun log-gamma (x) (declare (special pi)) "Returns the natural logarithm og the gamma finction evaluated at x>0. ~ If 0<x<1, the reflection formula is used. Source: Numerical Recipes." (cond ((not (numberp x)) (quail-error "~s is not a number!" x)) ((<= x 0) (quail-error "Argument must be positive: ~s" x)) ((< x 1) (- (+ (log pi) (log (- 1 x))) ; Reflection formula (+ (log (sin (* pi (- 1 x)))) ; Eqn (6.1.4) in NR (log-gamma (- 2 x))))) (t (let* ((coefs (make-array 6 :element-type 'double-float :initial-contents '(76.18009173D0 -86.50532033D0 24.01409822D0 -1.231739516D0 0.120858003D-2 -0.536382D-5))) (stp 2.50662827465D0) (z (- x 1D0)) (temp1 (+ z 5.5D0)) (temp (- (* (+ z 0.5D0) (log temp1)) temp1))) (+ temp (log (* stp (+ 1D0 (loop for i from 0 to 5 sum (progn () (setf z (+ z 1D0)) (/ (aref coefs i) z))))))))))) ;;;------------------------------------------------------------------------------- ;;; ;;; Factorial ;;; ;;; Sets up a global-table to cache results <- not implemented yet! ;;; ;;;------------------------------------------------------------------------------- #-:sbcl-linux(defconstant *table-of-factorials* (make-array 33 :initial-element 1)) #+:sbcl-linux(qk::define-constant *table-of-factorials* (make-array 33 :initial-element 1)) (defun fact (n &key (integer-arithmetic nil) (max-for-integers 32)) "Returns n! Source: Numerical Recipes." (if (or (not (integerp n)) (minusp n)) (quail-error "Argument must be a non-negative integer: ~s" n) (labels ((int-arith-fact (k) (let ((result 1)) (loop for i from 1 to k do (setf result (* i result))) result))) (if (or integer-arithmetic (<= n max-for-integers)) (int-arith-fact n) (exp (log-gamma (+ n 1))))))) ;;;------------------------------------------------------------------------------- ;;; ;;; Log-Factorial ;;; ;;; Sets up a table to cache results. ;;; ;;;------------------------------------------------------------------------------- #-:sbcl-linux(defconstant *table-of-log-factorials* (make-array 100 :initial-element -1)) #+:sbcl-linux(qk::define-constant *table-of-log-factorials* (make-array 100 :initial-element -1)) (defun log-n! (n) "Returns log(n!) Source: Numerical Recipes." (if (or (not (integerp n)) (minusp n)) (quail-error "Argument must be a non-negative integer: ~s" n)) (if (< n (length *table-of-log-factorials*)) (let ((table-value (aref *table-of-log-factorials* n))) (if (< table-value 0) (setf (aref *table-of-log-factorials* n) (log-gamma (+ n 1)))) (aref *table-of-log-factorials* n)) (log-gamma (+ n 1)))) ;;;------------------------------------------------------------------------------ ;;; ;;; Choose n k ;;; ;;; The binomial coefficient. ;;; ;;;------------------------------------------------------------------------------ (defun choose (n k) "Returns the binomial coefficient nCk or n!/(k! (n-k)!). ~ For small values it returns an integer, otherwise a floating point." (if (or (not (integerp n)) (minusp n)) (quail-error "Argument must be a non-negative integer: ~s" n)) (if (or (not (integerp k)) (minusp k) (> k n)) (error "Second argument, ~s , must be a non-negative integer <= ~s" k n)) (let ((result (exp (- (log-n! n) (log-n! k) (log-n! (- n k)))))) (if (<= result most-positive-fixnum) (setf result (round result))) result)) ;;;------------------------------------------------------------------------------ ;;; ;;; Complete Beta Function ;;; ;;; Beta(a,b) = Gamma(a) * Gamma(b) / Gamma(a+b) ;;; ;;;------------------------------------------------------------------------------ (defun beta (a b) "Returns the value of the complete beta function B(a,b)." (exp (- (+ (log-gamma a) (log-gamma b)) (log-gamma (+ a b))))) ;;;------------------------------------------------------------------------------ ;;; ;;; Incomplete Gamma Function ;;; ;;; Implementation relies on both a series expansion and a continued ;;; fraction expansion for the incomplete gamma and its complement, ;;; respectively. ;;; ;;; Here (as in NR) we call ;;; x ;;; 1 / ;;; P(a,x) = -------- / exp(-t) t^(a-1) dt ;;; gamma(a) / ;;; 0 ;;; ;;; The incomplete gamma function. This is just the cumulative ;;; distribution function of a gamma random variable with parameter a. ;;; ;;; The complement of P is Q(a,x) = 1 - P(a,x) ;;; ;;; There exists a series expansion for P(a,x)*gamma(a) ;;; And a continued-fraction expansion for Q(a,x)*gamma(a) ;;; ;;; Most importantly, their regions of convergence are complementary ;;; so an accurate incomplete gamma function can be had by using ;;; each where appropriate. ;;; ;;;--------------------------------------------------------------------------------- (defun gamma-inc (a x) ())
6,825
Common Lisp
.l
165
35.018182
87
0.436062
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
ff5bdf0cbf13ae36f4b7175973087327d7451780520bda5c2ea4373775451c10
33,394
[ -1 ]
33,395
surface.lsp
rwoldford_Quail/source/mathematics/functions/surface.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; surface.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) 1992 ;;; Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; R.W. Oldford 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(surface x-grid-of y-grid-of surface-heights-of surface-function-of calculate-heights))) (defclass surface () ((x-grid :accessor x-grid-of :initarg :x :initform NIL :documentation "The locations of the x grid points.") (y-grid :accessor y-grid-of :initarg :y :initform NIL :documentation "The locations of the y grid points.") (surface-heights :accessor surface-heights-of :initarg :surface-heights :initform NIL :documentation "The heights of the surface at each (x,y) location ~ in the grid. The locations must be arranged in a vector ~ varying the y coordinate fastest.") (surface-function :accessor surface-function-of :initarg :surface-function :initform NIL :documentation "The function (or fn) of two arguments which when fn-called on ~ x and y coordinates will return the height of the surface ~ at each grid location.")) (:documentation "A class representing a three dimensional surface.")) (defmethod initialize-instance :after ((self surface) &rest initargs &key surface-function ) (declare (ignore initargs)) (when surface-function (calculate-heights self)) ) (defun calculate-heights (surface) "Calculates and stores the surface heights for each x y pair ~ of the x-grid and y-grid of the surface using the function ~ stored as the surface-function-of surface." (let* ((heights (surface-heights-of surface)) (x (x-grid-of surface)) (y (y-grid-of surface)) (x-size (array-total-size x)) (y-size (array-total-size y)) (surface-fun (surface-function-of surface)) ) (unless (and heights (= (array-total-size heights) (* x-size y-size))) (setf heights (setf (surface-heights-of surface) (array 0 :dimensions (list (* x-size y-size)))))) (loop for i from 0 to (1- x-size) do (loop for j from 0 to (1- y-size) do (setf (eref heights (+ (* i y-size) j)) (fn-call surface-fun (eref x i) (eref y j))))))) (defun surface (x y &rest keyword-pairs &key surface-heights surface-function) "Creates and returns a surface object suitable for use in ~ surface view. ~ (:required ~ (:arg x NIL A 1-dimensional array of the x-coordinates of the surface.) ~ (:arg y NIL A 1-dimensional array of the x-coordinates of the surface.)) ~ (:rest ~ (:arg keyword-pairs NIL Additional optional initialization keyword arguments.)) ~ (:key ~ (:arg surface-heights NIL ~ A 1-dimensional array containing the height of the surface at ~ every x y pair. The number of elements in surface-height is the ~ product of the number of elements in x and y. The elements ~ themselves are arranged varying the elements of y fastest.) (:arg surface-function NIL If given, a function which when called on each x y pair ~ will return the corresponding value of surface-heights.) )" (if (and (null surface-heights) (null surface-function)) (let (result) (setf result (wb:prompt-user :prompt-string (format NIL "Please supply either ~ a surface-function or an array of ~ surface heights.") :read-type :eval :type T)) (cond ((functionp result) (setf surface-function result)) ((symbolp result) (setf surface-function (symbol-function result))) (T (setf surface-heights result))))) (apply #'make-instance 'surface :x x :y y :surface-heights surface-heights :surface-function surface-function keyword-pairs))
4,660
Common Lisp
.l
122
30.188525
88
0.560452
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
29ea15662e97bd0a13663290cb025063b56b809f3173fa5e7b38a69c70df7edc
33,395
[ -1 ]
33,396
fn.lsp
rwoldford_Quail/source/mathematics/functions/fn.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; fn.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; D.G. Anglin 1992. ;;; R.W. Oldford 1992. ;;; ;;; ;;;------------------------------------------------------------------------------- ;;; (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(fn fn-call))) (defclass fn (quail-object) ((name :reader name-of :initarg :name) (arglist :reader arglist-of :initarg :arglist) (body :reader body-of :initarg :body) (deriv-list :accessor deriv-list-of :initarg :deriv-list) (compiled-fn :reader compiled-fn-of :initarg :compiled-fn))) (defun fn-call (fn-object &rest args) "Calls function associated with the first argument on the remaining arguments. ~ The first argument can be a function, a symbol, or an object of class fn." (typecase fn-object (fn (apply (compiled-fn-of fn-object) args)) (function (apply fn-object args)) (symbol (apply (symbol-function fn-object) args)) (ref-array (array (collect-slices (f fn-object) (apply #'fn-call f args)) :dimensions (dimensions-of fn-object))) )) (defmacro fn (&rest args) (let* ((split (position-if-not #'(lambda (x) (and x (atom x))) args)) (anonymous (eq split 0)) (lambda-list (if split (elt args split) (error "Malformed fn: ~ no lambda-list provided."))) (function-name (if anonymous nil (first args))) (body (subseq args (+ 1 split))) (compiled-fn (if anonymous `(function (lambda ,lambda-list ,@body)) `(setf (symbol-function (quote ,function-name)) (function (lambda ,lambda-list ,@body)))))) (if function-name `(setf (get (quote ,function-name) :FN) (make-instance 'fn :name (quote ,function-name) :arglist (quote ,lambda-list) :body (quote ,body) :deriv-list nil :compiled-fn ,compiled-fn)) `(make-instance 'fn :name nil :arglist (quote ,lambda-list) :body (quote ,body) :deriv-list nil :compiled-fn ,compiled-fn)))) (defmethod add-deriv ((fn fn) deriv &optional (deriv-id '(0))) (with-slots (deriv-list) fn (setf deriv-list (append deriv-list (list (list deriv-id deriv)))))) (defmethod find-deriv ((fn fn) &optional (deriv-id '(0))) (with-slots (deriv-list) fn (second (find deriv-id deriv-list :test #'equal :key #'first)))) (defmethod print-object ((f fn) stream) (with-slots (name arglist body) f (let* ((dim (dimensions-of body)) (len (length dim))) (format stream "#<FN ") (if name (format stream "~S " name)) (format stream "~S " arglist) (qk::ref-print-recursion body dim (make-sequence 'list len) len 0 stream :left nil :right nil) (format stream ">"))) f)
3,792
Common Lisp
.l
95
27.821053
84
0.458571
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
71ca5be03be3bb237775effb1597dfe760a7e0b5a8564dc0154b61f102158ae5
33,396
[ -1 ]
33,397
quail-misc-constants.lsp
rwoldford_Quail/source/mathematics/borel-sets/quail-misc-constants.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; quail-misc-constants.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; Miscellaneous quail system constants ;;; ;;; In this file a number of quail system constants are defined. ;;; NOTE: Not all system constants are defined here. Only those which are not ;;; more reasonably placed in other files. ;;; ;;; (in-package :quail) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Handy constants to use programmatically to ;;; determine number of iterations to perform before ;;; asking the user for more information. ;;; (defconstant *small-number-of-iterations* 10) (defconstant *reasonable-number-of-iterations* 100) (defconstant *max-reasonable-number-of-iterations* 1000)
1,171
Common Lisp
.l
33
33.060606
86
0.468861
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
c049f45e078e07f171b5f65bb77d3879996cef7db269c2a1a446579e32eb5dd0
33,397
[ -1 ]
33,398
disjoint-sets-p-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/disjoint-sets-p-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; disjoint-sets-p-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; ;;; ;;; Author: ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; DISJOINT SETS PREDICATE METHODS ;;; ;;; Method | Argument type | ;;; |_____________________________________________| ;;; Name | Argument 1 | Argument 2 | ;;; ___________________________|______________________|______________________| ;;; | | | ;;; | | | ;;; op-disjoint-sets-p | borel-set | borel-set | ;;; | borel-set | complement-set | ;;; | borel-set | countable-collection | ;;; | borel-set |countable-intersection| ;;; | borel-set | countable-set | ;;; | borel-set | empty-set | ;;; | borel-set | explicit-finite-union| ;;; | borel-set | (extended-realp) | ;;; | complement-set | borel-set | ;;; | countable-collection | borel-set | ;;; |countable-intersection| borel-set | ;;; | countable-set | borel-set | ;;; | empty-set | borel-set | ;;; | explicit-finite-set | explicit-finite-set | ;;; | explicit-finite-set | interval | ;;; | explicit-finite-union| borel-set | ;;; | explicit-finite-union| explicit-finite-union| ;;; | interval | explicit-finite-set | ;;; | interval | interval | ;;; | (extended-realp) | borel-set | ;;; | (extended-realp) | (extended-realp) | (in-package :quail) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-disjoint-sets-p - disjoint sets predicate binary operator ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 borel-set)) (quail-error "Not enough information to determine whether ~s ~%~ is disjoint from ~s." set1 set2)) (defmethod op-disjoint-sets-p (set1 set2) (if (and (extended-realp set1) (extended-realp set2)) (if (= set1 set2) NIL T) (missing-method 'op-disjoint-sets-p set1 set2))) (defmethod op-disjoint-sets-p ((set1 borel-set) set2) (if (extended-realp set2) (if (memberp set2 set1) NIL T) (missing-method 'op-disjoint-sets-p set1 set2))) (defmethod op-disjoint-sets-p (set1 (set2 borel-set)) (op-disjoint-sets-p set2 set1)) (defmethod op-disjoint-sets-p ((set1 empty-set) (set2 borel-set)) T) (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 empty-set)) T) (defmethod op-disjoint-sets-p ((set1 interval) (set2 interval)) (separatep set1 set2)) (defmethod op-disjoint-sets-p ((set1 explicit-finite-set) (set2 explicit-finite-set)) (let* ((temp-set (concatenate 'list (contents-of set1) (contents-of set2))) (len (length temp-set)) (temp-set (remove-duplicates temp-set)) (len2 (length temp-set))) (= len len2))) (defmethod op-disjoint-sets-p ((set1 explicit-finite-union) (set2 borel-set)) (if (member set2 (contents-of set1)) NIL (let ((info (mapcar #'(lambda (x) (op-disjoint-sets-p x set2)) (contents-of set1))) (result T)) (loop for item in info do (when (not item) (progn (setf result NIL) (return)))) result))) (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 explicit-finite-union)) (op-disjoint-sets-p set2 set1)) ;;this isn't really necessary (defmethod op-disjoint-sets-p ((set1 explicit-finite-union) (set2 explicit-finite-union)) (if (eq set1 set2) ;; or op-same-set-p NIL (let ((info (mapcar #'(lambda (x) (op-disjoint-sets-p x set2)) (contents-of set1))) (result T)) (loop for item in info do (when (not item) (progn (setf result NIL) (return)))) result))) (defmethod op-disjoint-sets-p ((set1 complement-set) (set2 borel-set)) (if (op-disjoint-sets-p set2 (complement-wrt set1)) T (op-insidep set2 (set-of set1)))) (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 complement-set)) (op-disjoint-sets-p set2 set1)) (defmethod op-disjoint-sets-p ((set1 explicit-finite-set) (set2 interval)) (let ((result T)) (loop for item in (contents-of set1) do (when (memberp item set2) (progn (setf result NIL) (return)))) result)) (defmethod op-disjoint-sets-p ((set1 interval) (set2 explicit-finite-set)) (op-disjoint-sets-p set2 set1)) (defmethod op-disjoint-sets-p ((set1 countable-collection) (set2 borel-set)) (declare (special *max-reasonable-number-of-iterations*)) (do ((index (count-start-of set1) (next-index set1 index)) (counter 1 (+ counter 1)) (big-count *max-reasonable-number-of-iterations*) (result T) (set NIL)) ;; end-test ((or (count-endedp set1 index) (not result)) result) ;; Now the action (setf set (element set1 index)) (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is disjoint from set ~%~ ~s ? " set set2) (return T)) ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is *NOT* disjoint from set ~%~ ~s ? " set set2) (return NIL)) (T (quail-error "Can't tell whether set ~%~ ~s ~%~ is disjoint from set ~%~ ~s ~%~ or not!" set set2))))) ((not (op-disjoint-sets-p set set2)) (progn (setf result NIL) (return)))))) (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 countable-collection)) (op-disjoint-sets-p set2 set1)) (defmethod op-disjoint-sets-p ((set1 countable-set) (set2 borel-set)) (declare (special *max-reasonable-number-of-iterations*)) (let ((result T)) (do ((index (count-start-of set1) (next-index set1 index)) (counter 1 (+ counter 1)) (big-count *max-reasonable-number-of-iterations*) (item NIL)) ;; end-test ((count-endedp set1 index) result) ;; Now the action (setf item (element set1 index)) (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s items already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more items should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume ~s ~%~ is disjoint from ~%~ ~s ? " set1 set2) (return T)) ((quail-yes-or-no-p "Assume ~s ~%~ is *NOT* disjoint from ~%~ ~s ? " set1 set2) (progn (setf result NIL) (return))) (T (quail-error "Can't tell whether ~%~ ~s ~%~ is disjoint from ~%~ ~s ~%~ or not!" set1 set2))))) ((memberp item set2) (progn (setf result NIL) (return))))) result)) (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 countable-set)) (op-disjoint-sets-p set2 set1)) (defmethod op-disjoint-sets-p ((set1 countable-intersection) (set2 borel-set)) (quail-error "Not enough information to determine whether ~s ~%~ is disjoint from ~s." set1 set2)) (defmethod op-disjoint-sets-p ((set1 borel-set) (set2 countable-intersection)) (op-disjoint-sets-p set2 set1))
9,755
Common Lisp
.l
216
36.027778
90
0.450566
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f2846cd216682e3886b53e794693187629b3e5fca7adcc4277555bc4c93cd0e3
33,398
[ -1 ]
33,399
Z-misc-constants.lsp
rwoldford_Quail/source/mathematics/borel-sets/Z-misc-constants.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Z-misc-constants.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; Miscellaneous Z system constants ;;; ;;; In this file a number of Z system constants are defined. ;;; NOTE: Not all system constants are defined here. Only those which are not ;;; more reasonably placed in other files. ;;; ;;; (in-package 'Z) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Handy constants to use programmatically to ;;; determine number of iterations to perform before ;;; asking the user for more information. ;;; (defconstant *small-number-of-iterations* 10) (defconstant *reasonable-number-of-iterations* 100) (defconstant *max-reasonable-number-of-iterations* 1000)
1,155
Common Lisp
.l
33
32.575758
86
0.461191
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
613a35012ca33526339bd722d5e368f7aec254d929ef87bab37e8d2ca3c7a44f
33,399
[ -1 ]
33,400
quail-system-io.lsp
rwoldford_Quail/source/mathematics/borel-sets/quail-system-io.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; quail-system-io.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; QUAIL SYSTEM INPUT/OUTPUT ;;; ;;; In this file the officially sanctioned functions for direct communication ;;; with the user of quail software are defined. So are the io-streams for this ;;; communication. ;;; ;;; Variables: ;;; *quail-standard-input* ;;; *quail-standard-output* ;;; *quail-query-io* ;;; ;;; Functions: ;;; quail-error - error function. ;;; quail-cerror - continuable error. ;;; quail-query - prompt user for a form to evaluate. ;;; quail-y-or-n-p - ask user a question; wait for single character ;;; y or n response. ;;; quail-yes-or-no-p - ask user a question; wait for multiple character ;;; yes or no response. ;;; ;;;------------------------------------------------------------------------------------- (defvar *quail-standard-input* (make-synonym-stream *standard-input*)) (defvar *quail-standard-output* (make-synonym-stream *standard-output*)) (defvar *quail-query-io* (make-synonym-stream *query-io*)) (defun quail-error (format-string &rest args) "See error function for documentation." (apply #'error format-string args)) (defun quail-cerror (continue-format-string error-format-string &rest args) "See cerror function for documentation." (apply #'cerror (append (list continue-format-string error-format-string) args))) (defun quail-query (format-string &rest args) "Prompts the user with format-string and reads in user-typed expression." (declare (special *quail-query-io*)) (apply #'format *query-io* format-string args) (read *query-io*)) (defun quail-y-or-n-p (&optional format-string &rest args) "See y-or-n-p function for documentation. ~%~ Difference is all i/o is performed using the stream ~%~ that is the value of *quail-query-io* ." ;(declare (special *quail-query-io*)) ;(let ((*query-io* *quail-query-io*)) ;Shadowing doesn't seem to work (apply #'y-or-n-p format-string args) ;) ) (defun quail-yes-or-no-p (&optional format-string &rest args) "See yes-or-no-p function for documentation. ~%~ Difference is all i/o is performed using the stream ~%~ that is the value of *quail-query-io* ." ;(declare (special *quail-query-io*)) ;(let ((*query-io* *quail-query-io*)) ;Shadowing doesn't seem to work (apply #'yes-or-no-p format-string args) ;) )
3,018
Common Lisp
.l
69
40.550725
89
0.54831
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
98ecc38e6f1a1bf0a69965309afa41703d6f9d701162471b240891ed90b43e30
33,400
[ -1 ]
33,401
borel-test2.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-test2.lsp
(setf foo1 (make-instance 'interval :infimum 7 :supremum 23)) (setf foo2 (make-instance 'interval :infimum 34 :supremum 47 :closure-property :LEFT)) (setf foo3 (make-instance 'interval :infimum 2 :supremum 20)) (setf foo4 (make-instance 'interval :infimum 22 :supremum 32)) ;;;interval EFUs (setf foo (set-union foo1 foo3)) (setf foo (set-union foo1 foo2)) (setf bar (set-intersection foo1 foo2)) (setf bar (set-union foo3 foo4)) (setf dill (set-union bete 5)) (setf mill (set-union bete 2)) (setf bete (make-instance 'predicate-set :infimum 5 :supremum 17 :closure-property :open :defining-predicate #'(lambda (test-member) (and (< 5 test-member) (< test-member 17))))) (setf tete (make-instance 'predicate-set :infimum 8 :supremum 23 :closure-property :open :defining-predicate #'(lambda (test-member) (and (< 8 test-member) (< test-member 23))))) (describe foo) (describe bar) (setf fox (set-union foo foo)) (setf fox (set-union foo bar)) (setf whix (set-intersection foo bar)) (setf foo (set-union foo2 foo3)) (setf whix (set-intersection foo bar)) (setf whix (op-set-intersection dill mill)) (setf scull (set-complement foo bar)) (setf foo (set-union foo2 foo3)) (setf scull (set-complement foo bar)) (setf scull (op-set-complement dill mill)) ;why does address change predicate set (describe fox) (describe whix) (describe scull) (setf foo5 (make-instance 'interval :infimum 41 :supremum 72)) (setf bar (set-union foo3 foo4 foo5)) ;;; non-interval EFU ;;(setf foo (make-instance 'borel-set :infimum 7 :supremum 23)) (setf bar (set-union foo 25)) (setf fox (set-union foo bar)) (setf whix (set-intersection foo bar)) (setf scull (set-complement foo bar)) ;;; predicate-sets (setf sete (make-instance 'predicate-set :infimum -infinity :supremum +infinity :closure-property :closed :defining-predicate #'(lambda (test-member) (extended-integerp test-member)))) (setf bete (make-instance 'predicate-set :infimum 5 :supremum 17 :closure-property :open :defining-predicate #'(lambda (test-member) (and (< 5 test-member) (< test-member 17))))) (setf fox (set-union sete bete)) (setf whix (set-intersection sete bete)) (setf scull (set-complement bete sete)) (memberp 17 fox) (memberp 6 fox) (memberp infinity fox) (memberp 17 whix) (memberp 6 whix) (memberp infinity whix) (memberp 17 scull) (memberp 6 scull) (memberp infinity scull) ;;; complement-sets (setf alpha (make-instance 'complement-set :set foo3 :wrt foo1)) (setf gamma (set-complement 5 foo3)) (setf fox (set-union alpha gamma)) (setf whix (set-intersection alpha gamma)) (setf scull (set-complement alpha gamma)) (memberp 17 fox) (memberp 6 fox) (memberp infinity fox) (memberp 17 whix) (memberp 6 whix) (memberp infinity whix) (memberp 17 scull) (memberp 6 scull) (memberp infinity scull) (setf mix1 (set-union foo1 bete)) (setf mix2 (set-union foo1 gamma)) (setf mix3 (set-union bete gamma)) (memberp 17 mix1) (memberp 6 mix1) (memberp infinity mix1) (memberp 17 mix2) (memberp 6 mix2) (memberp infinity mix2) (memberp 17 mix3) (memberp 6 mix3) (memberp infinity mix3) (setf mix1 (set-intersection foo1 bete)) (setf mix2 (set-intersection foo1 gamma)) (setf mix3 (set-intersection bete gamma)) (memberp 17 mix1) (memberp 6 mix1) (memberp infinity mix1) (memberp 17 mix2) (memberp 6 mix2) (memberp infinity mix2) (memberp 17 mix3) (memberp 6 mix3) (memberp infinity mix3) (setf mix1 (set-complement foo1 bete)) (setf mix2 (set-complement foo1 gamma)) (setf mix3 (set-complement bete gamma)) (memberp 17 mix1) (memberp 6 mix1) (memberp infinity mix1) (memberp 17 mix2) (memberp 6 mix2) (memberp infinity mix2) (memberp 17 mix3) (memberp 6 mix3) (memberp infinity mix3) (setf doo (set-intersection mix1 gamma)) (describe doo) (setf moo (set-complement 6 doo)) (describe moo)
4,307
Common Lisp
.l
137
26.284672
87
0.664407
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
a32b6a3427454623f35ea822ac6eaa83fb73df8814484780f9758944d37de47b
33,401
[ -1 ]
33,402
borel-sets.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-sets.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; borel-sets.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990, 1992 ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; BOREL SETS ;;; ;;; In this file the classes representing Borel-Sets and operators on those ;;; classes are defined. Various specialized methods which implement the ;;; operators are defined elsewhere. ;;; ;;; Examples are given in "borel-examples.lisp". ;;; Special instances and relates functions, constants, and variables ;;; are in "borel-special.lisp". ;;; ;;; In the sequel, the base set, of which every set defined here is a subset, ;;; is the extended real line: ;;; ;;; [ -infinity, +infinity ] ;;; ;;; Other important notes: ********************************************************* ;;; ;;; 1. Where sensible, all operators are n-ary for n >=1 ;;; Each operator will invoke a binary method having the same name as the ;;; operator except prefixed by "op". For example, set-union is the name of the ;;; general n-ary union operator which calls the method op-set-union on two arguments. ;;; The "op" operators are specialized to do the right things on the basis ;;; of their argument types. ;;; ;;; 2. Any extended real number (extended-real-p => T) can be treated as if ;;; it were either a countable-set or an interval. ;;; In either case the set is closed and has the extended real number as ;;; its single element. ;;; ************************************************************************ ;;; ;;; ;;; Classes: ;;; ;;; Borel-Set (includes any extended-real-number ;;; as a singleton finite-set/closed-interval) ;;; Empty-Set ;;; Interval ;;; Complement-Set ;;; Predicate-Set ;;; ;;; ;;; ;;; Global constant: ;;; ;;; *the-extended-real-line* ... [ -infinity, +infinity ]. ;;; ;;; ;;;---------------------------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; borel-set ;;; (defclass borel-set (quail-object) ((infimum :reader infimum :initarg :infimum :initform NaN :documentation "The infimum of the set wrt the extended reals.") (supremum :reader supremum :initarg :supremum :initform NaN :documentation "The supremum of the set wrt the extended reals.") (closure-property :reader closure-property-of :initarg :closure-property :initform :unknown :documentation "Records what is known about the closure-property of this set.")) (:documentation "An arbitrary Borel set on the extended real line.") ) (defmethod initialize-instance :after ((self borel-set) &key) (let ((inf (infimum self)) (sup (supremum self))) (if (and (> inf sup) (not (empty-set-p self))) (quail-error "An attempt was made to create an instance of the class ~s~%~ that had an infimum (~s) larger than its supremum (~s)" (class-name (class-of self)) inf sup)))) (defmethod (setf infimum) (new-value (self borel-set)) (if (not (or (extended-realp new-value) (eq new-value NaN))) (quail-error "Illegal value ~s. ~%~ Infimum must be an extended-real or NaN" new-value) (if (> new-value (supremum self)) (quail-error "Illegal value ~s. ~%~ Infimum must not be > supremum = ~s" new-value (supremum self)) (setf (slot-value self 'infimum) new-value)))) (defmethod (setf supremum) (new-value (self borel-set)) (if (not (or (extended-realp new-value) (eq new-value NaN))) (quail-error "Illegal value ~s. ~%~ Supremum must be an extended-real or NaN" new-value) (if (< new-value (infimum self)) (quail-error "Illegal value ~s. ~%~ Supremum must not be > infimum = ~s" new-value (infimum self)) (setf (slot-value self 'supremum) new-value)))) (defmethod (setf closure-property-of) (new-value (self borel-set)) (if (not (or (eq new-value :closed) (eq new-value :neither) (eq new-value :open) (eq new-value :both) (eq new-value :unknown) (eq new-value :left-closed) (eq new-value :right-closed) (eq new-value :left) (eq new-value :right) (eq new-value :left-open) (eq new-value :right-open) (eq new-value :closed-left) (eq new-value :closed-right) (eq new-value :open-left) (eq new-value :open-right))) (quail-error "~s is not a defined closure-property" new-value) (setf (slot-value self 'closure-property) new-value))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Plus the generic functions ;;; determine-closure ;;; recalculate-bounds ;;; cardinality ;;; (defgeneric determine-closure (borel-set) (:documentation "Tries to determine closure, then sets the closure-property accordingly.~%~ N.B. This includes setting it to :unknown if it fails.") ) (defgeneric recalculate-bounds (borel-set) (:documentation "Attempts to determine and set the infimum and supremum slots of the ~%~ set.~%~ N.B. This includes setting it to :unknown if it fails.") ) (defgeneric cardinality (borel-set) (:documentation "The cardinality of the given borel-set.") ) ;;;----------------------------------------------------------------------------------- ;;; ;;; The generic "op-" functions. ;;; ;;;----------------------------------------------------------------------------------- (defgeneric op-borel-set-p (borel-set) (:documentation "Returns T or NIL depending on whether or not the argument is a borel-set.") ) (defgeneric op-set-complement (borel-set1 borel-set2) (:documentation "Returns the complement of its first argument in its second.") ) (defgeneric op-set-union (borel-set1 borel-set2) (:documentation "Returns the union of two borel-sets.") ) (defgeneric op-set-intersection (borel-set1 borel-set2) (:documentation "Returns the intersection of two borel-sets") ) (defgeneric op-memberp (borel-set number) (:documentation "Tests whether the number is a member of the given borel-set.") ) (defgeneric op-insidep (borel-set1 borel-set2) (:documentation "Tests whether the first borel-set is a subset of the second.") ) (defgeneric op-containsp (borel-set1 borel-set2) (:documentation "Tests whether the second borel-set is a subset of the first.") ) (defgeneric op-empty-set-p (borel-set) (:documentation "Tests whether this borel-set is empty (T) or not (NIL).") ) (defgeneric op-closed-set-p (borel-set) (:documentation "Tests whether this borel-set is KNOWN to be closed." ) ) (defgeneric op-open-set-p (borel-set) (:documentation "Tests whether this borel-set is KNOWN to be open.") ) (defgeneric op-neither-closure-p (borel-set) (:documentation "Tests whether this borel-set is KNOWN to be closed.") ) (defgeneric op-set-difference (borel-set1 borel-set2) (:documentation "Returns the set difference S1 - S2 of its two arguments S1 and S2") ) (defgeneric op-disjoint-sets-p (set1 set2) (:documentation "Checks to see if set1 and set2 are disjoint.")) ;;;---------------------------------------------------------------------------------- ;;; ;;; EMPTY-SET ;;; ;;;---------------------------------------------------------------------------------- (defclass empty-set (borel-set) ((infimum :allocation :class :documentation "Infimum of the empty set is +infinity.") (supremum :allocation :class :documentation "Supremum of the empty set is -infinity.") (closure-property :initform :both :allocation :class :documentation "The empty set is both open and closed.")) (:documentation "A borel-set having no elements.") ) (defmethod initialize-instance :after ((self empty-set) &key) (setf (infimum self) +infinity) (setf (supremum self) -infinity) self) (defmethod (setf infimum) (new-value (self empty-set)) (if (not (eq new-value +infinity)) (quail-error "Illegal value ~s. ~%~ Infimum of the empty-set is +infinity" new-value) (setf (slot-value self 'infimum) new-value))) (defmethod (setf supremum) (new-value (self empty-set)) (if (not (eq new-value -infinity)) (quail-error "Illegal value ~s. ~%~ 'supremum of the empty-set is -infinity" new-value) (setf (slot-value self 'supremum) new-value))) ;;;---------------------------------------------------------------------------- ;;; ;;; INTERVALS on the real-line. ;;; ;;;---------------------------------------------------------------------------- (defclass interval (borel-set) ((infimum :initform -infinity) (supremum :initform +infinity) (closure-property :initform :open :documentation "Closure-property of an interval is by default :open. ~%~ Other possibilities are: ~%~ :left (i.e. closed left, open right) ~%~ :right (i.e. closed right, open left) ~%~ :closed, :open, and :both (only for an extended real line).") ) (:documentation "An arbitrary interval on the extended real line.") ) (defmethod initialize-instance :after ((self interval) &key) (if (and (= (infimum self) (supremum self)) (not (eq (closure-property-of self) :closed))) (quail-error "An interval having equal infimum and supremum (here ~s) ~ must be closed on both ends.~%This one's closure-property was ~s." (infimum self) (closure-property-of self)))) (defmethod (setf infimum) :before (new-value (self interval)) (if (and (= new-value (supremum self)) (not (eq (closure-property-of self) :closed))) (quail-error "An interval having equal infimum and supremum (here ~s) ~ must be closed on both ends.~%This one's closure-property was ~s." new-value (closure-property-of self)) new-value)) (defmethod (setf supremum) :before (new-value (self interval)) (if (and (= new-value (infimum self)) (not (eq (closure-property-of self) :closed))) (quail-error "An interval having equal infimum and supremum (here ~s) ~ must be closed on both ends.~%This one's closure-property was ~s." new-value (closure-property-of self)) new-value)) (defmethod (setf closure-property-of) :before (new-value (self interval)) (if (and (= (infimum self) (supremum self)) (not (eq new-value :closed))) (quail-error "An interval having equal infimum and supremum (here ~s) ~ must be closed on both ends." (infimum self)) new-value)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Some generic functions peculiar to intervals ;;; (defgeneric left-open-p (interval) (:documentation "Tests whether the interval is open on the left.") ) (defgeneric left-closed-p (interval) (:documentation "Tests whether the interval is closed on the left.") ) (defgeneric right-open-p (interval) (:documentation "Tests whether the interval is open on the right.") ) (defgeneric right-closed-p (interval) (:documentation "Tests whether the interval is closed on the right.") ) (defgeneric separatep (interval1 interval2) (:documentation "Tests whether two intervals have null intersection.") ) ;;;---------------------------------------------------------------------------- ;;; ;;; Complement Sets ;;; ;;;---------------------------------------------------------------------------- (defclass complement-set (borel-set) ((set :initarg :set :accessor set-of :documentation "The set of which the complement was taken with respect to ~%~ the complement-set.") (wrt :initarg :wrt :initform *the-extended-real-line* :accessor complement-wrt :documentation "The default value is the extended real line.") ) (:documentation "The complement of a set with respect to ~%~ the complement-set.")) #| (defmethod infimum ((self complement-set)) (let ((inf1 (infimum (set-of self))) (inf2 (infimum (comparison-set-of self))) (sup1 (supremum (set-of self)))) (cond ((or (< inf2 inf1) (> inf2 sup1) (and (= inf1 inf2) (open-left (set-of self)) (closed-left (comparison-set-of self)))) inf2) (( |# ;;;---------------------------------------------------------------------------- ;;; ;;; Predicate-Sets ;;; ;;; Set defined where inclusion is determined by a predicate function p. ;;; ;;; i.e. { x : p(x) = T , x real in [-infinity, +infinity] } ;;; ;;; is called a predicate-set here. ;;; ;;;---------------------------------------------------------------------------- (defclass predicate-set (borel-set) ((defining-predicate :accessor defining-predicate-of :type function :initarg :defining-predicate ;;; :initform #'extended-reals-defining-predicate :initform #'extended-realp :documentation "A function of two arguments: the set and the test-element.~%~ When applied to the predicate-set and an extended-real~%~ it returns T if the value is in the set and NIL otherwise.")) (:documentation "Set defined where inclusion is determined by a predicate function p. ~%~%~ i.e. { x : p(x) = T , x real in [-infinity, +infinity] } ~%~%~ is called a predicate-set here. ~%~ The role of p() is played by a function attached to the slot ~%~ called defining-property."))
14,745
Common Lisp
.l
377
33.198939
96
0.557346
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
3ad116d23589d06f4e36607e4bda780c21405c6ce077b2f2d277815218463a33
33,402
[ -1 ]
33,403
set-collections-test.lsp
rwoldford_Quail/source/mathematics/borel-sets/set-collections-test.lsp
(setf foo (make-instance 'explicit-finite-collection)) (describe foo) (funcall (position-from-index-function-of foo) 1) (funcall (index-from-position-function-of foo) 1) (add-sets foo 400 500 600 300 200 100 0 700) (contains-set-p foo 0) (contains-set-p foo 4) (contains-set-p foo 123) (funcall (index-function-of foo) foo 200) (funcall (index-function-of foo) foo 12) (remove-sets foo 16 600 14) (remove-sets foo 0 2 4) (remove-sets-if foo #'(lambda (a) (> a 499))) (describe foo) (delete-sets foo 16 21 14) (delete-sets foo 6 2 4) (delete-sets-if foo #'(lambda (a) (> a 3))) (sorted-collection-p foo) (collection-sort foo #'<) (describe (copy-set foo)) (setf bar (make-instance 'explicit-finite-collection :contents '( 2 541 3 4 1))) (describe bar) (funcall (element-function-of bar) bar 1) (collection-sort bar #'>) (setf foobar (combine-collections foo bar)) (describe foobar) (setf barfoo (combine-collections bar foo)) (describe barfoo) ;;;;;;;;;;;;;;; ;;; Testing countable-collections (setf cc-1 (make-instance 'countable-collection)) (describe cc-1) (setf (element-function-of cc-1) #'(lambda (collection index) (declare (ignore collection)) index)) (setf cc-2 (make-instance 'countable-collection)) (describe cc-2) (setf (element-function-of cc-2) #'(lambda (collection index) (declare (ignore collection)) (- index))) (contains-set-p cc-1 3) (funcall (index-function-of cc-1) cc-1 3) (count-start-of cc-1) (contains-set-p cc-1 +infinity) (loop for i from 0 to 20 do (print (funcall (element-function-of cc-1) cc-1 i))) (loop for i from 0 to 20 do (print (funcall (element-function-of cc-2) cc-2 i))) (setf cc-1-2 (combine-collections cc-1 cc-2)) (describe cc-1-2) (setf ith-set-of (element-function-of cc-1-2)) (funcall ith-set-of cc-1-2 0) (funcall ith-set-of cc-1-2 1) (funcall ith-set-of cc-1-2 20) (loop for i from 0 to 20 collect (funcall ith-set-of cc-1-2 i)) (setf foo-cc-1 (combine-collections foo cc-1)) (setf cc-1-foo (combine-collections cc-1 foo)) (describe foo-cc-1) (setf ith-set-of (element-function-of foo-cc-1)) (funcall (element-function-of foo) foo (/ 10 2)) (funcall ith-set-of foo-cc-1 0) (funcall ith-set-of foo-cc-1 1) (funcall ith-set-of foo-cc-1 2) (funcall ith-set-of foo-cc-1 3) (funcall ith-set-of foo-cc-1 16) (funcall ith-set-of foo-cc-1 17) (funcall ith-set-of foo-cc-1 18) (loop for i from 1 to 31 by 2 do (print (funcall ith-set-of foo-cc-1 i))) (setf ith-set-of (element-function-of cc-1-foo)) (funcall ith-set-of cc-1-foo 0) (funcall ith-set-of cc-1-foo 1) (funcall ith-set-of cc-1-foo 2) (funcall ith-set-of cc-1-foo 3) (funcall ith-set-of cc-1-foo 16) (funcall ith-set-of cc-1-foo 17) (funcall ith-set-of cc-1-foo 18) (funcall ith-set-of cc-1-foo +infinity)
2,907
Common Lisp
.l
82
32.02439
65
0.677869
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
a44de2022b4da05ad78bb1a42d2c2bfe6832c69ecf499b852b832ac98e17d835
33,403
[ -1 ]
33,404
borel-functions.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-functions.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; borel-functions.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990, 1992 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; BOREL FUNCTIONS ;;; ;;; ;;; Basic operations: ;;; ;;; borel-set-p ... test whether the argument is KNOWN to be a borel-set. ;;; set-complement ... set complement. ;;; set-union ... union. ;;; set-intersection ... intersection. ;;; set-difference-p ... difference in sets (same as binary complement). ;;; sym-difference ... symmetric difference of sets. ;;; memberp ... membership testing. ;;; insidep ... subset test. ;;; containsp ... subset test in reverse order. ;;; same-set-p ... test whether sets have the same contents. ;;; disjoint-sets-p ... test whether sets are disjoint. ;;; empty-set-p ... test whether sets are empty. ;;; closed-set-p ... test whether set is KNOWN to be closed. ;;; open-set-p ... test whether set is KNOWN to be open. ;;; neither-closure-p ... test whether it is KNOWN that the set ;;; is neither open nor closed. ;;; closure-property-of ... get what is known about the closure-property ;;; of the set. ;;; Returns an informative keyword (e.g. :open, ;;; :closed, :neither, :both, :unknown, :left-closed, ;;; :right-closed, and possibly others). ;;; determine-closure ... tries to determine closure *and will set* the ;;; closure-property accordingly. ;;; recalculate-bounds ... attempts to determine, *and will set* the ;;; infimum and supremum slots of the set. ;;; cardinality ... number of elements in a countable set ;;; i.e. one of 0,1,2,... +infinity or NaN if ;;; unknown. ;;; ;;; ;;; Global constants: ;;; ;;; *the-empty-set* ... Set of NO ELEMENTS. ;;; *the-extended-real-line* ... [ -infinity, +infinity ]. ;;; ;;; ;;;---------------------------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; A predicate for testing whether things are borel-sets ;;; (defun borel-set-p (thing &rest other-things) "Tests whether all arguments are borel-sets." (if other-things (and (op-borel-set-p thing) (apply #'borel-set-p other-things)) (op-borel-set-p thing))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; closure-property testing: ;;; ;;; open-set-p - returns non-NIL if the set is *KNOWN* ;;; to be open otherwise NIL. ;;; closed-set-p - returns non-NIL if the set is *KNOWN* ;;; to be closed otherwise NIL. ;;; ;;; IMPLICATION: (not (open-set-p foo)) *DOES NOT IMPLY* (closed-set-p foo) ;;; and vice versa. ;;; ;;; neither-closure-p - returns non-NIL if the set is *KNOWN* ;;; to be neither open nor closed. ;;; (defun open-set-p (set1 &rest other-sets) "Test whether all the given sets are KNOWN to be open.~%~ N.B. Returning NIL does *NOT* imply that some set is closed!" (if other-sets (and (op-open-set-p set1) (apply #'open-set-p other-sets)) (op-open-set-p set1))) (defun closed-set-p (set1 &rest other-sets) "Test whether all the given sets are KNOWN to be closed. ~%~ N.B. Returning NIL does *NOT* imply that some set is open!" (if other-sets (and (op-closed-set-p set1) (apply #'closed-set-p other-sets)) (op-closed-set-p set1))) (defun neither-closure-p (set1 &rest other-sets) "Test whether all the given sets are KNOWN to be neither ~%~ open nor closed.~%~ N.B. Returning NIL does *NOT* imply that some set is either~%~ open or closed!" (if other-sets (and (op-neither-closure-p set1) (apply #'neither-closure-p other-sets)) (op-neither-closure-p set1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Testing for the empty set. ;;; (defun empty-set-p (set1 &rest other-sets) (if other-sets (and (op-empty-set-p set1) (apply #'empty-set-p other-sets)) (op-empty-set-p set1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The membership operator: memberp ;;; (defun memberp (value set) (if (extended-realp value) (op-memberp value set) (quail-error "~s cannot be a member of any Borel set! ~%~ It must be an extended-real." value))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The set-union operator: set-union ;;; ;;; N.B. If given a single argument, set-union ;;; returns *the-extended-real-line* as if union was taken ;;; with respect to *the-extended-real-line*. ;;; (defun set-union (set1 &rest other-sets) (declare (special *the-extended-real-line*)) "Returns the union of all the given sets. ~ If given a single argument, set-union returns *the-extended-real-line*~ as if the union was taken with respect to *the-extended-real-line*. ~ (:see-also op-set-union)" (if other-sets (let ((rest-of-them (rest other-sets))) (if rest-of-them (apply #'set-union (op-set-union set1 (first other-sets)) rest-of-them) (op-set-union set1 (first other-sets)))) *the-extended-real-line*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The set-intersection operator ;;; ;;; N.B. If given a single argument, set-intersection ;;; returns its argument as if the ;;; intersection was taken ;;; with respect to *the-extended-real-line*. ;;; (defun set-intersection (set1 &rest other-sets) "Returns the intersection of all the given sets. ~%~ If given a single argument, set-intersection returns its argument as if ~%~ the intersection was taken with respect to *the-extended-real-line*. ~ (:see-also op-set-intersection)" (if other-sets (apply #'set-intersection (op-set-intersection set1 (first other-sets)) (rest other-sets)) set1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The subset predicate: insidep ;;; ;;; N.B. ;;; 1. If given a single argument, insidep ;;; returns T as if the ;;; subset predicate was testing whether the ;;; argument was a subset of *the-extended-real-line*. ;;; 2. As an n-ary predicate it tests for ;;; monotone subsetting of its arguments. ;;; (monotone non-decreasing sets) ;;; (defun insidep (set1 &rest other-sets) (declare (special *the-extended-real-line*)) "1. Tests for monotone subsetting of its arguments.~%~ ~3,0T(I.e. monotone non-decreasing sets.) ~%~ 2. If given a single argument, insidep returns T~%~ ~3,0Tas if the subset predicate was testing whether the argument~%~ ~3,0Twas a subset of *the-extended-real-line*." (if other-sets (let ((next-set (first other-sets)) (rest-of-them (rest other-sets))) (if (or (eq set1 next-set) (op-insidep set1 next-set)) (if rest-of-them (apply #'insidep next-set rest-of-them) next-set))) T)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The converse, the contains predicate: containsp ;;; ;;; N.B. ;;; 1. If given a single argument, containsp tests ;;; whether its argument contains (i.e. IS) ;;; *the-extended-real-line*. ;;; 2. As an n-ary predicate it tests for ;;; monotone subsetting of its arguments. ;;; (monotone non-decreasing sets) ;;; 3. If T it returns the largest set (i.e. ;;; right-most argument. ;;; (defun containsp (set1 &rest other-sets) (declare (special *the-extended-real-line*)) "1. Tests for monotone containment of its arguments.~%~ ~3,0T(I.e. monotone non-increasing sets.) ~%~ 2. If given a single argument, containsp tests whether its argument~%~ ~3,0Tcontains *the-extended-real-line*." (if other-sets (let ((next-set (first other-sets)) (rest-of-them (rest other-sets))) (if (op-containsp set1 next-set) (if rest-of-them (apply #'containsp next-set rest-of-them) T))) (if (op-containsp set1 *the-extended-real-line*) T NIL))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; same-set-p ;;; ;;; ... Testing whether the contents of many sets are the same. ;;; (defun same-set-p (set1 &rest other-sets) (declare (special *the-extended-real-line*)) "Tests whether the given sets all have the same contents. ~%~ If a single argument is given, testing is done against ~%~ *the-extended-real-line*." (if other-sets (let ((set2 (first other-sets)) (rest-of-them (rest other-sets))) (if (or (eq set1 set2) (and (op-insidep set1 set2) (op-insidep set2 set1))) (if (null rest-of-them) T (apply #'same-set-p set2 rest-of-them)))) (and (op-insidep set1 *the-extended-real-line*) (op-insidep *the-extended-real-line* set1)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; disjoint-sets-p ;;; ;;; ... Testing whether the sets have null intersection. ;;; (defun disjoint-sets-p (set1 &rest other-sets) "Tests whether the given sets all null intersection. ~%~ If a single argument is given, NIL is returned as if ~%~ testing were done against *the-extended-real-line*." (if other-sets (let ((set2 (first other-sets)) (rest-of-them (rest other-sets))) (if (op-disjoint-sets-p set1 set2) (if (null rest-of-them) T (apply #'disjoint-sets-p set2 rest-of-them)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The set-complement operator ;;; ;;; N.B. ;;; 1. If given a single argument, set-complement assumes ;;; you mean complement with respect to the base set ;;; (i.e. wrt *the-extended-real-line*). ;;; 2. As a binary operator it returns the complement of ;;; its first argument in its second. ;;; 3. As an n-ary operator, it accumulates complements ;;; left to right. That is ;;; (set-complement S1 S2 S3 S4) ;;; behaves the same as ;;; (set-complement ;;; (set-complement ;;; (set-complement S1 S2) ;;; S3) ;;; S4) ;;; (defun set-complement (set1 &rest other-sets) (declare (special *the-extended-real-line*)) "1. If given a single argument, set-complement assumes~%~ ~3,0Tyou mean complement with respect to the base set ~%~ ~3,0T(i.e. wrt *the-extended-real-line*). ~%~ 2. As a binary operator it returns the complement of~%~ ~3,0Tits first argument in its second.~%~ 3. As an n-ary operator, it accumulates complements left to right.~%~ ~3,0TThat is~~%~~ ~3,0T(set-complement S1 S2 S3 S4)~~%~~ ~3,0Tbehaves the same as~~%~~ ~3,0T(set-complement~%~ ~3,0T (set-complement~%~ ~3,0T (set-complement S1 S2)~%~ ~3,0T S3)~%~ ~3,0T S4)." (if other-sets (let ((next-set (first other-sets)) (rest-of-them (rest other-sets))) (if rest-of-them (apply #'set-complement (op-set-complement set1 next-set) rest-of-them) (op-set-complement set1 next-set))) (op-set-complement set1 *the-extended-real-line*))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Symmetric difference as an n-ary operator ;;; ;;; As with other operators if only a single argument is given, ;;; it is assumed that the second argument is *the-extended-real-line*. ;;; (defun sym-difference (set1 &rest other-sets) (declare (special *the-extended-real-line*)) "Returns the symmetric difference of all the given sets.~%~ If a single argument is given, the sym-difference is applied to the~%~ given set and *the-extended-real-line*. ~ (:see-also set-difference-p)" (if other-sets (op-set-complement (apply #'set-intersection set1 other-sets) (apply #'set-union set1 other-sets)) (op-set-complement set1 *the-extended-real-line*))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Set difference as an n-ary operator. ;;; If only one argument is given, *the-empty-set* is returned ;;; as the result. That is it is assumed that one is trying ;;; to remove *the-extended-real-line* from the first set. ;;; ;;; (defun set-difference-p (set1 &rest other-sets) (declare (special *the-empty-set*)) "Returns the set difference of its arguments S1, S2, ..., Sn as~%~ S1 - S2 - ... - Sn.~%~ If only one argument is given, *the-empty-set* is returned.~%~ That is, it is assumed that one is trying to remove~%~ *the-extended-real-line* from the first set." (if other-sets (let ((next-set (first other-sets)) (rest-of-them (rest other-sets))) (if rest-of-them (apply #'set-difference-p (op-set-difference set1 next-set) rest-of-them) (op-set-difference set1 next-set))) *the-empty-set*))
14,623
Common Lisp
.l
352
36.514205
92
0.530286
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
5ee7280270fcf34058cbb2982982d79712bfe7a22ecd86980072c78c4e00f384
33,404
[ -1 ]
33,405
borel-special2.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-special2.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; borel-special2.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990, 1992. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; SPECIAL BOREL SET CONSTANTS, VARIABLES, AND FUNCTIONS ;;; ;;; In this file special Borel-Set constants, varibles, and related operators are defined. ;;; ;;; Global constants: ;;; ;;; *the-empty-set* ... Set of NO ELEMENTS. ;;; *the-real-line* ... ( -infinity, +infinity ). ;;; *the-extended-real-line* ... [ -infinity, +infinity ]. ;;; *the-integers* ;;; *the-extended-integers* ;;; *the-naturals* ;;; *the-extended-naturals* ;;; *the-rationals* ;;; *the-extended-rationals* ;;; ;;; Global variables: ;;; ;;; *default-set-less-than-predicate* ;;; *default-union-sort* ;;; *default-set-greater-than-predicate* ;;; ;;; Functions: ;;; ;;; real-linep ;;; extended-real-linep ;;; integersp ;;; extended-integersp ;;; naturalsp ;;; extended-naturalsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; GLOBAL CONSTANTS ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defconstant *the-empty-set* (make-instance 'empty-set)) (defconstant *the-real-line* (make-instance 'interval :infimum -infinity :supremum +infinity :closure-property :open)) (defconstant *the-extended-real-line* (make-instance 'interval :infimum -infinity :supremum +infinity :closure-property :both)) (defconstant *the-integers* (make-instance 'countable-set :infimum -infinity :supremum +infinity :begin-index -infinity :end-index +infinity :closure-property :open :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'integers-defining-predicate)) (defconstant *the-extended-integers* (make-instance 'countable-set :infimum -infinity :supremum +infinity :begin-index -infinity :end-index +infinity :closure-property :closed :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'extended-integers-defining-predicate)) (defconstant *the-naturals* (make-instance 'countable-set :infimum 0 :supremum +infinity :begin-index -infinity :end-index +infinity :closure-property :open :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'naturals-defining-predicate)) (defconstant *the-extended-naturals* (make-instance 'countable-set :infimum 0 :supremum +infinity :begin-index -infinity :end-index +infinity :closure-property :closed :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'extended-naturals-defining-predicate)) (defconstant *the-extended-rationals* (make-instance 'predicate-set :infimum -infinity :supremum +infinity :closure-property :closed :defining-predicate #'extended-rationals-defining-predicate)) (defconstant *the-rationals* (make-instance 'predicate-set :infimum -infinity :supremum +infinity :closure-property :open :defining-predicate #'rationals-defining-predicate)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; GLOBAL VARIABLES ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar *default-set-less-than-predicate* #'(lambda (set1 set2) (<= (infimum set1) (infimum set2)))) (defvar *default-union-sort* #'(lambda (set1 set2) (<= (infimum set1) (infimum set2)))) (defvar *default-set-greater-than-predicate* #'(lambda (set1 set2) (>= (supremum set1) (supremum set2)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Useful predicate tests. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun extended-real-linep (thing) (declare (special *the-extended-real-line*)) (or (same-set-p thing *the-extended-real-line*) (and (typep thing 'predicate-set) (eq (defining-predicate-of thing) #'extended-reals-defining-predicate) (= (infimum thing) -infinity) (= (supremum thing) +infinity) (eq (closure-property-of thing) (closure-property-of *the-extended-real-line*)) ))) (defun real-linep (thing) (declare (special *the-real-line*)) (and (not (borel-set-p thing)) (or (same-set-p thing *the-real-line*) (and (typep thing 'predicate-set) (eq (defining-predicate-of thing) #'reals-defining-predicate) (= (infimum thing) -infinity) (= (supremum thing) +infinity) (eq (closure-property-of thing) (closure-property-of *the-real-line*)))))) (defun extended-integersp (thing) (declare (special *the-extended-integers*)) (and (not (borel-set-p thing)) (or (same-set-p thing *the-extended-integers*) (and (typep thing 'predicate-set) (eq (defining-predicate-of thing) #'extended-integers-defining-predicate) (= (infimum thing) -infinity) (= (supremum thing) +infinity) (eq (closure-property-of thing) (closure-property-of *the-extended-integers*)))))) (defun integersp (thing) (declare (special *the-integers*)) (and (not (borel-set-p thing)) (or (same-set-p thing *the-integers*) (and (typep thing 'predicate-set) (eq (defining-predicate-of thing) #'integers-defining-predicate) (= (infimum thing) -infinity) (= (supremum thing) +infinity) (eq (closure-property-of thing) (closure-property-of *the-integers*)))))) (defun extended-naturalsp (thing) (declare (special *the-extended-naturals*)) (and (not (borel-set-p thing)) (or (same-set-p thing *the-extended-naturals*) (and (typep thing 'predicate-set) (eq (defining-predicate-of thing) #'extended-integers-defining-predicate) (= (infimum thing) 0) (= (supremum thing) +infinity) (eq (closure-property-of thing) (closure-property-of *the-extended-naturals*)))))) (defun naturalsp (thing) (declare (special *the-naturals*)) (and (not (borel-set-p thing)) (or (same-set-p thing *the-naturals*) (and (typep thing 'predicate-set) (eq (defining-predicate-of thing) #'integers-defining-predicate) (= (infimum thing) 0) (= (supremum thing) +infinity) (eq (closure-property-of thing) (closure-property-of *the-naturals*))))))
7,913
Common Lisp
.l
218
28.334862
92
0.514646
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
705e32c38b343e38dd7c63ac8a80feeeb060d36e32f366096c00bc7bdafafda4
33,405
[ -1 ]
33,406
memberp-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/memberp-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; memberp-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990, 1992 ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; Method | Argument type | ;;; |_____________________________________________| ;;; Name | Argument 1 | Argument 2 | ;;; ___________________________|______________________|______________________| ;;; | | | ;;; | | | ;;; op-memberp | (extended-realp) | borel-set | ;;; | (extended-realp) | complement-set | ;;; | (extended-realp) | countable-set | ;;; | (extended-realp) | empty-set | ;;; | (extended-realp) | explicit-finite-inter| ;;; | (extended-realp) | explicit-finite-set | ;;; | (extended-realp) | explicit-finite-union| ;;; | (extended-realp) | interval | ;;; | (extended-realp) | predicate-set | ;;; | (extended-realp) | (extended-realp) | ;;; | | | ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-memberp - Test whether an extended-real number ;;; is an element of the set ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-memberp (member set) (if (and (extended-realp set) (extended-realp member)) (= set member) (missing-method 'op-memberp member set))) (defmethod op-memberp (member (set borel-set)) (missing-method 'op-memberp member set)) ; must be specialized (defmethod op-memberp (member (set empty-set)) (declare (ignore member)) NIL) (defmethod op-memberp (number (set interval)) (let ((min (infimum set)) (max (supremum set))) (or (and (< min number) ; number definitely in (> max number)) ; the interval ; ; OR it (and (= min number) ; equals lower end-point (left-closed-p set)) ; and interval is closed ; on left ; OR it (and (= number max) ; equals upper end-point (right-closed-p set))) ; and interval is closed ; on right ) ) (defmethod op-memberp (member (set predicate-set)) (funcall (defining-predicate-of set) member)) (defmethod op-memberp (element (set explicit-finite-set)) (member element (contents-of set))) (defmethod op-memberp (member (set complement-set)) (and (op-memberp member (complement-wrt set)) (not (op-memberp member (set-of set))))) (defmethod op-memberp (member (self explicit-finite-union)) (loop for item in (contents-of self) do (when (op-memberp member item) (return T)))) (defmethod op-memberp (member (self explicit-finite-intersection)) (let ((result T)) (loop for item in (contents-of self) do (unless (op-memberp member item) (setf result NIL))) result)) (defmethod op-memberp (member (set countable-set)) (if (defining-predicate-of set) (funcall (defining-predicate-of set) set member) (contains-set-p set member))) (defmethod op-memberp (member (collection countable-union)) (if (defining-predicate-of collection) (funcall (defining-predicate-of collection) collection member) (call-next-method member collection))) (defmethod op-memberp (member (collection countable-intersection)) (declare (special *reasonable-number-of-iterations*)) (if (defining-predicate-of collection) (funcall (defining-predicate-of collection) collection member) (let ((result T)) (do ((index (count-start-of collection) (next-index collection index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*)) ;; end-test ((count-endedp collection index)) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume member ~%~ ~s ~%~ is in the collection ~%~ ~s ? " member collection) (return T)) ((quail-yes-or-no-p "Assume member ~%~ ~s ~%~ is *NOT* in the collection ~%~ ~s ? " member collection) (return NIL)) (T (quail-error "Can't tell whether the member ~%~ ~s ~%~ is in the collection ~%~ ~s ~%~ or not!" member member))))) ((unless (op-memberp member (element collection index)) (setf result NIL))))) result))) ;; not borel-sets, but collections of possible borel-sets so... #| (defmethod op-memberp (member (set set-collection)) (quail-error "Not enough information to determine whether ~s ~%~ is within the given set: ~s or not." member set)) (defmethod op-memberp (member (collection countable-collection)) (declare (special *reasonable-number-of-iterations*)) (do ((index (count-start-of collection) (next-index collection index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*)) ;; end-test ((count-endedp collection index)) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume member ~%~ ~s ~%~ is in the collection ~%~ ~s ? " member collection) (return T)) ((quail-yes-or-no-p "Assume member ~%~ ~s ~%~ is *NOT* in the collection ~%~ ~s ? " member collection) (return NIL)) (T (quail-error "Can't tell whether the member ~%~ ~s ~%~ is in the collection ~%~ ~s ~%~ or not!" member member))))) ((if (op-memberp member (element collection index)) (return T)))))) |#
8,321
Common Lisp
.l
186
34.274194
95
0.436244
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
06c8a872cf8453f695e65f4840ef20339a6a6aa1829122ff2e4102244986c7d4
33,406
[ -1 ]
33,407
set-intersection-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/set-intersection-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; set-intersection-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990 ;;; N. Wiebe 1997, 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; SET INTERSECTION METHODS ;;; ;;; Method | Argument type | ;;; |_____________________________________________| ;;; Name | Argument 1 | Argument 2 | ;;; ___________________________|______________________|______________________| ;;; | | | ;;; | | | ;;; op-set-intersection | borel-set | borel-set | ;;; | borel-set | complement-set | ;;; | borel-set | countable-union | ;;; | borel-set | empty-set | ;;; | borel-set |explicit-finite-inter | ;;; | borel-set | explicit-finite-set | ;;; | borel-set | explicit-finite-union| ;;; | borel-set | predicate-set | ;;; | borel-set | (extended-realp) | ;;; | complement-set | borel-set | ;;; | complement-set | complement-set | ;;; |countable-intersection|countable-intersection| ;;; | countable-union | borel-set | ;;; | empty-set | borel-set | ;;; | explicit-finite-inter| borel-set | ;;; | explicit-finite-inter|explicit-finite-inter | ;;; | explicit-finite-set | borel-set | ;;; | explicit-finite-set | explicit-finite-set | ;;; | explicit-finite-union| borel-set | ;;; | explicit-finite-union| explicit-finite-union| ;;; | interval | interval | ;;; | predicate-set | borel-set | ;;; | predicate-set | predicate-set | ;;; | (extended-realp) | borel-set | ;;; | (extended-realp) | (extended-realp) | (in-package :quail) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-set-intersection - Set Intersection binary operator ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-set-intersection ((set1 borel-set) (set2 borel-set)) (make-instance 'explicit-finite-intersection :contents (list set1 set2))) (defmethod op-set-intersection (set1 set2) (declare (special *the-empty-set*)) (if (and (extended-realp set1) (extended-realp set2)) (if (= set1 set2) set1 *the-empty-set*) (missing-method 'op-set-intersection set1 set2))) (defmethod op-set-intersection ((set1 borel-set) set2) (declare (special *the-empty-set*)) (if (extended-realp set2) (if (memberp set2 set1) set2 *the-empty-set*) (missing-method 'op-set-intersection set1 set2))) (defmethod op-set-intersection (set1 (set2 borel-set)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 empty-set) (set2 borel-set)) set1) (defmethod op-set-intersection ((set1 borel-set) (set2 empty-set)) set2) ;;; -------------------------- ;;; ;;; Intersection of intervals ;;; (defmethod op-set-intersection ((set1 interval) (set2 interval)) (declare (special *the-empty-set*)) (let (new-set) (if (separatep set1 set2) ;; then no intersection (setf new-set *the-empty-set*) ;; else sets overlap. More to sort out. (let* ((min1 (infimum set1)) (max1 (supremum set1)) (min2 (infimum set2)) (max2 (supremum set2)) (new-inf (max min1 min2)) (new-sup (min max1 max2)) (left-set (if (<= min1 min2) set1 set2)) (right-set (if (>= max1 max2) set1 set2)) (left-closed? NIL) (right-closed? NIL) new-closure-property) ;; Only closure-property remains to be figured out. ;; ;; First the left side: (if (or (and (> new-inf (infimum left-set)) (left-closed-p right-set)) (and (= min1 min2) (left-closed-p set1) (left-closed-p set2))) ;; then it's closed on the left (setf left-closed? T) ;; otherwise it's open on the left, ;; left-closed? remains nil ) ;; Now the right side: (if (or (and (< new-sup (supremum right-set)) (right-closed-p left-set)) (and (= max1 max2) (right-closed-p set1) (right-closed-p set2))) ;; then it's closed on the right (setf right-closed? T) ;; otherwise it's open on the right, ;; right-closed? remains nil ) ;; Which yields the closure-property: (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) ;; Finally make the appropriate set (if (not (= new-inf new-sup)) (setf new-set (make-instance 'interval :closure-property new-closure-property :infimum new-inf :supremum new-sup)) (setf new-set new-inf)))) new-set) ) (defmethod op-set-intersection ((set1 explicit-finite-set) (set2 explicit-finite-set)) (declare (special *the-empty-set*)) (if (or (> (infimum set1) (supremum set2)) (> (infimum set2) (supremum set1))) ;; then there is no intersection *the-empty-set* ;; else do more work (let* ((new-contents (seq-intersection (contents-of set1) (contents-of set2))) (new-len (length new-contents))) (cond ((zerop new-len) *the-empty-set*) ((= new-len 1) (elt new-contents 0)) (T (make-instance 'explicit-finite-set :contents new-contents :infimum (seq-min new-contents) :supremum (seq-max new-contents)))) ))) (defmethod op-set-intersection ((set1 explicit-finite-set) (set2 borel-set)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 borel-set) (set2 explicit-finite-set)) (declare (special *the-empty-set*)) (let ((intersecting-set (mapcan #'(lambda (x) (and (memberp x set1) (list x))) (contents-of set2)))) (cond ((null intersecting-set) *the-empty-set*) ((= (length intersecting-set) 1) (elt intersecting-set 0)) (T (make-instance 'explicit-finite-set :contents intersecting-set))))) (defmethod op-set-intersection ((set1 explicit-finite-set) (set2 countable-union)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 countable-union) (set2 explicit-finite-set)) (declare (special *the-empty-set*)) (let ((intersecting-set (mapcan #'(lambda (x) (and (memberp x set1) (list x))) (contents-of set2)))) (cond ((null intersecting-set) *the-empty-set*) ((= (length intersecting-set) 1) (elt intersecting-set 0)) (T (make-instance 'explicit-finite-set :contents intersecting-set))))) #| (defmethod op-set-intersection ((set1 finite-increasing-set) (set2 finite-increasing-set)) (declare (special *the-empty-set*)) (let (new-set) (if (or (> (infimum set1) (supremum set2)) (> (infimum set2) (supremum set1))) ;; then (setf new-set *the-empty-set*) ;; else (let ((contents (seq-intersection (contents-of set1) (contents-of set2)))) (if (zerop (length contents)) (setf new-set *the-empty-set*) (let ((new-min (elt contents 0)) (new-max (elt contents (- (length contents) 1)))) (setf new-set (make-instance 'finite-increasing-set :contents contents :infimum new-min :supremum new-max)))))) new-set)) |# (defmethod op-set-intersection ((set1 explicit-finite-union) (set2 explicit-finite-union)) (declare (special *the-empty-set*)) (if (eq set1 set2) ;;or op-same-setp set1 (if (op-disjoint-sets-p set1 set2) *the-empty-set* (let ((new-sets NIL) len) (loop for item1 in (contents-of set1) do (loop for item2 in (contents-of set2) do (setf new-sets (append new-sets (list (op-set-intersection item1 item2)))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (setf len (length new-sets)) (if (= len 1) (setf new-sets (elt new-sets 0)) (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))))) (defmethod op-set-intersection ((set1 borel-set) (set2 explicit-finite-union)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 explicit-finite-union) (set2 borel-set)) (declare (special *the-empty-set*)) (if (member set2 (contents-of set1) :test #'same-set-p) set2 (if (op-disjoint-sets-p set1 set2) *the-empty-set* (let ((new-sets NIL) len) (loop for item in (contents-of set1) do (setf new-sets (append new-sets (list (op-set-intersection item set2))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (setf len (length new-sets)) (if (= len 1) (setf new-sets (elt new-sets 0)) (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))))) (defmethod op-set-intersection ((set1 explicit-finite-intersection) (set2 explicit-finite-intersection)) (if (eq set1 set2) set1 (make-instance 'explicit-finite-intersection :contents (concatenate 'list (contents-of set1) (contents-of set2))))) (defmethod op-set-intersection ((set1 borel-set) (set2 explicit-finite-intersection)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 explicit-finite-intersection) (set2 borel-set)) (if (member set2 (contents-of set1) :test #'same-set-p) set1 (make-instance 'explicit-finite-intersection :contents (concatenate 'list (contents-of set1) (list set2))))) (defmethod op-set-intersection ((set1 explicit-finite-intersection) (set2 empty-set)) set2) (defmethod op-set-intersection ((set1 complement-set) (set2 borel-set)) (op-set-complement (set-of set1) (op-set-intersection (complement-wrt set1) set2))) (defmethod op-set-intersection ((set1 borel-set) (set2 complement-set)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 complement-set) (set2 complement-set)) (if (same-set-p set1 set2) set1 (op-set-complement (op-set-union (set-of set1) (set-of set2)) (op-set-intersection (complement-wrt set1) (complement-wrt set2))))) (defmethod op-set-intersection ((set1 predicate-set) (set2 predicate-set)) (if (eq set1 set2) set1 (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (funcall (defining-predicate-of set1) test-member) (funcall (defining-predicate-of set2) test-member)))))) (defmethod op-set-intersection ((set1 predicate-set) (set2 borel-set)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (funcall (defining-predicate-of set1) test-member) (memberp test-member set2))))) (defmethod op-set-intersection ((set1 borel-set) (set2 predicate-set)) (op-set-intersection set2 set1)) ;; all these are done already using the defining-predicate slot ;; however the following one should be easily coded (defmethod op-set-intersection ((set1 countable-intersection) (set2 countable-intersection)) (combine-collections set1 set2)) ;; is the following reasonable? (defmethod op-set-intersection ((set1 countable-union) (set2 borel-set)) (declare (special *the-empty-set*)) (print "big dummy") (if (contains-set-p set1 set2) set2 *the-empty-set*)) (defmethod op-set-intersection ((set1 countable-set) (set2 borel-set)) (op-set-intersection set2 set1)) ;;I CAN WRITE A BETTER METHOD FOR THIS (defmethod op-set-intersection ((set1 borel-set) (set2 countable-set)) (declare (special *the-empty-set*)) (if (op-disjoint-sets-p set1 set2) *the-empty-set* (make-instance 'explicit-finite-intersection :contents (list set1 set2)))) (defmethod op-set-intersection ((set1 borel-set) (set2 countable-union)) (op-set-intersection set2 set1)) (defmethod op-set-intersection ((set1 countable-intersection) (set2 borel-set)) (combine-collections set1 set2)) (defmethod op-set-intersection ((set1 countable-collection) (set2 empty-set)) set1) (defmethod op-set-intersection ((set1 countable-union) (set2 empty-set)) set2) (defmethod op-set-intersection ((set1 countable-intersection) (set2 empty-set)) set2) (defmethod op-set-intersection ((set1 countable-union) (set2 countable-union)) (declare (special *the-empty-set*)) (let ((new-sets NIL) len) (cond ((eq set1 set2) (setf new-sets set1)) ((finite-collection-p set1) (loop for item in (contents-of set1) do (setf new-sets (append new-sets (list (op-set-intersection item set2))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (setf len (length new-sets)) (cond ((zerop len) (setf new-sets *the-empty-set*)) ((= len 1) (setf new-sets (elt new-sets 0))) (T (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))) ((finite-collection-p set2) (loop for item in (contents-of set2) do (setf new-sets (append new-sets (list (op-set-intersection item set1))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (setf len (length new-sets)) (cond ((zerop len) (setf new-sets *the-empty-set*)) ((= len 1) (setf new-sets (elt new-sets 0))) (T (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))) (T (setf new-sets (make-instance 'explicit-finite-intersection :contents (list set1 set2))))) new-sets)) (defmethod op-set-intersection ((set1 countable-set) (set2 countable-set)) (declare (special *the-empty-set*)) (let ((new-sets NIL) len) (cond ((eq set1 set2) (setf new-sets set1)) ((finite-collection-p set1) (loop for item in (contents-of set1) do (setf new-sets (append new-sets (list (op-set-intersection item set2))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (setf len (length new-sets)) (cond ((zerop len) (setf new-sets *the-empty-set*)) ((= len 1) (setf new-sets (elt new-sets 0))) (T (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))) ((finite-collection-p set2) (loop for item in (contents-of set2) do (setf new-sets (append new-sets (list (op-set-intersection item set1))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (setf len (length new-sets)) (cond ((zerop len) (setf new-sets *the-empty-set*)) ((= len 1) (setf new-sets (elt new-sets 0))) (T (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))) (T (setf new-sets (make-instance 'explicit-finite-intersection :contents (list set1 set2))))) new-sets))
18,117
Common Lisp
.l
367
38.277929
105
0.51473
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
239c02b2af4356f1b383d2e0b5fa0fbc244b799028efd2959bdc619d88e7418a
33,407
[ -1 ]
33,408
Z-System-io.lsp
rwoldford_Quail/source/mathematics/borel-sets/Z-System-io.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; quail-system-io.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; QUAIL SYSTEM INPUT/OUTPUT ;;; ;;; In this file the officially sanctioned functions for direct communication ;;; with the user of quail software are defined. So are the io-streams for this ;;; communication. ;;; ;;; Variables: ;;; *quail-standard-input* ;;; *quail-standard-output* ;;; *quail-query-io* ;;; ;;; Functions: ;;; quail-error - error function. ;;; quail-cerror - continuable zerror. ;;; quail-query - prompt user for a form to evaluate. ;;; quail-y-or-n-p - ask user a question; wait for single character ;;; y or n response. ;;; quail-yes-or-no-p - ask user a question; wait for multiple character ;;; yes or no response. ;;; ;;;------------------------------------------------------------------------------------- (defvar *quail-standard-input* (make-synonym-stream *standard-input*)) (defvar *quail-standard-output* (make-synonym-stream *standard-output*)) (defvar *quail-query-io* (make-synonym-stream *query-io*)) (defun quail-error (format-string &rest args) "See error function for documentation." (apply #'error format-string args)) (defun quail-cerror (continue-format-string error-format-string &rest args) "See cerror function for documentation." (apply #'cerror (append (list continue-format-string error-format-string) args))) (defun quail-query (format-string &rest args) "Prompts the user with format-string and reads in user-typed expression." (declare (special *quail-query-io*)) (apply #'format *query-io* format-string args) (read *query-io*)) (defun quail-y-or-n-p (&optional format-string &rest args) "See y-or-n-p function for documentation. ~%~ Difference is all i/o is performed using the stream ~%~ that is the value of *quail-query-io* ." ;(declare (special *quail-query-io*)) ;(let ((*query-io* *quail-query-io*)) ;Shadowing doesn't seem to work (apply #'y-or-n-p format-string args) ;) ) (defun quail-yes-or-no-p (&optional format-string &rest args) "See yes-or-no-p function for documentation. ~%~ Difference is all i/o is performed using the stream ~%~ that is the value of *quail-query-io* ." ;(declare (special *quail-query-io*)) ;(let ((*query-io* *quail-query-io*)) ;Shadowing doesn't seem to work (apply #'yes-or-no-p format-string args) ;) )
3,019
Common Lisp
.l
69
40.565217
89
0.548464
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
fb56c75a5d2fbbb338be126b300f1ec7f2d05e4b9f2adc9ba9c448569f399b70
33,408
[ -1 ]
33,409
borel-sets-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-sets-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Borel-Sets-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990 ;;; N. Wiebe 1997, 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; BOREL SETS METHODS ;;; ;;; In this file the methods which implement operators on borel-sets ;;; are defined. Methods which implement the operators on argument combinations ;;; of different classes are defined elsewhere. ;;; ;;; ;;; Methods implemented in this file are as indicated in the ;;; following table: ;;; ;;; Method ;;; ;;; Name | Argument | ;;; ___________________________|______________________| ;;; | | ;;; | | ;;; op-borel-set-p | borel-set | ;;; | (extended-realp) | ;;; | | ;;; op-empty-set-p | borel-set | ;;; | complement-set | ;;; | countable-set | ;;; | empty-set | ;;; | (extended-realp) | ;;; | | ;;; op-closed-set-p | borel-set | ;;; | (extended-realp) | ;;; | | ;;; op-open-set-p | borel-set | ;;; | (extended-realp) | ;;; | | ;;; op-neither-closure-p | borel-set | ;;; | interval | ;;; | (extended-realp) | ;;; | | ;;; cardinality | borel-set | ;;; | countable-set | ;;; | empty-set | ;;; | (extended-realp) | ;;; | | ;;; ___________________________|______________________| ;;; ;;; ;;; Global constants: ;;; ;;; *max-reasonable-number-of-iterations* ;;; *big-set-count* ... Large positive integer representing ;;; the number of elements in a countable ;;; set that we are willing to check before ;;; asking the user whether we should continue. ;;; ;;;------------------------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Making each extended real appear as if it were a singleton set. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod infimum ((thing t)) (if (extended-realp thing) thing (missing-method 'infimum thing))) (defmethod supremum ((thing t)) (if (extended-realp thing) thing (missing-method 'supremum thing))) (defmethod closure-property-of ((thing t)) (if (extended-realp thing) :closed (missing-method 'infimum thing))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-borel-set-p - predicate test whether we have a borel-set or not. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-borel-set-p ((thing borel-set)) (declare (ignore thing)) T) (defmethod op-borel-set-p ((thing t)) ; include extended-real nos. (extended-realp thing)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-empty-set-p - Tests whether the set is empty. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-empty-set-p (set) (if (extended-realp set) NIL (missing-method 'op-empty-set-p set))) (defmethod op-empty-set-p ((set borel-set)) (quail-error "Not enough information to determine whether the given set: ~%~ ~s ~%~ is empty or not." set)) (defmethod op-empty-set-p ((set set-collection)) (quail-error "Not enough information to determine whether the given set: ~%~ ~s ~%~ is empty or not." set)) (defmethod op-empty-set-p ((set empty-set)) T) (defmethod op-empty-set-p ((set interval)) NIL) (defmethod op-empty-set-p ((set complement-set)) (op-insidep (complement-wrt set) (set-of set))) (defmethod op-empty-set-p ((set predicate-set)) (if (open-set-p set) (= (infimum set) (supremum set)) (if (closed-set-p set) ; Is this mathematically NIL ; correct to always return ; NIL in this case? (quail-error "Not enough information to determine whether the given set: ~%~ ~s ~%~ is empty or not." set)))) (defmethod op-empty-set-p ((set explicit-finite-collection)) ;; or just efu (let ((result T)) (loop for item in (contents-of set) do (when (not (op-empty-set-p item)) (return) (setf result NIL))) result)) (defmethod op-empty-set-p ((set countable-collection)) ;; or just countable-union (declare (special *max-reasonable-number-of-iterations*)) (let ((result T)) (do ((index (count-start-of set) (next-index set index)) (counter 1 (+ counter 1)) (big-count *max-reasonable-number-of-iterations*)) ;; end-test ((count-endedp set index) result) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume set ~s is empty?" set) (return T)) ((quail-yes-or-no-p "Assume set ~s ~%~ is *NOT* empty?" set) (progn (setf result NIL) (return))) (T (quail-error "Can't tell whether set ~s ~%~ empty or not!" set))))) ((not (op-empty-set-p (element set index))) (progn (setf result NIL) (return))))) result)) (defmethod op-empty-set-p ((set countable-intersection)) (disjoint-collection-p set)) (defmethod op-empty-set-p ((set countable-set)) (let ((num-elts (cardinality set))) (if (numberp num-elts) (= num-elts 0) NIL))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-closed-set-p - Test whether the set is KNOWN to be closed. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-closed-set-p (set) (if (extended-realp set) T (missing-method 'op-closed-set-p set))) (defmethod op-closed-set-p ((set borel-set)) (or (eq (closure-property-of set) :closed) (eq (closure-property-of set) :both))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-open-set-p - Test whether the set is KNOWN to be open. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-open-set-p (set) (if (extended-realp set) NIL (missing-method 'op-open-set-p set))) (defmethod op-open-set-p ((set borel-set)) (or (eq (closure-property-of set) :open) (eq (closure-property-of set) :both))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-neither-closure-p - Test whether the set is KNOWN to be both ;;; not closed and not open. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-neither-closure-p (set) (if (extended-realp set) NIL (missing-method 'op-neither-closure-p set))) (defmethod op-neither-closure-p ((set borel-set)) (or (eq (closure-property-of set) :neither) (eq (closure-property-of set) :unknown))) (defmethod op-neither-closure-p ((set interval)) (case (closure-property-of set) (:left-closed T) (:right-closed T) (:left-open T) (:right-open T) (:closed-left T) (:closed-right T) (:open-left T) (:open-right T) (:neither T) (:left T) (:right T))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; determine-closure - Try to determine the closure property of a set ;;; and then set it accordingly (in most cases). ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod determine-closure ((set explicit-finite-intersection)) (let ((new-closure (closure-property-of (first (contents-of set))))) (loop for item in (rest (contents-of set)) do (when (not (eq new-closure (closure-property-of item))) (setf new-closure :unknown) (return))) (setf (closure-property-of set) (if (eq new-closure (or :closed :open)) new-closure :unknown)))) (defmethod determine-closure ((set explicit-finite-union)) (let ((new-closure (closure-property-of (first (contents-of set))))) (loop for item in (rest (contents-of set)) do (when (not (eq new-closure (closure-property-of item))) (setf new-closure :unknown) (return))) (setf (closure-property-of set) new-closure))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Related closure methods that are specific to intervals ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod left-open-p (set) (if (extended-realp set) NIL (missing-method 'left-open-p set))) (defmethod right-open-p (set) (if (extended-realp set) NIL (missing-method 'right-open-p set))) (defmethod left-closed-p (set) (if (extended-realp set) T (missing-method 'left-closed-p set))) (defmethod right-closed-p (set) (if (extended-realp set) T (missing-method 'right-closed-p set))) (defmethod left-open-p ((set interval)) (case (closure-property-of set) (:open T) (:right-closed T) (:left-open T) (:closed-right T) (:open-left T) (:right T))) (defmethod right-open-p ((set interval)) (case (closure-property-of set) (:open T) (:left-closed T) (:right-open T) (:closed-left T) (:open-right T) (:left T))) (defmethod left-closed-p ((set interval)) (case (closure-property-of set) (:closed T) (:left-closed T) (:right-open T) (:closed-left T) (:open-right T) (:left T))) (defmethod right-closed-p ((set interval)) (case (closure-property-of set) (:closed T) (:right-closed T) (:left-open T) (:closed-right T) (:open-left T) (:right T))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Recalculate bounds (and set in most cases). ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod recalculate-bounds (thing) (unless (extended-realp thing) (missing-method 'recalculate-bounds thing))) (defmethod recalculate-bounds ((set borel-set)) (when (quail-yes-or-no-p "Sorry, don't even know how to try recalculating ~%~ the bounds of~% ~s. ~%Set to :unknown ?") (setf (infimum set) :unknown) (setf (supremum set) :unknown))) (defmethod recalculate-bounds ((self countable-union)) (declare (special *max-reasonable-number-of-iterations*)) (let ((new-inf +infinity) (new-sup -infinity)) (do ((index (count-start-of self) (next-index self index)) (counter 1 (+ counter 1)) (big-count *max-reasonable-number-of-iterations*) (current-set NIL)) ;; end-test ((or (count-endedp self index) (and (eq new-inf NaN) (eq new-sup NaN)))) ;; Now the action (setf current-set (element self index)) (if (> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ")) finally (return answer)))) (progn (if (not (quail-yes-or-no-p "Assume value of infimum is ~s ? " new-inf)) (setf new-inf NaN)) (if (not (quail-yes-or-no-p "Assume value of supremum is ~s ? " new-sup)) (setf new-sup NaN))))) (unless (eq new-inf NaN) (setf new-inf (min new-inf (infimum current-set)))) (unless (eq new-sup NaN) (setf new-sup (max new-sup (supremum current-set))))) (setf (infimum self) new-inf) (setf (supremum self) new-sup) (list new-inf new-sup))) (defmethod recalculate-bounds ((self explicit-finite-union)) (setf (infimum self) (apply #'min (mapcar #'infimum (contents-of self)))) (setf (supremum self) (apply #'max (mapcar #'supremum (contents-of self))))) (defmethod recalculate-bounds ((self explicit-finite-set)) (setf (infimum self) (apply #'min (contents-of self))) (setf (supremum self) (apply #'max (contents-of self)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; cardinality - Number of elements in a countable set. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod cardinality (set) (if (extended-realp set) 1 (missing-method 'cardinality set))) (defmethod cardinality ((set borel-set)) (if (empty-set-p set) ; cardinality is not 0 ; sensible in general NaN)) ; therefore given here ; as NaN, i.e. unknown. (defmethod cardinality ((set empty-set)) 0) (defmethod cardinality ((self countable-set)) (number-of-sets-in self)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Functions peculiar to intervals ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod separatep ((set1 interval) (set2 interval)) ;; separate and not touching (let ((min1 (infimum set1)) (max1 (supremum set1)) (min2 (infimum set2)) (max2 (supremum set2))) (or (> min1 max2) ; clear separation (> min2 max1) (and (= min1 max2) ; share end-points (and (left-open-p set1) ; as long as both (right-open-p set2))) ; are open (and (= max1 min2) ; i.e., they are not touching (and (right-open-p set1) (left-open-p set2)))))) (defun determine-interval-closure (left-closed? right-closed?) "Determines appropriate closure property for an interval having ~%~ given values of left-closed? (T or NIL) and right-closed? (T or NIL)." (cond ((and left-closed? right-closed?) :closed) (left-closed? :left) (right-closed? :right) (T :open)))
17,643
Common Lisp
.l
416
33.776442
89
0.431302
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
00929c87b995c18d579d45dd8c608f6e94f9e03df53d09e48dc089782051d340
33,409
[ -1 ]
33,410
utility.lsp
rwoldford_Quail/source/mathematics/borel-sets/utility.lsp
(in-package 'pcl) (defun missing-method (method &rest specializers) (let ((message-&-specializers (loop for s in specializers as i from 1 by 1 with message = "" collect (class-name (class-of s)) into name-list do (setf message (concatenate 'string message " ~s" (if (> i 5) (progn (setf i 1) " ~%")) )) finally (return (cons message name-list))))) (apply #'quail-error (concatenate 'string "The method ~S has not been specialized for the combination:~%" (car message-&-specializers)) method (cdr message-&-specializers)))) (defmacro := (accessor new-value &rest args) (if args (append `(setf , accessor , new-value) args) `(setf , accessor , new-value))) (defmacro flet* (&rest args) (cons 'labels args)) (defmacro mlet (&rest args) (cons 'macro-let args))
1,111
Common Lisp
.l
33
21.939394
76
0.492984
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
81458faf116fe9af9b8b9b699288a11631cae0c5b807a996b9a657edde9bdc5c
33,410
[ -1 ]
33,411
borel-test.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-test.lsp
;;;objects (setf bor (make-instance 'borel-set)) (setf empty (make-instance 'empty-set)) (setf foo2 (make-instance 'interval :infimum 34 :supremum 47 :closure-property :LEFT)) (setf comp (make-instance 'complement-set :set 8 :wrt foo2)) (setf comp3 (make-instance 'complement-set :set 9 :wrt bor)) (setf sete (make-instance 'predicate-set :infimum -infinity :supremum +infinity :closure-property :closed :defining-predicate #'(lambda (test-member) (extended-integerp test-member)))) (setf foo1 (make-instance 'interval :infimum 7 :supremum 23)) (setf foo (set-union foo1 foo2)) (setf bor2 (make-instance 'borel-set :closure-property :left-open)) (setf foo3 (make-instance 'interval :infimum 7 :supremum 20)) (setf foo4 (make-instance 'interval :infimum 22 :supremum 32)) (setf foo5 (make-instance 'interval :infimum 32 :supremum 35 :closure-property :closed)) (setf foo6 (make-instance 'interval :infimum 5 :supremum 32 :closure-property :right-closed)) (setf foo7 (make-instance 'interval :infimum 32 :supremum 35 :closure-property :left-open)) (setf foo12 (make-instance 'interval :infimum 32 :supremum 35)) (setf comp4 (make-instance 'complement-set :set foo2 :wrt 40)) (setf foo8 (make-instance 'interval :infimum 33 :supremum 34 :closure-property :closed)) (setf comp5 (make-instance 'complement-set :set foo8 :wrt foo7)) (setf foo9 (make-instance 'interval :infimum 1 :supremum 50)) (setf foo10 (make-instance 'interval :infimum 100 :supremum 102)) (setf foo (set-union foo3 foo4)) (setf foo11 (make-instance 'interval :infimum 7 :supremum 35)) (setf foo (set-union foo3 foo7)) (setf foo3 (copy-set foo3 :closure-property :left-closed)) (setf comp2 (set-complement 10 foo3)) (setf foo6 (make-instance 'interval :infimum 5 :supremum 15)) (setf comp3 (set-complement 10 foo6)) (setf (set-of comp2) 7) (setf bete (make-instance 'predicate-set :infimum 5 :supremum 17 :closure-property :open :defining-predicate #'(lambda (test-member) (and (< 5 test-member) (< test-member 17))))) (setf efs (make-instance 'explicit-finite-set :contents '(4 8 64 77 90))) (setf efs2 (make-instance 'explicit-finite-set :contents '(55 33 24 28))) (setf efs3 (make-instance 'explicit-finite-set :contents '(9 19 17 13))) (setf efs4 (make-instance 'explicit-finite-set :contents '(4 19 64 77 91))) (setf efs5 (make-instance 'explicit-finite-set :contents '(6 8 11 12 15))) (setf efs6 (make-instance 'explicit-finite-set :contents '(8 10))) ;;; extended reals (describe (set-union 3 4)) (describe (set-union 3 3)) (describe (set-intersection 4 4)) (describe (set-intersection 3 4)) (describe (set-complement 3 4)) (describe (set-complement 3 3)) (setf bor (make-instance 'borel-set)) (describe (set-union 3 bor)) ;;; faults in memberp (describe (set-intersection bor 3)) (describe (set-complement 3 bor)) (describe (set-complement bor 3)) (setf empty (make-instance 'empty-set)) (describe (set-union 3 empty)) (describe (set-intersection empty 3)) (describe (set-complement 3 empty)) (describe (set-complement empty 3)) (setf foo2 (make-instance 'interval :infimum 34 :supremum 47 :closure-property :LEFT)) (describe (set-union 3 foo2)) (describe (set-union foo2 40)) (describe (set-intersection 3 foo2)) (describe (set-intersection foo2 40)) (describe (set-complement 3 foo2)) (describe (set-complement foo2 40)) (describe (set-complement 40 foo2)) (describe (set-complement foo2 3)) (setf comp (make-instance 'complement-set :set 8 :wrt foo2)) (setf comp3 (make-instance 'complement-set :set 9 :wrt bor)) (describe (set-union 3 comp)) (describe (set-union comp 8)) (describe (set-union comp 3)) (describe (set-union 7 comp2)) (describe (set-intersection 3 comp)) (describe (set-intersection comp 8)) (describe (set-intersection comp 40)) (describe (set-complement 3 comp)) (describe (set-complement 8 comp)) (describe (set-complement 40 comp)) (describe (set-complement comp 3)) (describe (set-complement comp 40)) (describe (set-complement comp 8)) (setf sete (make-instance 'predicate-set :infimum -infinity :supremum +infinity :closure-property :closed :defining-predicate #'(lambda (test-member) (extended-integerp test-member)))) (describe (set-union 3 sete)) (describe (set-union sete 3.3)) (describe (set-intersection 3 sete)) (describe (set-intersection sete 3.3)) (describe (set-complement 3 sete)) (describe (set-complement 3.3 sete)) (describe (set-complement sete 3)) (describe (set-complement sete 3.3)) (setf foo1 (make-instance 'interval :infimum 7 :supremum 23)) (setf foo (set-union foo1 foo2)) (describe (set-union 3 foo)) (describe (set-intersection 3 foo)) (describe (set-intersection foo 8)) (describe (set-complement 3 foo)) (describe (set-complement 8 foo)) (describe (set-complement foo 3)) (describe (set-complement foo 8)) ;;; borel-sets (setf bor2 (make-instance 'borel-set :closure-property :left-open)) (describe (set-union bor bor2)) (describe (set-intersection bor bor2)) (describe (set-complement bor bor2)) (describe (set-union bor empty)) (describe (set-intersection bor empty)) (describe (set-complement bor empty)) (describe (set-complement empty bor)) (describe (set-union bor foo2)) (describe (set-intersection bor foo2)) (describe (set-complement bor foo2)) (describe (set-complement foo2 bor)) (describe (set-union bor comp)) (describe (set-intersection bor comp)) (describe (set-complement bor comp)) (describe (set-complement comp bor)) ;;; error - memberp and reals & borel (describe (set-union bor sete)) (describe (set-intersection bor sete)) (describe (set-complement bor sete)) (describe (set-complement sete bor)) (describe (set-union bor foo)) (describe (set-intersection bor foo)) (describe (set-complement bor foo)) (describe (set-complement foo bor)) ;;; empty-sets (describe (set-union empty empty)) (describe (set-intersection empty empty)) (describe (set-complement empty empty)) (describe (set-union empty foo2)) (describe (set-intersection empty foo2)) (describe (set-complement empty foo2)) (describe (set-complement foo2 empty)) (describe (set-union empty comp)) (describe (set-intersection empty comp)) (describe (set-complement empty comp)) (describe (set-complement comp empty)) (describe (set-union empty sete)) (describe (set-intersection empty sete)) (describe (set-complement empty sete)) (describe (set-complement sete empty)) (describe (set-union empty foo)) (describe (set-intersection empty foo)) (describe (set-complement empty foo)) (describe (set-complement foo empty)) ;;; intervals (setf foo3 (make-instance 'interval :infimum 7 :supremum 20)) (setf foo4 (make-instance 'interval :infimum 22 :supremum 32)) (setf foo5 (make-instance 'interval :infimum 32 :supremum 35 :closure-property :closed)) (setf foo6 (make-instance 'interval :infimum 5 :supremum 32 :closure-property :right-closed)) (setf foo7 (make-instance 'interval :infimum 32 :supremum 35 :closure-property :left-open)) (setf foo12 (make-instance 'interval :infimum 32 :supremum 35)) (describe (set-union foo4 foo2)) (describe (set-union foo4 foo4)) (describe (set-union foo1 foo3)) (describe (set-union foo4 foo5)) ;just touching (describe (set-intersection foo4 foo2)) (describe (set-intersection foo1 foo3)) (describe (set-intersection foo4 foo5)) (describe (set-intersection foo5 foo6)) (describe (set-complement foo4 foo2)) (describe (set-complement foo2 foo4)) (describe (set-complement foo5 foo7)) (describe (set-complement foo7 foo5)) (describe (set-complement foo3 foo6)) (describe (set-complement foo12 foo5)) (describe (set-union foo1 foo3)) (describe (set-intersection foo1 foo3)) (describe (set-complement foo1 foo3)) (describe (set-complement foo3 foo1)) (describe (set-union foo3 comp)) (describe (set-union comp foo2)) (setf comp4 (make-instance 'complement-set :set foo2 :wrt 40)) (describe (set-union comp4 foo2)) (describe (set-intersection foo3 comp)) (describe (set-intersection comp foo2)) (setf foo8 (make-instance 'interval :infimum 33 :supremum 34 :closure-property :closed)) (describe (set-intersection comp foo8)) (setf comp5 (make-instance 'complement-set :set foo8 :wrt foo7)) (describe (set-intersection comp4 foo7)) (describe (set-complement foo3 comp)) (describe (set-complement foo2 comp)) (describe (set-complement foo7 comp5)) (describe (set-complement foo8 comp5)) (describe (set-complement comp foo3)) (setf foo9 (make-instance 'interval :infimum 1 :supremum 50)) (describe (set-complement comp5 foo9)) (describe (set-complement comp5 foo5)) (describe (set-union foo3 sete)) (describe (set-intersection foo3 sete)) (describe (set-complement foo3 sete)) (describe (set-complement sete foo3)) (describe (set-union foo3 foo)) (describe (set-intersection foo3 foo)) (describe (set-intersection foo foo8)) (setf foo10 (make-instance 'interval :infimum 100 :supremum 102)) (describe (set-intersection foo foo10)) (describe (set-intersection foo9 foo)) (describe (set-complement foo3 foo)) (describe (set-complement foo1 foo)) (describe (set-complement foo9 foo)) (describe (set-complement foo10 foo)) (setf foo (set-union foo3 foo4)) (describe (set-complement foo6 foo)) (setf foo11 (make-instance 'interval :infimum 7 :supremum 35)) (setf foo (set-union foo3 foo7)) (describe (set-complement foo11 foo)) (setf foo3 (copy-set foo3 :closure-property :left-closed)) (describe (set-complement foo foo3)) (describe (set-complement foo foo10)) (describe (set-complement foo foo9)) ;;;complement-sets (setf comp2 (set-complement 10 foo3)) (describe (set-union comp2 comp)) (describe (set-intersection comp2 comp)) (describe (set-complement comp2 comp)) (describe (set-complement comp comp2)) (setf foo6 (make-instance 'interval :infimum 5 :supremum 15)) (setf comp3 (set-complement 10 foo6)) (describe (set-intersection comp2 comp3)) (describe (set-complement comp2 comp3)) (describe (set-complement comp3 comp2)) (setf (set-of comp2) 7) (describe (set-intersection comp2 comp3)) (describe (set-complement comp2 comp3)) (describe (set-complement comp3 comp2)) (describe (set-union comp2 sete)) (describe (set-intersection comp2 sete)) (describe (set-intersection sete comp2)) (describe (set-complement comp2 sete)) (describe (set-complement sete comp2)) (describe (set-union comp2 foo)) (describe (set-intersection comp2 foo)) (describe (set-intersection foo comp2)) (describe (set-complement comp2 foo)) (describe (set-complement foo comp2)) ;;; predicate-sets (setf bete (make-instance 'predicate-set :infimum 5 :supremum 17 :closure-property :open :defining-predicate #'(lambda (test-member) (and (< 5 test-member) (< test-member 17))))) (describe (set-union bete sete)) (describe (set-intersection bete sete)) (describe (set-complement bete sete)) (describe (set-complement sete bete)) (describe (set-union bete foo)) (describe (set-intersection bete foo)) (describe (set-complement bete foo)) (describe (set-complement foo bete)) ;;; explicit-finite-sets (setf efs (make-instance 'explicit-finite-set :contents '(4 8 64 77 90))) (setf efs2 (make-instance 'explicit-finite-set :contents '(55 33 24 28))) (setf efs3 (make-instance 'explicit-finite-set :contents '(9 19 17 13))) (setf efs4 (make-instance 'explicit-finite-set :contents '(4 19 64 77 91))) (setf efs5 (make-instance 'explicit-finite-set :contents '(6 8 11 12 15))) (setf efs6 (make-instance 'explicit-finite-set :contents '(8 10))) (setf efs7 (make-instance 'explicit-finite-set :contents '(11 8 10))) (insidep efs foo3) (insidep efs3 foo3) (insidep efs3 foo) (insidep foo3 efs) (insidep efs3 comp2) (describe (set-union efs 13)) (describe (set-union efs efs2)) (describe (set-union foo3 efs3)) (describe (set-union efs foo3)) (describe (set-union efs bor)) (describe (set-union efs empty)) (describe (op-set-union empty efs)) (describe (set-union efs comp)) (describe (set-union comp efs)) (describe (set-union efs sete)) (describe (set-union bete efs5)) (describe (set-union efs5 bete)) (describe (set-union sete efs)) (describe (set-union efs foo)) (describe (set-intersection 13 efs3)) (describe (set-intersection 14 efs)) (describe (set-intersection efs foo1)) (describe (set-intersection foo1 efs2)) (describe (set-intersection foo1 efs5)) (describe (set-intersection efs bor)) (describe (set-intersection efs empty)) (describe (set-intersection efs efs4)) (describe (set-intersection efs3 efs4)) (describe (set-intersection efs efs3)) (describe (set-intersection efs comp)) (describe (set-intersection efs comp2)) (describe (set-intersection comp2 efs6)) (describe (op-set-intersection bete efs5)) ;prefers pred to efs method (describe (op-set-intersection efs5 bete)) (describe (set-intersection efs foo)) (describe (set-intersection efs6 foo)) ;;again prefers other method (describe (set-intersection efs2 foo)) ;START HERE ON THE NEXT WORK DAY (describe (set-complement 64 efs4)) (describe (set-complement 78 efs4)) (describe (set-complement efs4 64)) (describe (set-complement efs4 77)) (describe (setf efs6 (set-complement 8 efs6))) (describe (set-complement bor efs)) (describe (set-complement efs bor)) (describe (op-set-complement efs empty)) (describe (set-complement empty efs)) (describe (set-complement efs foo1)) (describe (set-complement efs3 foo1)) (describe (set-complement efs2 foo1)) (describe (set-complement foo1 efs)) (describe (set-complement foo1 efs3)) (describe (set-complement foo2 efs2)) (describe (set-complement efs efs2)) (describe (set-complement efs3 efs4)) (describe (set-complement efs efs)) (describe (op-set-complement efs6 efs7)) (describe (set-complement comp efs)) (describe (set-complement efs comp)) (describe (set-complement efs sete)) ;;; results in complement-set ;;; would it be better as a ;;; predicate-set? (describe (set-complement sete efs)) (describe (set-complement efs bor)) (describe (set-complement bor efs)) (describe (op-set-complement efs foo)) (describe (set-complement foo efs)) (describe (copy-set foo1)) (describe (copy-set bor :infimum 5)) (describe (copy-set foo :contents (list (elt (contents-of foo) 0) empty))) (describe (copy-set bete :infimum 2 :supremum 18))
14,918
Common Lisp
.l
352
38.642045
94
0.718793
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
2aa3fc5a31519b34f0ceb33539a9fc5b23df82ea920755cd465a743008a73760
33,411
[ -1 ]
33,412
borel-sets2.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-sets2.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; borel-sets2.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990, 1992 ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; BOREL SETS 2 ;;; ;;; ;;; Classes: ;;; ;;; Countable-Union ;;; Countable-Intersection ;;; Explicit-Finite-Union ;;; Explicit-Finite-Intersection ;;; Countable-Set ;;; Explicit-Finite-Set ;;; ;;; Global Constants: ;;; ;;; *max-reasonable-number-of-iterations* ;;; ;;; Global Variables: ;;; ;;; *default-union-sort* ;;; *default-set-less-than-predicate* ;;; ;;;---------------------------------------------------------------------------- ;;; ;;; Countable Unions of sets ;;; ;;;---------------------------------------------------------------------------- (defclass countable-union (countable-collection predicate-set) ( (defining-predicate :initarg :defining-predicate :type function :initform #'(lambda (union member) (declare (special *max-reasonable-number-of-iterations*)) (do ((index (count-start-of union) (next-index union index)) (counter 1 (+ counter 1)) (big-count *max-reasonable-number-of-iterations*)) ;; end-test ((count-endedp union index)) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume value ~%~ ~s ~%~ is in the set? ~%~ ~s ? " member union) (return T)) ((quail-yes-or-no-p "Assume value ~%~ ~s ~%~ is *NOT* in the set? ~%~ ~s ? " member union) (return NIL)) (T (quail-error "Can't tell whether the value ~%~ ~s ~%~ is in the set ~%~ ~s ~%~ or not!" member union))))) ((op-memberp member (element union index)) (return T))))) ) ) (:documentation "The set representing the union of a countable (possibly :+infinite) number ~%~ of sets. ~%~ Each set in the union is indexed over a contiguous subset of ~%~ the extended integers: ~%~ [-infinity ,...,-1,0, 1, ... +infinity]~%~ and is accessed by applying the element function to the union and ~%~ the desired index.")) (defmethod combine-collections ((c2 borel-set) (c1 countable-collection)) (combine-collections c1 c2)) (defmethod combine-collections ((c1 countable-collection) (c2 borel-set)) (let* ((c1-cfun (contains-set-p-function-of c1)) (c1-ifun (element-function-of c1)) (ifp-1 (index-from-position-function-of c1)) (new-begin 0) (new-end (number-of-sets-in c1))) (make-instance (type-of c1) :from new-begin :to new-end :contains-set-p-function (function (lambda (collection set) (or (funcall c1-cfun collection set) (same-set-p c2 set)))) :disjoint? (cond ((not-disjoint-collection-p c1) NIL) ((and (disjoint-collection-p c1) (disjoint-sets-p c1 c2)) T) (T :unknown)) :element-function (function (lambda (collection index) (cond ((zerop index) ; borel-set first c2) (T (funcall c1-ifun ; All the rest later collection (funcall ifp-1 (- index 1)))) )))))) ;;;---------------------------------------------------------------------------- ;;; ;;; Countable Intersections of sets ;;; ;;;---------------------------------------------------------------------------- (defclass countable-intersection (countable-collection predicate-set) ( (defining-predicate :initform #'(lambda (intersection member) (declare (special *max-reasonable-number-of-iterations*)) (do ((index (count-start-of intersection) (next-index intersection index)) (counter 1 (+ counter 1)) (big-count *max-reasonable-number-of-iterations*) (current-set NIL)) ;; end-test ((count-endedp intersection index)) ;; Now the action (setf current-set (element intersection index)) (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume value ~%~ ~s ~%~ is in the set? ~%~ ~s ? " member intersection) (return T)) ((quail-yes-or-no-p "Assume value ~%~ ~s ~%~ is *NOT* in the set? ~%~ ~s ? " member intersection) (return NIL)) (T (quail-error "Can't tell whether the value ~%~ ~s ~%~ is in the set ~%~ ~s ~%~ or not!" member intersection))))) ((not (memberp member current-set)) (return NIL))))) )) (:documentation "The set representing the intersection of a countable~%~ (possibly :+infinite) number of sets. ~%~ Each set in the intersection is indexed over a contiguous subset~%~ of the extended integers: ~%~ [-infinity ,...,-1,0, 1, ... +infinity]~%~ and is accessed by applying the element function to the intersection and ~%~ the desired index.")) (defmethod combine-collections ((c2 borel-set) (c1 countable-intersection)) (combine-collections c1 c2)) (defmethod combine-collections ((c1 countable-intersection) (c2 borel-set)) (let* ((c1-cfun (contains-set-p-function-of c1)) (c1-ifun (element-function-of c1)) (ifp-1 (index-from-position-function-of c1)) (new-begin 0) (new-end (number-of-sets-in c1))) (make-instance (type-of c1) :from new-begin :to new-end :contains-set-p-function (function ;;is 'and' the only difference from the countable union (lambda (collection set) (and (funcall c1-cfun collection set) (same-set-p c2 set)))) :disjoint? (if (not-disjoint-collection-p c1) NIL T) :element-function (function (lambda (collection index) (cond ((zerop index) ; borel-set first c2) (T (funcall c1-ifun ; All the rest later collection (funcall ifp-1 (- index 1)))) )))))) ;;;---------------------------------------------------------------------------- ;;; ;;; Explicitly recorded finite unions of sets ;;; ;;;---------------------------------------------------------------------------- (defclass explicit-finite-union (explicit-finite-collection countable-union) ( (contents :documentation "A common lisp sequence where the entire collection of sets in the union ~%~ are stored.") ) (:documentation "A finite union of sets (with sets stored explicitly, as opposed to ~%~ implicitly within a countable-union.")) (defmethod initialize-instance :after ((self explicit-finite-union) &key) (declare (special *default-union-sort*)) (if (and (eq NaN (infimum self)) (eq NaN (supremum self))) (recalculate-bounds self)) (if (not (sorted-collection-p self)) (collection-sort self *default-union-sort*)) (if (eq (closure-property-of self) :unknown) (determine-closure self)) ) (defmethod disjoint-collection-p ((self explicit-finite-union)) (let ((result (disjointness-of self))) (if (eq result :unknown) (setf (disjointness-of self) (apply #'disjoint-sets-p (contents-of self))) result))) (defmethod not-disjoint-collection-p ((self explicit-finite-union)) (not (disjoint-collection-p self))) ;;works b/k if unknown gives an error ;;;---------------------------------------------------------------------------- ;;; ;;; Explicitly recorded finite intersection of sets ;;; ;;;---------------------------------------------------------------------------- (defclass explicit-finite-intersection (explicit-finite-collection countable-intersection) ((contents :documentation "A common lisp sequence where the entire collection of sets in the intersection ~%~ are stored.") ) (:documentation "A finite intersection of sets (with sets stored explicitly, as opposed to ~%~ implicitly within a countable-intersection.")) (defmethod initialize-instance :after ((self explicit-finite-intersection) &key) (declare (special *default-set-less-than-predicate*)) (if (not (sorted-collection-p self)) (collection-sort self *default-set-less-than-predicate*)) (if (eq (closure-property-of self) :unknown) (determine-closure self)) ;try to determine closure here ) ;;;---------------------------------------------------------------------------------- ;;; ;;; COUNTABLE-SET ;;; ;;; Has the property that its contents extended-real valued and are denumerable. ;;; Hence the new methods: element, cardinality ;;; ;;;---------------------------------------------------------------------------------- (defclass countable-set (countable-union) ((begin-index :initarg :begin-index) (end-index :initarg :end-index) (contains-set-p-function :initform #'(lambda (collection set) (declare (special *reasonable-number-of-iterations*)) (if (extended-realp set) (do ((index (count-start-of collection) (next-index collection index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*)) ;; end-test ((count-endedp collection index)) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is in the collection ~%~ ~s ? " set collection) (return T)) ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is *NOT* in the collection ~%~ ~s ? " set collection) (return NIL)) (T (quail-error "Can't tell whether the set ~%~ ~s ~%~ is in the collection ~%~ ~s ~%~ or not!" set collection))))) ((eq (element collection index) set) (return T)))) NIL)) :documentation "A function of two arguments which, when applied to the collection and any set, ~%~ tests whether the specified set is in the collection.~%~ Default function compares the given set to each set ~%~ in the collection (ad nauseum)")) (:documentation "A countable union whose elements are extended-reals.")) #| (defgeneric index-of (countable-set element) (:documentation "Returns index of the given element in the (countable) set.") ) |# ;;;---------------------------------------------------------------------------------- ;;; ;;; explicit-finite-set ;;; ;;; cardinality is never +infinity ;;; Method for element must be specialized for any subclass. ;;; ;;;---------------------------------------------------------------------------------- (defclass explicit-finite-set (explicit-finite-union countable-set) ((begin-index :initarg :begin-index) (end-index :initarg :end-index) (closure :initform :closed) ) (:documentation "A finite set whose elements are stored explicitly as a collection.")) (defmethod initialize-instance :after ((self explicit-finite-set) &key) (if (not (eq (closure-property-of self) :closed)) (setf (closure-property-of self) :closed))) (defmethod (setf closure-property-of) (new-value (self explicit-finite-set)) (if (not (eq new-value :closed)) (quail-error "Sorry. All finite sets are closed. ~%~ ~s is not an allowed value for an explicit-finite-set." new-value) (setf (slot-value self 'closure-property) :closed))) (defmethod add-sets :before ((collection explicit-finite-set) &rest sets) (labels ((check (x &rest other-x) (if other-x (and (extended-realp x) (apply #'check other-x)) (extended-realp x)))) (if (and sets (not (apply #'check sets))) (quail-error "An attempt was made to add a non-extended real ~s ~%~ to an explicit-finite-set (~s)." sets collection))))
16,024
Common Lisp
.l
401
28.167082
97
0.465608
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
77e341fc34c05a1ef7d6f5095fa1dfd52fd0bdfa6cda24f76158746230f138c9
33,412
[ -1 ]
33,413
copy-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/copy-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; copy-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; ;;; Method | Argument type | ;;; |______________________| ;;; Name | Argument | ;;; ___________________________|______________________| ;;; | | ;;; | | ;;; op-copy-args | borel-set | ;;; | complement-set | ;;; | countable-set | ;;; | empty-set | ;;; | explicit-finite-inter| ;;; | explicit-finite-set | ;;; | explicit-finite-union| ;;; | interval | ;;; | predicate-set | ;;; | (extended-realp) | ;;; | | ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; copy-set - uses op-copy-args to copy a borel-set or a set-collection ;;; op-copy-args - copies arguments to a list ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun copy-set (set &rest new-args) (if (extended-realp set) set (if new-args (apply #'make-instance (type-of set) (concatenate 'list new-args (op-copy-args set))) (apply #'make-instance (type-of set) (op-copy-args set))))) (defgeneric op-copy-args (set) (:documentation "Copies arguments.")) (defmethod op-copy-args :around ((set borel-set)) (concatenate 'list `(:infimum ,(infimum set) :supremum ,(supremum set) :closure-property ,(closure-property-of set)) (call-next-method set))) (defmethod op-copy-args :around ((set set-collection)) (concatenate 'list `(:contains-set-p-function ,(contains-set-p-function-of set) :disjoint? ,(disjointness-of set)) (call-next-method set))) (defmethod op-copy-args :around ((set predicate-set)) (concatenate 'list `(:defining-predicate ,(defining-predicate-of set)) (call-next-method set))) (defmethod op-copy-args :around ((set countable-collection)) (concatenate 'list `(:contains-set-p-function ,(contains-set-p-function-of set) :disjoint? ,(disjointness-of set) :from ,(begin-index-of set) :to ,(end-index-of set) :element-function ,(element-function-of set) :index-function ,(index-function-of set)) (call-next-method set))) (defmethod op-copy-args :around ((set explicit-finite-collection)) (concatenate 'list `(:contents ,(loop for item in (contents-of set) collect (copy-set item)) :set-less-than-predicate ,(set-less-than-predicate-of set)) (call-next-method set))) (defmethod op-copy-args ((set complement-set)) `(:set ,(copy-set (set-of set)) :wrt ,(copy-set (complement-wrt set)))) ;;; dummy primary methods (defmethod op-copy-args ((set set-collection)) (declare (ignore set))) (defmethod op-copy-args ((set borel-set)) (declare (ignore set))) (defmethod op-copy-args (set) (if (extended-realp set) (list set) (quail-error "The set ~s is not a borel set." set)))
4,314
Common Lisp
.l
86
40.127907
102
0.39386
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
481b38a06be6a8be0fbef09e28973aabc1feb18d1a55f7b547c6ded0c981f5ca
33,413
[ -1 ]
33,414
insidep-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/insidep-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; insidep-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990 ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; INSIDE PREDICATE METHODS ;;; ;;; Method | Argument type | ;;; |_____________________________________________| ;;; Name | Argument 1 | Argument 2 | ;;; ___________________________|______________________|______________________| ;;; | | | ;;; | | | ;;; op-insidep | borel-set | borel-set | ;;; | borel-set | complement-set | ;;; | borel-set | empty-set | ;;; | borel-set | explicit-finite-inter| ;;; | borel-set | explicit-finite-union| ;;; | borel-set | set-collection | ;;; | borel-set | (extended-realp) | ;;; | complement-set | borel-set | ;;; | countable-set | countable-set | ;;; | empty-set | borel-set | ;;; | empty-set | empty-set | ;;; |explicit-finite-inter | borel-set | ;;; |explicit-finite-inter |explicit-finite-inter | ;;; | explicit-finite-set | borel-set | ;;; | explicit-finite-set | explicit-finite-set | ;;; | explicit-finite-set | interval | ;;; | explicit-finite-union| borel-set | ;;; | explicit-finite-union| explicit-finite-union| ;;; | interval | interval | ;;; | interval | (extended-realp) | ;;; | (extended-realp) | borel-set | ;;; | (extended-realp) | (extended-realp) | ;;; | | | ;;; op-containsp | same as above | same as above | ;;; | | | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-insidep - Subset binary operator ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-insidep (set1 set2) (if (and (extended-realp set1) (extended-realp set2)) (= set1 set2) (missing-method 'op-insidep set1 set2))) (defmethod op-insidep (set1 (set2 borel-set)) (if (extended-realp set1) (memberp set1 set2) (missing-method 'op-insidep set1 set2))) (defmethod op-insidep ((set1 borel-set) set2) (if (extended-realp set2) NIL (missing-method 'op-insidep set1 set2))) (defmethod op-insidep :around ((set1 interval) set2) (if (= (infimum set1) (supremum set1)) ;singleton, would have to be closed (op-insidep (infimum set1) set2) (call-next-method set1 set2))) (defmethod op-insidep ((set1 borel-set) (set2 borel-set)) (unless (eq set1 set2) (quail-error "Not enough information to determine whether ~s ~%~ is inside ~s." set1 set2))) (defmethod op-insidep ((set1 empty-set) (set2 borel-set)) set2) (defmethod op-insidep ((set1 borel-set) (set2 empty-set)) NIL) (defmethod op-insidep ((set1 empty-set) (set2 empty-set)) T) (defmethod op-insidep :around ((set1 complement-set) (set2 borel-set)) (cond ((empty-set-p (set-of set1)) (op-insidep (complement-wrt set1) set2)) ((empty-set-p (complement-wrt set1)) T) (T (call-next-method set1 set2)))) (defmethod op-insidep ((set1 complement-set) (set2 borel-set)) (or (op-insidep (complement-wrt set1) set2) (let ((set (op-set-complement (op-set-intersection (complement-wrt set1) set2) (complement-wrt set1)))) (op-insidep set (set-of set1))))) (defmethod op-insidep :around ((set1 borel-set) (set2 complement-set)) (cond ((empty-set-p (set-of set2)) (op-insidep set1 (complement-wrt set2))) ((empty-set-p (complement-wrt set2)) NIL) (T (call-next-method set1 set2)))) (defmethod op-insidep ((set1 borel-set) (set2 complement-set)) (and (op-insidep set1 (complement-wrt set2)) (op-disjoint-sets-p set1 (set-of set2)))) (defmethod op-insidep ((set1 interval) (set2 interval)) (let* ((min1 (infimum set1)) (max1 (supremum set1)) (min-in? (memberp min1 set2)) (max-in? (memberp max1 set2))) (or (and min-in? max-in?) ; both end-points are in (and min-in? ; left-side is in, (= max1 (supremum set2)) ; equal & open right-sides (right-open-p set1) (right-open-p set2)) (and max-in? ; right-side is in, (= min1 (infimum set2)) ; equal & open left-sides (left-open-p set1) (left-open-p set2)) (and (= min1 (infimum set2)) ;equal bounds and set1 open (= max1 (supremum set2)) (open-set-p set1))))) ;;; b/k EFS are always ordered (defmethod op-insidep ((set1 explicit-finite-set) (set2 interval)) (and (< (infimum set2) (infimum set1)) (> (supremum set2) (supremum set1)))) (defmethod op-insidep ((set1 explicit-finite-set) (set2 explicit-finite-set)) (if (or (> (infimum set2) (infimum set1)) (> (supremum set1) (supremum set2))) ;; then answer is false. NIL ;; else do more work. (if (and (listp (contents-of set1)) (listp (contents-of set2))) ;; if both are lists then we can use subsetp (subsetp (contents-of set1) (contents-of set2)) ;; else check out the cardinality of the intersection. (= (cardinality (op-set-intersection set1 set2)) (cardinality set1)))) ) (defmethod op-insidep ((set1 explicit-finite-set) (set2 borel-set)) (let ((result T)) (loop for item in (contents-of set1) do (when (not (memberp item set2)) (progn (setf result NIL) (return)))) result)) (defmethod op-insidep ((set1 countable-set) (set2 countable-set)) (declare (special *big-set-count*)) (if (or (> (infimum set2) (infimum set1)) (> (supremum set1) (supremum set2))) ;; then answer is false. NIL ;; else check out the cardinality of the intersection. (= (cardinality (op-set-intersection set1 set2)) (cardinality set1)))) (defmethod op-insidep ((set1 explicit-finite-union) (set2 explicit-finite-union)) (let ((result T)) (loop for item in (contents-of set1) do (unless (op-insidep item set2) (setf result NIL))) result)) (defmethod op-insidep ((set1 borel-set) (set2 explicit-finite-union)) (loop for item in (contents-of set2) do (when (op-insidep set1 item) (return T)))) (defmethod op-insidep ((set1 explicit-finite-union) (set2 borel-set)) (let ((result T)) (loop for item in (contents-of set1) do (unless (op-insidep item set2) (setf result NIL))) result)) (defmethod op-insidep ((set1 borel-set) (set2 explicit-finite-intersection)) (let ((result T)) (loop for item in (contents-of set2) do (unless (op-insidep set1 item) (quail-error "Not enough information to determine whether ~s ~%~ is inside ~s." set1 set2))) result)) (defmethod op-insidep ((set1 explicit-finite-intersection) (set2 explicit-finite-intersection)) (let ((result T)) (loop for item in (contents-of set2) do (unless (op-insidep set1 item) (quail-error "Not enough information to determine whether ~s ~%~ is inside ~s." set1 set2))) result)) (defmethod op-insidep ((set1 explicit-finite-intersection) (set2 borel-set)) (let ((result T)) (loop for item in (contents-of set1) do (unless (op-insidep item set2) (quail-error "Not enough information to determine whether ~s ~%~ is inside ~s." set1 set2))) result)) (defmethod op-insidep ((set1 borel-set) (set2 countable-collection)) (contains-set-p set2 set1)) (defmethod op-insidep ((set1 countable-collection) (set2 borel-set)) (declare (special *reasonable-number-of-iterations*)) (do ((index (count-start-of set1) (next-index set1 index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*) (result T)) ;; end-test ((count-endedp set1 index) result) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume collection ~%~ ~s ~%~ is in the set ~%~ ~s ? " set1 set2) (return T)) ((quail-yes-or-no-p "Assume collection ~%~ ~s ~%~ is *NOT* in the set ~%~ ~s ? " set1 set2) (progn (setf result NIL) (return NIL))) (T (quail-error "Can't tell whether the collection ~%~ ~s ~%~ is in the set ~%~ ~s ~%~ or not!" set1 set2))))) ((not (op-insidep (element set1 index) set2)) (progn (setf result NIL) (return NIL)))))) (defmethod op-insidep (set1 (set2 countable-set)) (if (extended-realp set1) (contains-set-p set2 set1) NIL)) (defmethod op-insidep ((set1 countable-set) set2) (if (extended-realp set2) (and (= (number-of-sets-in set1) 1) (= set2 (element set1 (count-start-of set1)))) NIL)) (defmethod op-insidep ((set1 borel-set) (set2 countable-set)) (if (extended-realp set1) (contains-set-p set2 set1) NIL)) (defmethod op-inside :around ((set1 countable-intersection) (set2 borel-set)) (if (call-next-method set1 set2) set2 (quail-error "Can't tell whether the collection ~%~ ~s is in the set ~s ~%~ or not!" set1 set2))) (defmethod op-insidep ((set1 borel-set) (set2 countable-intersection)) (declare (special *reasonable-number-of-iterations*)) (do ((index (count-start-of set2) (next-index set2 index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*) (result T)) ;; end-test ((count-endedp set2 index) result) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is in the collection ~%~ ~s ? " set1 set2) (return T)) ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is *NOT* in the collection ~%~ ~s ? " set1 set2) (progn (setf result NIL) (return NIL))) (T (quail-error "Can't tell whether the set ~%~ ~s ~%~ is in the collection ~%~ ~s ~%~ or not!" set1 set2))))) ((not (op-insidep set1 (element set2 index))) (progn (setf result NIL) (return NIL)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-containsp - Set containment (reverse of subset binary operator) ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-containsp (set1 set2) (op-insidep set2 set1)) #| This needs to be fixed. (defmethod op-insidep ((set1 countably-infinite-increasing-set) (set2 countably-infinite-increasing-set)) (declare (special *big-set-count*)) (let ((inf1 (infimum set1)) (inf2 (infimum set2)) (sup1 (supremum set1)) (sup2 (supremum set2))) (if (or (> sup1 sup2) (< inf1 inf2)) ;; then answer is false. NIL ;; else more work needs to be done. (loop with x-i = (element set1 0) and big-count = *big-set-count* for i from 0 by 1 as j from (index-of set2 x-i) by 1 do (cond ((not j) (return NIL)) ((or (>= i big-count) (>= j big-count)) (if (quail-y-or-n-p "Have found that ~A elements of the first set (~S)~%~ are contained in the second set (~S).~%~ And have checked ~A elements of the second set.~%~ Assume first set is inside the second? Otherwise I'll keep checking." i set1 set2 j) (return T) (setf big-count (+ big-count (/ *big-set-count* 2))))) (if (> (setf answer (and answer (memberp (element set1 i) set2))) (when (null answer) (return))) |#
15,571
Common Lisp
.l
341
35.390029
96
0.464508
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
47feb3e173d7d79c39d7006859de069c6a8a4831426af89f8706b73a3706539f
33,414
[ -1 ]
33,415
simplify-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/simplify-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; simplify-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; ;;; ;;; Authors: ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; SIMPLIFY METHODS ;;; ;;; Method | Argument type | ;;; |_______________________ ;;; Name | Argument | ;;; ___________________________|_______________________| ;;; | | ;;; | | ;;; simplify-object | explicit-finite-union | ;;; | complement-set | ;;; | | (in-package :quail) (defun touch-p (set1 set2) (let ((min1 (infimum set1)) (max1 (supremum set1)) (min2 (infimum set2)) (max2 (supremum set2))) (or (and (= min1 max2) (or (and (right-open-p set2) (left-closed-p set1)) (and (right-closed-p set2) (left-open-p set1)))) (and (= min2 max1) (or (and (right-open-p set1) (left-closed-p set2)) (and (right-closed-p set1) (left-open-p set2))))))) (defgeneric simplify-object (set) (:documentation "Reduce set-object to its simplest form.")) (defmethod simplify-object ((set explicit-finite-union)) (labels ((simplify-now (set1 &rest other-sets) (let ((set2 (first other-sets)) (rest-of-them (rest other-sets)) temp collection) (cond (rest-of-them (if (op-disjoint-sets-p set1 set2) (setf collection (concatenate 'list collection (list set1) (apply #'simplify-now (concatenate 'list (list set2) rest-of-them)))) (progn (setf temp (op-set-union set1 set2)) (if (and (typep temp 'explicit-finite-union) (not (typep temp 'explicit-finite-set))) (setf collection (concatenate 'list collection (list (first (contents-of temp))) (apply #'simplify-now (concatenate 'list (rest (contents-of temp)) rest-of-them)))) (setf collection (concatenate 'list collection (apply #'simplify-now (concatenate 'list (list temp) rest-of-them)))))))) (set2 (if (op-disjoint-sets-p set1 set2) (setf collection (concatenate 'list collection (list set1 set2))) (progn (setf temp (op-set-union set1 set2)) (if (and (typep temp 'explicit-finite-union) (not (typep temp 'explicit-finite-set))) (setf collection (concatenate 'list collection (list (first (contents-of temp))) (apply #'simplify-now (rest (contents-of temp))))) (setf collection (concatenate 'list collection (list temp))))))) (set1 (setf collection (concatenate 'list collection (list set1)))))))) (if (not (sorted-collection-p set)) (collection-sort set *default-union-sort*)) (let ((contents (apply #'simplify-now (contents-of set))) new-set) (if (= (length contents) 1) (setf new-set (elt contents 0)) (progn (setf new-set (make-instance 'explicit-finite-union :contents contents)) (disjoint-collection-p new-set))) new-set))) (defmethod simplify-object ((self explicit-finite-intersection)) (apply #'set-intersection (contents-of self))) #| ;;; should this be coerce instead?;; only for singletons, borel-sets, or explicit-finite-sets (defmethod simplify-object ((self complement-set)) (cond ((op-disjoint-sets-p (set-of self) (complement-wrt self)) (complement-wrt self)) ((and (extended-realp (set-of self)) (typep 'interval (complement-wrt self))) self))) ;;not finished |# (defmethod simplify-object ((self interval)) (if (and (= (infimum self) (supremum self)) (eq (closure-property-of self) :closed)) (infimum self) self))
5,146
Common Lisp
.l
100
35.71
133
0.415227
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
6533cfedb505cd7a100f359c58c69c75148b624776724ec7e46e832513e6c547
33,415
[ -1 ]
33,416
borel-test3.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-test3.lsp
;;;countable-unions (setf cu1 (make-instance 'countable-union :from 1 :to +infinity :element-function #'(lambda (collection index) (declare (ignore collection)) (make-instance 'interval :closure-property :closed :infimum index :supremum (+ index 5))) )) (setf bug (make-instance 'interval :infimum 7 :supremum 12 :closure-property :open)) (setf bug (make-instance 'interval :infimum 7 :supremum 12 :closure-property :closed)) (contains-set-p cu1 bug) (disjoint-sets-p bug cu1) (memberp 100 cu1) (memberp -3 cu1) (insidep bug cu1) (insidep cu1 bug) (describe (set-union 10 cu1)) (describe (set-union cu1 -10)) (describe (set-union bor cu1)) (describe (set-union cu1 bor)) (describe (op-set-union empty cu1)) (describe (set-union cu1 empty)) (describe (op-set-union cu1 foo1)) (describe (op-set-union foo1 cu1)) (describe (op-set-union comp cu1)) (describe (op-set-union bete cu1)) (describe (op-set-union cu1 bete)) (describe (op-set-union cu1 cu1)) (setf cu2 (set-union cu1 bug)) ;;should it do this? (i) (same-set-p cu1 cu2) (describe (set-union cu1 cu2)) (describe (set-union cu1 foo)) (describe (set-union foo cu1)) (setf foo13 (make-instance 'interval :infimum 5 :supremum 10 :closure-property :closed)) (setf foo14 (make-instance 'interval :infimum 20 :supremum 25 :closure-property :closed)) (setf bar (set-union foo13 foo14)) (describe (setf bear (op-set-union bar cu1))) (describe (setf racoon (set-union cu1 bar))) (describe (set-union efs cu1)) (describe (set-union cu1 efs)) (describe (op-set-intersection 10 cu1)) (describe (op-set-intersection cu1 -10)) (describe (op-set-intersection bor cu1)) (describe (op-set-intersection cu1 bor)) (describe (op-set-intersection empty cu1)) (describe (op-set-intersection cu1 empty)) (describe (op-set-intersection cu1 bug)) (describe (op-set-intersection bug cu1)) (describe (op-set-intersection comp cu1)) (describe (op-set-intersection cu1 comp)) (describe (op-set-intersection bete cu1)) (describe (op-set-intersection cu1 bete)) (describe (op-set-intersection cu1 cu1)) (describe (op-set-intersection cu1 foo)) (describe (op-set-intersection foo cu1)) (describe (op-set-intersection efs cu1)) (describe (op-set-intersection cu1 efs)) (describe (op-set-complement 10 cu1)) (describe (op-set-complement -10 cu1)) (describe (op-set-complement cu1 -10)) (describe (op-set-complement bor cu1)) (describe (op-set-complement cu1 bor)) (describe (op-set-complement empty cu1)) (describe (op-set-complement cu1 empty)) (describe (op-set-complement cu1 bug)) (describe (op-set-complement bug cu1)) (describe (op-set-complement comp cu1)) (describe (op-set-complement cu1 comp)) (describe (op-set-complement bete cu1)) (describe (op-set-complement cu1 bete)) (describe (op-set-complement cu1 cu1)) (describe (op-set-complement cu1 foo)) (describe (op-set-complement foo cu1)) (describe (op-set-complement efs cu1)) (describe (op-set-complement cu1 efs)) ;;;countable-intersections (setf ci1 (make-instance 'countable-intersection :from 1 :to +infinity :element-function #'(lambda (collection index) (declare (ignore collection)) (make-instance 'interval :closure-property :closed :infimum index :supremum (+ index 5))) )) (contains-set-p ci1 bug) (disjoint-sets-p bug ci1) (memberp 100 ci1) (memberp -3 ci1) (insidep bug ci1) (insidep ci1 bug) (setf ci2 (set-union ci1 bug)) (same-set-p ci1 ci2) ;is that an appropriate error? (setf comp (set-complement bug ci1)) ;predicate-sets? (setf comp2 (set-complement ci1 bug)) (describe (set-intersection bug ci1)) (describe (set-union 10 ci1)) (describe (set-union ci1 -10)) (describe (set-union bor ci1)) (describe (set-union ci1 bor)) (describe (op-set-union empty ci1)) (describe (set-union ci1 empty)) (describe (op-set-union ci1 foo1)) (describe (op-set-union foo1 ci1)) (describe (op-set-union comp ci1)) (describe (op-set-union ci1 comp)) (describe (op-set-union bete ci1)) (describe (op-set-union ci1 cu1)) (describe (op-set-union cu1 ci1)) (describe (op-set-union ci1 bete)) (describe (op-set-union ci1 ci1)) (describe (set-union ci1 cu2)) (describe (set-union ci1 foo)) (describe (set-union foo ci1)) (describe (set-union efs ci1)) (describe (set-union ci1 efs)) (describe (op-set-intersection 10 ci1)) (describe (op-set-intersection ci1 10000)) (describe (op-set-intersection bor ci1)) (describe (op-set-intersection ci1 bor)) (describe (op-set-intersection empty ci1)) (describe (op-set-intersection ci1 empty)) (describe (op-set-intersection ci1 bug)) (describe (op-set-intersection bug ci1)) (describe (op-set-intersection comp ci1)) (describe (op-set-intersection ci1 comp)) (describe (op-set-intersection bete ci1)) (describe (op-set-intersection ci1 bete)) (describe (op-set-intersection ci1 ci1)) (describe (op-set-intersection cu1 ci1)) (describe (op-set-intersection ci1 cu1)) (describe (op-set-intersection ci1 foo)) (describe (op-set-intersection foo ci1)) (describe (op-set-intersection efs ci1)) (describe (op-set-intersection ci1 efs)) (describe (op-set-complement 10 ci1)) (describe (op-set-complement -10 ci1)) (describe (op-set-complement ci1 -10)) (describe (op-set-complement ci1 10)) (describe (op-set-complement bor ci1)) (describe (op-set-complement ci1 bor)) (describe (op-set-complement empty ci1)) (describe (op-set-complement ci1 empty)) (describe (op-set-complement ci1 bug)) (describe (op-set-complement bug ci1)) (describe (op-set-complement comp ci1)) (describe (op-set-complement ci1 comp)) (describe (op-set-complement bete ci1)) (describe (op-set-complement ci1 bete)) (describe (op-set-complement ci1 ci1)) (describe (op-set-complement ci1 foo)) (describe (op-set-complement foo ci1)) (describe (op-set-complement efs ci1)) (describe (op-set-complement ci1 efs)) (describe (op-set-complement foo ci1)) (describe (op-set-complement ci1 foo)) ;;;countable-sets (setf natural-numbers (make-instance 'countable-set :infimum 0 :supremum +infinity :begin-index 0 :end-index +infinity :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'(lambda (set test-member) (declare (ignore set)) (and (extended-integerp test-member) (> test-member 0))))) (contains-set-p natural-numbers -41) (contains-set-p natural-numbers 4) (contains-set-p natural-numbers 304) (disjoint-sets-p 6 natural-numbers) (disjoint-sets-p -41 natural-numbers) (op-memberp 4 natural-numbers) (memberp -3 natural-numbers) (insidep bug natural-numbers) (insidep 5 natural-numbers) (insidep -34 natural-numbers) (insidep natural-numbers bug) (setf cs2 (set-union natural-numbers 2)) (same-set-p natural-numbers cs2) (setf comp (set-complement bug natural-numbers)) ;predicate-sets? (setf comp2 (set-complement natural-numbers bug)) (setf efi (set-intersection bug natural-numbers)) ;7 8 9 10 11 12 (describe (set-union 10 natural-numbers)) (describe (set-union natural-numbers -10)) (describe (set-union bor natural-numbers)) (describe (set-union natural-numbers bor)) (describe (op-set-union empty natural-numbers)) (describe (op-set-union natural-numbers empty)) (describe (op-set-union natural-numbers foo1)) (describe (op-set-union foo1 natural-numbers)) (describe (op-set-union comp natural-numbers)) (describe (op-set-union natural-numbers comp)) (describe (op-set-union bete natural-numbers)) (describe (op-set-union natural-numbers bete)) (describe (op-set-union natural-numbers cu1)) (describe (op-set-union cu1 natural-numbers)) (describe (op-set-union natural-numbers natural-numbers)) (describe (set-union natural-numbers cu2)) (describe (op-set-union natural-numbers foo)) (describe (set-union foo natural-numbers)) (describe (set-union efs natural-numbers)) (describe (set-union natural-numbers efs)) (describe (set-union ci1 natural-numbers)) (describe (set-union natural-numbers ci1)) (describe (op-set-intersection 10 natural-numbers)) (describe (op-set-intersection natural-numbers 10000)) (describe (op-set-intersection bor natural-numbers)) (describe (op-set-intersection natural-numbers bor)) (describe (op-set-intersection empty natural-numbers)) (describe (op-set-intersection natural-numbers empty)) (describe (op-set-intersection natural-numbers bug)) (describe (op-set-intersection bug natural-numbers)) (setf bug2 (make-instance 'interval :infimum -10 :supremum -5)) (describe (op-set-intersection natural-numbers bug2)) (describe (op-set-intersection bug2 natural-numbers)) (describe (op-set-intersection comp natural-numbers)) (describe (op-set-intersection natural-numbers comp)) (describe (op-set-intersection bete natural-numbers)) (describe (op-set-intersection natural-numbers bete)) (describe (op-set-intersection natural-numbers natural-numbers)) (describe (op-set-intersection cu1 natural-numbers)) (describe (op-set-intersection natural-numbers cu1)) (describe (op-set-intersection ci1 natural-numbers)) (describe (op-set-intersection natural-numbers ci1)) (describe (op-set-intersection natural-numbers foo)) (describe (op-set-intersection foo natural-numbers)) (describe (op-set-intersection efs natural-numbers)) (describe (op-set-intersection natural-numbers efs)) (describe (op-set-complement 10 natural-numbers)) (describe (op-set-complement -10 natural-numbers)) (describe (op-set-complement natural-numbers -10)) (describe (op-set-complement natural-numbers 10)) (describe (op-set-complement bor natural-numbers)) (describe (op-set-complement natural-numbers bor)) (describe (op-set-complement empty natural-numbers)) (describe (op-set-complement natural-numbers empty)) (describe (op-set-complement natural-numbers bug)) (describe (op-set-complement bug natural-numbers)) (describe (op-set-complement comp natural-numbers)) (describe (op-set-complement natural-numbers comp)) (describe (op-set-complement bete natural-numbers)) (describe (op-set-complement natural-numbers bete)) (describe (op-set-complement natural-numbers natural-numbers)) ;;;START HERE LATER (describe (op-set-complement cu1 natural-numbers)) (describe (op-set-complement natural-numbers cu1)) (describe (op-set-complement ci1 natural-numbers)) (describe (op-set-complement natural-numbers ci1)) (describe (op-set-complement natural-numbers foo)) (describe (op-set-complement foo natural-numbers)) (describe (op-set-complement efs natural-numbers)) (describe (op-set-complement natural-numbers efs)) ;;; efis (setf efi1 (make-instance 'explicit-finite-intersection :contents (list ci1 bug))) (disjoint-sets-p bug efi1) (memberp 100 efi1) (memberp -3 efi1) (insidep bug efi1) (insidep efi1 bug) (setf efi2 (op-set-intersection bug efi1)) (same-set-p efi2 efi1) (setf comp (set-complement efi1 bug)) (setf comp2 (set-complement bug efi1)) (describe (set-union bug efi1)) (disjoint-sets-p efi efi1) (memberp 9 efi) (memberp 100 efi) (memberp -3 efi) (insidep bug efi) (insidep efi bug) (setf efi2 (op-set-intersection bug efi)) (same-set-p efi2 efi) (setf comp (set-complement efi bug)) (setf comp2 (set-complement bug efi)) (describe (set-union bug efi)) ;predicate-set? (describe (set-union 10 efi1)) (describe (set-union efi1 -10)) (describe (set-union bor efi1)) (describe (set-union efi1 bor)) (describe (op-set-union empty efi1)) (describe (set-union efi1 empty)) (describe (op-set-union efi1 foo1)) (describe (op-set-union foo1 efi1)) (describe (op-set-union comp efi1)) (describe (op-set-union efi1 comp)) (describe (op-set-union bete efi1)) (describe (op-set-union efi1 cu1)) (describe (op-set-union cu1 efi1)) (describe (op-set-union efi1 bete)) (describe (op-set-union efi1 ci1)) (describe (op-set-union ci1 efi1)) (describe (op-set-union efi1 natural-numbers)) (describe (op-set-union natural-numbers efi1)) (describe (op-set-union efi1 efi1)) (describe (set-union efi1 foo)) (describe (set-union foo efi1)) (describe (set-union efs efi1)) (describe (set-union efi1 efs)) (describe (op-set-intersection 10 efi1)) (describe (op-set-intersection efi1 10000)) (describe (op-set-intersection bor efi1)) (describe (op-set-intersection efi1 bor)) (describe (op-set-intersection empty efi1)) (describe (op-set-intersection efi1 empty)) (describe (op-set-intersection efi1 bug)) (describe (op-set-intersection bug efi1)) (describe (op-set-intersection comp efi1)) (describe (op-set-intersection efi1 comp)) (describe (op-set-intersection bete efi1)) (describe (op-set-intersection efi1 bete)) (describe (op-set-intersection efi1 efi1)) (describe (op-set-intersection cu1 efi1)) (describe (op-set-intersection efi1 cu1)) (describe (op-set-intersection efi1 foo)) (describe (op-set-intersection foo efi1)) (describe (op-set-intersection efs efi1)) (describe (op-set-intersection efi1 efs)) (describe (op-set-intersection ci1 efi1)) (describe (op-set-intersection efi1 ci1)) (describe (op-set-intersection natural-numbers efi1)) (describe (op-set-intersection efi1 natural-numbers)) (describe (op-set-complement 10 efi1)) (describe (op-set-complement -10 efi1)) (describe (op-set-complement efi1 -10)) (describe (op-set-complement efi1 10)) (describe (op-set-complement bor efi1)) (describe (op-set-complement efi1 bor)) (describe (op-set-complement empty efi1)) (describe (op-set-complement efi1 empty)) (describe (op-set-complement efi1 bug)) (describe (op-set-complement bug efi1)) (describe (op-set-complement comp efi1)) (describe (op-set-complement efi1 comp)) (describe (op-set-complement bete efi1)) (describe (op-set-complement efi1 bete)) (describe (op-set-complement efi1 efi1)) (describe (op-set-complement efi1 foo)) (describe (op-set-complement foo efi1)) (describe (op-set-complement efs efi1)) (describe (op-set-complement efi1 efs)) (describe (op-set-complement cu1 efi1)) (describe (op-set-complement efi1 cu1)) (describe (op-set-complement ci1 efi1)) (describe (op-set-complement efi1 ci1)) (describe (op-set-complement natural-numbers efi1)) (describe (op-set-complement efi1 natural-numbers)) (describe (op-set-complement efi1 efi1)) (describe (op-set-complement efi1 cu1))
14,848
Common Lisp
.l
365
36.936986
80
0.723767
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
5b316dbd356e44a194c482febd0e4a54fbb23f078a2d4b8ba07b25f528f24062
33,416
[ -1 ]
33,417
set-complement-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/set-complement-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; set-complement-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990 ;;; N. Wiebe 1997, 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; SET COMPLEMENT METHODS ;;; ;;; Method | Argument type | ;;; |_____________________________________________| ;;; Name | Argument 1 | Argument 2 | ;;; ___________________________|______________________|______________________| ;;; | | | ;;; | | | ;;; op-set-complement | borel-set | borel-set | ;;; | borel-set | empty-set | ;;; | borel-set | (extended-realp) | ;;; | complement-set | borel-set | ;;; | complement-set | complement-set | ;;; | complement-set | interval | ;;; | complement-set | predicate-set | ;;; | empty-set | borel-set | ;;; | explicit-finite-set | borel-set | ;;; | explicit-finite-set | explicit-finite-set | ;;; | explicit-finite-set | interval | ;;; | explicit-finite-set | (extended-realp) | ;;; | explicit-finite-union| explicit-finite-union| ;;; | explicit-finite-union| interval | ;;; | interval | complement-set | ;;; | interval | explicit-finite-union| ;;; | interval | interval | ;;; | interval | predicate-set | ;;; | predicate-set | interval | ;;; | predicate-set | predicate-set | ;;; | (extended-realp) | borel-set | ;;; | (extended-realp) | complement-set | ;;; | (extended-realp) | explicit-finite-set | ;;; | (extended-realp) | explicit-finite-union| ;;; | (extended-realp) | (extended-realp) | ;;; op-set-difference | same as above | same as above | ;;; | | | (in-package :quail) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-set-complement - Set complement as a binary operator ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-set-complement (set1 set2) (declare (special *the-empty-set*)) (if (and (extended-realp set1) (extended-realp set2)) (if (= set1 set2) *the-empty-set* set2) (missing-method 'op-set-complement set1 set2))) (defmethod op-set-complement ((set1 borel-set) (set2 borel-set)) (if (op-disjoint-sets-p set1 set2) set2 (make-instance 'complement-set :set set1 :wrt set2))) (defmethod op-set-complement ((set1 borel-set) set2) (declare (special *the-empty-set*)) (if (extended-realp set2) (if (memberp set2 set1) *the-empty-set* set2) (missing-method 'op-set-complement set1 set2))) (defmethod op-set-complement (set1 (set2 borel-set)) (if (extended-realp set1) (if (memberp set1 set2) (make-instance 'complement-set :set set1 :wrt set2) set2) (missing-method 'op-set-complement set1 set2))) (defmethod op-set-complement (set1 (set2 complement-set)) (if (extended-realp set1) (if (memberp set1 (set-of set2)) set2 (if (memberp set1 (complement-wrt set2)) (if (extended-realp (set-of set2)) (make-instance 'complement-set :set (make-instance 'explicit-finite-set :contents (list set1 (set-of set2))) :wrt (complement-wrt set2)) (make-instance 'complement-set :set set1 :wrt set2)))) (missing-method 'op-set-complement set1 set2))) ;;; do I really want this? (defmethod op-set-complement (set1 (set2 explicit-finite-union)) (if (extended-realp set1) (if (memberp set1 set2) (if (member set1 (contents-of set2) :test #'same-set-p) (if (> (length (contents-of set2)) 2) (copy-set (remove-sets set2 set1)) (elt (contents-of (remove-sets set2 set1)) 0)) (make-instance 'complement-set :set set1 :wrt set2)) set2) (missing-method 'op-set-complement set1 set2))) (defmethod op-set-complement ((set1 borel-set) (set2 empty-set)) set2) (defmethod op-set-complement ((set1 empty-set) (set2 borel-set)) set2) (defmethod op-set-complement ((set1 interval) (set2 interval)) (declare (special *the-empty-set*)) (let (new-set new-inf new-sup new-closure-property (left-closed? NIL) (right-closed? NIL) (min1 (infimum set1)) (min2 (infimum set2)) (max1 (supremum set1)) (max2 (supremum set2))) (cond ((disjoint-sets-p set1 set2) ; no intersection, (setf new-set set2)) ; op-set-complement is all of set2 ((op-insidep set2 set1) (setf new-set *the-empty-set*)) ; op-set-complement is empty ((and (<= min1 min2) ; op-set-complement is interval (not (and (left-closed-p set2) (left-open-p set1))) (or (< max1 max2) ; between max1 and max2 (and (= max1 max2) (right-open-p set1) (right-closed-p set2)))) (setf new-inf max1) (setf new-sup max2) (if (right-open-p set1) (setf left-closed? T)) (if (right-closed-p set2) (setf right-closed? T)) (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) (if (eq new-inf new-sup) (setf new-set new-inf) (setf new-set (make-instance 'interval :infimum new-inf :supremum new-sup :closure-property new-closure-property)))) ((and (or (> min1 min2) ; op-set-complement is interval (and (= min1 min2) (left-open-p set1) (left-closed-p set2))) (>= max1 max2) (not (and (right-closed-p set2) (right-open-p set1)))) ; between min2 and min1 (setf new-inf min2) (setf new-sup min1) (if (left-open-p set1) (setf right-closed? T)) (if (left-closed-p set2) (setf left-closed? T)) (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) (if (eq new-inf new-sup) (setf new-set new-inf) (setf new-set (make-instance 'interval :infimum new-inf :supremum new-sup :closure-property new-closure-property)))) (T ; there are two intervals ; in the op-set-complement ; the first from min2 to min1 ; the second from max1 to max2 (let (sub-int1 sub-int2) ;; work on first sub-interval (if (left-closed-p set2) (setf left-closed? T)) (if (left-open-p set1) (setf right-closed? T)) (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) (if (eq min1 min2) (setf sub-int1 min1) (setf sub-int1 (make-instance 'interval :infimum min2 :supremum min1 :closure-property new-closure-property))) ;; reinitialize closure-propertys (setf left-closed? NIL) (setf right-closed? NIL) ;; now work on second sub-interval (if (right-open-p set1) (setf left-closed? T)) (if (right-closed-p set2) (setf right-closed? T)) (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) (if (eq max1 max2) (setf sub-int2 max1) (setf sub-int2 (make-instance 'interval :infimum max1 :supremum max2 :closure-property new-closure-property))) ;; build the op-set-complement (if (every #'extended-realp (list sub-int1 sub-int2)) (setf new-set (make-instance 'explicit-finite-set :contents (list sub-int1 sub-int2))) (setf new-set (make-instance 'explicit-finite-union :infimum min2 :supremum max2 :contents (list sub-int1 sub-int2) :disjoint? T :closure-property (if (and (closed-set-p sub-int1) (closed-set-p sub-int2)) :closed :neither)))) new-set)) ) new-set) ) (defmethod op-set-complement ((set1 complement-set) (set2 borel-set)) (op-set-union (op-set-intersection set2 (set-of set1)) (op-set-complement (complement-wrt set1) set2))) (defmethod op-set-complement ((set1 explicit-finite-set) (set2 explicit-finite-set)) (declare (special *the-empty-set*)) (let (new-set) (if (or (> (infimum set1) (supremum set2)) (> (infimum set2) (supremum set1))) ;; then return set2 (setf new-set set2) ;; else do more work (let ((contents (seq-complement (contents-of set1) (contents-of set2)))) (cond ((zerop (length contents)) (setf new-set *the-empty-set*)) ((eq (length contents) 1) (setf new-set (elt contents 0))) (T (let ((new-min (elt contents 0)) (new-max (elt contents (- (length contents) 1)))) (setf new-set (make-instance 'explicit-finite-set :contents contents :infimum new-min :supremum new-max))))))) new-set)) ;;; should this be switched to borel-set?? (defmethod op-set-complement ((set1 explicit-finite-set) (set2 interval)) (if (op-disjoint-sets-p set1 set2) set2 (let ((new-contents (mapcan #'(lambda (x) (and (memberp x set2) (list x))) (contents-of set1)))) (cond ((null new-contents) set2) ((= (length new-contents) 1) (progn (setf new-contents (elt new-contents 0)) (make-instance 'complement-set :set new-contents :wrt set2))) (T (progn (setf new-contents (make-instance 'explicit-finite-set :contents new-contents)) (make-instance 'complement-set :set new-contents :wrt set2))))))) (defmethod op-set-complement ((set1 explicit-finite-set) (set2 borel-set)) (declare (special *the-empty-set*)) (if (empty-set-p set2) *the-empty-set* (make-instance 'complement-set :set set1 :wrt set2))) (defmethod op-set-complement (set1 (set2 explicit-finite-set)) (if (extended-realp set1) (if (member set1 (contents-of set2)) (if (= (length (contents-of set2)) 2) (elt (contents-of (remove-sets set2 set1)) 0) (copy-set (remove-sets set2 set1))) set2) (missing-method 'op-set-complement set1 set2))) (defmethod op-set-complement ((set1 explicit-finite-set) set2) (declare (special *the-empty-set*)) (if (extended-realp set2) (if (member set2 (contents-of set1)) *the-empty-set* set2) (missing-method 'op-set-complement set1 set2))) ;;; EFUs (defmethod op-set-complement ((set1 explicit-finite-union) (set2 explicit-finite-union)) (if (op-disjoint-sets-p set1 set2) set2 (let (new-set) (loop for item in (contents-of set1) do (if new-set (setf new-set (op-set-intersection new-set (op-set-complement item set2))) (setf new-set (op-set-complement item set2)))) (if (null new-set) (setf new-set *the-empty-set*)) new-set))) (defmethod op-set-complement ((set1 explicit-finite-union) (set2 interval)) (let ((new-sets NIL)) (loop for item in (contents-of set1) do (if new-sets (setf new-sets (set-intersection new-sets (set-complement item set2))) (setf new-sets (set-complement item set2)))) new-sets)) (defmethod op-set-complement ((set1 predicate-set) (set2 explicit-finite-union)) (if (member set1 (contents-of set2)) (copy-set (remove-sets set2 set1)) (make-instance 'complement-set :set set1 :wrt set2))) (defmethod op-set-complement ((set1 explicit-finite-union) (set2 borel-set)) (let ((new-sets NIL)) (loop for item in (contents-of set1) do (if new-sets (setf new-sets (set-intersection new-sets (set-complement item set2))) (setf new-sets (set-complement item set2)))) new-sets)) (defmethod op-set-complement ((set1 interval) (set2 explicit-finite-union)) (let ((new-sets NIL)) (loop for item in (contents-of set2) do (setf new-sets (append new-sets (list (op-set-complement set1 item))))) (setf new-sets (delete-if #'empty-set-p new-sets)) (cond ((null new-sets) (setf new-sets *the-empty-set*)) ((= (length new-sets) 1) (setf new-sets (elt new-sets 0))) (T (if (every #'extended-realp new-sets) (setf new-sets (make-instance 'explicit-finite-set :contents new-sets)) (setf new-sets (make-instance 'explicit-finite-union :contents new-sets))))) new-sets)) ;;; predicate-sets, intervals, complement-sets (defmethod op-set-complement ((set1 complement-set) (set2 complement-set)) (if (op-disjoint-sets-p set1 set2) ;; does this make it faster or not really? set2 (op-set-complement (set-of set2) (op-set-union (op-set-complement (complement-wrt set1) (complement-wrt set2)) (op-set-intersection (set-of set1) (complement-wrt set2)))))) (defmethod op-set-complement ((set1 interval) (set2 complement-set)) (op-set-complement (op-set-union set1 (set-of set2)) (complement-wrt set2))) (defmethod op-set-complement ((set1 complement-set) (set2 interval)) (op-set-union (op-set-complement (complement-wrt set1) set2) (set-intersection (set-of set1) set2))) (defmethod op-set-complement ((set1 predicate-set) (set2 predicate-set)) (declare (special *the-empty-set*)) (if (eq set1 set2) *the-empty-set* (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (not (funcall (defining-predicate-of set1) test-member)) (funcall (defining-predicate-of set2) test-member)))))) (defmethod op-set-complement ((set1 predicate-set) (set2 interval)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (not (funcall (defining-predicate-of set1) test-member)) (op-memberp test-member set2))))) (defmethod op-set-complement ((set1 interval) (set2 predicate-set)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (not (op-memberp test-member set1)) (funcall (defining-predicate-of set2) test-member))))) (defmethod op-set-complement ((set1 predicate-set) (set2 complement-set)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (not (funcall (defining-predicate-of set1) test-member)) (op-memberp test-member set2))))) (defmethod op-set-complement ((set1 complement-set) (set2 predicate-set)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (and (not (op-memberp test-member set1)) (funcall (defining-predicate-of set2) test-member))))) (defmethod op-set-complement ((set1 borel-set) (set2 countable-union)) (make-instance 'complement-set :set set1 :wrt set2)) (defmethod op-set-complement ((set1 interval) (set2 countable-union)) (if (containsp set2 set1) (make-instance 'complement-set :set set1 :wrt set2) set2)) (defmethod op-set-complement ((set1 countable-union) (set2 borel-set)) (declare (special *the-empty-set*)) (if (eq set1 set2) *the-empty-set* (if (contains-set-p set1 set2) ;;third alt, don't know, gives error *the-empty-set* set2))) (defmethod op-set-complement ((set1 interval) (set2 countable-set)) (declare (special *the-empty-set*)) (if (eq set1 set2) *the-empty-set* (if (op-disjoint-sets-p set1 set2) set2 (make-instance 'complement-set :set set1 :wrt set2)))) (defmethod op-set-complement ((set1 countable-set) (set2 borel-set)) (declare (special *the-empty-set*)) (if (eq set1 set2) *the-empty-set* (if (op-disjoint-sets-p set1 set2) set2 (make-instance 'complement-set :set set1 :wrt set2)))) (defmethod op-set-complement ((set1 countable-union) (set2 empty-set)) set2) (defmethod op-set-complement ((set1 borel-set) (set2 countable-intersection)) (declare (special *the-empty-set*)) (if (eq set1 set2) *the-empty-set* (make-instance 'complement-set :set set1 :wrt set2))) (defmethod op-set-complement ((set1 countable-intersection) (set2 borel-set)) (declare (special *the-empty-set*)) (if (eq set1 set2) *the-empty-set* (make-instance 'complement-set :set set1 :wrt set2))) (defmethod op-set-complement ((set1 countable-intersection) (set2 empty-set)) set2) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-set-difference - Set difference binary operator ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-set-difference (set1 set2) (op-set-complement set2 set1))
19,847
Common Lisp
.l
410
38.221951
101
0.516477
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
ce81fdf7a5e29ef343db40c679799c7e3cafcd168a7e87e8e6f89192e3b70178
33,417
[ -1 ]
33,418
set-union-methods.lsp
rwoldford_Quail/source/mathematics/borel-sets/set-union-methods.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; set-union-methods.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1989, 1990 ;;; N. Wiebe 1997, 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; SET UNION METHODS ;;; ;;; Method | Argument type | ;;; |_____________________________________________| ;;; Name | Argument 1 | Argument 2 | ;;; ___________________________|______________________|______________________| ;;; | | | ;;; | | | ;;; op-set-union | borel-set | borel-set | ;;; | borel-set | empty-set | ;;; | borel-set | explicit-finite-set | ;;; | borel-set | explicit-finite-union| ;;; | borel-set | (extended-realp) | ;;; | complement-set | complement-set | ;;; | complement-set | (extended-realp) | ;;; | complement-set | interval | ;;; | complement-set | predicate-set | ;;; | countable-union | borel-set | ;;; | countable-union | countable-union | ;;; | empty-set | borel-set | ;;; | empty-set | explicit-finite-union| why ;;; | empty-set | (extended-realp) | ;;; | explicit-finite-set | borel-set | ;;; | explicit-finite-set | explicit-finite-set | ;;; | explicit-finite-set | interval | ;;; | explicit-finite-set | (extended-realp) | ;;; | explicit-finite-union| borel-set | ;;; | explicit-finite-union| empty-set | ;;; | explicit-finite-union| explicit-finite-union| ;;; | explicit-finite-union| (extended-realp) | ;;; | interval | complement-set | ;;; | interval | explicit-finite-set | ;;; | interval | interval | ;;; | interval | predicate-set | ;;; | predicate-set | complement-set | ;;; | predicate-set | interval | ;;; | predicate-set | predicate-set | ;;; | (extended-realp) | borel-set | ;;; | (extended-realp) | complement-set | ;;; | (extended-realp) | empty-set | ;;; | (extended-realp) |explicit-finite-set | ;;; | (extended-realp) |explicit-finite-union | ;;; | (extended-realp) | (extended-realp) | (in-package :quail) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; op-set-union - Set Union binary operator ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod op-set-union (set1 set2) (if (and (extended-realp set1) (extended-realp set2)) (if (= set1 set2) set1 (make-instance 'explicit-finite-set :contents (list set1 set2))) (missing-method 'op-set-union set1 set2))) (defmethod op-set-union ((set1 borel-set) (set2 borel-set)) (declare (special *default-set-less-than-predicate*)) (make-instance 'explicit-finite-union :contents (list set1 set2) :set-less-than-predicate *default-set-less-than-predicate*)) (defmethod op-set-union (set1 (set2 borel-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 borel-set) set2) (declare (special *default-set-less-than-predicate*)) (if (extended-realp set2) (if (op-memberp set2 set1) set1 (make-instance 'explicit-finite-union :contents (list set1 set2) :set-less-than-predicate *default-set-less-than-predicate* :disjoint? T)) (missing-method 'op-set-union set1 set2))) (defmethod op-set-union ((set1 empty-set) set2) (if (extended-realp set2) set2 (missing-method 'op-set-union set1 set2))) (defmethod op-set-union (set1 (set2 empty-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 empty-set) (set2 borel-set)) set2) (defmethod op-set-union ((set1 borel-set) (set2 empty-set)) set1) (defmethod op-set-union (set1 (set2 complement-set)) (if (extended-realp set1) (if (same-set-p set1 (set-of set2)) (complement-wrt set2) (make-instance 'explicit-finite-union :contents (list set1 set2))) (missing-method 'op-set-union set1 set2))) (defmethod op-set-union ((set1 complement-set) set2) (op-set-union set2 set1)) ;;;;;;;;;;;;;;;;;;; ;;; ;;; union of intervals ;;; (defmethod op-set-union ((set1 interval) (set2 interval)) (let* (new-set (min1 (infimum set1)) (min2 (infimum set2)) (max1 (supremum set1)) (max2 (supremum set2)) (new-inf (min min1 min2)) (new-sup (max max1 max2))) (if (separatep set1 set2) ;; then union is union of two disjoint intervals (setf new-set (make-instance 'explicit-finite-union :contents (list set1 set2) :infimum new-inf :supremum new-sup)) ;; otherwise it's another interval and closure-property needs to be ;; figured out. (let (new-closure-property (left-closed? NIL) (right-closed? NIL) (left-set (if (<= min1 min2) set1 set2)) (right-set (if (>= max1 max2) set1 set2))) ;; ;; First the left side: (if (or (left-closed-p left-set) (and (= min1 min2) (or (left-closed-p set1) (left-closed-p set2)))) ;; then it's closed on the left (setf left-closed? T) ;; otherwise it's open on the left, ;; left-closed? remains nil ) ;; Now the right side: (if (or (right-closed-p right-set) (and (= max1 max2) (or (right-closed-p set1) (right-closed-p set2)))) ;; then it's closed on the right (setf right-closed? T) ;; otherwise it's open on the right, ;; right-closed? remains nil ) ;; Which yields the closure-property: (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) ;; Finally make the appropriate interval (setf new-set (make-instance 'interval :closure-property new-closure-property :infimum new-inf :supremum new-sup)))) (simplify-object new-set)) ) (defmethod op-set-union ((set1 explicit-finite-set) (set2 explicit-finite-set)) (let ((new-contents (seq-union (contents-of set1) (contents-of set2))) (new-inf (min (infimum set1) (infimum set2))) (new-sup (max (supremum set1) (supremum set2)))) (make-instance 'explicit-finite-set :contents new-contents :infimum new-inf :supremum new-sup))) (defmethod op-set-union ((set1 explicit-finite-set) set2) (if (extended-realp set2) (make-instance 'explicit-finite-set :contents (concatenate 'list (contents-of set1) (list set2))) (missing-method 'op-set-union set1 set2))) (defmethod op-set-union (set1 (set2 explicit-finite-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 explicit-finite-union) (set2 borel-set)) (if (member set2 (contents-of set1) :test #'same-set-p) set1 (make-instance 'explicit-finite-union :contents (concatenate 'list (contents-of set1) (list set2))))) (defmethod op-set-union ((set1 explicit-finite-union) (set2 countable-union)) (let ((new-collection (copy-set set2))) (loop for item in (contents-of set1) do (when (not (contains-set-p set2 item)) (setf new-collection (combine-collections new-collection item)))) new-collection)) (defmethod op-set-union ((set1 explicit-finite-union) (set2 countable-set)) (make-instance 'explicit-finite-union :contents (concatenate 'list (contents-of set1) (list set2)))) (defmethod op-set-union ((set1 borel-set) (set2 explicit-finite-union)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 borel-set) (set2 explicit-finite-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 explicit-finite-set) (set2 borel-set)) (if (every #'(lambda(x) (memberp x set2)) (contents-of set1)) set2 (make-instance 'explicit-finite-union :contents (concatenate 'list (list set1 set2))))) (defmethod op-set-union ((set1 explicit-finite-union) (set2 explicit-finite-union)) (if (eq set1 set2) ;;or op-same-set-p set1 (simplify-object (make-instance 'explicit-finite-union :contents (concatenate 'list (contents-of set1) (contents-of set2)))))) (defmethod op-set-union ((set1 explicit-finite-union) set2) (if (extended-realp set2) (if (memberp set2 set1) set1 (make-instance 'explicit-finite-union :contents (concatenate 'list (contents-of set1) (list set2)))) (missing-method 'op-set-union set1 set2))) (defmethod op-set-union (set1 (set2 explicit-finite-union)) (op-set-union set2 set1)) ;;; predicate-set, interval, and complement-sets (defmethod op-set-union ((set1 complement-set) (set2 interval)) (op-set-union (op-set-complement (set-of set1) (op-set-union (complement-wrt set1) set2)) (op-set-intersection (set-of set1) set2))) (defmethod op-set-union ((set1 interval) (set2 complement-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 complement-set) (set2 complement-set)) (if (not (op-empty-set-p (op-set-intersection (set-of set1) (complement-wrt set2)))) (if (not (op-empty-set-p (op-set-intersection (set-of set2) (complement-wrt set1)))) (op-set-union (complement-wrt set1) (complement-wrt set2)) (op-set-complement (set-of set1) (op-set-union (complement-wrt set1) (complement-wrt set2)))) (op-set-complement (op-set-union (set-of set1) (set-of set2)) (op-set-union (complement-wrt set1) (complement-wrt set2))))) (defmethod op-set-union ((set1 predicate-set) (set2 predicate-set)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (or (funcall (defining-predicate-of set1) test-member) (funcall (defining-predicate-of set2) test-member))) :infimum (min (infimum set1) (infimum set2)) :supremum (max (supremum set1) (supremum set2)))) (defmethod op-set-union ((set1 predicate-set) (set2 interval)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (or (funcall (defining-predicate-of set1) test-member) (memberp test-member set2))))) (defmethod op-set-union ((set1 interval) (set2 predicate-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 predicate-set) (set2 complement-set)) (make-instance 'predicate-set :defining-predicate #'(lambda (test-member) (or (funcall (defining-predicate-of set1) test-member) (and (memberp test-member (complement-wrt set2)) (not (memberp test-member (set-of set2)))))))) (defmethod op-set-union ((set1 complement-set) (set2 predicate-set)) (op-set-union set2 set1)) ;;; EFS (defmethod op-set-union ((set1 explicit-finite-set) (set2 interval)) (if (op-insidep set1 set2) set2 (if (or (not (op-disjoint-sets-p set1 set2)) (< (infimum set2) (supremum set1)) (< (infimum set1) (supremum set2))) (let* ((contents (contents-of set1)) (upper-set (remove-if #'(lambda (x) (if (<= x (supremum set2)) x)) contents)) (lower-set (remove-if #'(lambda (x) (if (>= x (infimum set2)) x)) contents)) (upper-set (if upper-set (if (not (= (length upper-set) 1)) (make-instance 'explicit-finite-set :contents upper-set) (elt upper-set 0)))) (lower-set (if lower-set (if (not (= (length lower-set) 1)) (make-instance 'explicit-finite-set :contents lower-set) (elt lower-set 0)))) set2-copy) (labels ((check-boundaries (set1 set2) (let (left-closed? right-closed? new-closure-property (set2-copy (copy-set set2))) (if (and (left-open-p set2) (find (infimum set2) (contents-of set1))) (setf left-closed? T) (setf left-closed? (left-closed-p set2))) (if (and (right-open-p set2) (find (supremum set2) (contents-of set1))) (setf right-closed? T) (setf right-closed? (right-closed-p set2))) (setf new-closure-property (determine-interval-closure left-closed? right-closed?)) (setf (closure-property-of set2-copy) new-closure-property) set2-copy))) (setf set2-copy (check-boundaries set1 set2))) (cond ((and lower-set upper-set) (make-instance 'explicit-finite-union :contents (list lower-set set2-copy upper-set))) (lower-set (make-instance 'explicit-finite-union :contents (list lower-set set2-copy))) (upper-set (make-instance 'explicit-finite-union :contents (list set2-copy upper-set))))) (make-instance 'explicit-finite-union :contents (list set1 set2))))) (defmethod op-set-union ((set1 interval) (set2 explicit-finite-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 countable-union) (set2 countable-union)) (if (eq set1 set2) set1 (combine-collections set1 set2))) (defmethod op-set-union ((set1 countable-set) (set2 countable-set)) (if (eq set1 set2) set1 (combine-collections set1 set2))) ;remove-duplicates? (defmethod op-set-union ((set1 countable-union) (set2 borel-set)) (if (contains-set-p set1 set2) set1 (combine-collections set1 set2))) (defmethod op-set-union ((set1 borel-set) (set2 countable-union)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 countable-set) (set2 borel-set)) (make-instance 'explicit-finite-union :contents (list set1 set2))) (defmethod op-set-union ((set1 countable-set) (set2 empty-set)) set1) (defmethod op-set-union ((set1 borel-set) (set2 countable-set)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 countable-union) (set2 empty-set)) set1) (defmethod op-set-union ((set1 countable-intersection) (set2 borel-set)) (if (eq set1 set2) set1 (make-instance 'explicit-finite-union :contents (list set1 set2)))) (defmethod op-set-union ((set1 countable-intersection) (set2 empty-set)) set1) ;;; not borel-sets ;;; (defmethod op-set-union ((set1 set-collection) set2) (declare (special *default-set-less-than-predicate*)) (if (extended-realp set2) (if (memberp set2 set1) set1 (make-instance 'explicit-finite-union :contents (list set1 set2) :set-less-than-predicate *default-set-less-than-predicate* :disjoint? T)) (missing-method 'op-set-union set1 set2))) (defmethod op-set-union (set1 (set2 set-collection)) (op-set-union set2 set1)) (defmethod op-set-union ((set1 set-collection) (set2 empty-set)) set1) (defmethod op-set-union ((set1 empty-set) (set2 set-collection)) set2) #| Finite-increasing-set as a class does not exist (defmethod op-set-union ((set1 finite-increasing-set) (set2 finite-increasing-set)) (let* ((new-contents (seq-union (contents-of set1) (contents-of set2))) (new-min (min (infimum set1) (infimum set2))) (new-max (max (supremum set1) (supremum set2)))) (make-instance 'finite-increasing-set :contents new-contents :infimum new-min :supremum new-max))) |#
18,520
Common Lisp
.l
360
41.102778
105
0.517642
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
4274267024329a1bb549a6b97c295b7222f0c58d4e3f3c21ef8a59b00af76786
33,418
[ -1 ]
33,419
set-collections.lsp
rwoldford_Quail/source/mathematics/borel-sets/set-collections.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; set-collections.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990, 1992 ;;; N. Wiebe 1998 ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; COLLECTIONS OF SETS ;;; ;;; In this file the classes representing arbitrary collections of sets and operators ;;; on those classes are defined. Various specialized methods which implement the ;;; operators are defined elsewhere. ;;; ;;; These collections are most interesting to us when their members must be borel-sets. ;;; (See Borel-Sets.lisp for class definitions on Borel-Sets.) ;;; ;;; ;;; Classes: ;;; ;;; ;;; 1. set-collection ... The base class. ;;; ;;; Operators: contains-set-p ;;; disjoint-collection-p ;;; not-disjoint-collection-p ;;; combine-collections. ;;; ;;; ;;; 2. countable-collection ... A countable set-collection with each set is ;;; indexed by an integer. ;;; ;;; Additional ;;; Operators: begin-index-of ;;; end-index-of ;;; number-of-sets-in ;;; finite-collection-p ;;; element ;;; element-function-of ;;; index. ;;; ;;; ;;; 3. explicit-finite-collection ... A finite countable-collection whose sets ;;; are stored explicitly in a sequence. ;;; Members can be accessed by index from 0 to ;;; N-1. ;;; ;;; Additional ;;; Operators: add-sets - add sets to the collection ;;; remove-sets - remove ... ;;; remove-sets-if - first arg is a predicate ;;; delete-sets - destructive remove ;;; delete-sets-if - ibid ;;; collection-sort - order sets according to some ;;; pairwise "strictly less than" ;;; predicate for two sets. ;;; safe-collection-sort - non-destructive sort ;;; sorted-collection-p - test if sorted ;;; reset-end-index - handy to reset count ;;; ;;; ;;; ;;; ;;; Wouldn't it be neat if we also had: ;;; ;;; 4. algebra ... A collection of subsets of a base set that is ;;; closed under complement and finite union or ;;; intersection (choose one, the other follows ;;; by De Morgan). ;;; and ;;; 5. sigma-algebra ... An algebra closed under countable union and ;;; intersection. ;;; ;;; Unfortunately, contains-set-p is a tad difficult to implement for algebras. :-) ;;; (Though not impossible to rig up a "close-enough" approximation assuming there ;;; are generators defined for the algebra and all sets to be tested for inclusion ;;; are constructed directly from the generators using complement, union and ;;; intersection operators as defined by us. ... rwo) ;;; ;;;---------------------------------------------------------------------------------- ;;;---------------------------------------------------------------------------------- ;;; ;;; Arbitrary collection of sets ;;; ;;;---------------------------------------------------------------------------------- (defclass set-collection (quail-object) ((contains-set-p-function :accessor contains-set-p-function-of :initarg :contains-set-p-function :initform #'(lambda (self set) (quail-yes-or-no-p "Does the collection: ~%~ ~s ~%~ contain the set: ~%~ ~s ?" self set)) :type function :documentation "A function of two arguments which, when applied to the collection and any set, ~%~ tests whether the specified set is in the collection.") (disjointness :initarg :disjoint? :initform :unknown :accessor disjointness-of :documentation "A slot (T, NIL, or :unknown) indicating whether the sets in the collection are known ~%~ a priori to be disjoint (i.e. empty intersections), not disjoint, or unknown (the default).")) (:documentation "The class representing an arbitrary collection of sets. ~%~ Membership in the collection is determined by the function~%~ found on the contains-set-p-function slot of the collection. The ~%~ default is that all borel-sets are in the collection.")) (defgeneric contains-set-p (set-collection set) (:documentation "Test whether the collection has the given set as a member.") ) (defgeneric disjoint-collection-p (set-collection) (:documentation "Test whether the sets of this collection are all disjoint.") ) (defgeneric not-disjoint-collection-p (set-collection) (:documentation "Test whether the sets of this collection are not all disjoint.") ) (defgeneric combine-collections (set-collection1 set-collection2) (:documentation "Combine two collections into a single one. ~%~ N.B. No guarantee a set does not appear more than once.") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The methods ;;; (defmethod contains-set-p ((collection set-collection) set) (funcall (contains-set-p-function-of collection) collection set)) (defmethod disjoint-collection-p ((collection set-collection)) (let ((result (disjointness-of collection))) (if (eq result :unknown) NIL result))) (defmethod not-disjoint-collection-p ((collection set-collection)) (let ((result (disjointness-of collection))) (if (eq result :unknown) NIL (not result)))) (defmethod combine-collections ((c1 set-collection) (c2 set-collection)) (let ((new-collection (make-instance 'set-collection)) (c1-fun (contains-set-p-function-of c1)) (c2-fun (contains-set-p-function-of c2))) (setf (contains-set-p-function-of new-collection) (function (lambda (collection set) (or (funcall c1-fun collection set) (funcall c2-fun collection set))))) (setf (disjointness-of new-collection) (if (and (not-disjoint-collection-p c1) (not-disjoint-collection-p c2)) NIL :unknown)) new-collection)) ;;;---------------------------------------------------------------------------------- ;;; ;;; Countable collection of sets ;;; ;;;---------------------------------------------------------------------------------- (defclass countable-collection (set-collection) ((begin-index :initarg :from :initform 0 :reader begin-index-of :documentation "The starting index of the collection. Must be an extended integer. ~%~ Default is 0.)") (end-index :initarg :to :initform +infinity :reader end-index-of :documentation "The last index of the collection. Must be an extended integer. ~%~ Default is +infinity.") (count-start :accessor count-start-of :type function :documentation "The integer index where complete enumeration of the collection ~%~ begins.") (count-end-test :accessor count-end-test-of :type function :documentation "A function of two arguments: the countable-collection and an extended-integer ~%~ representing the current index in enumeration of the collection. ~%~ When applied, it produces T if the set has been completely enumerated ~%~ and NIL otherwise.") (count-increment-function :accessor count-increment-function-of :type function :documentation "A function of two arguments: the countable-collection and a single ~%~ extended-integer index representing the current index in the count. ~%~ When applied, it produces the next index in the counting sequence. ~%~ A sensible default will be produced based on the values of ~%~ the local slots begin-index, end-index, count-start, and count-end.") (index-from-position-function :accessor index-from-position-function-of :type function :documentation "A function of two arguments: the countable-collection and a single ~%~ non-negative extended-integer representing the 0-based position that ~~ the desired index hold in the enumeration order of the collection.") (position-from-index-function :accessor position-from-index-function-of :type function :documentation "A function of two arguments: the countable-collection and a single ~%~ extended-integer representing the index of the set of interest in ~%~ the collection. ~%~ Returns a non-negative extended-integer giving the 0-based position that ~~ the desired set has in the enumeration order of the collection.") (element-function :accessor element-function-of :initarg :element-function :initform #'(lambda (collection index) (declare (ignore index)) (quail-error "No element-function has been defined for this collection: ~%~ ~s ." collection)) :type function :documentation "A function of two arguments. The first argument is the entire collection. ~%~ The second is an integer, i say, representing the index of the set to be retrieved. ~%~ It must lie between the begin-index-of and end-index-of the collection (inclusive). ~%~ Function must return the set i of the collection.") (index-function :accessor index-function-of :initarg :index-function :initform #'(lambda (collection set) (declare (special *reasonable-number-of-iterations*)) (do ((index (count-start-of collection) (next-index collection index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*)) ;; end-test ((count-endedp collection index)) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ")) finally (return answer)))) (return NIL))) ((same-set-p (element collection index) set) (return index))))) :documentation "A function of two arguments. The first argument is the entire collection. ~%~ The second is a set whose index in the collection is to be retrieved. ~%~ The function returns this index or NIL if set was not found.") (contains-set-p-function :initform #'(lambda (collection set) (declare (special *reasonable-number-of-iterations*)) (do ((index (count-start-of collection) (next-index collection index)) (counter 1 (+ counter 1)) (big-count *reasonable-number-of-iterations*)) ;; end-test ((count-endedp collection index)) ;; Now the action (cond ((> counter big-count) (if (quail-yes-or-no-p "Have tested ~s sets already. Should testing continue?" (- counter 1)) (setf big-count (+ big-count (loop with answer = NIL until (and answer (integerp answer) (>= answer 0)) do (setf answer (quail-query "How many more sets should be tested? ") ) finally (return answer)))) (cond ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is in the collection ~%~ ~s ? " set collection) (return T)) ((quail-yes-or-no-p "Assume set ~%~ ~s ~%~ is *NOT* in the collection ~%~ ~s ? " set collection) (return NIL)) (T (quail-error "Can't tell whether the set ~%~ ~s ~%~ is in the collection ~%~ ~s ~%~ or not!" set collection))))) ((same-set-p (element collection index) set) (return T))))) :documentation "A function of two arguments which, when applied to the collection and any set, ~%~ tests whether the specified set is in the collection.~%~ Default function compares the given set to each set ~%~ in the collection (ad nauseum)")) (:documentation "The collection of a countable number of sets. ~%~ Each set in the collection is indexed by an integer between the begin-index ~%~ and the end-index (inclusively).~%~ A set is accessed by applying the element function to the collection and ~%~ the desired index. This in turn calls the function stored on the slot ~%~ called element-function.")) (defmethod initialize-instance :after ((self countable-collection) &key) (let ((last (end-index-of self)) (first (begin-index-of self))) (if (not (and (extended-integerp first) (extended-integerp last))) (quail-error "Can't define a collection indexed from ~s to ~s.~%~ The begin and end indices must be extended-integers." first last) (set-count-controls self)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; SETF METHODS ;;; to check values on slots begin- and end-index. ;;; (defmethod (setf begin-index-of) (new-value (collection countable-collection)) (if (extended-integerp new-value) (progn (setf (slot-value collection 'begin-index) new-value) (set-count-controls collection) new-value) (quail-error "New-value must be an extended-integer, it cannot be ~s." new-value))) (defmethod (setf end-index-of) (new-value (collection countable-collection)) (if (extended-integerp new-value) (progn (setf (slot-value collection 'end-index) new-value) (set-count-controls collection) new-value) (quail-error "New-value must be an extended-integer, it cannot be ~s." new-value))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; New operators ;;; (defgeneric element (countable-collection integer) (:documentation "Returns the set in the countable collection having index i, where~%~ i is an integer between the begin-index and the end-index (inclusive).") ) (defgeneric index-of (countable-collection set) (:documentation "Returns the index in the countable collection of the specified set. ~%~ If set is not found, NIL is returned.") ) (defgeneric number-of-sets-in (countable-collection) (:documentation "Returns the number of sets in the countable collection.") ) (defgeneric finite-collection-p (countable-collection) (:documentation "Tests whether the number of sets in the countable collection is finite.") ) (defgeneric set-count-controls (countable-collection) (:documentation "Sets the count control slots: count-start, count-increment-function, and ~%~ count-end-test. Based on the current values of begin-index and end-index.") ) (defgeneric next-index (countable-collection current-index) (:documentation "Returns the next-index after the current-index. ~%~ Used in complete enumeration of a set.") ) (defgeneric count-endedp (countable-collection current-index) (:documentation "Used in complete enumeration of a set. ~%~ End test for the enumeration.") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The methods for countable-collection ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The following method does not work for ;;; combinations of countable- and explicit-finite-collections ;;; Beats me why.. methinks a bug in MACL ... :-) rwo (defmethod combine-collections ((c1 countable-collection) (c2 countable-collection)) (let* ((c1-cfun (contains-set-p-function-of c1)) (c2-cfun (contains-set-p-function-of c2)) (c1-ifun (element-function-of c1)) (c2-ifun (element-function-of c2)) (ifp-1 (index-from-position-function-of c1)) (ifp-2 (index-from-position-function-of c2)) (n1 (number-of-sets-in c1)) (n2 (number-of-sets-in c2)) (small-n (min n1 n2)) (new-begin 0) (new-end (+ n1 n2 -1)) (small-c (if (<= n1 n2) 1 2))) (make-instance (cond ((subtypep (type-of c1) (type-of c2)) (type-of c2)) ((subtypep (type-of c2) (type-of c1)) (type-of c1)) (T 'countable-collection)) :from new-begin :to new-end :contains-set-p-function (function (lambda (collection set) (or (funcall c1-cfun collection set) (funcall c2-cfun collection set)))) :disjoint? (if (and (not-disjoint-collection-p c1) (not-disjoint-collection-p c2)) NIL :unknown) :element-function (function (lambda (collection index) (cond ((eq index +infinity) ; Are we over-reaching? (if (eq small-n +infinity) (quail-error "Set with index +infinity is not well-defined for ~%~ the collection: ~s " collection) (case small-c (1 (funcall c2-ifun c2 (funcall ifp-2 (/ index 2)))) ;always +infinity anyway (2 (funcall c1-ifun ;isn't it the other way around? c1 (funcall ifp-1 (/ index 2))))))) ((and (evenp index) (< (/ index 2) small-n)) ; First evens go to the (case small-c ; smallest collection. (1 (funcall c1-ifun c1 (funcall ifp-1 (/ index 2)) )) (2 (funcall c2-ifun c2 (funcall ifp-2 (/ index 2)))))) ((and (oddp index) ; First odds go to the (< (/ ; larger collection. (- index 1) 2) small-n)) (case small-c (1 (funcall c2-ifun ; Note switch here. c2 (funcall ifp-2 (/ (- index 1) 2)))) (2 (funcall c1-ifun c1 (funcall ifp-1 (/ (- index 1) 2)))))) (T (case small-c (1 (funcall c2-ifun ; All the rest go to the c2 ; larger collection. (funcall ifp-2 (- index small-n)))) (2 (funcall c1-ifun c1 (funcall ifp-1 (- index small-n)) ))))) ; end cond ))))) ;;;;;;;;;; ;;; (defmethod number-of-sets-in ((collection countable-collection)) (let* ((b-i (begin-index-of collection)) (e-i (end-index-of collection)) (max-i (max b-i e-i)) (min-i (min b-i e-i))) (+ 1 (- max-i min-i)))) (defmethod finite-collection-p ((self countable-collection)) (< (number-of-sets-in self) +infinity)) (defmethod element ((self countable-collection) index) (if (extended-integerp index) (if (or (> index (max (end-index-of self) (begin-index-of self))) (< index (min (end-index-of self) (begin-index-of self)))) (quail-error "Index (~s) is out of range. ~%~ All indices must be between ~s and ~s inclusively." index (begin-index-of self) (end-index-of self)) (funcall (element-function-of self) self index)) (quail-error "Illegal index: ~s ~%Must be an extended-integer." index))) (defmethod index-of ((collection countable-collection) set) (funcall (index-function-of collection) collection set)) (defmethod contains-set-p ((collection countable-collection) set) (funcall (contains-set-p-function-of collection) collection set)) (defmethod next-index ((collection countable-collection) current-index) (if (extended-integerp current-index) (funcall (count-increment-function-of collection) collection current-index) (quail-error "Illegal argument: ~s ~%~ Current index must be an extended-integer." current-index))) (defmethod count-endedp ((collection countable-collection) index) (if (extended-integerp index) (funcall (count-end-test-of collection) collection index) (quail-error "Illegal argument: ~s ~%~ Index must be an extended-integer." index))) (defmethod disjoint-collection-p ((collection countable-collection)) (let ((result (disjointness-of collection))) (if (eq result :unknown) NIL result))) (defmethod not-disjoint-collection-p ((collection countable-collection)) (let ((result (disjointness-of collection))) (if (eq result :unknown) NIL (not result)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The following is a critically ;;; important method. In the future, ;;; most of the functions in it should be defined ;;; once, stored in a class-shared hash-table and ;;; looked up when needed! ... rwo ;;; (defmethod set-count-controls ((collection countable-collection)) (let* ((begin-index (begin-index-of collection)) (end-index (end-index-of collection)) (max-index (max begin-index end-index)) (min-index (min begin-index end-index))) (cond ((and (= min-index -infinity) (= max-index +infinity)) (setf (count-start-of collection) 0) (setf (count-end-test-of collection) #'(lambda (collection current-index) (declare (ignore collection current-index)) NIL)) (setf (count-increment-function-of collection) #'(lambda (collection current-index) (declare (ignore collection)) (cond ((= current-index 0) 1) ((> current-index 0) (* -1 current-index)) ((< current-index 0) (+ 1 (* -1 current-index)))))) (setf (index-from-position-function-of collection) #'(lambda (position) (cond ((or (not (extended-integerp position)) (< position 0)) (quail-error "No such position exists in the enumeration: ~s" position)) ((= position +infinity) (quail-error "This position is not well defined in the current enumeration: ~s" position)) ((zerop position) 0) ((evenp position) (* -1 (/ position 2))) (T (/ (+ position 1) 2))))) (setf (position-from-index-function-of collection) #'(lambda (index) (cond ((not (extended-integerp index)) (quail-error "Illegal index, ~s, must be an extended-integer." index)) ((or (= index +infinity) (= index -infinity)) (quail-error "This index does not have a well defined position in the ~ current enumeration:~%~s" index)) ((zerop index) 0) ((< index 0) (* -2 index)) (T (- (* index 2) 1)))))) ((and (= min-index -infinity) (> max-index -infinity)) (setf (count-start-of collection) max-index) (setf (count-end-test-of collection) #'(lambda (collection current-index) (declare (ignore collection current-index)) NIL)) (setf (count-increment-function-of collection) #'(lambda (collection current-index) (declare (ignore collection)) (- current-index 1))) (setf (index-from-position-function-of collection) #'(lambda (position) (cond ((or (not (extended-integerp position)) (< position 0)) (quail-error "No such position exists in the enumeration: ~s" position)) (T (- max-index position))))) (setf (position-from-index-function-of collection) #'(lambda (index) (cond ((not (extended-integerp index)) (quail-error "Illegal index, ~s, must be an extended-integer." index)) ((> index max-index) (quail-error "Index out of range: ~s.~%~ Must be an extended-integer <= ~s." index max-index)) ((= index -infinity) +infinity) (T (- index max-index)))))) ((and (= max-index +infinity) (< min-index +infinity)) (setf (count-start-of collection) min-index) (setf (count-end-test-of collection) #'(lambda (collection current-index) (declare (ignore collection current-index)) NIL)) (setf (count-increment-function-of collection) #'(lambda (collection current-index) (declare (ignore collection)) (+ current-index 1))) (setf (index-from-position-function-of collection) #'(lambda (position) (cond ((or (not (extended-integerp position)) (< position 0)) (quail-error "No such position exists in the enumeration: ~s" position)) (T (+ position min-index))))) (setf (position-from-index-function-of collection) #'(lambda (index) (cond ((not (extended-integerp index)) (quail-error "Illegal index, ~s, must be an extended-integer." index)) ((< index min-index) (quail-error "Index out of range: ~s.~%~ Must be an extended-integer >= ~s." index min-index)) ((= index +infinity) +infinity) (T (- index min-index)))))) ((and (> min-index -infinity) (< max-index +infinity)) (setf (count-start-of collection) min-index) (setf (count-end-test-of collection) #'(lambda (collection current-index) (> current-index (max (begin-index-of collection) (end-index-of collection))))) (setf (count-increment-function-of collection) #'(lambda (collection current-index) (declare (ignore collection)) (+ current-index 1))) (setf (index-from-position-function-of collection) #'(lambda (position) (cond ((or (not (extended-integerp position)) (< position 0) (> position (- max-index min-index))) (quail-error "No such position exists in the enumeration: ~s" position)) (T (+ position min-index))))) (setf (position-from-index-function-of collection) #'(lambda (index) (cond ((not (extended-integerp index)) (quail-error "Illegal index, ~s, must be an extended-integer." index)) ((or (< index min-index) (> index max-index)) (quail-error "Index out of range: ~s.~%~ Must be an extended-integer in [~s,~s]." index min-index max-index)) (T (- index min-index)))))) ((= begin-index end-index) (setf (count-start-of collection) begin-index) (setf (count-end-test-of collection) #'(lambda (collection current-index) (/= current-index (begin-index-of collection)))) (setf (count-increment-function-of collection) (if (or (= begin-index +infinity) (= begin-index -infinity)) #'(lambda (collection current-index) (if (= current-index (begin-index-of collection)) ;; any extended-integer /= begin-index will do 0 (begin-index-of collection))) #'(lambda (collection current-index) (if (= current-index (begin-index-of collection)) ;; any extended-integer /= begin-index will do +infinity (begin-index-of collection))))) (setf (index-from-position-function-of collection) #'(lambda (position) (cond ((or (not (extended-integerp position)) (/= position 0)) (quail-error "Only position 0 exists in this enumeration, not ~s" position)) (T 0)))) (setf (position-from-index-function-of collection) #'(lambda (index) (cond ((not (extended-integerp index)) (quail-error "Illegal index, ~s, must be an extended-integer." index)) ((/= index begin-index) (quail-error "Index out of range: ~s.~%~ Must be an extended-integer in [~s,~s]." index min-index max-index)) (T 0))))) )) T) ;;;---------------------------------------------------------------------------------- ;;; ;;; Finite collections of sets whose contents are stored explicitly ;;; on a contents slot (as opposed to implicitly as above). ;;; ;;;---------------------------------------------------------------------------------- (defclass explicit-finite-collection (countable-collection) ((contents :initform NIL :initarg :contents :reader contents-of :documentation "The entire contents of the collection explicitly constructed and ~%~ stored in a sequence.") (set-less-than-predicate :initform NIL :initarg :set-less-than-predicate :reader set-less-than-predicate-of :documentation "Function of two arguments (set1 set2) used to order the contents ~%~ of the collection.") ;; Now modifications of inherited slots. (begin-index :initform 0 :reader begin-index-of :documentation "The starting index of the collection. ~%~ Always 0 for this kind of collection.") (end-index :initform -1 :reader end-index-of :documentation "The last index of the collection. ALWAYS equal to ~%~ (- (length (contents-of collection)) 1 ) .") (element-function :initform #'(lambda (collection index) (elt (contents-of collection) index)) :initarg :element-function-overruled-by :documentation "A function of two arguments. The first argument is the entire collection. ~%~ The second is a non-negative integer, i say, representing the zero-based ~%~ index of the set to be retrieved. ~%~ Function is expected to return the i'th set in the collection. ~%~ Default should not need to be changed but can be overruled at ~%~ initialization with initarg :element-function-overruled-by .") (contains-set-p-function :initarg :contains-set-p-function-overruled-by :initform #'(lambda (collection set) (find set (contents-of collection) :test #'same-set-p)) :documentation "A function of two arguments which, when applied to the collection ~%~ and any set, tests whether the specified set is in the collection. ~%~ Default should not need to be changed but can be overruled at ~%~ initialization with initarg :contains-set-p-function-overruled-by .")) (:documentation "The collection of a finite number of sets. ~%~ All sets in the collection are instantiated and explicitly stored in the contents-of this collection. ~%~ Each set in the collection is indexed by an integer between the begin-index, 0, ~%~ and the end-index (inclusively).~%~ A set is accessed by applying the element function to the collection and ~%~ the desired index. This in turn calls the function stored on the slot ~%~ called element-function.")) (defmethod initialize-instance :after ((self explicit-finite-collection) &key) (if (set-less-than-predicate-of self) ;; Then sort the contents. ;; The sort automatically resets the end-index. (collection-sort self (set-less-than-predicate-of self)) ;; Else make sure the size of the collection is correct. (reset-end-index self))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; SETF METHODS ;;; ;;; (defmethod (setf begin-index-of) (new-value (collection explicit-finite-collection)) (if (and (integerp new-value) (zerop new-value)) (setf (slot-value collection 'begin-index) new-value) (quail-error "This kind of collection must have begin-index = 0."))) (defmethod (setf end-index-of) (new-value (collection explicit-finite-collection)) (if (and (integerp new-value) (= new-value (- (length (contents-of collection)) 1))) (setf (slot-value collection 'end-index) new-value) (quail-error "This kind of collection must have end-index = ~s." (- (length (contents-of collection)) 1)))) (defmethod set-count-controls ((collection explicit-finite-collection)) (let ((n-1 (- (number-of-sets-in collection) 1))) (setf (count-start-of collection) 0) (setf (count-end-test-of collection) #'(lambda (collection current-index) (> current-index (end-index-of collection)))) (setf (count-increment-function-of collection) #'(lambda (collection current-index) (declare (ignore collection)) (+ current-index 1))) (setf (index-from-position-function-of collection) #'(lambda (position) (cond ((or (not (extended-integerp position)) (< position 0) (> position n-1)) (quail-error "No such position exists in the enumeration: ~s" position)) (T position)))) (setf (position-from-index-function-of collection) #'(lambda (index) (cond ((or (not (extended-integerp index)) (< index 0) (> index n-1)) (quail-error "No such index exists in the enumeration: ~s" index)) (T index))))) T) (defmethod number-of-sets-in ((collection explicit-finite-collection)) (let* ((b-i (begin-index-of collection)) (e-i (end-index-of collection)) (max-i (max b-i e-i)) (min-i (min b-i e-i))) (if (contents-of collection) (+ 1 (- max-i min-i)) 0))) (defmethod (setf contents-of) (new-value (collection explicit-finite-collection)) (if (typep new-value 'sequence) (let () (setf (slot-value collection 'contents) new-value) (reset-end-index collection) new-value) (quail-error "New-value for contents, ~s, is not of type sequence." new-value))) (defmethod (setf set-less-than-predicate-of) (new-value (collection explicit-finite-collection)) (cond ((null new-value) (setf (slot-value collection 'set-less-than-predicate) new-value)) ((typep new-value 'function) (setf (slot-value collection 'set-less-than-predicate) new-value)) ((and (typep new-value 'list) (eq (car new-value) 'lambda)) (setf (slot-value collection 'set-less-than-predicate) (function new-value))) ((symbolp new-value) (cond ((or (special-form-p new-value) (macro-function new-value)) (setf (slot-value collection 'set-less-than-predicate) (eval `(function (lambda (s1 s2) (funcall ,new-value s1 s2)))))) ((fboundp new-value) (setf (slot-value collection 'set-less-than-predicate) (symbol-function new-value))))) (T (quail-error "Not a function: ~s." new-value)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Overrides of some inherited methods follow. ;;; (defmethod combine-collections ((c1 explicit-finite-collection) (c2 explicit-finite-collection)) (let (new-contents new-collection sort-fun) (setf sort-fun (or (set-less-than-predicate-of c1) (set-less-than-predicate-of c2))) (setf new-contents (let ((cc1 (copy-seq (contents-of c1))) (cc2 (copy-seq (contents-of c2)))) (delete-duplicates (concatenate (type-of-seq cc1) cc1 cc2) ; :after initialize-instance :test #'same-set-p))) ; sorts if it's necessary (setf new-collection (make-instance 'explicit-finite-collection :contains-set-p-function #'(lambda (collection set) (find set (contents-of collection) :test #'same-set-p)) :disjoint? (if (and (not-disjoint-collection-p c1) (not-disjoint-collection-p c2)) NIL :unknown) :element-function #'(lambda (collection index) (elt (contents-of collection) index)) :set-less-than-predicate sort-fun :contents new-contents)) new-collection)) (defmethod index-of ((collection explicit-finite-collection) set) (position set (contents-of collection) :test #'same-set-p)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Some defgenerics for new operators on ;;; explicit-finite-collections ;;; (defgeneric reset-end-index (explicit-finite-collection) (:documentation "Resets the end-index-of the collection.") ) (defgeneric sorted-collection-p (explicit-finite-collection) (:documentation "Are the contents of the collection sorted?") ) (defgeneric add-sets (explicit-finite-collection &rest sets) (:documentation "Adds the specified sets to the collection (if not already in the collection).") ) (defgeneric remove-sets (explicit-finite-collection &rest sets) (:documentation "Removes the specified sets from the collection (if in the collection).") ) (defgeneric remove-sets-if (explicit-finite-collection test) (:documentation "Removes those sets from the collection for which application ~%~ of the test predicate returns T.") ) (defgeneric collection-sort (explicit-finite-collection &optional less-than-predicate) (:documentation "Destructively rearranges the order of the sets in the collection~%~ according to the less-than-predicate if supplied. ~%~ If predicate is not supplied, then ~%~ (set-less-than-predicate-of collection) is used. ~%~") ) (defgeneric delete-sets (explicit-finite-collection &rest sets) (:documentation "Deletes the specified set from the collection (if in the collection).~%~ A destructive version of remove-a-set.") ) (defgeneric delete-sets-if (explicit-finite-collection test) (:documentation "Deletes those sets from the collection for which application ~%~ of the test predicate returns T.~%~ A destructive version of remove-sets-if.") ) (defgeneric safe-collection-sort (explicit-finite-collection &optional less-than-predicate) (:documentation "Rearranges the order of the sets in the collection~%~ according to the less-than-predicate if supplied. ~%~ If predicate is not supplied, then ~%~ (set-less-than-predicate-of collection) is used. ~%~ (Non-destructive version of collection-sort.") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; And their methods ;;; (defmethod reset-end-index ((collection explicit-finite-collection)) (setf (end-index-of collection) (- (length (contents-of collection)) 1))) (defmethod sorted-collection-p ((collection explicit-finite-collection)) (if (set-less-than-predicate-of collection) T NIL)) (defmethod add-sets ((collection explicit-finite-collection) &rest sets) (if sets (let ((base-seq (contents-of collection))) (setf (contents-of collection) (delete-duplicates (if (sorted-collection-p collection) (merge (type-of-seq base-seq) base-seq sets (set-less-than-predicate-of collection)) (concatenate (type-of-seq base-seq) base-seq sets)) :test #'same-set-p)) collection))) (defmethod remove-sets ((collection explicit-finite-collection) &rest sets) (loop for set in sets with base-seq = (contents-of collection) do (setf base-seq (remove set base-seq)) finally (setf (contents-of (copy-set collection)) base-seq)) collection) (defmethod remove-sets-if ((collection explicit-finite-collection) test) (setf (contents-of collection) (remove-if test (contents-of (copy-set collection)))) collection) (defmethod collection-sort ((collection explicit-finite-collection) &optional (less-than-predicate (set-less-than-predicate-of collection))) (setf (contents-of collection) (sort (contents-of collection) less-than-predicate)) (setf (set-less-than-predicate-of collection) less-than-predicate) collection) (defmethod delete-sets ((collection explicit-finite-collection) &rest sets) (loop for set in sets with base-seq = (contents-of collection) do (setf base-seq (delete set base-seq)) finally (setf (contents-of collection) base-seq)) collection) (defmethod delete-sets-if ((collection explicit-finite-collection) test) (setf (contents-of collection) (delete-if test (contents-of collection))) collection) (defmethod safe-collection-sort ((collection explicit-finite-collection) &optional (less-than-predicate (set-less-than-predicate-of collection))) (let ((copy-of-contents (copy-seq (contents-of collection)))) (setf (contents-of collection) (sort copy-of-contents less-than-predicate)) (setf (set-less-than-predicate-of collection) less-than-predicate) collection))
47,429
Common Lisp
.l
1,073
32.643989
100
0.530625
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
12585cd45d559874e3423179e70697298903e325da4b2d04b0b0652a096e27fa
33,419
[ -1 ]
33,420
borel-special.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-special.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; borel-special.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990, 1992. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; SPECIAL BOREL SET FUNCTIONS ;;; ;;; In this file special Borel-Set operators are defined. ;;; (defun extended-realp (x) "Returns T if the argument is a real number, NIL otherwise." (or (eq infinity x) (eq +infinity x) (eq -infinity x) (realp x))) (defun extended-integerp (x) "Returns T if the argument is a integer, NIL otherwise." (or (eq infinity x) (eq +infinity x) (eq -infinity x) (integerp x))) (defun extended-rationalp (x) "Returns T if the argument is a rational number, NIL otherwise." (or (not (eq infinity x)) (not (eq +infinity x)) (not (eq -infinity x)) (rationalp x))) (defun naturalp (x) "Returns T if the argument is a natural number, NIL otherwise." (and (integerp x) (>= x 0))) (defun extended-naturalp (x) "Returns T if the argument is a natural number, NIL otherwise." (or (not (eq infinity x)) (not (eq +infinity x)) (naturalp x))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Some interesting defining predicates ;;; ;;; (defun extended-reals-defining-predicate (set member) (declare (ignore set)) (extended-realp member)) (defun extended-rationals-defining-predicate (set member) (declare (ignore set)) (extended-rationalp member)) (defun extended-integers-defining-predicate (set member) (declare (ignore set)) (extended-integerp member)) (defun extended-naturals-defining-predicate (set member) (declare (ignore set)) (extended-naturalp member)) (defun reals-defining-predicate (set member) (declare (ignore set)) ;(realp member) (and (numberp member) (not (complexp member)))) (defun rationals-defining-predicate (set member) (declare (ignore set)) (rationalp member)) (defun integers-defining-predicate (set member) (declare (ignore set)) (integerp member)) (defun naturals-defining-predicate (set member) (declare (ignore set)) (naturalp member))
2,531
Common Lisp
.l
78
28.269231
86
0.568887
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
9ee96037ba552d54b37113326a55f32760dc531f3925baf7bf771264547a123a
33,420
[ -1 ]
33,421
borel-examples.lsp
rwoldford_Quail/source/mathematics/borel-sets/borel-examples.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Borel-Examples.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1990 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1990. ;;; ;;; ;;;---------------------------------------------------------------------------------- ;;; ;;; EXAMPLES OF BOREL-SETS ;;; ;;; In this file examples of familiar borel-sets are constructed. ;;; Some of these have been constructed elsewhere and assigned to global ;;; constants. ;;; ;;;---------------------------------------------------------------------------------- ;;;---------------------------------------------------------------------------------- ;;; ;;; Some typical intervals ;;; ;;;---------------------------------------------------------------------------------- ;;; [-1,1] (setf a (make-instance 'interval :infimum -1 :supremum 1 :closure-property :closed)) ;;; (-1,1) (setf b (make-instance 'interval :infimum -1 :supremum 1 :closure-property :open)) ;;; or (-1,1) again (setf b (make-instance 'interval :infimum -1 :supremum 1)) ; default is open ;;; [0.5, 3) (setf c (make-instance 'interval :infimum 0.5 :supremum 3 :closure-property :closed-left)) ;;; [0.5,1) (setf d (set-intersection b c)) ; by intersection ;;; ;;;------------------------------------------------------------------------------------------ ;;; ;;; An explicit-finite-set ;;; ;;;------------------------------------------------------------------------------------------ ;;; { 0, 1, 3, 2, 4, 10} (setf ef1 (make-instance 'explicit-finite-set :contents '(0 1 3 2 4 10))) ;;;---------------------------------------------------------------------------------- ;;; ;;; REALS ;;; ;;;---------------------------------------------------------------------------------- (setf real-nos (make-instance 'interval :infimum -infinity :supremum +infinity)) ;;; or (setf extended-reals (make-instance 'interval :infimum -infinity :supremum +infinity :closure-property :both)) ;;; or (setf extended-reals-too (make-instance 'predicate-set :closure-property :both :defining-predicate #'(lambda (set value) (declare (ignore set)) (extended-realp value)))) ;;;---------------------------------------------------------------------------------- ;;; ;;; The EXTENDED INTEGERS ;;; ;;; {-infinity, ..., -2, -1, 0, 1, 2, ..., +infinity} ;;; ;;;---------------------------------------------------------------------------------- (setf the-extended-integers (make-instance 'countable-set :infimum -infinity :supremum +infinity :begin-index -infinity :end-index +infinity :closure-property :closed :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'(lambda (set test-member) (declare (ignore set)) (extended-integerp test-member)))) ;;;----------------------------------------------------------------------------------------- ;;; ;;; The NATURAL-NUMBERS ;;; ;;; {0,1, 2, 3, 4, ...} ;;; ;;; An countably-infinite-increasing-set because they are COUNTED in increasing order. ;;;----------------------------------------------------------------------------------------- (setf natural-numbers (make-instance 'countable-set :infimum 0 :supremum +infinity :begin-index 0 :end-index +infinity :element-function #'(lambda (set index) (declare (ignore set)) index) :defining-predicate #'(lambda (set test-member) (declare (ignore set)) (and (extended-integerp test-member) (> test-member 0))))) ;;;----------------------------------------------------------------------------------------- ;;; ;;; The UNIQUE FIBONACCI NUMBERS ;;; ;;; {1, 2, 3, 5, 8, 13, ...} ;;; ;;; An countably-infinite-increasing-set because they are COUNTED in increasing order. ;;;----------------------------------------------------------------------------------------- (setf unique-fibonacci-numbers (make-instance 'countable-set :infimum 1 :supremum +infinity :begin-index 0 :end-index +infinity :element-function #'(lambda (set index) (cond ((= index 0) 1) ((= index 1) 2) ((= index +infinity) +infinity) (T (+ (element set (- index 1)) (element set (- index 2)))))) ) ) ;;; or better (setf unique-fibonacci-numbers (make-instance 'countable-set :infimum 1 :supremum +infinity :begin-index 0 :end-index +infinity :element-function #'(lambda (set index) (cond ((= index +infinity) +infinity) (T (+ (element set (- index 1)) (element set (- index 2)))))) ) ) ;;;----------------------------------------------------------------------------------------- ;;; ;;; The Cantor Ternary Set ;;; ;;;----------------------------------------------------------------------------------------- (setf cantor-set (make-instance 'predicate-set :closure-property :closed :defining-predicate #'(lambda (set value) (cond ((< 0 value) NIL) ((> value 1) NIL) (T (loop for i from 1 by 1 with big-count = *max-reasonable-number-of-iterations* do (if (= 1 (ternary-expansion value i)) (return NIL) (if (> i big-count) ;; . query user, ;; . increase big-count, ;; . et cetera. )))))) ) ) ;;;------------------------------------------------------------------------------------------ ;;; ;;; An F-SIGMA Set ;;; ;;;------------------------------------------------------------------------------------------ (setf open-3-4-as-F-sigma (make-instance 'countable-union :from 1 :to +infinity :element-function #'(lambda (union index) (make-instance 'interval :closure-property :closed :infimum (+ 3 (/ 1 index)) :supremum (- 4 (/ 1 index)))) :closure-property :open) ) (describe (copy-set open-3-4-as-F-sigma)) ;;; ;;; BTW ;;; ;;; (element open-3-4-as-F-sigma +infinity) ;;; ;;; ==> [3,4] ;;; ;;; ... too bad, ;;; close though! ;;;------------------------------------------------------------------------------------------ ;;; ;;; Similarly G-DELTA Sets could be defined. ;;; (countable-unions of open sets) ;;; ;;;------------------------------------------------------------------------------------------
8,086
Common Lisp
.l
236
24.991525
94
0.342425
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
a425638b3ee2b0abd7dd64e01f2d604bdbe6e07a2d4413441f5cc616cff9f8d0
33,421
[ -1 ]
33,422
measures.lsp
rwoldford_Quail/source/mathematics/measures/measures.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; measures.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; ;;;-------------------------------------------------------------------------------- (in-package :quail) (defclass measure ((support :reader support-of :allocation :class :initform "Need a form to produce the set of values having positive probability mass." :documentation "Set of all values having positive probability mass.")) ()) (defmethod measure ((set borel-set) (measure measure)) (missing-method measure 'measure)) (defmethod measure ((measure measure) (set borel-set)) (measure set measure)) (defclass lebesgue-measure (measure) ()) (defmethod measure ((set interval) (measure lebesgue-measure)) (- (supremum set) (infimum set))) (defclass counting-measure (measure) ()) (defmethod measure ((set countable-set) (measure counting-measure)) (size set)) (defclass prob-measure (measure) ((support :reader support-of :allocation :class :initform "Need a form to produce the set of values having positive probability mass." :documentation "Set of all values having positive probability mass.") (distribution :initarg :cdf :reader distribution-of) (density :initarg :pdf :reader density-of) (characteristic-function :initarg :c-theta :reader characteristic-function-of))) (defmethod prob ((a borel-set) (dF prob-measure)) (measure a dF)) (defmethod prob ((dF prob-measure) (a borel-set)) (prob a dF)) (defmethod rand ((p prob-measure)) (missing-method p 'rand)) (defmethod cdf ((self prob-measure) x) (declare (special -infinity)) (prob (make-interval -infinity x) self)) (defmethod pdf ((self prob-measure) x) (missing-method self 'pdf))
2,185
Common Lisp
.l
60
30.766667
87
0.566047
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
57b943f60faf20ce0f29de70243b0177bc7bdac3584b6b7a26b1dc3ff9bb1ba8
33,422
[ -1 ]
33,423
graphs.lsp
rwoldford_Quail/source/mathematics/graph-theory/graphs.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; graphs.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (C) 2001 Statistical Computing Laboratory, University Of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 2001. ;;; ;;; ;;;---------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(vertex make-vertex edge make-edge make-planar-graph planar-graph add-edge remove-edge add-vertex remove-vertex directed-edge edges-of vertices-of graph-value-of start-of-edge end-of-edge travelled-edge-p mark-edge-travelled mark-edge-untravelled number-of-edges-of number-of-vertices-of connected-vertices-p connect-vertices make-complete-graph determine-graph-from) )) (defgeneric add-edge (graph-thing edge) (:documentation "Adds the edge to some kind of graph (sub)structure.") ) (defgeneric remove-edge (graph-thing edge) (:documentation "Removes the edge to some kind of graph (sub)structure.") ) (defgeneric add-vertex (graph-thing vertex) (:documentation "Adds the vertex to some kind of graph (sub)structure.") ) (defgeneric remove-vertex (graph-thing vertex) (:documentation "Removes the vertex to some kind of graph (sub)structure.") ) (defgeneric number-of-vertices-of (graph-thing) (:documentation "Returns the number of vertices of a graph (sub)structure.") ) (defgeneric number-of-edges-of (graph-thing) (:documentation "Returns the number of edges of a graph (sub)structure.") ) ;;;;;;; ;;; ;;; Classes ;;; (defclass vertex () ((edges :initform NIL :initarg :edges :accessor edges-of :documentation "The edges connected to this vertex.") (graph-value :initform NIL :initarg :graph-value :accessor graph-value-of :documentation "A place to store an arbitrary value associated ~ with this vertex.") ) (:documentation "A class structure representing a vertex (or node) in a planar graph.") ) (defun make-vertex (&key (graph-value NIL) (edges NIL)) "Creates and returns a vertex." (let ((vertex (make-instance 'vertex :graph-value graph-value :edges edges)) ) (loop for edge in edges do (add-vertex edge vertex)) vertex) ) (defclass edge () ((vertices :initform NIL :initarg :vertices :accessor vertices-of :documentation "The vertices connected by this edge.") (graph-value :initform NIL :initarg :graph-value :accessor graph-value-of :documentation "A place to store an arbitrary value associated ~ with this edge.") (travelled? :initform NIL :initarg :travelled? :accessor travelled-edge-p :documentation "A place to store a flag to indicate whether this ~ edge has been travelled by some path. Useful for marking~ paths in a graph.") ) (:documentation "A class structure representing an edge in a planar graph.") ) (defun make-edge (&key (graph-value NIL) (vertices NIL)) "Creates and returns a graph edge." (let ((edge (make-instance 'edge :graph-value graph-value :vertices vertices)) ) (loop for vertex in vertices do (add-edge vertex edge)) edge) ) (defun mark-edge-travelled (edge) "As the name suggests, this function marks the edge as having ~ been travelled." (setf (travelled-edge-p edge) T)) (defun mark-edge-untravelled (edge) "As the name suggests, this function marks the edge as NOT having ~ been travelled, i.e. as having been untravelled." (setf (travelled-edge-p edge) NIL)) (defclass directed-edge (edge) ((from :initform NIL :initarg :from :accessor start-of-edge :documentation "The vertex at the start of by this directed edge.") (to :initform NIL :initarg :to :accessor end-of-edge :documentation "The vertex at the end of by this directed edge.") ) (:documentation "A class structure representing a directed edge in a planar graph.") ) (defmethod initialize-instance :after ((self directed-edge) &key from to vertices) (cond ((and vertices from to) (unless (eq (first vertices) from) (setf (first vertices) from)) (unless (eq (second vertices) to) (setf (second vertices) to)) ) ((and from to) (setf (first vertices) from) (setf (second vertices) to) ) ((and vertices (null from) (null to)) (setf from (first vertices)) (setf to (second vertices)) ) ((and vertices from (null to)) (setf vertices (remove from vertices)) (if (/= 1 (length vertices)) (quail-error "~&Vertex information is inconsistent.")) (setf to (first vertices)) (setf vertices (list from to))) ((and vertices to (null from)) (setf vertices (remove to vertices)) (if (/= 1 (length vertices)) (quail-error "~&Vertex information is inconsistent.")) (setf from (first vertices)) (setf vertices (list from to))) (T (quail-error "~&Vertex information is inconsistent.")) ) (setf (vertices-of self) vertices) (setf (start-of-edge self) from) (setf (end-of-edge self) from) ) (defclass planar-graph () ((vertices :initform NIL :initarg :vertices :accessor vertices-of :documentation "The vertices contained in this planar-graph.") (edges :initform NIL :initarg :edges :accessor edges-of :documentation "The edges contained in this planar-graph.") ) (:documentation "A class structure representing a planar graph.") ) (defun make-planar-graph (&key (vertices NIL) (edges NIL)) "Creates and returns a planar-graph." (make-instance 'planar-graph :edges edges :vertices vertices) ) ;;;;;; ;;; ;;; Methods ;;; (defmethod add-edge :around (graph-thing (edge edge)) (unless (member edge (edges-of graph-thing)) (call-next-method))) (defmethod add-edge ((vertex vertex) (edge edge)) (push edge (edges-of vertex))) (defmethod add-edge ((graph planar-graph) (edge edge)) (push edge (edges-of graph))) ;;; (defmethod remove-edge ((vertex vertex) (edge edge)) (setf (edges-of vertex) (remove edge (edges-of vertex))) ) (defmethod remove-edge ((graph planar-graph) (edge edge)) (setf (edges-of graph) (remove edge (edges-of graph))) ) ;;; (defmethod add-vertex :around (graph-thing (vertex vertex)) (unless (member vertex (vertices-of graph-thing)) (call-next-method))) (defmethod add-vertex ((edge edge) (vertex vertex)) (push vertex (vertices-of edge))) (defmethod add-vertex ((graph planar-graph) (vertex vertex)) (push vertex (vertices-of graph))) ;;; (defmethod remove-vertex ((edge edge) (vertex vertex)) (setf (vertices-of edge) (remove vertex (vertices-of edge))) ) (defmethod remove-vertex ((graph planar-graph) (vertex vertex)) (setf (vertices-of graph) (remove vertex (vertices-of graph))) ) ;;; (defmethod number-of-vertices-of ((graph planar-graph)) "Returns the number of vertices in the given graph." (length (vertices-of graph))) (defmethod number-of-vertices-of ((edge edge)) "Returns the number of vertices connected in the given edge." (length (vertices-of edge))) ;;; (defmethod number-of-edges-of ((graph planar-graph)) "Returns the number of edges in the given graph." (length (edges-of graph))) (defmethod number-of-edges-of ((vertex vertex)) "Returns the number of edges at the given vertex." (length (edges-of vertex))) ;;; (defun determine-graph-from (start) "Beginning at the graph-element start, connections are followed ~ to termination to produce the entire collection of vertices and ~ edges which are connected to one another and to the start element.~ A planar-graph object is returned containing the vertices and edges ~ which were found." (let (vertices-found edges-found) (labels ((chase-down-edges (vertex) (let ((new-edges (loop for e in (edges-of vertex) unless (member e edges-found) collect e))) (loop for e in new-edges do (push e edges-found)) (loop for e in new-edges do (chase-down-vertices e)) ) ) (chase-down-vertices (edge) (let ((new-vertices (loop for v in (vertices-of edge) unless (member v vertices-found) collect v))) (loop for v in new-vertices do (push v vertices-found)) (loop for v in new-vertices do (chase-down-edges v)) ) ) ) (cond ((typep start 'vertex) (setf vertices-found (list start)) (chase-down-edges start) ) ((typep start 'edge) (setf edges-found (list start)) (chase-down-vertices start) ) ) (make-instance 'planar-graph :edges edges-found :vertices vertices-found) ) ) ) ;;; Other functions (defun connected-vertices-p (vertex1 vertex2) "Returns list of common edges if an edge exists joining vertex1 and vertex2, NIL otherwise." (intersection (edges-of vertex1) (edges-of vertex2) :test #'(lambda (e1 e2) (or (eq e1 e2) (and (member vertex1 (vertices-of e1)) (member vertex1 (vertices-of e2)) (member vertex2 (vertices-of e1)) (member vertex2 (vertices-of e2))) ) ) ) ) (defun connect-vertices (vertex1 vertex2 &key (edge-value NIL)) "Makes an edge and connects the two vertices with this edge ~ (having value of edge-value). ~ Returns the edge which makes the connection." (let ((edge (make-edge :vertices (list vertex1 vertex2) :graph-value edge-value))) (add-edge vertex1 edge) (add-edge vertex2 edge) edge)) (defun complete-graph! (planar-graph) "Takes a planar graph and adds edges until the graph is complete, that is ~ until every vertex is connected to every other vertex. Changes the original ~ graph and returns it." (let ((vertices (vertices-of planar-graph)) other-vertices edge edges ) (loop for vertex in vertices do (setf other-vertices (remove vertex vertices)) (loop for ov in other-vertices unless (connected-vertices-p vertex ov) do (setf edge (connect-vertices vertex ov)) (push edge edges) ) ) (loop for e in edges do (add-edge planar-graph e)) planar-graph)) (defun make-complete-graph (items) "From any number of values to be associated with vertices, ~ creates and returns a planar-graph in which every vertex is ~ connected to every other vertex." (let ((vertices (loop for item in items collect (make-vertex :graph-value item))) ) (complete-graph! (make-planar-graph :vertices vertices))))
11,927
Common Lisp
.l
316
29.775316
95
0.604933
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
2a0bd2ab9cb4288ead77baa5936c90031df2b4ce0756dd154fe6f95b606d540e
33,423
[ -1 ]
33,424
euler.lsp
rwoldford_Quail/source/mathematics/graph-theory/euler.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; euler.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (C) 2001 Statistical Computing Laboratory, University Of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 2001. ;;; ;;; ;;;---------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(extend-complete-graph-to-euler get-euler-trail euler-pairwise-order mirror-euler-pairwise-order))) (defun extend-complete-graph-to-euler (complete-graph) "Adds sufficient edges to the complete graph such that the ~ number of edges at each vertex is even." (let ((vertices (vertices-of complete-graph)) edges ) (loop for v in vertices unless (evenp (number-of-edges-of v)) do (let ((connection-made? NIL) (other-vertices (remove v vertices)) edge) (loop until connection-made? for ov in other-vertices unless (evenp (number-of-edges-of ov)) do (setf connection-made? T) (setf edge (connect-vertices v ov)) (push edge edges)) ) ) (loop for e in edges do (add-edge complete-graph e)) complete-graph)) (defun get-euler-trail (planar-graph &key (start NIL) (comparison-fn NIL)) ;; Error checking. (let ((vertices (vertices-of planar-graph)) returned-vertices (remaining-edges (copy-list (edges-of planar-graph))) next-route current-node) (unless (reduce #'(lambda (x y) (and x (evenp (number-of-edges-of y))) ) vertices :initial-value T) (quail-error "No Euler trail exists because there are vertices ~ in the graph which have an odd number of edges ~ associated with them.") ) (unless (member start (vertices-of planar-graph)) (setf start (first (vertices-of planar-graph)))) (unless (functionp comparison-fn) (setf comparison-fn (function (lambda (a b) (declare (ignore a b)) 1))) ) ;; Here comes the algorithm (labels ;; some helper functions ((collect-eligible-routes (node) (loop for edge in (edges-of node) unless (travelled-edge-p edge) collect edge)) (number-of-eligible-routes (node) (length (collect-eligible-routes node))) (destination-of (edge from) (let ((remaining-vertices (remove from (vertices-of edge)))) (if (= 1 (length remaining-vertices)) (first remaining-vertices) remaining-vertices))) (find-best-route (available-routes from) (let (best-route) (setf available-routes (loop for route in available-routes for dest = (destination-of route from) unless (and (eq dest start) (= 1 (number-of-eligible-routes start)) (setf best-route route)) collect route)) (if (null available-routes) best-route (reduce #'(lambda (a b) (if (<= (graph-value-of a) (graph-value-of b)) a b)) available-routes) ) ) ) ) ;; Initialization (loop for edge in remaining-edges unless (graph-value-of edge) do (setf (graph-value-of edge) (apply comparison-fn (mapcar #'graph-value-of (vertices-of edge))))) (setf current-node start) (push current-node returned-vertices) ;; Here goes the traversal (loop until (null remaining-edges) do (setf next-route (find-best-route (collect-eligible-routes current-node) current-node) ) (mark-edge-travelled next-route) (setf current-node (destination-of next-route current-node)) (setf remaining-edges (remove next-route remaining-edges)) (push current-node returned-vertices) ) (reverse returned-vertices) ) ) ) ;;; ;;; ;;; Putting it together to give an Euler pairwise ordering ;;; (defun euler-pairwise-order (items &key (comparison-fn) (start NIL)) "Returns a list of the items repeated so that each item in items~ repeated often enough so ~ that every pair of items occur beside one another (and no oftener). ~ Choice of ordering will depend upon the comparison-fn. The ~ comparison-fn is a function which can be called on any ~ two items and which will return a numerical score where two items ~ are considered closer or more similar if the score is smaller and ~ the opposite if it is larger. If supplied, start is that element (eq) of items ~ from which the Euler trail is to start (and finish). ~ Returns multiple-values: euler trail of original items, ~ euler-trail of vertices in the graph, the planar-graph itself." (let* ((planar-graph (make-complete-graph items)) (euler-graph (extend-complete-graph-to-euler planar-graph)) start-vertex euler-trail return-values) (when start (setf start-vertex (find start (vertices-of euler-graph) :test #'(lambda (x y) (or (equal x (graph-value-of y)) (and (numberp x) (numberp (graph-value-of y)) (= x (graph-value-of y)) )))))) (setf euler-trail (get-euler-trail euler-graph :comparison-fn comparison-fn :start start-vertex)) (setf return-values (mapcar #'graph-value-of euler-trail )) (values return-values euler-trail euler-graph ) ) ) (defun mirror-euler-pairwise-order (items &key (comparison-fn NIL) (start NIL) (mirror-fn #'(lambda (x) (list :mirror x))) (match-fn #'(lambda (x y) (cond ((and x (listp x) (eq (first x) :mirror)) (setf x (second x))) ((and y (listp y) (eq (first y) :mirror)) (setf y (second y))) ) (equal x y)) ) ) "Like euler-pairwise-order except that each item in items has a mirrored ~ version found by calling mirror-fn on it. The original item and its ~ mirrored version are recognized as a match by funcalling the match-fn ~ on both. Default mirroring matches item with the list (:mirror item). ~%~ Returns an euler pairwise list of the combined items and mirrored-items ~ with the exception that no item is beside its mirrored self. ~ Otherwise the returned list is such that each item~ in the combined list is repeated often enough so ~ that every pair of items occur beside one another (and no oftener). ~ Choice of ordering will depend upon the comparison-fn. The ~ comparison-fn is a function which can be called on any ~ two items and which will return a numerical score where two items ~ are considered closer or more similar if the score is smaller and ~ the opposite if it is larger. If supplied, start is that element (eq) of ~ combined items from which the Euler trail is to start (and finish). ~%~ Returns multiple-values: euler trail of original items, ~ euler-trail of vertices in the graph, the planar-graph itself. ~ (:see-also (euler-pairwise-order :function))" (let* ((new-items (append items (loop for item in items collect (funcall mirror-fn item)))) (planar-graph (make-complete-graph new-items)) euler-graph euler-trail return-values start-vertex ) (when start (setf start-vertex (find start (vertices-of euler-graph) :test #'(lambda (x y) (or (equal x (graph-value-of y)) (and (numberp x) (numberp (graph-value-of y)) (= x (graph-value-of y)) )))))) ;; remove mirrored edges (loop for edge in (edges-of planar-graph) for v1 = (first (vertices-of edge)) for v2 = (second (vertices-of edge)) when (funcall match-fn (graph-value-of v1) (graph-value-of v2)) do (remove-edge v1 edge) (remove-edge v2 edge) (remove-edge planar-graph edge) ) (setf euler-graph (extend-complete-graph-to-euler planar-graph)) (setf euler-trail (get-euler-trail euler-graph :comparison-fn comparison-fn :start start-vertex)) (setf return-values (mapcar #'graph-value-of euler-trail)) (values return-values euler-trail euler-graph) ) ) #| (euler-pairwise-order '(a b c d e)) (loop for item in '(a b c d e) collect (euler-pairwise-order '(a b c d e) :start item)) (euler-pairwise-order '(a b c d e) :start 'c) (mirror-euler-pairwise-order '(a b c d e)) (mirror-euler-pairwise-order '(1 2 3 4 5) :mirror-fn #'- :match-fn #'(lambda (x y) (= x (- y))) ) (setf items (append (iseq 1 5) (mapcar #'- (iseq 1 5)))) (setf planar-graph (make-complete-graph items)) (loop for edge in (edges-of planar-graph) for v1 = (first (vertices-of edge)) for v2 = (second (vertices-of edge)) when (= (graph-value-of v1) (- (graph-value-of v2))) do (remove-edge v1 edge) (remove-edge v2 edge) (remove-edge planar-graph edge) ) (inspect planar-graph) (setf euler-graph (extend-complete-graph-to-euler planar-graph)) (mapcar #'graph-value-of (get-euler-trail euler-graph)) (equal '(1 2) (reverse '(2 1))) |#
11,315
Common Lisp
.l
281
27.55516
85
0.519339
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
a4d64eb32863487cf8d642382ca5c4c7519162a589f768197b0bd450acbf2a6a
33,424
[ -1 ]
33,425
surface-plot.lsp
rwoldford_Quail/source/mathematics/graphics/surface-plot.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; surface-plot.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is an addition to Window-basics for moving pointclouds ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992 ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(surface-plot))) (defclass surface-plot (plot) ;; kind-of rotating-plot? ((controls :initform nil :accessor controls-of :initarg :controls)) ;; short-circuit general initialization for data scheme (:default-initargs :initform-fn NIL )) ;;; Potentially different initialization scheme #| #'surface-data-init) ) (defun surface-data-init (&key (data :prompt) (x :prompt) (y :prompt) (surface-heights :prompt) (surface-function :prompt) &allow-other-keys) "Initializes the surface data for a surface-plot. ~ (:key ~ (:arg surface :prompt The surface object to be produced.) (:arg data :prompt A dataset used to choose the x and y coordinates of the surface.) ~ (:arg x :prompt A 1-dimensional array of the x-coordinates of the surface. ~ Or if data is a dataset, this ) ~ (:arg y :prompt A 1-dimensional array of the x-coordinates of the surface.) ~ (:arg surface-heights :prompt A 1-dimensional array containing the height of the surface at ~ every x y pair. The number of elements in surface-heights is the ~ product of the number of elements in x and y. The elements ~ themselves are arranged varying the elements of y fastest.) (:arg surface-function NIL If given a function which when called on each x y pair ~ will return the corresponding value of surface-heights.) ~ Keyword argument data could be a dataset and X and Y indices into the dataset.~ Or x and y are 1-dimensional arrays which identify the x and y grid points ~ of the surface. ~ Surface-heights is a vectoand either X or Y are :prompt (the default),~ the user is prompted to provide a dataset.~ If X is :prompt the user is prompted for an X variable.~ If Y is :prompt the user is prompted for a Y variable.~ If no dataset has been specified, the make-dataset-from-vars function ~ is used to build a dataset from X and Y, and X and Y becomes the first ~ and second indices into the dataset obtained by applying the ~ list-variates function to the dataset." |# (defun surface-plot (&rest keyword-pairs &key surface data x y surface-heights surface-function (draw? T)) "Creates and returns a surface plot object suitable for use in ~ surface view. ~ (:rest ~ (:arg keyword-pairs NIL Additional optional initialization keyword arguments.)) ~ (:key ~ (:arg surface NIL The surface object to be produced.) (:arg data NIL A dataset used to choose the x and y coordinates of the surface.) ~ (:arg x NIL A 1-dimensional array of the x-coordinates of the surface.) ~ (:arg y NIL A 1-dimensional array of the x-coordinates of the surface.) ~ (:arg surface-heights NIL A 1-dimensional array containing the height of the surface at ~ every x y pair. The number of elements in surface-heights is the ~ product of the number of elements in x and y. The elements ~ themselves are arranged varying the elements of y fastest.) (:arg surface-function NIL If given a function which when called on each x y pair ~ will return the corresponding value of surface-heights.) ~ (:arg draw? T If non-NIL the surface plot is drawn in a window.) ~ )" (unless surface (if (null x) (if (null data) (setq x (choose-dataset "Enter the x-grid array.")) (setq x (choose-variable data 1 "Choose X variable")))) (if (null y) (if (null data) (setq y (choose-dataset "Enter the y-grid array.")) (setq y (choose-variable data 1 "Choose Y variable")))) (setf surface (surface x y :surface-heights surface-heights :surface-function surface-function ))) (let ((surface-plot (apply #'make-surface-plot 'surface-plot :surface surface keyword-pairs))) (if draw? (draw-view surface-plot)) surface-plot)) (eval-when (load eval) (setf (symbol-function 'vw::surface-plot) #'surface-plot)) (defun make-surface-plot (plot &rest keyword-pairs) (apply #'make-instance plot keyword-pairs)) (defmethod construct-sub-views ((self surface-plot) &rest keyword-pairs &key color-table fast-color-table surface ) (setf (interior-view-of self) (apply #'make-instance 'surface-view :color-table color-table :fast-color-table fast-color-table :surface surface :viewed-object surface keyword-pairs)) (setf (controls-of self) (rotate-controls :target (interior-view-of self) ))) (defmethod init-position-subviews ((self surface-plot) &key (panel-size 0.1)) (let ((space-left (make-region (subview-position-region self)))) (place-subview self (controls-of self) (sub-region space-left :w :width panel-size :remains space-left)) (place-subview self (interior-view-of self) space-left)))
6,224
Common Lisp
.l
133
37.135338
97
0.57966
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
0292d44a4eb4fab423181fdbe1a9c8b39d465dd7808027fe420126ffd50f06c6
33,425
[ -1 ]
33,426
rotate-surface.lsp
rwoldford_Quail/source/mathematics/graphics/rotate-surface.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; rotate-surface.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) 1992 ;;; Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; R.W. Oldford 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(rotate-surface set-increment))) (defmethod set-increment ((self surface-view) val) (case val (:faster (setq val (* (vw::increment-of self) 1.5))) (:slower (setq val (/ (vw::increment-of self) 1.5))) (t nil)) (setf (vw::increment-of self) val)) (defmethod views::move-points ((self surface-view) &rest args ) (apply #'rotate-surface self args)) (defmethod stop-rotate ((self surface-view)) (if (wb:mouse-down-p) #'(lambda() (not (wb:mouse-down-p))) #'(lambda() (wb:mouse-down-p)))) (defmethod rotate-surface ((self surface-view) &key viewport (direction :y) (steps 1000) (increment (vw::increment-of self)) ) (unless viewport (setq viewport (if (> (length (viewports-of self)) 1) (which-viewport self) (car (viewports-of self))))) (sleep 0.25) (if (and viewport (not (moving-p self)) (active-viewport-p viewport)) (let* ((stop-fn (stop-rotate self)) (color-table (fast-color-table-of self)) (hide? (hidden-lines-p self viewport)) (depth-cue? (depth-cue-p self viewport)) (fill? (surface-fill-p self viewport)) (canvas (window-of viewport)) (sx (cdr (assoc viewport (vp-x-of self)))) (sy (cdr (assoc viewport (vp-y-of self)))) (old-x (cdr (assoc viewport (vp-old-x-of self)))) (old-y (cdr (assoc viewport (vp-old-y-of self)))) (cx (x-cache-of self)) (cy (y-cache-of self)) (cz (z-cache-of self)) (szv (cdr (assoc viewport (vp-z-pos-pars-of self)))) (col (cdr (assoc viewport (vp-col-pars-of self)))) (ncol (number-of-colors-of self)) (range (truncate (* (screen-range-of self) (sqrt 3)))) (colrange (/ ncol 2 range)) (a (cdr (assoc viewport (vp-rotation-of self)))) (ax (update-scratch-x-of self)) (ay (update-scratch-y-of self)) (lower-y (cdr (assoc viewport (vp-lower-y-of self)))) (upper-y (cdr (assoc viewport (vp-upper-y-of self)))) (dim-x (number-of-elements cx)) (dim-y (number-of-elements cy)) (dim-z (number-of-elements cz)) (max-x (width-of viewport)) (max-y (height-of viewport)) (vp-left (+ 1 (left-of viewport))) (vp-bottom (+ 1 (bottom-of viewport))) (dl (cdr (assoc viewport (vp-draw-line-of self)))) (nl (cdr (assoc viewport (vp-num-lines-of self)))) (cos-theta (cos increment)) (sin-theta (sin increment)) (old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0)) (y-origin (bottom-of viewport)) (x-origin (left-of viewport)) (spin-orientation (spin-orientation-of self)) ) (when (not (functionp stop-fn)) (setq stop-fn #'(lambda () NIL))) (unwind-protect (progn (setf (moving-p self) t) (case spin-orientation (:surface (loop for i from 1 to steps until (funcall stop-fn) do (case direction (:x (wb::spin-surface-x a cos-theta sin-theta old-a)) (:y (wb::spin-surface-y a cos-theta sin-theta old-a)) (:z (wb::spin-surface-z a cos-theta sin-theta old-a))) (wb::update-surface-data cx cy cz a sx sy old-x old-y szv ax ay col dim-x dim-y dim-z max-x max-y range ncol) (cond (fill? (wb:canvas-clear canvas :canvas-left vp-left :canvas-bottom vp-bottom :width max-x :height max-y) (wb:fast-surface-fill canvas x-origin y-origin sx sy cz szv col ncol (* (aref a 8) colrange) color-table) (when hide? (wb:fast-hide-lines canvas sx sy cz lower-y upper-y dl nl szv x-origin y-origin max-x max-y a col ncol (* (aref a 8) colrange) NIL color-table) ) ) (hide? (wb:canvas-clear canvas :canvas-left vp-left :canvas-bottom vp-bottom :width max-x :height max-y) (wb:fast-hide-lines canvas sx sy cz lower-y upper-y dl nl szv x-origin y-origin max-x max-y a col ncol (* (aref a 8) colrange) depth-cue? color-table)) (T (wb:fast-show-lines canvas x-origin y-origin old-x old-y cz szv col ncol (* (aref a 8) colrange) NIL T color-table) (wb:fast-show-lines canvas x-origin y-origin sx sy cz szv col ncol (* (aref a 8) colrange) depth-cue? NIL color-table))) )) (:screen (loop for i from 1 to steps until (funcall stop-fn) do (case direction (:x (wb::spin-screen-x a cos-theta sin-theta old-a)) (:y (wb::spin-screen-y a cos-theta sin-theta old-a)) (:z (wb::spin-screen-z a cos-theta sin-theta old-a))) (wb::update-surface-data cx cy cz a sx sy old-x old-y szv ax ay col dim-x dim-y dim-z max-x max-y range ncol) (cond (fill? (wb:canvas-clear canvas :canvas-left vp-left :canvas-bottom vp-bottom :width max-x :height max-y) (wb:fast-surface-fill canvas x-origin y-origin sx sy cz szv col ncol (* (aref a 8) colrange) color-table) (when hide? (wb:fast-hide-lines canvas sx sy cz lower-y upper-y dl nl szv x-origin y-origin max-x max-y a col ncol (* (aref a 8) colrange) NIL color-table) ) ) (hide? (wb:canvas-clear canvas :canvas-left vp-left :canvas-bottom vp-bottom :width max-x :height max-y) (wb:fast-hide-lines canvas sx sy cz lower-y upper-y dl nl szv x-origin y-origin max-x max-y a col ncol (* (aref a 8) colrange) depth-cue? color-table)) (T (wb:fast-show-lines canvas x-origin y-origin old-x old-y cz szv col ncol (* (aref a 8) colrange) NIL T color-table) (wb:fast-show-lines canvas x-origin y-origin sx sy cz szv col ncol (* (aref a 8) colrange) depth-cue? NIL color-table)) ) ) ) ) ) (setf (moving-p self) nil) ) ) ) )
10,929
Common Lisp
.l
245
21.804082
97
0.337395
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
802193b66e0629a0194b7646110359a5302fbf4d25982262149e45f527fabd2b
33,426
[ -1 ]
33,427
surface-view.lsp
rwoldford_Quail/source/mathematics/graphics/surface-view.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; surface-view.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) 1992 ;;; Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; R.W. Oldford 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(surface-view surface-of color-table-of fast-color-table-of vp-saved-rotations-of moving-p spin-orientation-of hidden-lines-p toggle-hidden-lines surface-fill-p toggle-surface-fill depth-cue-p toggle-depth-cue standardize-surface-data number-of-colors-of set-spin-orientation) )) (defclass surface-view (square-view-mixin view) ((middle-menu :allocation :class :initform nil) (surface :initform NIL :accessor surface-of :initarg :surface) (color-table :initform NIL :accessor color-table-of :initarg :color-table) (fast-color-table :initform NIL :accessor fast-color-table-of :initarg :fast-color-table) (vp-rotation :initarg :vp-rotation :initform nil :accessor vp-rotation-of :documentation "An association list of viewport rotation pairs.") (vp-depth-cue? :initarg :vp-depth-cue? :initform nil :accessor vp-depth-cue?-of :documentation "An association list of viewport depth-cue? pairs.") (vp-hidden-lines? :initarg :vp-hidden-lines? :initform nil :accessor vp-hidden-lines?-of :documentation "An association list of viewport hidden-lines? pairs.") (vp-surface-fill? :initarg :vp-surface-fill? :initform nil :accessor vp-surface-fill?-of :documentation "An association list of viewport surface-fill? pairs.") (increment :initform (/ pi 180) :initarg :increment :accessor vw::increment-of :documentation "An angle increment.") (vp-x :initform NIL :initarg :vp-x :accessor vp-x-of :documentation "An association list of viewport x-coordinate pairs.") (vp-y :initform NIL :initarg :vp-y :accessor vp-y-of :documentation "An association list of viewport y-coordinate pairs.") (vp-old-x :initform NIL :initarg :vp-old-x :accessor vp-old-x-of :documentation "An association list of viewport old-x-coordinate pairs.") (vp-old-y :initform NIL :initarg :vp-old-y :accessor vp-old-y-of :documentation "An association list of viewport old-y-coordinate pairs.") (update-scratch-x :initform NIL :initarg :update-scratch-x :accessor update-scratch-x-of :documentation "A temporary storage for x-coordinates.") (update-scratch-y :initform NIL :initarg :update-scratch-y :accessor update-scratch-y-of :documentation "A temporary storage for y-coordinates.") (vp-lower-y :initform NIL :initarg :vp-lower-y :accessor vp-lower-y-of :documentation "An association list of viewport . vector pairs, each vector ~ gives the current lower y bound of the surface for each x ~ coordinate in the viewport.") (vp-upper-y :initform NIL :initarg :vp-upper-y :accessor vp-upper-y-of :documentation "An association list of viewport . vector pairs, each vector ~ gives the current upper y bound of the surface for each x ~ coordinate in the viewport.") (x-cache :initform NIL :initarg :x-cache :accessor x-cache-of) (y-cache :initform NIL :initarg :y-cache :accessor y-cache-of) (z-cache :initform NIL :initarg :z-cache :accessor z-cache-of) (vp-saved-rotations :initform NIL :initarg :vp-saved-rotations :accessor vp-saved-rotations-of :documentation "An association list of viewport . list pairs. The elements of each list ~ are the saved rotations from the starting (identity) position.") (vp-theta-cache :initform NIL :accessor vp-theta-cache-of :documentation "An association list of viewport . (con cos-theta sin-theta) pairs. ~ A cache to avoid multiple trigonometric calculations.") (vp-col-pars :initform NIL :accessor vp-col-pars-of :documentation "An association list of viewport . vector pairs, each vector ~ contains 3 colour parameters used to select colours from the ~ colour table.") (vp-z-pos-pars :initform NIL :accessor vp-z-pos-pars-of :documentation "An association list of viewport . vector pairs, each vector ~ contains 5 parameters used to select the entry point ~ in the surface vector and to determine the direction and step size ~ for traversing the surface vector.") (vp-draw-line :initform NIL :accessor vp-draw-line-of :documentation "An association list of viewport . vector pairs, each vector ~ contains 8 parameters used to determine the lines needed to draw ~ between two positions.") (vp-num-lines :initform NIL :accessor vp-num-lines-of :documentation "An association list of viewport . vector pairs, each vector ~ contains the number of lines needed to draw ~ between two positions.") (screen-range :initform (expt 2 16) :initarg :screen-range :accessor screen-range-of) (moving? :initform nil :accessor moving-p) (spin-orientation :initform :surface :accessor spin-orientation-of :documentation "One of :screen (the default) ~ or :surface indicating whether the rotation ~ of the view is to be with respect to the screen coordinate ~ system or with respect to the surface coordinate system.") ) ) (defmethod right-button-fn ((self surface-view) &key viewport ) (declare (ignore self viewport)) ;;(menu-choose-item self 'right-menu viewport ) ) (defmethod initialize-instance :after ((self surface-view) &rest initargs &key (red? NIL) (green? NIL) (blue? NIL) (from-color NIL) (to-color NIL) (colors NIL) (n-colors 256)) (declare (ignore initargs)) (unless (fast-color-table-of self) (setf (fast-color-table-of self) (wb:make-color-table :colors (or colors (color-table-of self)) :number (cond (colors (length colors)) ((color-table-of self) (length (color-table-of self))) (T n-colors)) :red? red? :green? green? :blue? blue? :from-color from-color :to-color to-color :fast-colors? T))) (unless (and (color-table-of self) (= (length (color-table-of self)) (length (fast-color-table-of self)))) (setf (color-table-of self) (wb:make-color-table :colors (fast-color-table-of self) :number (number-of-colors-of self) :red? red? :green? green? :blue? blue? :from-color from-color :to-color to-color :fast-colors? NIL))) (if (surface-of self) (init-surface-view self) ) ) (defmethod viewed-object-of ((self surface-view)) (surface-of self)) (defmethod (setf viewed-object-of) (new-value (self surface-view)) (setf (surface-of self) new-value)) (defmethod number-of-colors-of ((self surface-view)) (length (fast-color-table-of self))) (defmethod hidden-lines-p ((self surface-view) &optional viewport) (unless viewport (setq viewport (if (> (length (viewports-of self)) 1) (which-viewport self) (car (viewports-of self))))) (cdr (assoc viewport (vp-hidden-lines?-of self)))) (defun toggle-hidden-lines (surface-view viewport) (let ((result (assoc viewport (vp-hidden-lines?-of surface-view)))) (setf (cdr result) (not (cdr result))))) (defmethod surface-fill-p ((self surface-view) &optional viewport) (unless viewport (setq viewport (if (> (length (viewports-of self)) 1) (which-viewport self) (car (viewports-of self))))) (cdr (assoc viewport (vp-surface-fill?-of self)))) (defun toggle-surface-fill (surface-view viewport) (let ((result (assoc viewport (vp-surface-fill?-of surface-view)))) (setf (cdr result) (not (cdr result))))) (defmethod depth-cue-p ((self surface-view) &optional viewport) (unless viewport (setq viewport (if (> (length (viewports-of self)) 1) (which-viewport self) (car (viewports-of self))))) (cdr (assoc viewport (vp-depth-cue?-of self)))) (defun toggle-depth-cue (surface-view viewport) (let ((result (assoc viewport (vp-depth-cue?-of surface-view)))) (setf (cdr result) (not (cdr result))))) (defun set-spin-orientation (surface-view &optional (orientation :screen)) (if (member orientation (list :screen :surface)) (setf (spin-orientation-of surface-view) orientation) (quail-error "~&Illegal spin orientation: ~a for ~a" orientation surface-view))) (defun standardize-surface-data (surface-view) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (let* ((s (surface-of surface-view)) (x (x-grid-of s)) (y (y-grid-of s)) (z (surface-heights-of s)) (z-loc (mean z)) (xmin (min x)) (xmax (max x)) (xloc (/ (+ xmax xmin) 2.0)) (ymin (min y)) (ymax (max y)) (yloc (/ (+ ymax ymin) 2.0))) (flet ((s-data (cx x range location) (let ((maxx 0) (dx (array-total-size cx))) #| (loop for i from 0 to (- dx 1) maximize (abs (setf (eref cx i) (round (- (eref x i) location)))) into max finally (setf maxx max)) (loop for i from 0 to (- dx 1) do (setf (aref cx i) (round (+ (/ (* (eref cx i) range) maxx))))) |# (loop for i from 0 to (- dx 1) maximize (abs (- (eref x i) location)) into max finally (setf maxx max)) (loop for i from 0 to (- dx 1) do (setf (eref cx i) (round (/ (* (- (eref x i) location) range) maxx)))) ))) (s-data (x-cache-of surface-view) x (screen-range-of surface-view) xloc) (s-data (y-cache-of surface-view) y (screen-range-of surface-view) yloc) (s-data (z-cache-of surface-view) z (screen-range-of surface-view) z-loc) ))) (defun init-surface-view (s-v) (let* ((s (surface-of s-v)) (x (x-grid-of s)) (y (y-grid-of s)) (dim-x (array-total-size x)) (dim-y (array-total-size y)) (dim-z (* dim-x dim-y))) (setf (x-cache-of s-v) (make-array (list dim-x) :element-type 'integer :initial-element 0)) (setf (y-cache-of s-v) (make-array (list dim-y) :element-type 'integer :initial-element 0)) (setf (z-cache-of s-v) (make-array (list dim-z) :element-type 'integer :initial-element 0)) (standardize-surface-data s-v) )) ;;; Add do-nothing primary FEB 04, 1998 (defmethod add-viewport ((self surface-view) viewport pvp &key (theta .05) (depth-cue? NIL) (hidden-lines? NIL) (surface-fill? NIL)) (declare (ignore self viewport pvp theta depth-cue? hidden-lines? surface-fil l?)) (call-next-method)) (defmethod add-viewport :before ((self surface-view) viewport pvp &key (theta .05) (depth-cue? NIL) (hidden-lines? NIL) (surface-fill? NIL)) (declare (ignore pvp)) ;;(format *terminal-io* "~&viewport = ~a" viewport) (unless (member viewport (viewports-of self)) (let* ((s (surface-of self)) (x (x-grid-of s)) (y (y-grid-of s)) (dim-x (array-total-size x)) (dim-y (array-total-size y)) (dim-z (* dim-x dim-y)) (max-x (width-of viewport)) (max-y (height-of viewport)) (a (make-array (list 9) :element-type 'single-float :initial-contents (list 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0))) (sx (make-array (list dim-z) :element-type 'integer :initial-element 0)) (sy (make-array (list dim-z) :element-type 'integer :initial-element 0)) (old-x (make-array (list dim-z) :element-type 'integer :initial-element 0)) (old-y (make-array (list dim-z) :element-type 'integer :initial-element 0)) (szv (make-array (list 5) :element-type 'integer :initial-element 0)) (col (make-array (list 3) :element-type ;;'fixnum 'single-float :initial-element 0.0 )) (ax (or (update-scratch-x-of self) (make-array (list (* 2 dim-x)) :element-type 'single-float :initial-element 0.0))) (ay (or (update-scratch-y-of self) (make-array (list (* 2 dim-y)) :element-type 'single-float :initial-element 0.0))) (vp-theta-cache (cons (cos theta) (sin theta))) (ncol (array-total-size (fast-color-table-of self))) ) (setf (vw::increment-of self) theta) (push (cons viewport (make-array (list max-x) :element-type 'integer :initial-element 0)) (vp-lower-y-of self)) (push (cons viewport (make-array (list max-x) :element-type 'integer :initial-element 0)) (vp-upper-y-of self)) (push (cons viewport depth-cue?) (vp-depth-cue?-of self)) (push (cons viewport hidden-lines?) (vp-hidden-lines?-of self)) (push (cons viewport surface-fill?) (vp-surface-fill?-of self)) (push (cons viewport sx) (vp-x-of self)) (push (cons viewport sy) (vp-y-of self)) (push (cons viewport old-x) (vp-old-x-of self)) (push (cons viewport old-y) (vp-old-y-of self)) (push (cons viewport a) (vp-rotation-of self)) (wb::spin-surface-x a (cos 4.5) (sin 4.5)) (wb::spin-surface-z a (cos -1.3) (sin -1.3)) (push (cons viewport (list (make-array (list 9) :element-type 'single-float :initial-contents (loop for i from 0 to 8 collect (aref a i))))) (vp-saved-rotations-of self)) (setf (update-scratch-x-of self) ax) (setf (update-scratch-y-of self) ay) (push (cons viewport vp-theta-cache) (vp-theta-cache-of self)) (push (cons viewport col) (vp-col-pars-of self)) (push (cons viewport szv) (vp-z-pos-pars-of self)) (push (cons viewport (make-array (list 8) :element-type 'integer :initial-element 0)) (vp-draw-line-of self)) (push (cons viewport (make-array (list 1) :element-type 'integer :initial-element 0)) (vp-num-lines-of self)) (wb::update-surface-data (x-cache-of self) (y-cache-of self) (z-cache-of self) a sx sy old-x old-y szv ax ay col dim-x dim-y dim-z max-x max-y (truncate (* (screen-range-of self) (sqrt 3))) ncol) ) ) ) ;;; Add do-nothing primary for delete-viewport FEB 04, 1998 (defmethod delete-viewport ((self surface-view) viewport) (declare (ignore self viewport)) (call-next-method)) (defmethod delete-viewport :before ((self surface-view) viewport) ;; remove the viewport VIEWPORT and corresponding MAP and PARENT-VIEWPORT (unless (not (member viewport (viewports-of self))) (let ((p (position viewport (viewports-of self)))) (setf (vp-lower-y-of self) (delete (elt (vp-lower-y-of self) p) (vp-lower-y-of self))) (setf (vp-upper-y-of self) (delete (elt (vp-upper-y-of self) p) (vp-upper-y-of self))) (setf (vp-depth-cue?-of self) (delete (elt (vp-depth-cue?-of self) p) (vp-depth-cue?-of self))) (setf (vp-hidden-lines?-of self) (delete (elt (vp-hidden-lines?-of self) p) (vp-hidden-lines?-of self))) (setf (vp-surface-fill?-of self) (delete (elt (vp-surface-fill?-of self) p) (vp-surface-fill?-of self))) (setf (vp-x-of self) (delete (elt (vp-x-of self) p) (vp-x-of self))) (setf (vp-y-of self) (delete (elt (vp-y-of self) p) (vp-y-of self))) (setf (vp-old-x-of self) (delete (elt (vp-old-x-of self) p) (vp-old-x-of self))) (setf (vp-old-y-of self) (delete (elt (vp-old-y-of self) p) (vp-old-y-of self))) (setf (vp-rotation-of self) (delete (elt (vp-rotation-of self) p) (vp-rotation-of self))) (setf (vp-col-pars-of self) (delete (elt (vp-col-pars-of self) p) (vp-col-pars-of self))) (setf (vp-z-pos-pars-of self) (delete (elt (vp-z-pos-pars-of self) p) (vp-z-pos-pars-of self))) (setf (vp-draw-line-of self) (delete (elt (vp-draw-line-of self) p) (vp-draw-line-of self))) (setf (vp-num-lines-of self) (delete (elt (vp-num-lines-of self) p) (vp-num-lines-of self))) ) ) ) (defmethod draw-view ((self surface-view) &key viewport) (draw-surface self viewport)) (defmethod draw-surface ((self surface-view) viewport) (let* ((color-table (color-table-of self)) (hide? (hidden-lines-p self viewport)) (depth-cue? (depth-cue-p self viewport)) (fill? (surface-fill-p self viewport)) (canvas (window-of viewport)) (sx (cdr (assoc viewport (vp-x-of self)))) (sy (cdr (assoc viewport (vp-y-of self)))) (old-x (cdr (assoc viewport (vp-old-x-of self)))) (old-y (cdr (assoc viewport (vp-old-y-of self)))) (cx (x-cache-of self)) (cy (y-cache-of self)) (cz (z-cache-of self)) (szv (cdr (assoc viewport (vp-z-pos-pars-of self)))) (col (cdr (assoc viewport (vp-col-pars-of self)))) (ncol (number-of-colors-of self)) (range (truncate (* (screen-range-of self) (sqrt 3)))) (colrange (/ ncol 2 range)) (a (cdr (assoc viewport (vp-rotation-of self)))) (ax (update-scratch-x-of self)) (ay (update-scratch-y-of self)) (dim-x (array-total-size cx)) (dim-y (array-total-size cy)) (dim-z (array-total-size cz)) (lower-y (cdr (assoc viewport (vp-lower-y-of self)))) (upper-y (cdr (assoc viewport (vp-upper-y-of self)))) (max-x (width-of viewport)) (max-y (height-of viewport)) (dl (cdr (assoc viewport (vp-draw-line-of self)))) (nl (cdr (assoc viewport (vp-num-lines-of self)))) (y-origin (bottom-of viewport)) (x-origin (left-of viewport)) ) (unless (= max-x (array-total-size lower-y) (array-total-size upper-y)) (let ((vp-ly (assoc viewport (vp-lower-y-of self))) (vp-uy (assoc viewport (vp-upper-y-of self)))) (setf (cdr vp-ly) (make-array (list max-x) :element-type 'integer :initial-element 0)) (setf (cdr vp-uy) (make-array (list max-x) :element-type 'integer :initial-element 0)) (setq lower-y (cdr vp-ly)) (setq upper-y (cdr vp-uy)))) (wb::update-surface-data cx cy cz a sx sy old-x old-y szv ax ay col dim-x dim-y dim-z max-x max-y range ncol) (cond (fill? (wb:surface-fill canvas x-origin y-origin sx sy cz szv col ncol (* (aref a 8) colrange) color-table) (when hide? (wb:hide-lines canvas sx sy cz lower-y upper-y dl nl szv x-origin y-origin max-x max-y a col ncol (* (aref a 8) colrange) NIL color-table) )) (hide? (wb:hide-lines canvas sx sy cz lower-y upper-y dl nl szv x-origin y-origin max-x max-y a col ncol (* (aref a 8) colrange) depth-cue? color-table) ) (T (wb:show-lines canvas x-origin y-origin sx sy cz szv col ncol (* (aref a 8) colrange) depth-cue? color-table)) ) )) (defun depth-cue-menu-fn (surface-view) (let ((viewport (which-viewport surface-view))) (toggle-depth-cue surface-view viewport) (wb:canvas-clear (window-of viewport) :canvas-left (1+ (left-of viewport)) :canvas-bottom (1+ (bottom-of viewport)) :width (width-of viewport) :height (height-of viewport)) (draw-surface surface-view viewport) )) (defun hidden-lines-menu-fn (surface-view) (let ((viewport (which-viewport surface-view))) (toggle-hidden-lines surface-view viewport) (wb:canvas-clear (window-of viewport) :canvas-left (1+ (left-of viewport)) :canvas-bottom (1+ (bottom-of viewport)) :width (width-of viewport) :height (height-of viewport)) (draw-surface surface-view viewport) )) (defun surface-fill-menu-fn (surface-view) (let ((viewport (which-viewport surface-view))) (toggle-surface-fill surface-view viewport) (wb:canvas-clear (window-of viewport) :canvas-left (1+ (left-of viewport)) :canvas-bottom (1+ (bottom-of viewport)) :width (width-of viewport) :height (height-of viewport)) (draw-surface surface-view viewport) )) ;;;**** This is not the way to do things! ... rwo ;;; Anyway add do-nothing primaries FEB 04, 1998 (defmethod get-menu-items ((self surface-view) (slot-name (eql 'vw::middle-menu))) (declare (ignore self slot-name)) (call-next-method)) (defmethod get-menu-items :around ((self surface-view) (slot-name (eql 'vw::middle-menu))) `(("Highlight?" (toggle-select-view)) ("Invisible?" (set-drawing-style :invisible? :toggle)) ("Toggle depth cueing" (depth-cue-menu-fn)) ("Toggle hidden lines" (hidden-lines-menu-fn)) ("Toggle fill surface" (surface-fill-menu-fn)) ("Choose new colors" (prompt-for-surface-info)) ("Coordinate system" nil "" :sub-items ((":screen" (set-spin-orientation :screen)) (":data" (set-spin-orientation :surface)))) )) (defmethod get-menu-items :around ((self surface-view) (slot-name (eql 'vw::right-menu))) `(("Redraw" (draw-view :viewport :erase? t)) ("Inspect" (inspect-view) "Inspect this view" :sub-items (("Inspect this view" (inspect-view)) ("Inspect the viewed object" (inspect-viewed-object)))) )) (defmethod prompt-for-surface-info ((self surface-view)) (let* ((blue?-prompt "Whole blue spectrum? Enter T or NIL") (blue-default "NIL") (red?-prompt "Whole red spectrum? Enter T or NIL") (red-default "NIL") (green?-prompt "Whole green spectrum? Enter T or NIL") (green-default "NIL") (ncol-prompt "Number of colors") (ncol-default "256") (items (list (cons blue?-prompt blue-default) (cons red?-prompt red-default) (cons green?-prompt green-default) (cons ncol-prompt ncol-default))) blue-val red-val green-val ncol new-info) (flet ((test-val-for-num (read-val) (if (and (symbolp read-val) (not (boundp read-val))) :wrong (progn (setf read-val (eval read-val)) (if (not (numberp read-val)) :wrong read-val)))) (test-val-for-boole (read-val) (if (and (symbolp read-val) (not (boundp read-val))) :wrong (if (eval read-val) T NIL)))) (setf new-info (loop for pair in (wb:collect-input items ) collect (let ((read-val (read-from-string (cdr pair)))) (if (or (string= (car pair) blue?-prompt) (string= (car pair) red?-prompt) (string= (car pair) green?-prompt) ) (cons (car pair) (do ((ans (test-val-for-boole read-val) (test-val-for-boole (read-from-string (wb:prompt-user :prompt-string (concatenate 'string (car pair) " MUST BE T OR NIL") :type 'string))))) ((not (eq ans :wrong)) ans))) (cons (car pair) (do ((ans (test-val-for-num read-val) (test-val-for-num (read-from-string (wb:prompt-user :prompt-string (concatenate 'string (car pair) " MUST BE A NUMBER") :type 'string))))) ((not (eq ans :wrong)) ans)))))) ) (setf blue-val (cdr (assoc blue?-prompt new-info :test #'string=))) (setf red-val (cdr (assoc red?-prompt new-info :test #'string=))) (setf green-val (cdr (assoc green?-prompt new-info :test #'string=))) (setf ncol (cdr (assoc ncol-prompt new-info :test #'string=))) (setf (color-table-of self) (wb:make-color-table :number ncol :red? red-val :green? green-val :blue? blue-val :fast-colors? NIL)) (setf (fast-color-table-of self) (wb:make-color-table :number ncol :red? red-val :green? green-val :blue? blue-val :fast-colors? T)) ) ) )
30,535
Common Lisp
.l
736
27.610054
124
0.497684
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
ce705f0fa098ef8f44e975f6f7f9bd1f3d05fa665966bd5773c75f1dc34d4c41
33,427
[ -1 ]
33,428
surface-view-test.lsp
rwoldford_Quail/source/mathematics/graphics/surface-view-test.lsp
(setf x (array (loop for i in (iseq -9 10) collect (/ i 3)) :dimensions '(20))) (setf y (array (loop for i in (iseq -9 10) collect (/ i 3)) :dimensions '(20))) (setf z #'(lambda (x y) (+ (* .6 (exp (* -2 (+ (* x x) (* y y))))) (* .4 (exp (* -2 (+ (* (- x 1.5) (- x 1.5)) (* (- y 1.5) (- y 1.5))))))))) (setf x (array (loop for i in (iseq -2 2) collect i) :dimensions '(5))) (setf y (array (loop for i in (iseq -2 2) collect i) :dimensions '(5))) (setf z #'(lambda (x y) (exp (* -2 (+ (* x x) (* y y)))))) (surface-plot :x x :y y :surface-function z)
783
Common Lisp
.l
17
31.352941
60
0.362565
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
2f8887ac74b30a1ed7130699910677fc739b45d1b030364d0753ce870bdb2df3
33,428
[ -1 ]
33,429
deriv.lsp
rwoldford_Quail/source/mathematics/calculus/deriv.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; deriv.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992, 1994. ;;; ;;;-------------------------------------------------------------------------------- (in-package :quail) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(deriv deriv-wrt))) (defgeneric deriv (function &key wrt) (:documentation "Takes the derivative of its first argument with ~ respect to the value of the keyword parameter wrt. ~ (:required ~ (:arg function The thing to be differentiated. ~ Current methods allow handle the cases where function ~ is a list, a lambda expression, a function, ~ or an fn.) ~ ) ~ (:key ~ (:arg wrt NIL This is the variable that the derivative is ~ to be taken with respect to. It should be a symbol or NIL. ~ If wrt is not supplied or is NIL, then some attempt is made to ~ determine what wrt should be. This is done by calling the ~ function deriv-wrt on the required argument. Typically, ~ this will return the first argument of function.)) ~ (:see-also deriv-wrt simplify) ~ (:examples (:files (Differentiation ~ q:Examples;Mathematics;Calculus;deriv.lisp ~ ))) " )) (defgeneric deriv-wrt (function) (:documentation "Determines the default parameter name which is to ~ be used for purposes of differentiation. For functions ~ and the like this will be the first required parameter in ~ the functions lambda-list. ~ Returns NIL if no default parameter could be determined.")) ;;;------------------------------------------------------------------------ ;;; ;;; deriv-wrt methods ;;; ;;;------------------------------------------------------------------------ (defun required-parameter-only (symbol) "Returns the symbol if its first character is not an ampersand (&), ~ NIL otherwise." (if (not (string-equal (string symbol) "&" :start1 0 :end1 1)) symbol)) (defmethod deriv-wrt ((function T)) NIL) (defmethod deriv-wrt ((function list)) (if (eq (car function) 'lambda) (required-parameter-only (first (second function))))) (defmethod deriv-wrt ((function function)) (required-parameter-only (first (qk::get-lambda-list function)))) (defmethod deriv-wrt ((function fn)) (required-parameter-only (first (arglist-of function)))) ;;;------------------------------------------------------------------------ ;;; ;;; deriv methods ;;; ;;;------------------------------------------------------------------------ (defmethod deriv ((function function) &key wrt) (let ((f-wrt (deriv-wrt function))) (unless wrt (setf wrt (deriv-wrt function))) (if (eq wrt f-wrt) (eval `(function (lambda ,(list wrt) (numerical-deriv ,function :x ,wrt))))))) (defmethod deriv ((function fn) &key wrt) (unless wrt (setf wrt (deriv-wrt wrt))) (let* ((deriv-id (position wrt (arglist-of function) :test #'eql)) (result (find-deriv function (if deriv-id (setf deriv-id (list deriv-id)))))) (unless result (setf result (deriv (list* 'lambda (arglist-of function) (body-of function)) :wrt wrt)) (setf result (eval `(fn ,(second result) ,@(rest (rest result))))) (add-deriv function result)) result)) (defmethod-multi deriv ((function (symbol number list)) &key wrt) (setf function (simplify function)) (labels ( ;; ;; selectors ;; (first-arg (binary-expr) (second binary-expr)) (second-arg (binary-expr) (third binary-expr)) (args (expression) (rest expression)) (num-args (expression) (length (rest expression))) (base (p) (cadr p)) (power (p) (caddr p)) (exponent (x) (cadr x)) (log-arg (x) (cadr x)) ;(log-base (x) (third x)) (lambda-arglist (x) (cadr x)) (lambda-contents (x) (caddr x)) ;; ;; predicates ;; (constant-p (x) (qk::extnump x)) (variable-p (x) (symbolp x)) (same-variable-p (x y) (and (variable-p x) (variable-p y) (eq x y))) (sum-p (x) (and (listp x) (eq '+ (car x)))) (difference-p (x) (and (listp x) (eq '- (car x)))) (product-p (x) (and (listp x) (eq '* (car x)))) (quotient-p (x) (and (listp x) (eq '/ (car x)))) (power-p (x) (and (listp x) (eq 'expt (car x)))) (exp-p (x) (and (listp x) (eq 'exp (car x)))) (log-p (x) (and (listp x) (eq 'log (car x)))) (cos-p (x) (and (listp x) (eq 'cos (car x)))) (sin-p (x) (and (listp x) (eq 'sin (car x)))) (tan-p (x) (and (listp x) (eq 'tan (car x)))) (cosh-p (x) (and (listp x) (eq 'cosh (car x)))) (sinh-p (x) (and (listp x) (eq 'sinh (car x)))) (tanh-p (x) (and (listp x) (eq 'tanh (car x)))) (lambda-p (x) (and (listp x) (eq 'lambda (car x)))) (fn-list-p (x) (and (listp x) (eq 'fn (car x)))) ;;(funcall-p (x) (and (listp x) (eq 'funcall (car x)))) ;;(fn-call-p (x) (and (listp x) (eq 'fn-call (car x)))) ;;(apply-p (x) (and (listp x) (eq 'apply (car x)))) ;;(arbitrary-proc-call-p (x) (and x (listp x))) ;; ;; constructors ;; (make-sum (a b) (cond ((and (qk::extnump a) (qk::extnump b)) (+ a b)) ((numberp a) (if (= 0 a) b (list '+ a b))) ((numberp b) (if (= 0 b) a (list '+ a b))) (T (list '+ a b)))) (make-difference (a b) (cond ((and (qk::extnump a) (qk::extnump b)) (- a b)) ((numberp a) (if (= 0 a) (list '- b) (list '- a b))) ((numberp b) (if (= 0 b) a (list '- a b))) (T (list '- a b)))) (make-product (a b) (cond ((and (qk::extnump a) (qk::extnump b)) (* a b)) ((numberp a) (if (= 1 a) b (if (= 0 a) 0 (list '* a b)))) ((numberp b) (if (= 1 b) a (if (= 0 b) 0 (list '* a b)))) (T (list '* a b)))) (make-quotient (a b) (cond ((and (qk::extnump a) (qk::extnump b)) (/ a b)) ((numberp a) (if (= 0 a) 0 (list '/ a b))) ((numberp b) (if (= 1 b) a (list '/ a b))) (T (list '/ a b)))) (make-power (a b) (cond ((and (qk::extnump a) (qk::extnump b)) (expt a b)) ((numberp b) (if (= 1 b) a (if (= 0 b) 1 (list 'expt a b)))) ((numberp a) (if (= 1 a) 1 (if (= 0 a) 0 (list 'expt a b)))) (T (list 'expt a b)))) (make-exp (a) (cond ((numberp a) (if (= a 0) 1 (list 'exp a))) ((log-p a) (log-arg a)) ((sum-p a) (make-product (make-exp (first-arg a)) (make-exp (second-arg a)))) (T (list 'exp a)))) (make-log (a &optional base) (if base ;; then (cond ((qk::extnump a) (if (qk::extnump base) (log a base) (list 'log a base))) ((exp-p a) (make-product (make-log (exp 1) base) (exponent a)) ) ((product-p a) (make-sum (make-log (first-arg a)) (make-log (second-arg a)))) ((power-p a) (if (equal base (base a)) (power a) (make-product (make-log (base a) base) (power a)))) (T (list 'log a base))) ;; else (cond ((qk::extnump a) (log a)) ((exp-p a) (exponent a)) ((product-p a) (make-sum (make-log (first-arg a)) (make-log (second-arg a)))) ((power-p a) (make-product (make-log (base a)) (power a))) (T (list 'log a))))) (make-cos (x) (if (qk::extnump x) (cos x) (list 'cos x))) (make-sin (x) (if (qk::extnump x) (sin x) (list 'sin x))) ;(make-tan (x) (if (qk::extnump x) (tan x) (list 'tan x))) (make-cosh (x) (if (qk::extnump x) (cosh x) (list 'cosh x))) (make-sinh (x) (if (qk::extnump x) (sinh x) (list 'sinh x))) ;(make-tanh (x) (if (qk::extnump x) (tanh x) (list 'tanh x))) (make-lambda (var-list alg-expr) (list 'lambda var-list alg-expr)) (make-fn (var-list alg-expr) (list 'fn var-list alg-expr)) ) (unless wrt (setf wrt (deriv-wrt function))) (simplify (cond ((or (constant-p function) (null wrt)) 0) ((variable-p function) (if (same-variable-p function wrt) 1 0)) ((sum-p function) (let ((nargs (num-args function))) (cond ((> nargs 2) (let ((result NIL) (args (args function))) (do* ((i 0 (+ i 1)) arg derivative ) ((>= i nargs) result) (setf arg (elt args i)) (setf derivative (deriv arg :wrt wrt)) (when (not (and (numberp derivative) (zerop derivative))) (push derivative result)) ) (setf result (simplify (cons '+ (reverse result)))) )) ((= nargs 2) (make-sum (deriv (first-arg function) :wrt wrt) (deriv (second-arg function) :wrt wrt))) ((= nargs 1) (deriv (first-arg function) :wrt wrt)) ((= nargs 0) 0 ) ) ) ) ((difference-p function) (let ((nargs (num-args function))) (cond ((> nargs 2) (simplify (list '- (loop for arg in (args function) collect (deriv arg :wrt wrt))))) ((= nargs 2) (simplify (make-difference (deriv (first-arg function) :wrt wrt) (deriv (second-arg function) :wrt wrt)))) ((= nargs 1) (let ((result (deriv (first-arg function) :wrt wrt))) (if (constantp result) (- result) (list '- result)))) ((= nargs 0) 0 ) ) ) ) ((product-p function) (let ((nargs (num-args function))) (cond ((> nargs 2) (let ((arg2 (cons '* (rest (args function))))) (simplify (list '+ (make-product (deriv (first-arg function) :wrt wrt) arg2) (make-product (first-arg function) (deriv arg2 :wrt wrt))))) ) ((= nargs 2) (simplify (make-sum (make-product (deriv (first-arg function) :wrt wrt) (second-arg function)) (make-product (first-arg function) (deriv (second-arg function) :wrt wrt))))) ((= nargs 1) (deriv (first-arg function) :wrt wrt)) ((= nargs 0) 0 ) ) ) ) ((quotient-p function) (let ((nargs (num-args function))) (cond ((> nargs 2) (let ((arg1 (first-arg function)) (arg2 (cons '* (rest (args function))))) (simplify (make-quotient (make-difference (make-product arg2 (deriv arg1 :wrt wrt)) (make-product arg1 (deriv arg2 :wrt wrt))) (make-power arg2 2)))) ) ((= nargs 2) (make-quotient (make-difference (make-product (second-arg function) (deriv (first-arg function) :wrt wrt)) (make-product (first-arg function) (deriv (second-arg function) :wrt wrt))) (make-power (second-arg function) 2))) ((= nargs 1) (deriv (list '/ 1 (first-arg function)) :wrt wrt)) ((= nargs 0) 0 ) ) ) ) ((power-p function) (make-product (power function) (make-product (make-power (base function) (make-difference (power function) 1)) (deriv (base function) :wrt wrt)))) ((exp-p function) (make-product function (deriv (exponent function) :wrt wrt))) ((log-p function) (make-quotient (deriv (log-arg function) :wrt wrt) (log-arg function))) ((cos-p function) (make-product (make-product -1 (make-sin (first-arg function))) (deriv (first-arg function) :wrt wrt))) ((sin-p function) (make-product (make-cos (first-arg function)) (deriv (first-arg function) :wrt wrt))) ((tan-p function) (make-product (make-power (make-cos (first-arg function)) -2) (deriv (first-arg function) :wrt wrt))) ((cosh-p function) (make-product (make-sinh (first-arg function)) (deriv (first-arg function) :wrt wrt))) ((sinh-p function) (make-product (make-cosh (first-arg function)) (deriv (first-arg function) :wrt wrt))) ((tanh-p function) (make-product (make-power (make-cosh (first-arg function)) -2) (deriv (first-arg function) :wrt wrt))) ((lambda-p function) (make-lambda (lambda-arglist function) (deriv (lambda-contents function) :wrt wrt))) ((functionp function) (list 'function (deriv (second function) :wrt wrt))) ((fn-list-p function) (make-fn (lambda-arglist function) (deriv (lambda-contents function) :wrt wrt))) (T (quail-error "deriv: can't differentiate the expression ~ ~s with respect to ~s" function wrt)) ) ) ))
16,145
Common Lisp
.l
397
26.377834
86
0.426578
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
3f3029960dc60fe151299c6b31de7a6c6ed2d1d8b5a9d550b17883429f24f19f
33,429
[ -1 ]
33,430
simpsons.lsp
rwoldford_Quail/source/mathematics/calculus/simpsons.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; simpsons.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; Stat 440/840: Rupa and Rita (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(extended-simpsons))) (defun extended-simpsons (integrand a b &key (epsilon 1.0D-7) (max-iterations 10)) "Numerically evaluates the function integrand from a to b. ~ Uses an automatically extended simpson's rule." (let* ((h (- b a)) (n 1) (iold) (inew (/ (* h (+ (funcall integrand a) (funcall integrand b))) 2)) (sold) (snew 0) (f-total) (tee) (diff)) (loop for i from 1 do (setf tee (+ a (/ h 2))) (setf f-total 0) (loop for j from 1 to n do (setf f-total (+ f-total (funcall integrand (+ tee (* (- j 1) h)))))) (setf iold inew) (setf inew (/ (+ iold (* h f-total)) 2)) (setf sold snew) (setf snew (/ (- (* 4 inew) iold) 3)) (setf h (/ h 2)) (setf n (* n 2)) (setf diff (- snew sold)) (if (< (abs diff) (* epsilon (abs sold))) (return snew)) (if (> i max-iterations) (quail-error "Extended-simpsons rule faled to converge. ~%~ Number of iterations = ~s ~%~ Tolerance = ~s . ~%" i epsilon)))))
1,754
Common Lisp
.l
45
29.155556
86
0.429248
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
11690da147b30e24235ad994d36c9c640b5b0e996cb893f6611561562f278aac
33,430
[ -1 ]
33,431
simplify.lsp
rwoldford_Quail/source/mathematics/calculus/simplify.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; simplify.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 '(simplify))) (defun simplify-difference (expression) (flet ((constant-p (x) (qk::extnump x)) (sum-p (x) (and (listp x) (eq '+ (car x))))) (let ((arg-list (rest expression))) (if arg-list (let* ((first-arg (first arg-list)) (first-simplified-arg (simplify first-arg)) (remaining-args (rest arg-list))) (if remaining-args (let ((remaining-result (append (list '+) (loop for arg in remaining-args collect (simplify arg))))) (cond ((or (equal first-simplified-arg remaining-result) (equal first-arg remaining-result) (and (constant-p first-simplified-arg) (or (and (= (length remaining-args) 1) (or (and (constant-p (second remaining-result)) (= first-simplified-arg (second remaining-result))) (and (constant-p (first remaining-args)) (= first-simplified-arg (first remaining-args)))))) ) (and (= (length remaining-args) 1) (or (equal first-arg (second remaining-result)) (equal first-arg (first remaining-args)) (equal first-simplified-arg (second remaining-result)) (equal first-simplified-arg (first remaining-args))) )) 0) ((and (sum-p remaining-result) (member first-simplified-arg remaining-result :test #'(lambda (x y) (or (and (constant-p x) (constant-p y) (= x y)) (equal x y))))) (let ((pos (position first-simplified-arg remaining-result :test #'(lambda (x y) (or (and (constant-p x) (constant-p y) (= x y)) (equal x y)))) ) ) (setf remaining-result (simplify (loop for i from 0 to (- (length remaining-result) 1) when (not (= pos i)) collect (elt remaining-result i)))) (simplify (list '- remaining-result)) ) ) (T (setf remaining-result (simplify remaining-result)) (cond ((and (constant-p first-simplified-arg) (constant-p remaining-result)) (- first-simplified-arg remaining-result)) ((constant-p remaining-result) (if (= 0 remaining-result) first-simplified-arg (simplify (list '+ first-simplified-arg (- remaining-result)))) ) ((constant-p first-simplified-arg) (cond ((= 0 first-simplified-arg) (list '- remaining-result)) ((and (sum-p remaining-result) (member first-simplified-arg remaining-result :test #'(lambda (x y) (and (constant-p x) (constant-p y) (= x y)))) ) (let ((pos (position first-simplified-arg remaining-result :test #'(lambda (x y) (and (constant-p x) (constant-p y) (= x y)))) ) ) (setf remaining-result (simplify (loop for i from 0 to (- (length remaining-result) 1) when (not (= pos i)) collect (elt remaining-result i)))) (simplify (list '- remaining-result)) ) ) (T (list '- first-simplified-arg remaining-result)))) ((equal first-simplified-arg remaining-result) 0) ((and (sum-p remaining-result) (member first-simplified-arg remaining-result :test #'(lambda (x y) (or (and (constant-p x) (constant-p y) (= x y)) (equal x y))))) (let ((pos (position first-simplified-arg remaining-result :test #'(lambda (x y) (or (and (constant-p x) (constant-p y) (= x y)) (equal x y)))) ) ) (setf remaining-result (simplify (loop for i from 0 to (- (length remaining-result) 1) when (not (= pos i)) collect (elt remaining-result i)))) (simplify (list '- remaining-result)) ) ) (T (list '- first-simplified-arg remaining-result)))))) (if (constant-p first-simplified-arg) (- first-simplified-arg) (list '- first-simplified-arg)) ) ) 0) ) )) (defun flatten-sum (expression) (flet (;(constant-p (x) (qk::extnump x)) (sum-p (x) (and (listp x) (eq '+ (car x))))) (let ((arg-list (rest expression))) (if arg-list (let (flat-args result) (setf flat-args (do ((i 0 (+ i 1)) arg flat-list ) ((= i (length arg-list)) flat-list) (setf arg (simplify (elt arg-list i))) (cond ((sum-p arg) (setf arg (flatten-sum arg)) (setf flat-list (append flat-list (rest arg))) ) (T (setf flat-list (append flat-list (list arg))) ) ) )) (setf result (if (listp flat-args) (if (= (length flat-args) 1) (first flat-args) (cons '+ flat-args)) flat-args) ) result ) 0)))) (defun flatten-product (expression) (flet (;(constant-p (x) (qk::extnump x)) (product-p (x) (and (listp x) (eq '* (car x))))) (let ((arg-list (rest expression))) (if arg-list (let (flat-args result) (setf flat-args (do ((i 0 (+ i 1)) arg flat-list ) ((= i (length arg-list)) flat-list) (setf arg (simplify (elt arg-list i))) (cond ((product-p arg) (setf arg (flatten-product arg)) (setf flat-list (append flat-list (rest arg))) ) (T (setf flat-list (append flat-list (list arg))) ) ) )) (setf result (if (listp flat-args) (if (= (length flat-args) 1) (first flat-args) (cons '* flat-args)) flat-args) ) result ) 0)))) (defun simplify-sum (expression) (flet ((constant-p (x) (qk::extnump x)) (sum-p (x) (and (listp x) (eq '+ (car x))))) (setf expression (flatten-sum expression)) (if (sum-p expression) (let ((arg-list (rest expression))) (if arg-list (let* ((simple-pieces (loop for piece in arg-list collect (simplify piece))) (non-nums (remove-if #'constant-p simple-pieces)) (extended-nums (remove-if #'(lambda (x) (not (constant-p x))) simple-pieces)) result) (when non-nums (setf non-nums (flatten-sum (cons '+ non-nums))) (setf non-nums (if (sum-p non-nums) (rest non-nums) (list non-nums))) ) (when extended-nums (setf extended-nums (apply #'+ extended-nums)) ) (cond ((and non-nums extended-nums) (let ((singletons (remove-duplicates non-nums :test #'equal)) count) (do* ((i 0 (+ i 1)) s ) ((= i (length singletons)) NIL) (setf s (elt singletons i)) (setf count (count s non-nums :test #'equal)) (push (if (> count 1) (simplify (list '* count s)) s) result) ) (if (= extended-nums 0) (if (> (length result) 1) (setf result (append (list '+ ) (reverse result))) (setf result (first result))) (if (> (length result) 1) (setf result (append (list '+ extended-nums) (reverse result))) (setf result (list '+ extended-nums (first result))))) ) ) (extended-nums (setf result extended-nums)) (non-nums (let ((singletons (remove-duplicates non-nums :test #'equal)) count) (do* ((i 0 (+ i 1)) s ) ((= i (length singletons)) NIL) (setf s (elt singletons i)) (setf count (count s non-nums :test #'equal)) (push (if (> count 1) (simplify (list '* count s)) s) result) ) (if (> (length result) 1) (setf result (cons '+ (reverse result))) (setf result (first result))) ) ) (T (quail-error "~&In simplify-addition: expression = ~s." expression))) (cond ((constant-p result) result) ((and (sum-p result) (= (length result) 2)) (second result)) (T result)) ) 0) ) expression)) ) (defun simplify-product (expression) (flet ((constant-p (x) (qk::extnump x)) (product-p (x) (and (listp x) (eq '* (car x))))) (setf expression (flatten-product expression)) (if (product-p expression) (let ((arg-list (rest expression))) (if arg-list (let* ((simple-pieces (loop for piece in arg-list collect (simplify piece))) (non-nums (remove-if #'constant-p simple-pieces)) (extended-nums (remove-if #'(lambda (x) (not (constant-p x))) simple-pieces)) result) (when non-nums (setf non-nums (flatten-product (cons '* non-nums))) (setf non-nums (if (product-p non-nums) (rest non-nums) (list non-nums))) ) (when extended-nums (setf extended-nums (apply #'* extended-nums)) ) (cond ((and non-nums extended-nums) (cond ((= extended-nums 0) 0) ((= extended-nums 1) (setf result (append (list '*) non-nums))) (T (setf result (append (list '* extended-nums) non-nums))) ) ) (extended-nums (setf result extended-nums)) (non-nums (let ((singletons (remove-duplicates non-nums :test #'equal)) count) (do* ((i 0 (+ i 1)) s ) ((= i (length singletons)) NIL) (setf s (elt singletons i)) (setf count (count s non-nums :test #'equal)) (push (if (> count 1) (simplify (list 'expt s count)) s) result) ) (if (> (length result) 1) (setf result (cons '* (reverse result))) (setf result (first result))) ) ) (T result)) (cond ((constant-p result) result) ((and (product-p result) (= (length result) 2)) (second result)) (T result)) ) 1) ) expression)) ) (defun simplify-division (expression) ;(flet ;(;(constant-p (x) (qk::extnump x)) ;(quotient-p (x) (and (listp x) (eq '/ (car x)))) ; ) (let ((arg-list (rest expression))) (if arg-list (if (= 1 (length arg-list)) expression (list '/ (first arg-list) (simplify (cons '* (rest arg-list))))) expression) ) ;) ) (defun simplify (expression) (labels (;(constant-p (x) (qk::extnump x)) ;(variable-p (x) (symbolp x)) ;(same-variable-p (x y) ; (and (variable-p x) (variable-p y) (eq x y))) (sum-p (x) (and (listp x) (eq '+ (car x)))) (difference-p (x) (and (listp x) (eq '- (car x)))) (product-p (x) (and (listp x) (eq '* (car x)))) (quotient-p (x) (and (listp x) (eq '/ (car x)))) ) (cond ((sum-p expression) (simplify-sum expression)) ((difference-p expression) (simplify-difference expression)) ((product-p expression) (simplify-product expression)) ((quotient-p expression) (simplify-division expression)) ((and expression (listp expression)) (loop for thing in expression collect (simplify thing)) ) (T expression) ) ) )
16,925
Common Lisp
.l
427
20.826698
86
0.361613
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
ef63a61bf3d3956c5506092670c52ed02095c97ea0b490367d12b89eb258ddc7
33,431
[ -1 ]
33,432
numerical-deriv.lsp
rwoldford_Quail/source/mathematics/calculus/numerical-deriv.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; numerical-deriv.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; Ba Pham 1991 ;;; R.W. Oldford 1992. ;;; ;;;-------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(numerical-deriv))) (defun numerical-deriv (fun &key x ;; (n 4) (eps 0.2)) "Numerical derivative of a continuous function fun using a polynomial ~ of degree three fitting through 4 points in the range +- eps about the ~ desired point x. ~ (:references Computational Methods in Elementary Numerical Analysis by ~ J.L. Morris.) ~ (:see-also deriv) ~ (:examples (:files (Differentiation in Quail ~ q:Examples;Mathematics;Calculus;deriv.lisp ~ )))" (let* ((n 4) (low (- x eps)) (high (+ x eps)) (h (/ (- high low) n)) (nn (+ n 1)) (m (floor n 2)) (prod 1) (isum 0) (osum 0)) (if (not (= (+ low (* m h)) x)) (error "Differentiate: use an even number for n")) (dotimes (j nn) (dotimes (k nn) (if (not (= j k)) (block one (dotimes (i nn) (if (and (not (= i j)) (not (= i k))) (setf prod (* prod (/ (- m i) (- j i)))))) (setf isum (+ isum (/ prod (- j k)))) (setf prod 1)))) (setf osum (+ osum (* isum (funcall fun (+ low (* j h)))))) (setf isum 0)) (float (/ osum h))))
1,872
Common Lisp
.l
51
28.960784
84
0.420937
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
3f303b7a644f6724d09f9b2fe063098d20d5a543834370f6e96f69b3ae70ac27
33,432
[ -1 ]
33,433
test-deriv.lsp
rwoldford_Quail/source/mathematics/calculus/test-deriv.lsp
(in-package :q) ;; x^2 - 3 - (x + y + z + x) - x^2 ;; deriv = 2x -2 -2x = -2 (deriv '(- (* X X) 3 (+ x y z x) (* x x)) :wrt 'x) ;; x^2 - 3 - (x + y + z + x) - x^3 ;; deriv = 2x -2 -3x^2 (deriv '(- (* X X) 3 (+ x y z x) (expt x 3)) :wrt 'x) (simplify '(- (* X X) 3 (+ x y z x) (* x x))) (simplify '(+ (- x (* X X) 3 (+ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)))) (simplify '(- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3)))) (simplify '(- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3))) ) (setf x 2 y 3 z 4) (deriv '(- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (/ x (* X X) 3 (/ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3))) :wrt 'x ) (numerical-deriv #'(lambda (x) (- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (/ x (* X X) 3 (/ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3)))) :x x) (deriv '(* x 2 (+ x 5) x y) :wrt 'x) (float (eval (deriv '(/ x 2 (+ x 5) x) :wrt 'x) )) (numerical-deriv #'(lambda (x) (/ x 2 (+ x 5) x)) :x x) (float (eval (deriv '(- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (/ x (* X X) 3 (+ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3))) :wrt 'x) )) (numerical-deriv #'(lambda (x) (- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (/ x (* X X) 3 (+ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3)))) :x x) (simplify '(/ x y z (+ x x))) (simplify '(+)) (simplify '(+ 2)) (simplify '(+ 2 3 4 x y 1)) X Y (+ 10 (+ X Y))))) (simplify '(+ 10 (+ (+ 10 (+ X Y (+ 10 (expt (+ X Y x) (/ y y x))))) X Y (+ 10 (+ X Y))))) (simplify '(+ 10 (+ 10 x))) (q::flatten-sum '(+ 10 )) (q::flatten-product '(* 10 (* 2 X (* 2 X (* 2 X))) (* 2 Y) (* 3 10) (* 2 X) (* 2 Y))) (q::flatten-product '(* 10 (* 2 Y) (* 3 10) (* 2 X) (* 2 Y))) (q::flatten-product '(* 10 Y x (* 3 x))) (simplify 'y) (defun test-simp (xyz-expression) (let ((simp-exp (simplify xyz-expression))) (eval `(loop for x from -2 to 2 do (loop for y from -2 to 2 do (loop for z from -2 to 2 do (cond ((not (zerop (- ,xyz-expression ,simp-exp))) (format *terminal-io* "~&Failed.") (format *terminal-io* "~&~%x = ~s y = ~s z = ~s" x y z) (format *terminal-io* "~&orig = ~s simp = ~s" ,xyz-expression ,simp-exp)) (T (format *terminal-io* "~&Passed."))) ) ) finally (return :done)) ))) (defun test-div () (loop for w in '(-2 -1 1 2) do (loop for x in '(-2 -1 1 2) do (loop for y in '(-2 -1 1 2) do (loop for z in '(-2 -1 1 2) do (cond ((not (zerop (- (/ w x y z) (/ w (* x y z))))) (format *terminal-io* "~&Failed.") (format *terminal-io* "~&~%w = ~s x = ~s y = ~s z = ~s" w x y z) ) (T (format *terminal-io* "~&Passed."))) ) ) ) finally (return :done)) ) (test-div) (test-simp '(+ 10 (+ (+ 10 (+ X Y (+ 10 (+ X Y)))) X Y (+ 10 (+ X Y))))) (simplify-difference '(- x (* X X) )) (setf expression '(- x (expt X 2) )) (setf expression '(+ (expt X 2))) (simplify-difference '(- x (expt X 2))) (test-simp '(- (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3)) (- x (* X X) 3 (+ x y z ) (expt x 3)) 3 (- x (* X X) 3 (+ x y z ) (expt x 3))))
4,832
Common Lisp
.l
137
22.970803
86
0.315778
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
feada5e255cddb5baa1df8c1ec573d264540aa13d12ef2ff33d34ab3344cfc66
33,433
[ -1 ]
33,434
orig-newton.lsp
rwoldford_Quail/source/mathematics/root-finders/orig-newton.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; newton.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; Stat 440/840: Rupa and Rita (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(newton))) (defun newton (f &key (start 0.0) (tolerance .0000001) (max-iterations 150) (deriv NIL)) "Finds the root of the equation f(x) = 0 where f is a real-valued ~ continuous function of a single numerical argument. Uses Newton's method.~ (:required ~ (:arg f The function whose root we are to find.) ~ ) ~ (:key ~ (:arg start 0.0 A first guess at the root.) ~ (:arg tolerance .0000001 The relative convergence criterion. ~ If the absolute difference between the current and previous values is smaller than ~ the tolerance times the previous value, then the current value ~ is declared the root.) ~ (:arg max-iterations 150 The maximum number of iterations to perform before giving ~ up. If this is reached the most recent value is returned as the first value and ~ NIL as the second value.) ~ (:arg deriv NIL The function that is the derivative of f. If it is not specified ~ it will be computed within the newton procedure.)) ~ (:returns Returns multiple values. The first is the root or the most recent ~ value depending on whether convergence was reached or not. The second value ~ is T if the procedure converged and NIL otherwise.)" (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (let ((xold) (xnew start) (converged? NIL)) ;; Check if derivative is given. If not, compute it. (unless (functionp deriv) (setf deriv (quail::deriv f))) (loop for i from 1 do (setf xold xnew) ;; Checking for zero divide (when (= (funcall deriv xold) 0) (format *quail-terminal-io* "~&Warning!: Newton hit a zero derivative at the point x = ~s.~%~ Continuing in the neighbourhood ...~%" xold) ;; Restart at a random place nearby. (loop for j from 1 to 10 until (/= (funcall deriv xold) 0) do (setf xold (* xold (+ .95 (/ (random 100) 1000.0)))))) ;; The Newton step (setf xnew (- xold (/ (funcall f xold) (funcall deriv xold)))) ;; Converged? (when (< (abs (- xnew xold)) (* tolerance (abs xold))) (setf converged? T) (return xnew)) ;;Max iterations exceeded? (when (>= i max-iterations) (return xnew))) (values xnew converged?)))
2,985
Common Lisp
.l
65
37.661538
90
0.566759
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
27fecf8c7894eeaac1b1dcb1ed87ffda38bb7f02fb88ec47fa7135cae7f1982d
33,434
[ -1 ]
33,435
illinois.lsp
rwoldford_Quail/source/mathematics/root-finders/illinois.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; illinois.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; St 440/840 Garth & John ;;; ;;;-------------------------------------------------------------------------------- (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(illinois))) (defun illinois (funtn l r &key (max-iterations 1000) (epsilon .0000001) ) "Takes a function and two points, one on the left of ~ the root (l) and one on the right (r). It returns an approximation ~ of the root using the secant method with the illinois twist. If ~ it does not come up with an answer within the # ~ of iterations it will return nil. ~ Notice you can change the ~ epsilonerance and the number of iterations." ;********************************************************************* (let ( (p) (fl (funcall funtn l)) (fr (funcall funtn r)) (test 2)) ; Tests to see if the function is of negative slope (cond ((and (> fl 0) (< fr 0)) (loop for i from 1 to max-iterations do ; Standart Secant method (<- p (float (- r (/ (* fr (- r l)) (- fr fl))))) ; Tests if our calculated root is to the left of the root (cond ((< (funcall funtn p) 0) (if (<= (abs(- p r)) epsilon) (return (float p))) (<- r p) ; This is the illinois part, if we move the same pt. twice in a row ; we use the function divided by two (if (= test 1) (<- fr (/ (funcall funtn r) 2)) (<- fr (funcall funtn r))) (<- test 1)) ; Tests if our calculated root is to the right of the root ((> (funcall funtn p) 0) (if (<= (abs(- p l)) epsilon) (return (float p))) (<- l p) ; Again this is the illinois twist (if (= test 0) (<- fl (/ (funcall funtn l) 2)) (<- fl (funcall funtn l))) (<- test 0)) ((= (funcall funtn p) 0) (return (float p))) ))) ; Tests to see if the function is of positive slope. Once this is ; done the rest of the documentation as above applies ((and (< fl 0) (> fr 0)) (loop for i from 1 to max-iterations do ; Standart Secant method (<- p (float (- r (/ (* fr (- r l)) (- fr fl))))) ; Tests if our calculated root is to the right of the root (cond ((> (funcall funtn p) 0) (if (<= (abs(- p r)) epsilon) (return (float p))) (<- r p) ; This is the illinois part, if we move the same pt. twice in a row ; we use the function divided by two (if (= test 1) (<- fr (/ (funcall funtn r) 2)) (<- fr (funcall funtn r))) (<- test 1)) ; Tests if our calculated root is to the left of the root ((< (funcall funtn p) 0) (if (<= (abs(- p l)) epsilon) (return (float p))) (<- l p) ; Again this is the illinois twist (if (= test 0) (<- fl (/ (funcall funtn l) 2)) (<- fl (funcall funtn l))) (<- test 0)) ((= (funcall funtn p) 0) (return (float p))) ))) ((or (and (>= fl 0) (>= fr 0)) (and (<= fl 0) (<= fr 0))) (print "you have given an unacceptable set of points") ) )))
4,328
Common Lisp
.l
96
30.5
84
0.39633
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
ff94ac361a7238ebb6684bf1433dfe18954ae2f2238b1266a7069ff79344393a
33,435
[ -1 ]
33,436
newton.lsp
rwoldford_Quail/source/mathematics/root-finders/newton.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; newton.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1992 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; Stat 440/840: Rupa and Rita (in-package :quail-kernel) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(newton))) (defun newton (f &key (start 0.0) (tolerance .0000001) (max-iterations 150) (deriv NIL)) "Finds the root of the equation f(x) = 0 where f is a real-valued ~ continuous function of a single numerical argument. Uses Newton's method.~ (:required ~ (:arg f The function whose root we are to find.) ~ ) ~ (:key ~ (:arg start 0.0 A first guess at the root.) ~ (:arg tolerance .0000001 The relative convergence criterion. ~ If the absolute difference between the current and previous values is smaller than ~ the tolerance times the previous value, then the current value ~ is declared the root.) ~ (:arg max-iterations 150 The maximum number of iterations to perform before giving ~ up. If this is reached the most recent value is returned as the first value and ~ NIL as the second value.) ~ (:arg deriv NIL The function that is the derivative of f. If it is not specified ~ it will be computed within the newton procedure.)) ~ (:returns Returns multiple values. The first is the root or the most recent ~ value depending on whether convergence was reached or not. The second value ~ is T if the procedure converged and NIL otherwise.)" (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (let ((xold) (xnew start) (converged? NIL)) ;; Check if derivative is given. If not, compute it. (unless (functionp deriv) (setf deriv (quail::deriv f))) (loop for i from 1 do (setf xold xnew) ;; Checking for zero divide (when (= (funcall deriv xold) 0) (format *quail-terminal-io* "~&Warning!: Newton hit a zero derivative at the point x = ~s. ~%Continuing in the neighbourhood ...~%" xold) ;; Restart at a random place nearby. (loop for j from 1 to 10 until (/= (funcall deriv xold) 0) do (setf xold (* xold (+ .95 (/ (random 100) 1000.0)))))) ;; The Newton step (setf xnew (- xold (/ (funcall f xold) (funcall deriv xold)))) ;; Converged? (when (< (abs (- xnew xold)) (* tolerance (abs xold))) (setf converged? T) (return xnew)) ;;Max iterations exceeded? (when (>= i max-iterations) (return xnew))) (values xnew converged?) ) )
2,973
Common Lisp
.l
66
37.090909
90
0.569333
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
7806c1dd44e35919f2079716e3bda69023cc1d7459c0531f907412ab2f7c87e2
33,436
[ -1 ]
33,437
window-basics-package.lsp
rwoldford_Quail/source/window-basics/window-basics-package.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; window-basics-package.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Copyright (c) 1991 Statistical Computing Laboratory, University of Waterloo ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1991. ;;; ;;; ;;;---------------------------------------------------------------------------- #+:cl-2 (defpackage #:window-basics #+:sbcl-linux (:use :clim-lisp :clim :clim-extensions) ; "COMMON-LISP" 19 November 2019 #+:aclpc-linux (:use :common-lisp) (:nicknames "WB") (:import-from "QUAIL-KERNEL" *QUAIL-RESTORE-LISP-FUNCTIONS* *QUAIL-STANDARD-INPUT* *QUAIL-STANDARD-OUTPUT* *QUAIL-QUERY-IO* *QUAIL-DEBUG-IO* *QUAIL-ERROR-OUTPUT* *QUAIL-TRACE-OUTPUT* *QUAIL-TERMINAL-IO* QUAIL-PRINT QUAIL-ERROR QUAIL-CERROR QUAIL-QUERY QUAIL-Y-OR-N-P QUAIL-YES-OR-NO-P) (:shadow "MAKE-POINT" "POINT-X" "POINT-Y" "DRAW-LINE" "DRAW-RECTANGLE" "DRAW-ELLIPSE" "DRAW-POLYGON" "MOUSE-DOWN-P" "SHIFT-KEY-P" "CONTROL-KEY-P" "MAKE-POSITION" "COPY-POSITION" "POSITION-X" "POSITION-Y" "MOVE-TO" "LINE-TO" "MAKE-COLOR" "*BLACK-COLOR*" "*WHITE-COLOR*" "*PINK-COLOR*" "*RED-COLOR*" "*ORANGE-COLOR*" "*YELLOW-COLOR*" "*GREEN-COLOR*" "*DARK-GREEN-COLOR*" "*LIGHT-BLUE-COLOR*" "*BLUE-COLOR*" "*PURPLE-COLOR*" "*BROWN-COLOR*" "*TAN-COLOR*" "*LIGHT-GRAY-COLOR*" "*GRAY-COLOR*" "*DARK-GRAY-COLOR*" "REDISPLAY" "COLORP" "COLOR") ;"COLOR" added 07MAY2024 to avoid sbcl compiler error (:export "MAKE-POINT" "POINT-X" "POINT-Y" "DRAW-LINE" "DRAW-RECTANGLE" "DRAW-ELLIPSE" "DRAW-POLYGON" "MOUSE-DOWN-P" "SHIFT-KEY-P" "CONTROL-KEY-P" "MAKE-POSITION" "COPY-POSITION" "POSITION-X" "POSITION-Y" "MOVE-TO" "LINE-TO" "MAKE-COLOR" "*BLACK-COLOR*" "*WHITE-COLOR*" "*PINK-COLOR*" "*RED-COLOR*" "*ORANGE-COLOR*" "*YELLOW-COLOR*" "*GREEN-COLOR*" "*DARK-GREEN-COLOR*" "*LIGHT-BLUE-COLOR*" "*BLUE-COLOR*" "*PURPLE-COLOR*" "*BROWN-COLOR*" "*TAN-COLOR*" "*LIGHT-GRAY-COLOR*" "*GRAY-COLOR*" "*DARK-GRAY-COLOR*") (:export #:window-basics)) #-:cl-2 (in-package "WINDOW-BASICS" :use '(pcl lisp) :nicknames '(wb)) #-:cl-2 (export '(*CANVAS* MAKE-CANVAS)) #-:CL-2 (IMPORT '(QUAIL-KERNEL::*QUAIL-RESTORE-LISP-FUNCTIONS* QUAIL-KERNEL:*QUAIL-STANDARD-INPUT* QUAIL-KERNEL:*QUAIL-STANDARD-OUTPUT* QUAIL-KERNEL:*QUAIL-QUERY-IO* QUAIL-KERNEL:*QUAIL-DEBUG-IO* QUAIL-KERNEL:*QUAIL-ERROR-OUTPUT* QUAIL-KERNEL:*QUAIL-TRACE-OUTPUT* QUAIL-KERNEL:*QUAIL-TERMINAL-IO* QUAIL-KERNEL:QUAIL-ERROR QUAIL-KERNEL:QUAIL-CERROR QUAIL-KERNEL:QUAIL-QUERY QUAIL-KERNEL:QUAIL-Y-OR-N-P QUAIL-KERNEL:QUAIL-YES-OR-NO-P) "WINDOW-BASICS")
3,088
Common Lisp
.l
79
31.987342
89
0.537796
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
3a24dc0825d38689ab684ad6dbcaea66a4e441b952f0c8c9927be6e7e1f9381d
33,437
[ -1 ]
33,442
positions.lsp
rwoldford_Quail/source/window-basics/macros/positions.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; positions.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-position copy-position position-p position-x position-y))) ;;;============================================================ ;;; Positions ;;;============================================================ ;;; changed representation of positions from cons to vectors, jam, 11-17-88. ;;; --makes it easier to extend to 3d ;;; --makes it possible to implement some graphics operations ;;; on the CM, because you can have array valued pvars, ;;; but not cons valued pvars. (defmacro make-position (&optional (x 0) (y 0)) `(vector ,x ,y)) (defmacro copy-position (position) (let ((sym (gensym))) `(let ((,sym ,position)) (vector (aref ,sym 0) (aref ,sym 1))))) (defmacro position-p (object) (let ((sym (gensym))) `(let ((,sym ,object)) (and (vectorp ,sym) (= (length ,sym) 2))))) (defmacro position-x (object) `(aref ,object 0)) (defmacro position-y (object) `(aref ,object 1)) (defsetf position-x (position) (new-value) `(setf (aref ,position 0) ,new-value)) (defsetf position-y (position) (new-value) `(setf (aref ,position 1) ,new-value))
2,052
Common Lisp
.l
51
36.882353
116
0.501259
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
6f6fa587ce481db7921b6438cd431c85837b1baf9445a6e3fe6c31457263a99c
33,442
[ -1 ]
33,443
macros-pc.lsp
rwoldford_Quail/source/window-basics/macros/macros-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; macros-pc.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is an addition to Window-basics for moving pointclouds ;;; ;;; Authors: ;;; R.W. Oldford 1992 ;;; G.W. Bennett 1995 ;;; ;;; This file is for the PC-port but is an unmodified ;;; copy of the standard macros-mcl and -clx files. (gwb) ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(with-focused-canvas host-to-canvas-y))) (defvar display-mode-of) (defmacro with-focused-canvas (canvas &body body) "Executes the body with all drawing methods focused on the ~ canvas." `(case (display-mode-of ,canvas) (:active ,@body) ;; change when we know how to focus (ccl::with-focused-view (the-scroller ,canvas) ,@body)) (:postscript ,@body) (:printer ,@body) (:mcl-printer ,@body))) ;;;------------------------------------------------------------------------ ;;; Explicit fns to map between downwards-positive y-coords on mac and ;;; upwards-positive y-coords in canvas world. (defmacro host-to-canvas-y (canvas y) `(- (canvas-height ,canvas) ,y)) (defmacro canvas-to-host-y (canvas y) `(- (canvas-height ,canvas) ,y))
1,579
Common Lisp
.l
33
44.545455
125
0.496109
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
4dd71b13957d1bb5738dfb4898544e76f7cb9eb599224a1256a1435a962c7dad
33,443
[ -1 ]
33,444
operations.lsp
rwoldford_Quail/source/window-basics/macros/operations.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; operations.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; R.W. Oldford 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*canvas-operations* ) )) (defvar *canvas-operations* (loop for boole in (list :boole-1 :boole-2 :boole-c1 :boole-c2 :boole-and :boole-nand :boole-ior :boole-xor :boole-nor :boole-eqv :boole-andc1 :boole-andc2 :boole-orc1 :boole-orc2) when (boole-to-op boole) collect (boole-to-op boole)) "List of all transfer operations available for a canvas.")
1,317
Common Lisp
.l
38
29.157895
86
0.455477
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
bc6640f0418e0e761a72fb79d2e2f7b18058265e69b4237fc22c5a7ef1f3ae16
33,444
[ -1 ]
33,445
operations-pc.lsp
rwoldford_Quail/source/window-basics/macros/operations-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; operations-pc.lisp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; G.W. Bennett 1995 ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(boole-to-op) )) #| (defmacro boole-to-op (value) (declare (special cg::po-replace cg::po-paint cg::po-invert cg::po-erase)) `(case ,value (:default cg::po-replace) (,boole-1 cg::po-replace) ;(,boole-c1 (+ cg::d~st cg::d~s~t cg::~d~st cg::~d~s~t)) (,boole-ior cg::po-paint) ;(,boole-orc1 (+ cg::d~st cg::~d~st cg::dst cg::d~s~t cg::~d~s~t cg::ds~t)) (,boole-xor cg::po-invert) ;(,boole-eqv (+ cg::dst cg::~d~st cg::ds~t cg::~d~s~t)) (,boole-andc1 cg::po-erase) ;;(,boole-and cg::dst) ;(,boole-and (+ cg::dst cg::ds~t)) (otherwise NIL))) |# (defmacro boole-to-op (value) (declare (special cg::po-replace cg::po-paint cg::po-invert cg::po-erase)) `(cond ((eq ,value :default) cg::po-replace) ((eq ,value :boole-1) cg::po-replace) ((eq ,value :boole-c1) (+ cg::po-d~st cg::po-d~s~t cg::po-~d~st cg::po-~d~s~t)) ((eq ,value :boole-ior) cg::po-paint) ((eq ,value :boole-orc1) (+ cg::po-d~st cg::po-~d~st cg::po-dst cg::po-d~s~t cg::po-~d~s~t cg::po-ds~t)) ((eq ,value :boole-xor) cg::po-invert) ((eq ,value :boole-eqv) (+ cg::po-dst cg::po-~d~st cg::po-ds~t cg::po-d~s~t)) ((eq ,value :boole-andc1) cg::po-erase) ((eq ,value :boole-and) cg::po-dst) ((eq ,value :boole-and) (+ cg::po-dst cg::po-ds~t)) (T cg::po-replace)))
2,353
Common Lisp
.l
52
41.576923
112
0.492817
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
8efa1617e6f3b3d41e062a4653776475c97ac018d984118f3d682a25e914657f
33,445
[ -1 ]
33,447
macros-sblx.lsp
rwoldford_Quail/source/window-basics/macros/macros-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; macros-sblx.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is an addition to Window-basics for moving pointclouds ;;; ;;; Authors: ;;; R.W. Oldford 1992 ;;; G.W. Bennett 1995, 2017 ;;; ;;; This file is for the PC-port but is an unmodified ;;; copy of the standard macros-mcl and -clx files. (gwb) ;;; Copied as macros-sblx.lsp 12au2017 (gwb) ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(with-focused-canvas host-to-canvas-y))) (defvar display-mode-of) (defmacro with-focused-canvas (canvas &body body) "Executes the body with all drawing methods focused on the ~ canvas." `(case (display-mode-of ,canvas) (:active ,@body) ;; change when we know how to focus (ccl::with-focused-view (the-scroller ,canvas) ,@body)) (:postscript ,@body) (:printer ,@body) (:mcl-printer ,@body))) ;;;------------------------------------------------------------------------ ;;; Explicit fns to map between downwards-positive y-coords on mac and ;;; upwards-positive y-coords in canvas world. (defmacro host-to-canvas-y (canvas y) `(- (canvas-height ,canvas) ,y)) (defmacro canvas-to-host-y (canvas y) `(- (canvas-height ,canvas) ,y))
1,597
Common Lisp
.l
34
44.764706
124
0.514414
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
e57617b6a73a638b40963b505a75b391876526f63b1376101a6bd6f88ed7a171
33,447
[ -1 ]
33,448
operations-sblx.lsp
rwoldford_Quail/source/window-basics/macros/operations-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; operations-sblx.lisp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; G.W. Bennett 1995 2017 ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(boole-to-op) )) #| (defmacro boole-to-op (value) (declare (special cg::po-replace cg::po-paint cg::po-invert cg::po-erase)) `(case ,value (:default cg::po-replace) (,boole-1 cg::po-replace) ;(,boole-c1 (+ cg::d~st cg::d~s~t cg::~d~st cg::~d~s~t)) (,boole-ior cg::po-paint) ;(,boole-orc1 (+ cg::d~st cg::~d~st cg::dst cg::d~s~t cg::~d~s~t cg::ds~t)) (,boole-xor cg::po-invert) ;(,boole-eqv (+ cg::dst cg::~d~st cg::ds~t cg::~d~s~t)) (,boole-andc1 cg::po-erase) ;;(,boole-and cg::dst) ;(,boole-and (+ cg::dst cg::ds~t)) (otherwise NIL))) (defmacro boole-to-op (value) (declare (special cg::po-replace cg::po-paint cg::po-invert cg::po-erase)) `(cond ((eq ,value :default) cg::po-replace) ((eq ,value :boole-1) cg::po-replace) ((eq ,value :boole-c1) (+ cg::po-d~st cg::po-d~s~t cg::po-~d~st cg::po-~d~s~t)) ((eq ,value :boole-ior) cg::po-paint) ((eq ,value :boole-orc1) (+ cg::po-d~st cg::po-~d~st cg::po-dst cg::po-d~s~t cg::po-~d~s~t cg::po-ds~t)) ((eq ,value :boole-xor) cg::po-invert) ((eq ,value :boole-eqv) (+ cg::po-dst cg::po-~d~st cg::po-ds~t cg::po-d~s~t)) ((eq ,value :boole-andc1) cg::po-erase) ((eq ,value :boole-and) cg::po-dst) ((eq ,value :boole-and) (+ cg::po-dst cg::po-ds~t)) (T cg::po-replace))) |# ;;; Until I know better what to do here, take the results from operations-clx.lsp (defmacro boole-to-op (value) `(case ,value (:default boole-1) (:boole-1 boole-1) (:boole-c1 boole-c1) (:boole-ior boole-ior) (:boole-orc1 boole-orc1) (:boole-xor boole-xor) (:boole-eqv boole-eqv) (:boole-andc1 boole-andc1) (:boole-and boole-and) (otherwise NIL)))
2,797
Common Lisp
.l
65
39.092308
112
0.507331
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
8ef09cb6e7c4abd934d215f1cdabe0cdce9e7e649e1823a0ef7116add091caa7
33,448
[ -1 ]
33,449
display-mode.lsp
rwoldford_Quail/source/window-basics/macros/display-mode.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; display-mode.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; N.G. Bennett 1992 ;;; R.W. Oldford 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(display-mode-of with-display-mode))) (defclass display-mode-mixin () ((display-mode :initform :active :initarg :display-mode :accessor display-mode-of :documentation "This slot determines the mode of display for ~ the canvas. (ie :printer, :postscript or :active)") )) (defvar display-mode) (defmacro with-display-mode (canvas display-mode (command &rest args) &body forms) "If display-mode is :active (the default), then the forms are evaluated ~ as usual. If the display-mode is not :active, but rather is one of ~ (:postscript :printer) then forms are not evaluated. Instead, ~ the command with its arguments is processed to find a like command ~ for the given display-mode." `(let ((display-mode ,display-mode)) (cond ((eq :active display-mode) ,@forms) ((eq :postscript display-mode) (let* ((canvas ,canvas) (old-mode (display-mode-of canvas)) result) (setf result (,(get-postscript-command command) ,@args)) (setf (display-mode-of canvas) :active) (,command ,@args) (setf (display-mode-of canvas) old-mode) result)) #| Here's where we might need to define "printer-.." commands for some port besides the Mac. .... rwo ((eq :printer display-mode) (let* ((canvas ,canvas) (old-mode (display-mode-of canvas)) result) (setf result (,(get-printer-command command) ,@args)) (setf (display-mode-of canvas) :active) (,command ,@args) (setf (display-mode-of canvas) old-mode) result)) |# (T ,@forms))) ) (defun get-printer-command (command-name) "Returns the printer command name corresponding to the given ~ command-name." (intern (concatenate 'string "PRINTER-" (string command-name)) :window-basics)) (defun get-postscript-command (command-name) "Returns the postscript command name corresponding to the given ~ command-name." (intern (concatenate 'string "PS-" (string command-name)) :window-basics))
3,103
Common Lisp
.l
77
33.350649
103
0.554521
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
413e82de75a353fdc69786b057c575264064d7b3a70550c154dc6ea33d0e5a32
33,449
[ -1 ]
33,450
(old)show-lines.lsp
rwoldford_Quail/source/window-basics/surface/(old)show-lines.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; (old)show-lines.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (export '(show-lines fast-show-lines)) (defun fast-show-lines (canvas x-origin y-origin x y cz szv c ncol aa depth-cue? erase? fast-color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round fast-move-to fast-line-to )) (with-pen-values-restored canvas (with-focused-canvas canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd dimx dimy ) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) (loop for j from dmy downto 1 by 1 do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for i from dmx downto 1 by 1 do (set-draw-color canvas (aref fast-color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) ) 2))) ))) (decf dd step-in-first) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) (loop for i from dmx downto 0 by 1 do (set-draw-color canvas (aref fast-color-table (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-second)) ) 2)))))) (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (fast-line-to (+ x-origin (the fixnum (aref x (- dd step-in-second)))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y (- dd step-in-second)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) (setf dd dc) (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for i from dmx downto 1 by 1 do (set-draw-color canvas (aref fast-color-table (- (truncate cd) (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) ) 2))) ))) (decf dd step-in-first) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) ) (T (if (= (abs step-in-first) 1) (progn (setf dimx dmy) (setf dimy dmx)) (progn (setf dimy dmy) (setf dimx dmx))) (setf dc 0) (if erase? (set-draw-color canvas (aref fast-color-table 0)) (set-draw-color canvas (aref fast-color-table (truncate (/ ncol 2)))) ) (loop for j from 0 to dimy do (setf dd dc) (fast-move-to (+ (the fixnum (aref x dd)) x-origin) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for i from 0 to (- dimx 1) do (incf dd (1+ dimy)) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (incf dc) ) (setf dd 0) (loop for i from 0 to dimx do (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for j from 0 to (- dimy 1) do (incf dd) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (incf dd) ) ) ) )))) (defun show-lines (canvas x-origin y-origin x y cz szv c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline + - * / aref canvas-move-to canvas-draw-to)) (with-pen-values-restored canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd ) (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) (cond (depth-cue? (loop for j from dmy downto 1 by 1 do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for i from dmx downto 1 by 1 do (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))) )) ) ) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) (loop for i from dmx downto 0 by 1 do (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x (- dd step-in-second)))) (+ y-origin (the fixnum (aref y (- dd step-in-second)))) :color (aref color-table (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-second)) ) 2)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for i from dmx downto 1 by 1 do (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (- (truncate cd) (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))) )) ) ) ) (T (loop for j from dmy downto 0 by 1 do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for i from (- dmx 1) downto 0 by 1 do (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (truncate (/ ncol 2)))) ) (decf dc step-in-second) ) (setf dc (- (* first-dim second-dim) 1 origin)) (loop for i from dmx downto 0 by 1 do (setf col1 (truncate (- cd (/ (* i (aref c 1)) dmx)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for j from (- dmy 1) downto 0 by 1 do (decf dd step-in-second) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (truncate (/ ncol 2)))) ) (decf dc step-in-first) ) ) ) )))
13,176
Common Lisp
.l
377
17.70557
86
0.331762
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
bf32be6092a8d11e05513f0cce8048128bd425157f0b278643006a7708733c12
33,450
[ -1 ]
33,451
old-show-lines.lsp
rwoldford_Quail/source/window-basics/surface/old-show-lines.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; show-lines.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(show-lines fast-show-lines))) (defun fast-show-lines (canvas x-origin y-origin x y cz szv c ncol aa depth-cue? erase? fast-color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round fast-move-to fast-line-to )) (with-pen-values-restored canvas (with-focused-canvas canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd dimx dimy ) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) (loop for j from dmy downto 1 by 1 do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for i from dmx downto 1 by 1 do (set-draw-color canvas (aref fast-color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) ) 2))) ))) (decf dd step-in-first) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) (loop for i from dmx downto 0 by 1 do (set-draw-color canvas (aref fast-color-table (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-second)) ) 2)))))) (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (fast-line-to (+ x-origin (the fixnum (aref x (- dd step-in-second)))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y (- dd step-in-second)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) (setf dd dc) (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for i from dmx downto 1 by 1 do (set-draw-color canvas (aref fast-color-table (- (truncate cd) (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) ) 2))) ))) (decf dd step-in-first) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) ) (T (if (= (abs step-in-first) 1) (progn (setf dimx dmy) (setf dimy dmx)) (progn (setf dimy dmy) (setf dimx dmx))) (setf dc 0) (if erase? (set-draw-color canvas (canvas-background-color canvas) ;;(aref fast-color-table 0) ) (set-draw-color canvas (aref fast-color-table (truncate (/ ncol 2)))) ) (loop for j from 0 to dimy do (setf dd dc) (fast-move-to (+ (the fixnum (aref x dd)) x-origin) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for i from 0 to (- dimx 1) do (incf dd (1+ dimy)) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (incf dc) ) (setf dd 0) (loop for i from 0 to dimx do (fast-move-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (loop for j from 0 to (- dimy 1) do (incf dd) (fast-line-to (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (incf dd) ) ) ) )))) (defun show-lines (canvas x-origin y-origin x y cz szv c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline + - * / aref canvas-move-to canvas-draw-to)) (with-pen-values-restored canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd ) (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) (cond (depth-cue? (loop for j from dmy downto 1 by 1 do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for i from dmx downto 1 by 1 do (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))) )) ) ) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) (loop for i from dmx downto 0 by 1 do (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x (- dd step-in-second)))) (+ y-origin (the fixnum (aref y (- dd step-in-second)))) :color (aref color-table (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-second)) ) 2)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for i from dmx downto 1 by 1 do (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (- (truncate cd) (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))) )) ) ) ) (T (loop for j from dmy downto 0 by 1 do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for i from (- dmx 1) downto 0 by 1 do (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (truncate (/ ncol 2)))) ) (decf dc step-in-second) ) (setf dc (- (* first-dim second-dim) 1 origin)) (loop for i from dmx downto 0 by 1 do (setf col1 (truncate (- cd (/ (* i (aref c 1)) dmx)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (loop for j from (- dmy 1) downto 0 by 1 do (decf dd step-in-second) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (truncate (/ ncol 2)))) ) (decf dc step-in-first) ) ) ) )))
13,324
Common Lisp
.l
379
17.844327
95
0.333126
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
aad6b4f72fe11874b63e1f6be4c79f233678466b5fe636a50f7596b9f841e158
33,451
[ -1 ]
33,452
surface-fill.lsp
rwoldford_Quail/source/window-basics/surface/surface-fill.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; surface-fill.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(surface-fill fast-surface-fill))) (defun fast-surface-fill (canvas x-origin y-origin x y cz szv c ncol aa fast-color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round)) #-:sbcl(declare (inline fast-move-to fast-line-to )) (with-pen-values-restored canvas (with-focused-canvas canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd ) (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) ; (loop for j from dmy downto 1 by 1 do (do ((j dmy (decf j))) ((< j 1)) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from dmx downto 1 by 1 do (do ((i dmx (decf i))) ((< i 1)) (set-fast-color canvas (aref fast-color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) (aref cz (- dd step-in-first step-in-second)) (aref cz (- dd step-in-second)) ) 4))) ))) (wb:canvas-draw-filled-polygon canvas (list (cons (+ x-origin (aref x dd)) (+ y-origin (aref y dd))) (cons (+ x-origin (aref x (- dd step-in-first))) (+ y-origin (aref y (- dd step-in-first)))) (cons (+ x-origin (aref x (- dd step-in-first step-in-second))) (+ y-origin (aref y (- dd step-in-first step-in-second)))) (cons (+ x-origin (aref x (- dd step-in-second))) (+ y-origin (aref y (- dd step-in-second)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) ) ))) (defun surface-fill (canvas x-origin y-origin x y cz szv c ncol aa color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline + - * / aref)) #-:sbcl(declare (inline canvas-move-to canvas-draw-to)) (with-pen-values-restored canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd ) (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) ; (loop for j from dmy downto 1 by 1 do (do ((j dmy (decf j))) ((< j 1)) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from dmx downto 1 by 1 do (do ((i dmx (decf i))) ((< i 1)) (wb:canvas-draw-filled-polygon canvas (list (cons (+ x-origin (aref x dd)) (+ y-origin (aref y dd))) (cons (+ x-origin (aref x (- dd step-in-first))) (+ y-origin (aref y (- dd step-in-first)))) (cons (+ x-origin (aref x (- dd step-in-first step-in-second))) (+ y-origin (aref y (- dd step-in-first step-in-second)))) (cons (+ x-origin (aref x (- dd step-in-second))) (+ y-origin (aref y (- dd step-in-second))))) :color (aref color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) (aref cz (- dd step-in-first step-in-second)) (aref cz (- dd step-in-second)) ) 4))) ))) (decf dd step-in-first) ) (decf dc step-in-second) ) ) ))
5,655
Common Lisp
.l
139
26.741007
99
0.40051
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
179d133b1cfce858987b8a8ac5c827b3dd8757f94fe48772ad18127e30b11472
33,452
[ -1 ]
33,453
hide-lines.lsp
rwoldford_Quail/source/window-basics/surface/hide-lines.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; hide-lines.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(hide-lines fast-hide-lines))) (defun hide-lines (canvas x y cz lower-y upper-y dl nl szv x-origin y-origin mx my a c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate)) #-:sbcl-linux(declare (inline show-line)) (with-pen-values-restored canvas (let* ((first-dim (aref szv 0)) (second-dim (aref szv 1)) (step-in-first (aref szv 2)) (step-in-second (aref szv 3)) (origin (aref szv 4)) (dmx (- first-dim 1)) (dmy (- second-dim 1)) cd dc col1 dd col2 a2 a5 base st ct ) ; (loop for i from 0 to (- mx 1) do (do ((i 0 (incf i))) ((= i mx)) (setf (aref lower-y i) my) (setf (aref upper-y i) 0)) (setf a2 (aref a 2)) (cond ((< (abs a2) 1e-5) (setf st 0.0) (setf ct 1.0)) (T (setf a5 (aref a 5)) (setf base (sqrt (+ (* a2 a2) (* a5 a5)))) (setf st (/ a2 base)) (setf ct (/ a5 base)))) (setf dc origin) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) ; (loop for j from 0 to (- dmy 1) do (do ((j 0 (incf j))) ((= j dmy)) (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (setf col2 (- col1 (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf col1 (truncate (- cd (/ (* (+ j 0.5) (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from 0 to dmx do (do ((i 0 (incf i))) ((> i dmx)) (setf col2 (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-second)) ) 2))))) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) (setf cd (truncate (- cd (aref c 2)))) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (setf col2 (- cd (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) ) (T (setf col2 (truncate (/ ncol 2))) ; (loop for j from 0 to (- dmy 1) do (do ((j 0 (incf j))) ((= j dmy)) (setf dd dc) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf dd dc) ; (loop for i from 0 to dmx do (do ((i 0 (incf i))) ((> i dmx)) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) ) )))) (defun show-line (canvas x1 y1 x2 y2 x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (declare (fixnum x1 y1 x2 y2 mx my col2) (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round)) #-:sbcl-linux(declare (inline canvas-move-to canvas-draw-to update-border)) (let (nx1 ny1 nx2 ny2 s) (setf mx (truncate mx 2)) (setf my (truncate my 2)) (decf x1 mx) (decf y1 my) (decf x2 mx) (decf y2 my) (setf nx1 (round (+ (* x1 ct) (* y1 (- st)) mx))) (setf ny1 (round (+ (* y1 ct) (* x1 st) my ))) (setf nx2 (round (+ (* x2 ct) (* y2 (- st)) mx))) (setf ny2 (round (+ (* y2 ct) (* x2 st) my))) (setf s 1) (setf (aref nl 0) 0) (update-border upper-y nx1 ny1 nx2 ny2 s dl nl) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (canvas-move-to canvas (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)) :color (aref color-table col2)) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (canvas-move-to canvas (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)) :color (aref color-table col2)) ) (setf s -1) (setf (aref nl 0) 0) (update-border lower-y nx1 ny1 nx2 ny2 s dl nl) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (canvas-move-to canvas (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)) :color (aref color-table col2)) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (canvas-move-to canvas (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)) :color (aref color-table col2)) ) ) ) (defun update-border (border x1 y1 x2 y2 s dl nl) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * )) #-:sbcl-linux(declare (inline update-line)) (let ((dx 0) (dy 0) (up T) (tx1 0) (ty1 0) (tx2 0) (sx 0) (sy 0) (dxa 0) (dya 0) (d 0) (inc1 0) (inc2 0) (x 0) (y 0) ) (declare (fixnum dxa dya dx dy tx1 tx2 ty1 sx sy d inc1 inc2 x y s x1 y1 x2 y2)) (block outer (setf tx2 0) (setf dx (- x2 x1)) (setf dy (- y2 y1)) (if (and (= 0 dx) (= 0 dy)) (return-from outer 0)) (if (> dx 0) (setf sx 1) (setf sx -1)) (setf dxa (* dx sx)) (if (> dy 0) (setf sy 1) (setf sy -1)) (setf dya (* dy sy)) (setf up nil) (if (> dya dxa) (progn (setf inc1 (+ dxa dxa)) (setf d (- inc1 dya)) (setf inc2 (- d dya)) (if (> (* s dy) 0) (progn (setf x x1) (do ((y y1 (+ y sy))) ((if (minusp sy) (< y y2) (> y y2))) (if (> (* s (- y (aref border x))) 0) (progn (if (not up) (progn (setf up t) (setf tx1 x) (setf ty1 y) )) (setf (aref border x) y) ) (if up (progn (setf up nil) (update-line tx1 ty1 tx2 (- y sy) dl nl) ) ) ) (setf tx2 x) (if (< d 0) (incf d inc1) (progn (incf d inc2) (incf x sx) ) ) ) (if up (update-line tx1 ty1 x2 y2 dl nl) ) (return-from outer 0) ) ) (setf x x2) (do ((y y2 (- y sy))) ((if (minusp sy) (> y y1) (< y y1))) (if (> (* s (- y (aref border x))) 0) (progn (if (not up) (progn (setf up t) (setf tx1 x) (setf ty1 y) )) (setf (aref border x) y) ) (if up (progn (setf up nil) (update-line tx2 (+ y sy) tx1 ty1 dl nl) ) ) ) (setf tx2 x) (if (<= d 0) (incf d inc1) (progn (incf d inc2) (incf x (- sx)) ) ) ) (if up (update-line x1 y1 tx1 ty1 dl nl) ) (return-from outer 0) ) ) (setf inc1 (+ dya dya)) (setf d (- inc1 dxa)) (setf inc2 (- d dxa)) (setf y y1) (do ((x x1 (+ x sx))) ((if (minusp sx) (< x x2) (> x x2))) (if (> (* s (- y (aref border x))) 0) (progn (if (not up) (progn (setf up t) (setf tx1 x) (setf ty1 y) )) (setf (aref border x) y) ) (if up (progn (setf up nil) (update-line tx1 ty1 (- x sx) (aref border (- x sx)) dl nl) ) ) ) (if (<= d 0) (incf d inc1) (progn (incf d inc2) (incf y sy) ) ) ) (if up (update-line tx1 ty1 x2 y2 dl nl) ) (return-from outer 0) ) ) ) (defun update-line (x1 y1 x2 y2 dl nl) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * > =)) (let ((n 0) (size1 0) (size2 0) (size3 0)) (declare (fixnum x1 y1 x2 y2 n size1 size2 size3)) (block outer (setf n (aref nl 0)) (if (> n 1) (progn (setf size1 (+ (* (- x2 x1) (- x2 x1)) (* (- y2 y1) (- y2 y1)))) (setf size2 (+ (* (- (aref dl 3) (aref dl 1)) (- (aref dl 3) (aref dl 1))) (* (- (aref dl 2) (aref dl 0)) (- (aref dl 2) (aref dl 0))))) (setf size3 (+ (* (- (aref dl 7) (aref dl 5)) (- (aref dl 7) (aref dl 5))) (* (- (aref dl 6) (aref dl 4)) (- (aref dl 6) (aref dl 4))))) (if (> size1 size2) (if (> size2 size3) (setf n 1) (setf n 0) ) (if (> size1 size3) (setf n 1) (return-from outer 0) ) ) ) (incf (aref nl 0) 1) ) (if (= n 0) (progn (setf (aref dl 0) x1) (setf (aref dl 1) y1) (setf (aref dl 2) x2) (setf (aref dl 3) y2) ) (progn (setf (aref dl 4) x1) (setf (aref dl 5) y1) (setf (aref dl 6) x2) (setf (aref dl 7) y2) ) ) (return-from outer 1) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Faster versions of same ;;; (defun fast-hide-lines (canvas x y cz lower-y upper-y dl nl szv x-origin y-origin mx my a c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate )) #-:sbcl-linux(declare (inline fast-show-line)) (with-pen-values-restored canvas (with-focused-canvas canvas (let* ((first-dim (aref szv 0)) (second-dim (aref szv 1)) (step-in-first (aref szv 2)) (step-in-second (aref szv 3)) (origin (aref szv 4)) (dmx (- first-dim 1)) (dmy (- second-dim 1)) cd dc col1 dd col2 a2 a5 base st ct ) ; (loop for i from 0 to (- mx 1) do (do ((i 0 (incf i))) ((= i mx)) (setf (aref lower-y i) my) (setf (aref upper-y i) 0)) (setf dc origin) (setf a2 (aref a 2)) (cond ((< (abs a2) 1e-5) (setf st 0.0) (setf ct 1.0)) (T (setf a5 (aref a 5)) (setf base (sqrt (+ (* a2 a2) (* a5 a5)))) (setf st (/ a2 base)) (setf ct (/ a5 base)))) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) ; (loop for j from 0 to (- dmy 1) do (do ((j 0 (incf j))) ((= j dmy)) (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (setf col2 (- col1 (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf col1 (truncate (- cd (/ (* (+ j 0.5) (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from 0 to dmx do (do ((i 0 (incf i))) ((> i dmx)) (setf col2 (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-second)) ) 2))))) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) (setf cd (truncate (- cd (aref c 2)))) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (setf col2 (- col1 (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) ) (T (setf col2 (truncate (/ ncol 2))) ; (loop for j from 0 to (- dmy 1) do (do ((j 0 (incf j))) ((= j dmy)) (setf dd dc) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf dd dc) ; (loop for i from 0 to dmx do (do ((i 0 (incf i))) ((> i dmx)) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) ; (loop for i from 0 to (- dmx 1) do (do ((i 0 (incf i))) ((= i dmx)) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) )))))) (defun fast-show-line (canvas x1 y1 x2 y2 x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (declare (fixnum x1 y1 x2 y2 mx my col2) (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round )) #-:sbcl-linux(declare (inline fast-move-to fast-line-to update-border)) (let (nx1 ny1 nx2 ny2 s) (setf mx (truncate mx 2)) (setf my (truncate my 2)) (decf x1 mx) (decf y1 my) (decf x2 mx) (decf y2 my) (setf nx1 (round (+ (* x1 ct) (* y1 (- st)) mx))) (setf ny1 (round (+ (* y1 ct) (* x1 st) my ))) (setf nx2 (round (+ (* x2 ct) (* y2 (- st)) mx))) (setf ny2 (round (+ (* y2 ct) (* x2 st) my))) (setf s 1) (setf (aref nl 0) 0) (update-border upper-y nx1 ny1 nx2 ny2 s dl nl) (set-fast-color canvas (aref color-table col2)) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (fast-move-to canvas (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin)))) (fast-line-to canvas (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)))) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (fast-move-to canvas (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin)))) (fast-line-to canvas (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)))) ) (setf s -1) (setf (aref nl 0) 0) (update-border lower-y nx1 ny1 nx2 ny2 s dl nl) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (fast-move-to canvas (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin)))) (fast-line-to canvas (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)))) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (fast-move-to canvas (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin)))) (fast-line-to canvas (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)))) ) ) )
30,145
Common Lisp
.l
826
19.031477
95
0.322076
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
11c766f16608724e71e9ebb1ae222b3ec6298aff1d173d188ee57a1f8bb5686f
33,453
[ -1 ]
33,454
old-hide-lines.lsp
rwoldford_Quail/source/window-basics/surface/old-hide-lines.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; hide-lines.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(hide-lines fast-hide-lines))) (defun hide-lines (canvas x y cz lower-y upper-y dl nl szv x-origin y-origin mx my a c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate show-line)) (with-pen-values-restored canvas (let* ((first-dim (aref szv 0)) (second-dim (aref szv 1)) (step-in-first (aref szv 2)) (step-in-second (aref szv 3)) (origin (aref szv 4)) (dmx (- first-dim 1)) (dmy (- second-dim 1)) cd dc col1 dd col2 a2 a5 base st ct ) (loop for i from 0 to (- mx 1) do (setf (aref lower-y i) my) (setf (aref upper-y i) 0)) (setf a2 (aref a 2)) (cond ((< (abs a2) 1e-5) (setf st 0.0) (setf ct 1.0)) (T (setf a5 (aref a 5)) (setf base (sqrt (+ (* a2 a2) (* a5 a5)))) (setf st (/ a2 base)) (setf ct (/ a5 base)))) (setf dc origin) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (loop for j from 0 to (- dmy 1) do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (loop for i from 0 to (- dmx 1) do (setf col2 (- col1 (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf col1 (truncate (- cd (/ (* (+ j 0.5) (aref c 2)) dmy)))) (setf dd dc) (loop for i from 0 to dmx do (setf col2 (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-second)) ) 2))))) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) (setf cd (truncate (- cd (aref c 2)))) (loop for i from 0 to (- dmx 1) do (setf col2 (- cd (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) ) (T (setf col2 (truncate (/ ncol 2))) (loop for j from 0 to (- dmy 1) do (setf dd dc) (loop for i from 0 to (- dmx 1) do (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf dd dc) (loop for i from 0 to dmx do (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) (loop for i from 0 to (- dmx 1) do (show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) ) )))) (defun show-line (canvas x1 y1 x2 y2 x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (declare (fixnum x1 y1 x2 y2 mx my col2) (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round canvas-move-to canvas-draw-to update-border)) (let (nx1 ny1 nx2 ny2 s) (setf mx (truncate mx 2)) (setf my (truncate my 2)) (decf x1 mx) (decf y1 my) (decf x2 mx) (decf y2 my) (setf nx1 (round (+ (* x1 ct) (* y1 (- st)) mx))) (setf ny1 (round (+ (* y1 ct) (* x1 st) my ))) (setf nx2 (round (+ (* x2 ct) (* y2 (- st)) mx))) (setf ny2 (round (+ (* y2 ct) (* x2 st) my))) (setf s 1) (setf (aref nl 0) 0) (update-border upper-y nx1 ny1 nx2 ny2 s dl nl) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (canvas-move-to canvas (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)) :color (aref color-table col2)) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (canvas-move-to canvas (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)) :color (aref color-table col2)) ) (setf s -1) (setf (aref nl 0) 0) (update-border lower-y nx1 ny1 nx2 ny2 s dl nl) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (canvas-move-to canvas (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)) :color (aref color-table col2)) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (canvas-move-to canvas (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin))) (canvas-draw-to canvas (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)) :color (aref color-table col2)) ) ) ) (defun update-border (border x1 y1 x2 y2 s dl nl) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * update-line)) (let (dx dy up tx1 ty1 tx2 sx sy dxa dya d inc1 inc2 x y ) (declare (fixnum dxa dya dx dy tx1 tx2 ty1 sx sy d inc1 inc2 x y s x1 y1 x2 y2)) (block outer (setf tx2 0) (setf dx (- x2 x1)) (setf dy (- y2 y1)) (if (and (= 0 dx) (= 0 dy)) (return-from outer 0)) (if (> dx 0) (setf sx 1) (setf sx -1)) (setf dxa (* dx sx)) (if (> dy 0) (setf sy 1) (setf sy -1)) (setf dya (* dy sy)) (setf up nil) (if (> dya dxa) (progn (setf inc1 (+ dxa dxa)) (setf d (- inc1 dya)) (setf inc2 (- d dya)) (if (> (* s dy) 0) (progn (setf x x1) (do ((y y1 (+ y sy))) ((if (minusp sy) (< y y2) (> y y2))) (if (> (* s (- y (aref border x))) 0) (progn (if (not up) (progn (setf up t) (setf tx1 x) (setf ty1 y) )) (setf (aref border x) y) ) (if up (progn (setf up nil) (update-line tx1 ty1 tx2 (- y sy) dl nl) ) ) ) (setf tx2 x) (if (< d 0) (incf d inc1) (progn (incf d inc2) (incf x sx) ) ) ) (if up (update-line tx1 ty1 x2 y2 dl nl) ) (return-from outer 0) ) ) (setf x x2) (do ((y y2 (- y sy))) ((if (minusp sy) (> y y1) (< y y1))) (if (> (* s (- y (aref border x))) 0) (progn (if (not up) (progn (setf up t) (setf tx1 x) (setf ty1 y) )) (setf (aref border x) y) ) (if up (progn (setf up nil) (update-line tx2 (+ y sy) tx1 ty1 dl nl) ) ) ) (setf tx2 x) (if (<= d 0) (incf d inc1) (progn (incf d inc2) (incf x (- sx)) ) ) ) (if up (update-line x1 y1 tx1 ty1 dl nl) ) (return-from outer 0) ) ) (setf inc1 (+ dya dya)) (setf d (- inc1 dxa)) (setf inc2 (- d dxa)) (setf y y1) (do ((x x1 (+ x sx))) ((if (minusp sx) (< x x2) (> x x2))) (if (> (* s (- y (aref border x))) 0) (progn (if (not up) (progn (setf up t) (setf tx1 x) (setf ty1 y) )) (setf (aref border x) y) ) (if up (progn (setf up nil) (update-line tx1 ty1 (- x sx) (aref border (- x sx)) dl nl) ) ) ) (if (<= d 0) (incf d inc1) (progn (incf d inc2) (incf y sy) ) ) ) (if up (update-line tx1 ty1 x2 y2 dl nl) ) (return-from outer 0) ) ) ) (defun update-line (x1 y1 x2 y2 dl nl) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * > =)) (let (n size1 size2 size3) (declare (fixnum x1 y1 x2 y2 n size1 size2 size3)) (block outer (setf n (aref nl 0)) (if (> n 1) (progn (setf size1 (+ (* (- x2 x1) (- x2 x1)) (* (- y2 y1) (- y2 y1)))) (setf size2 (+ (* (- (aref dl 3) (aref dl 1)) (- (aref dl 3) (aref dl 1))) (* (- (aref dl 2) (aref dl 0)) (- (aref dl 2) (aref dl 0))))) (setf size3 (+ (* (- (aref dl 7) (aref dl 5)) (- (aref dl 7) (aref dl 5))) (* (- (aref dl 6) (aref dl 4)) (- (aref dl 6) (aref dl 4))))) (if (> size1 size2) (if (> size2 size3) (setf n 1) (setf n 0) ) (if (> size1 size3) (setf n 1) (return-from outer 0) ) ) ) (incf (aref nl 0) 1) ) (if (= n 0) (progn (setf (aref dl 0) x1) (setf (aref dl 1) y1) (setf (aref dl 2) x2) (setf (aref dl 3) y2) ) (progn (setf (aref dl 4) x1) (setf (aref dl 5) y1) (setf (aref dl 6) x2) (setf (aref dl 7) y2) ) ) (return-from outer 1) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; Faster versions of same ;;; (defun fast-hide-lines (canvas x y cz lower-y upper-y dl nl szv x-origin y-origin mx my a c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate fast-show-line)) (with-pen-values-restored canvas (with-focused-canvas canvas (let* ((first-dim (aref szv 0)) (second-dim (aref szv 1)) (step-in-first (aref szv 2)) (step-in-second (aref szv 3)) (origin (aref szv 4)) (dmx (- first-dim 1)) (dmy (- second-dim 1)) cd dc col1 dd col2 a2 a5 base st ct ) (loop for i from 0 to (- mx 1) do (setf (aref lower-y i) my) (setf (aref upper-y i) 0)) (setf dc origin) (setf a2 (aref a 2)) (cond ((< (abs a2) 1e-5) (setf st 0.0) (setf ct 1.0)) (T (setf a5 (aref a 5)) (setf base (sqrt (+ (* a2 a2) (* a5 a5)))) (setf st (/ a2 base)) (setf ct (/ a5 base)))) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (loop for j from 0 to (- dmy 1) do (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (loop for i from 0 to (- dmx 1) do (setf col2 (- col1 (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf col1 (truncate (- cd (/ (* (+ j 0.5) (aref c 2)) dmy)))) (setf dd dc) (loop for i from 0 to dmx do (setf col2 (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-second)) ) 2))))) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) (setf cd (truncate (- cd (aref c 2)))) (loop for i from 0 to (- dmx 1) do (setf col2 (- col1 (truncate (/ (* (+ i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))))) (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) ) (T (setf col2 (truncate (/ ncol 2))) (loop for j from 0 to (- dmy 1) do (setf dd dc) (loop for i from 0 to (- dmx 1) do (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (setf dd dc) (loop for i from 0 to dmx do (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-second)) (aref y (+ dd step-in-second)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) (incf dc step-in-second)) (setf dd dc) (loop for i from 0 to (- dmx 1) do (fast-show-line canvas (aref x dd) (aref y dd) (aref x (+ dd step-in-first)) (aref y (+ dd step-in-first)) x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (incf dd step-in-first)) )))))) (defun fast-show-line (canvas x1 y1 x2 y2 x-origin y-origin lower-y upper-y dl nl ct st mx my col2 color-table) (declare (fixnum x1 y1 x2 y2 mx my col2) (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round fast-move-to fast-line-to update-border)) (let (nx1 ny1 nx2 ny2 s) (setf mx (truncate mx 2)) (setf my (truncate my 2)) (decf x1 mx) (decf y1 my) (decf x2 mx) (decf y2 my) (setf nx1 (round (+ (* x1 ct) (* y1 (- st)) mx))) (setf ny1 (round (+ (* y1 ct) (* x1 st) my ))) (setf nx2 (round (+ (* x2 ct) (* y2 (- st)) mx))) (setf ny2 (round (+ (* y2 ct) (* x2 st) my))) (setf s 1) (setf (aref nl 0) 0) (update-border upper-y nx1 ny1 nx2 ny2 s dl nl) (set-fast-color canvas (aref color-table col2)) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (fast-move-to (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin)))) (fast-line-to (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)))) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (fast-move-to (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin)))) (fast-line-to (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)))) ) (setf s -1) (setf (aref nl 0) 0) (update-border lower-y nx1 ny1 nx2 ny2 s dl nl) (when (> (aref nl 0) 0) (setf (aref dl 0) (- (aref dl 0) mx)) (setf (aref dl 1) (- (aref dl 1) my)) (setf (aref dl 2) (- (aref dl 2) mx)) (setf (aref dl 3) (- (aref dl 3) my)) (fast-move-to (round (+ (* (aref dl 0) ct) (* (aref dl 1) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 1) ct) (* (aref dl 0) (- st)) my y-origin)))) (fast-line-to (round (+ (* (aref dl 2) ct) (* (aref dl 3) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 3) ct) (* (aref dl 2) (- st)) my y-origin)))) ) (when (> (aref nl 0) 1) (setf (aref dl 4) (- (aref dl 4) mx)) (setf (aref dl 5) (- (aref dl 5) my)) (setf (aref dl 6) (- (aref dl 6) mx)) (setf (aref dl 7) (- (aref dl 7) my)) (fast-move-to (round (+ (* (aref dl 4) ct) (* (aref dl 5) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 5) ct) (* (aref dl 4) (- st)) my y-origin)))) (fast-line-to (round (+ (* (aref dl 6) ct) (* (aref dl 7) st) mx x-origin)) (host-to-canvas-y canvas (round (+ (* (aref dl 7) ct) (* (aref dl 6) (- st)) my y-origin)))) ) ) )
29,723
Common Lisp
.l
809
18.309023
95
0.312304
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
151ea148d782cda61f6f6189c3820bd3085e93d80480cb17a343bb13c0a44a87
33,454
[ -1 ]
33,455
surface-update.lsp
rwoldford_Quail/source/window-basics/surface/surface-update.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; surface-update.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) 1992 ;;; Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '())) (defun update-surface-data (x y z a xi yi old-x old-y ziv ax ay col dx dy dz mx my range ncol) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline + * - aref truncate float)) (let ((cfx (float (/ (min mx my) (* 2 range)))) k minz (mz (make-array (list 4) :element-type 'single-float :initial-element 0.0)) (myi (make-array (list 4) :element-type 'integer :initial-element 0)) (cd (truncate (/ ncol 2))) (dmx (truncate (/ mx 2))) (dmy (truncate (/ my 2)))) ; (loop for i from 0 to (- dx 1) do (do ((i 0 (incf i))) ((= i dx)) (setf (aref ax i) (* (aref a 0) (aref x i))) (setf (aref ax (+ dx i)) (* (aref a 3) (aref x i)))) ; (loop for j from 0 to (- dy 1) do (do ((j 0 (incf j))) ((= j dy)) (setf (aref ay j) (* (aref a 1) (aref y j))) (setf (aref ay (+ dy j)) (* (aref a 4) (aref y j)))) (setf k 0) ; (loop for i from 0 to (- dx 1) do (do ((i 0 (incf i))) ((= i dx)) ; (loop for j from 0 to (- dy 1) do (do ((j 0 (incf j))) ((= j dy)) (setf (aref old-x k) (aref xi k)) (setf (aref xi k) (+ (round (* (+ (aref ax i) (aref ay j) (* (aref a 2) (aref z k))) cfx)) dmx)) (setf (aref old-y k) (aref yi k)) (setf (aref yi k) (+ (round (* (+ (aref ax (+ dx i)) (aref ay (+ dy j)) (* (aref a 5) (aref z k))) cfx)) dmy)) (incf k))) (setf (aref mz 0) (+ (* (aref a 6) (aref x 0)) (* (aref a 7) (aref y 0)))) (setf (aref mz 1) (+ (* (aref a 6) (aref x 0)) (* (aref a 7) (aref y (- dy 1))))) (setf (aref mz 2) (+ (* (aref a 6) (aref x (- dx 1))) (* (aref a 7) (aref y (- dy 1))))) (setf (aref mz 3) (+ (* (aref a 6) (aref x (- dx 1))) (* (aref a 7) (aref y 0)))) (setf (aref myi 0) (aref yi 0)) (setf (aref myi 1) (aref yi (- dy 1))) (setf (aref myi 2) (aref yi (- dz 1))) (setf (aref myi 3) (aref yi (- dz dy))) (setf minz 0) ; (loop for i from 1 to 3 do (do ((i 1 (incf i))) ((> i 3)) (if (or (> (aref mz minz) (aref mz i)) (and (= (aref mz minz) (aref mz i)) (< (aref myi minz) (aref myi i)))) (setf minz i))) (setf (aref col 0) (float (/ (* (- cd) (aref mz minz)) range))) (cond ((= minz 0) (cond ((or (> (aref mz 1) (aref mz 3)) (and (= (aref mz 1) (aref mz 3)) (< (aref myi 1) (aref myi 3)))) (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 3)) range)))) (setf (aref ziv 0) dx) (setf (aref ziv 1) dy) (setf (aref ziv 2) dy) (setf (aref ziv 3) 1) (setf (aref ziv 4) 0)) (t (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 1)) range)))) (setf (aref ziv 0) dy) (setf (aref ziv 1) dx) (setf (aref ziv 2) 1) (setf (aref ziv 3) dy) (setf (aref ziv 4) 0)))) ((= minz 1) (cond ((or (> (aref mz 0) (aref mz 2)) (and (= (aref mz 0) (aref mz 2)) (< (aref myi 0) (aref myi 2)))) (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 2)) range)))) (setf (aref ziv 0) dx) (setf (aref ziv 1) dy) (setf (aref ziv 2) dy) (setf (aref ziv 3) -1) (setf (aref ziv 4) (- dy 1))) (t (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 0)) range)))) (setf (aref ziv 0) dy) (setf (aref ziv 1) dx) (setf (aref ziv 2) -1) (setf (aref ziv 3) dy) (setf (aref ziv 4) (- dy 1))))) ((= minz 2) (cond ((or (> (aref mz 3) (aref mz 1)) (and (= (aref mz 3) (aref mz 1)) (< (aref myi 3) (aref myi 1)))) (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 1)) range)))) (setf (aref ziv 0) dx) (setf (aref ziv 1) dy) (setf (aref ziv 2) (- dy)) (setf (aref ziv 3) -1) (setf (aref ziv 4) (- dz 1))) (t (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 3)) range)))) (setf (aref ziv 0) dy) (setf (aref ziv 1) dx) (setf (aref ziv 2) -1) (setf (aref ziv 3) (- dy)) (setf (aref ziv 4) (- dz 1))))) ((= minz 3) (cond ((or (> (aref mz 2) (aref mz 0)) (and (= (aref mz 2) (aref mz 0)) (< (aref myi 2) (aref myi 0)))) (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 0)) range)))) (setf (aref ziv 0) dx) (setf (aref ziv 1) dy) (setf (aref ziv 2) (- dy)) (setf (aref ziv 3) 1) (setf (aref ziv 4) (- dz dy))) (t (setf (aref col 1) (+ (aref col 0) (float (/ (* cd (aref mz 2)) range)))) (setf (aref ziv 0) dy) (setf (aref ziv 1) dx) (setf (aref ziv 2) 1) (setf (aref ziv 3) (- dy)) (setf (aref ziv 4) (- dz dy)))))) (setf (aref col 2) (+ (aref col 0) (aref col 0) (- (aref col 1)))) ) )
6,941
Common Lisp
.l
186
24.532258
86
0.354015
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
681b80e09c3d66e951ac55f22cd05046a07403d0fe6894abfddfa691d5f8e749
33,455
[ -1 ]
33,456
surface-rotate.lsp
rwoldford_Quail/source/window-basics/surface/surface-rotate.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; surface-rotate.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) 1992 ;;; Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; R.W. Oldford 1992 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '())) (defun spin-surface-x (a cos-theta sin-theta &optional old-a) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline CL:+ CL:* CL:- aref)) (unless old-a (setf old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0))) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref old-a i) (aref a (CL:+ (CL:* i 3) 1))) ) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref a (CL:+ (CL:* i 3) 1)) (CL:+ (CL:* (aref a (CL:+ (CL:* i 3) 1)) cos-theta) (CL:* (aref a (CL:+ (CL:* i 3) 2)) sin-theta))) (setf (aref a (CL:+ (CL:* i 3) 2)) (CL:- (CL:* (aref a (CL:+ (CL:* i 3) 2)) cos-theta) (CL:* (aref old-a i) sin-theta))) )) (defun spin-surface-y (a cos-theta sin-theta &optional old-a) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline CL:+ CL:* CL:- aref)) (unless old-a (setf old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0))) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref old-a i) (aref a (CL:+ (CL:* i 3) 2))) ) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref a (CL:+ (CL:* i 3) 2)) (CL:+ (CL:* (aref a (CL:+ (CL:* i 3) 2)) cos-theta) (CL:* (aref a (CL:* i 3)) sin-theta))) (setf (aref a (CL:* i 3)) (CL:- (CL:* (aref a (CL:* i 3)) cos-theta) (CL:* (aref old-a i) sin-theta))) )) (defun spin-surface-z (a cos-theta sin-theta &optional old-a) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline CL:+ CL:* CL:- aref)) (unless old-a (setf old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0))) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref old-a i) (aref a (CL:* i 3))) ) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref a (CL:* i 3)) (CL:+ (CL:* (aref a (CL:* i 3)) cos-theta) (CL:* (aref a (CL:+ (CL:* i 3) 1)) sin-theta))) (setf (aref a (CL:+ (CL:* i 3) 1)) (CL:- (CL:* (aref a (CL:+ (CL:* i 3) 1)) cos-theta) (CL:* (aref old-a i) sin-theta))) )) (defun spin-screen-x (a cos-theta sin-theta &optional old-a) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline CL:+ CL:* CL:- aref)) (unless old-a (setf old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0))) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref old-a i) (aref a (CL:+ i 3))) ) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref a (CL:+ i 3)) (CL:- (CL:* (aref a (CL:+ i 3)) cos-theta) (CL:* (aref a (CL:+ i 6)) sin-theta))) (setf (aref a (CL:+ i 6)) (CL:+ (CL:* (aref a (CL:+ i 6)) cos-theta) (CL:* (aref old-a i) sin-theta))) )) (defun spin-screen-y (a cos-theta sin-theta &optional old-a) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline CL:+ CL:* CL:- aref)) (unless old-a (setf old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0))) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref old-a i) (aref a (CL:+ i 6))) ) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref a (CL:+ i 6)) (CL:- (CL:* (aref a (CL:+ i 6)) cos-theta) (CL:* (aref a i) sin-theta))) (setf (aref a i) (CL:+ (CL:* (aref a i) cos-theta) (CL:* (aref old-a i) sin-theta))) )) (defun spin-screen-z (a cos-theta sin-theta &optional old-a) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline CL:+ CL:* CL:- aref)) (unless old-a (setf old-a (make-array (list 3) :element-type 'single-float :initial-element 0.0))) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref old-a i) (aref a i)) ) ; (loop for i from 0 to 2 do (do ((i 0 (incf i))) ((> i 2)) (setf (aref a i) (CL:- (CL:* (aref a i) cos-theta) (CL:* (aref a (CL:+ i 3)) sin-theta))) (setf (aref a (CL:+ i 3)) (CL:+ (CL:* (aref a (CL:+ i 3)) cos-theta) (CL:* (aref old-a i) sin-theta))) ))
6,162
Common Lisp
.l
177
24.728814
86
0.405741
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
aaffeb397c2c1c20b148161ecc3d7e7e91603ad92f4a273ec27e134d1e5c2456
33,456
[ -1 ]
33,457
show-lines.lsp
rwoldford_Quail/source/window-basics/surface/show-lines.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; show-lines.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; ;;; Authors: ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(show-lines fast-show-lines))) (defun fast-show-lines (canvas x-origin y-origin x y cz szv c ncol aa depth-cue? erase? fast-color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline aref + - / * sqrt truncate round)) #-:sbcl(declare (inline fast-move-to fast-line-to )) (with-pen-values-restored canvas (with-focused-canvas canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd dimx dimy ) (cond (depth-cue? (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) ; (loop for j from dmy downto 1 by 1 do (do ((j dmy (decf j))) ((< j 1)) (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (fast-move-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ; (loop for i from dmx downto 1 by 1 do (do ((i dmx (decf i))) ((< i 1)) (set-draw-color canvas (aref fast-color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) ) 2))) ))) (decf dd step-in-first) (fast-line-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from dmx downto 0 by 1 do (do ((i dmx (decf i))) ((< i 0)) (set-draw-color canvas (aref fast-color-table (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-second)) ) 2)))))) (fast-move-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) (fast-line-to canvas (+ x-origin (the fixnum (aref x (- dd step-in-second)))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y (- dd step-in-second)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) (setf dd dc) (fast-move-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ; (loop for i from dmx downto 1 by 1 do (do ((i dmx (decf i))) ((< i 1)) (set-draw-color canvas (aref fast-color-table (- (truncate cd) (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-first)) ) 2))) ))) (decf dd step-in-first) (fast-line-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) ) (T (if (= (abs step-in-first) 1) (progn (setf dimx dmy) (setf dimy dmx)) (progn (setf dimy dmy) (setf dimx dmx))) (setf dc 0) (if erase? (set-draw-color canvas (canvas-background-color canvas) ;;(aref fast-color-table 0) ) (set-draw-color canvas (aref fast-color-table (truncate (/ ncol 2)))) ) ; (loop for j from 0 to dimy do (do ((j 0 (incf j))) ((> j dimy)) (setf dd dc) (fast-move-to canvas (+ (the fixnum (aref x dd)) x-origin) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ; (loop for i from 0 to (- dimx 1) do (do ((i 0 (incf i))) ((= i dimx)) (incf dd (1+ dimy)) (fast-line-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (incf dc) ) (setf dd 0) ; (loop for i from 0 to dimx do (do ((i 0 (incf i))) ((> i dimx)) (fast-move-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ; (loop for j from 0 to (- dimy 1) do (do ((j 0 (incf j))) ((= j dimy)) (incf dd) (fast-line-to canvas (+ x-origin (the fixnum (aref x dd))) (host-to-canvas-y canvas (+ y-origin (the fixnum (aref y dd))))) ) (incf dd) ) ) ) )))) (defun show-lines (canvas x-origin y-origin x y cz szv c ncol aa depth-cue? color-table) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0)) (inline + - * / aref)) #-:sbcl(declare (inline canvas-move-to canvas-draw-to)) (with-pen-values-restored canvas (let* ((first-dim (the fixnum (aref szv 0))) (second-dim (the fixnum (aref szv 1))) (step-in-first (the fixnum (aref szv 2))) (step-in-second (the fixnum (aref szv 3))) (origin (the fixnum (aref szv 4))) (dmx (the fixnum (- first-dim 1))) (dmy (the fixnum (- second-dim 1))) cd dc col1 dd ) (setf cd (+ (truncate (/ ncol 2)) (aref c 0))) (setf dc (- (* first-dim second-dim) 1 origin)) (cond (depth-cue? ; (loop for j from dmy downto 1 by 1 do (do ((j dmy (decf j))) ((< j 1)) (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) ; (loop for i from dmx downto 1 by 1 do (do ((i dmx (decf i))) ((< i 1)) (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (- col1 (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))) )) ) ) (setf col1 (truncate (- cd (/ (* (- j 0.5) (aref c 2)) dmy)))) (setf dd dc) ; (loop for i from dmx downto 0 by 1 do (do ((i dmx (decf i))) ((< i 0)) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x (- dd step-in-second)))) (+ y-origin (the fixnum (aref y (- dd step-in-second)))) :color (aref color-table (- col1 (truncate (/ (* i (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (- dd step-in-second)) ) 2)))))) (decf dd step-in-first) ) (decf dc step-in-second) ) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) ; (loop for i from dmx downto 1 by 1 do (do ((i dmx (decf i))) ((< i 1)) (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (- (truncate cd) (truncate (/ (* (- i 0.5) (aref c 1)) dmx)) (truncate (* aa (/ (+ (aref cz dd) (aref cz (+ dd step-in-first)) ) 2))) )) ) ) ) (T ; (loop for j from dmy downto 0 by 1 do (do ((j dmy (decf j))) ((< j 0)) (setf col1 (truncate (- cd (/ (* j (aref c 2)) dmy)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) ; (loop for i from (- dmx 1) downto 0 by 1 do (do ((i (1- dmx) (decf i))) ((< i 0)) (decf dd step-in-first) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (truncate (/ ncol 2)))) ) (decf dc step-in-second) ) (setf dc (- (* first-dim second-dim) 1 origin)) ; (loop for i from dmx downto 0 by 1 do (do ((i dmx (decf i))) ((< i 0)) (setf col1 (truncate (- cd (/ (* i (aref c 1)) dmx)))) (setf dd dc) (canvas-move-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd)))) ; (loop for j from (- dmy 1) downto 0 by 1 do (do ((j (1- dmy) (decf j))) ((< j 0)) (decf dd step-in-second) (canvas-draw-to canvas (+ x-origin (the fixnum (aref x dd))) (+ y-origin (the fixnum (aref y dd))) :color (aref color-table (truncate (/ ncol 2)))) ) (decf dc step-in-first) ) ) ) )))
13,756
Common Lisp
.l
394
18.893401
95
0.345535
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
784146e74e59d9f3f6374a5e7c20e20e3279982a1b1e4ab7077258bba2c11cc8
33,457
[ -1 ]
33,458
color.lsp
rwoldford_Quail/source/window-basics/color/color.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; color.lsp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; N. Wiebe 1998 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*light-grey-color* *grey-color* *dark-grey-color* *cyan-colour* *black-colour* *white-colour* *pink-colour* *red-colour* *orange-colour* *yellow-colour* *green-colour* *dark-green-colour* *light-blue-colour* *blue-colour* *purple-colour* *brown-colour* *tan-colour* *light-gray-colour* *gray-colour* *dark-gray-colour* *light-grey-colour* *grey-colour* *dark-grey-colour* *bright-green-color* *magenta-color* *bright-green-colour* *magenta-colour* *colors* *bright-white-color* *default-canvas-background-color* *default-canvas-pen-color* shade-to-color color-to-shade optimize-color-record deoptimize-color-record rgb_to_lhs lhs_to_rgb hue-of lightness-of saturation-of lighten darken))) ;;; ;;; The following are typically shadowed from the host system ;;; (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*black-color* *white-color* *pink-color* *red-color* *orange-color* *yellow-color* *green-color* *dark-green-color* *light-blue-color* *blue-color* *purple-color* *brown-color* *tan-color* *light-gray-color* *gray-color* *dark-gray-color*) )) ;;;======================================================================== ;;; Colors/Colours ;;; ;;;======================================================================== ;;; ;;; These follow a red green blue (RGB) model for representing colour. ;;; ;;; (defparameter *black-color* (make-color 0.0 0.0 0.0)) (defparameter *white-color* (make-color 1.0 1.0 1.0)) (defparameter *pink-color* (make-color 0.9490196078431372 0.03137254901960784 0.5176470588235295)) (defparameter *red-color* (make-color 0.8666666666666667 0.03137254901960784 0.023529411764705882)) (defparameter *orange-color* (make-color 1.0 0.39215686274509803 0.00784313725490196)) (defparameter *yellow-color* (make-color 0.9882352941176471 0.9529411764705882 0.0196078431372549)) (defparameter *green-color* (make-color 0.12156862745098039 0.7176470588235294 0.0784313725490196)) (defparameter *dark-green-color* (make-color 0.0 0.39215686274509803 0.06666666666666667)) (defparameter *light-blue-color* (make-color 0.00784313725490196 0.6705882352941176 0.9176470588235294)) (defparameter *blue-color* (make-color 0.0 0.0 0.8313725490196079)) (defparameter wb::*cyan-color* (wb::make-color 0.0 1.0 1.0)) (defparameter *purple-color* (make-color 0.27450980392156865 0.0 0.6470588235294118)) (defparameter *brown-color* (make-color 0.33725490196078434 0.17254901960784313 0.0196078431372549)) (defparameter *tan-color* (make-color 0.5647058823529412 0.44313725490196076 0.22745098039215686)) (defparameter *light-gray-color* (make-color 0.7529411764705882 0.7529411764705882 0.7529411764705882)) (defparameter *gray-color* (make-color 0.5019607843137255 0.5019607843137255 0.5019607843137255)) (defparameter *dark-gray-color* (make-color 0.25098039215686274 0.25098039215686274 0.25098039215686274)) ;;; ;;; Accounting for different spellings of gray (defparameter *grey-color* *gray-color*) (defparameter *light-grey-color* *light-gray-color*) (defparameter *dark-grey-color* *dark-gray-color*) ;;; ;;; Accounting for different spellings of colour (defparameter *black-colour* *black-color*) (defparameter *white-colour* *white-color*) (defparameter *pink-colour* *pink-color*) (defparameter *red-colour* *red-color*) (defparameter *orange-colour* *orange-color*) (defparameter *yellow-colour* *yellow-color*) (defparameter *green-colour* *green-color*) (defparameter *dark-green-colour* *dark-green-color*) (defparameter *light-blue-colour* *light-blue-color*) (defparameter *blue-colour* *blue-color*) (defparameter *cyan-colour* *cyan-color*) (defparameter *purple-colour* *purple-color*) (defparameter *brown-colour* *brown-color*) (defparameter *tan-colour* *tan-color*) (defparameter *light-gray-colour* *light-gray-color*) (defparameter *gray-colour* *gray-color*) (defparameter *dark-gray-colour* *dark-gray-color*) ;(defparameter *grey-colour* *gray-color* ;;DUPLICATE of line 128 01SEP2021 ;(defparameter *light-grey-colour* *light-gray-color* ) ;;DUPLICATE of line 127 01SEP2021 ;(defparameter *dark-grey-colour* *dark-gray-color*) ;;DUPLICATE of line 129 01SEO2021 (defparameter *bright-green-color* (make-color 0 1.0 0)) (defparameter *bright-green-colour* *bright-green-color*) (defparameter *magenta-color* (make-color 1.0 0 1.0)) (defparameter *magenta-colour* *magenta-color*) (defvar *colors* (list *white-color* *pink-color* *red-color* *orange-color* *yellow-color* *green-color* *cyan-color* *blue-color* *purple-color* *brown-color* *tan-color* *gray-color* *black-color* *dark-green-color* *light-gray-color* *light-blue-color* *dark-gray-color*) "The list of predefined colors -- useful as an iteration sequence.") (defparameter *bright-white-color* (make-color 1.0 1.0 1.0)) ;;; ;;; Some default canvas colours. ;;; (defvar *default-canvas-background-color* *white-color* "The default colour for the background of a canvas. ~ (:see-also *default-canvas-pen-color*)" ) (defvar *default-canvas-pen-color* *black-color* "The default colour for the pen of a canvas. ~ (:see-also *default-canvas-background-color*)" ) ;;; ;;; some utility functions ;;; (defun shade-to-color (shade) "Translates a shade to a color." (declare (special *black-shade* *white-shade* *light-gray-shade* *dark-gray-shade* *gray-shade* *black-color* *white-color* *light-gray-color* *dark-gray-color* *gray-color*)) (cond ((eq *black-shade* shade) *black-color*) ((eq *white-shade* shade) *white-color*) ((eq *light-gray-shade* shade) *light-gray-color*) ((eq *gray-shade* shade) *gray-color*) ((eq *dark-gray-shade* shade) *dark-gray-color*) (t *gray-color*))) (defun color-to-shade (color) "Translates a color into a shade." (declare (special *black-shade* *white-shade* *light-gray-shade* *dark-gray-shade* *gray-shade* *black-color* *white-color* *light-gray-color* *dark-gray-color*)) (cond ((eq-colors *black-color* color) *black-shade*) ((eq-colors *white-color* color) *white-shade*) ((eq-colors *light-gray-color* color) *light-gray-shade*) ((eq-colors *gray-color* color) *gray-shade*) ((eq-colors *dark-gray-color* color) *dark-gray-shade*) (t *gray-shade*))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Transformative Colour Functions ;;; ;;; algorithms extracted from "Color Theory and Modeling for Computer Graphics, ;;; Visualization, and Multimedia Applications" by Haim Levkowitz, 1997, p 66 & 68. ;; values that are a little over 1? truncate ;;; compute rgb from lhs (defun lhs_to_rgb (l h s &key (model :triangle)) ;;;lightness hue saturation (if (and (>= l 0) (<= l 1)) (if (or (null h) (and (>= h 0) (< h 360))) ;;correction here (if (and (>= s 0) (<= s 1)) (let (r g b) (if (or (zerop s) (not h)) ;;or h = nil ;;;achromatic (setq r l g l b l) ;;;chromatic (let* ((M 1) (k (floor h 60)) ;sector-number (f (- (/ h 60) k)) ;;hue within sector (fprime (if (oddp k) (- 1 f) f)) latq min mid max wmin wmid wmax) (cond ((equal model :triangle) (setq wmin (/ 1 3) wmid (/ 1 3) wmax (/ 1 3))) ((equal model :hexcone) (setq wmin 0 wmid 0 wmax 1)) ((equal model :double-hexcone) (setq wmin (/ 1 2) wmid 0 wmax (/ 1 2))) (T (error "Don't know this model ~s ." model))) (setf latq (* (+ (* wmid fprime) wmax) M)) (if (<= l latq) (progn (setf min (* (- 1 s) l)) (setf mid (/ (+ (* fprime l) (* min (- (* (- 1 fprime) wmax) (* fprime wmin)))) (+ wmax (* fprime wmid)))) (setf max (/ (- l (* wmid mid) (* wmin min)) wmax))) (progn (setf max (+ (* s M) (* (- 1 s) l))) (setf mid (/ (- (* (- 1 fprime) l) (* max (- (* (- 1 fprime) wmax) (* fprime wmin)))) (+ (* (- 1 fprime) wmid) wmin))) (setf min (if (> wmin 0) (/ (- l (* wmax max) (* wmid mid)) wmin) (/ (- mid (* fprime max)) (- 1 fprime)))))) (case k (0 (setq r max g mid b min)) (1 (setq r mid g max b min)) (2 (setq r min g max b mid)) (3 (setq r min g mid b max)) (4 (setq r mid g min b max)) (5 (setq r max g min b mid))))) (list r g b)) (error "Saturation values range from 0 to 1: ~s " s)) (error "Hue values range from 0 up to, but not including 360; ~%~ NIL for chromatic colours: ~s " h)) (error "Lightness values range from 0 to 1: ~s " l))) ;;; compute lhs from rgb ;;; should be able to take just a colour as well (defun rgb_to_lhs (r g b &key (model :triangle)) ;;;red green blue (let* ((cmax (max r g b)) (cmin (min r g b)) (cmid (elt (sort (list r g b) #'<=) 1)) l h s) (if (equal cmax cmin) (setq l cmax h nil s 0) ;;;achromatic (let* ((M 1) ;;;chromatic (k (cond ((and (> r g) (>= g b)) 0) ((and (>= g r) (> r b)) 1) ((and (> g b) (>= b r)) 2) ((and (>= b g) (> g r)) 3) ((and (> b r) (>= r g)) 4) ((and (>= r b) (> b g)) 5))) (f (if (evenp k) (/ (- cmid cmin) (- cmax cmin)) (/ (- cmax cmid) (- cmax cmin)))) wmin wmid wmax latq) (cond ((equal model :triangle) (setq wmin (/ 1 3) wmid (/ 1 3) wmax (/ 1 3))) ((equal model :hexcone) (setq wmin 0 wmid 0 wmax 1)) ((equal model :double-hexcone) (setq wmin (/ 1 2) wmid 0 wmax (/ 1 2))) (T (error "Don't know this model ~s ." model))) (setf latq (* (+ (* wmid f) wmax) M)) (progn (setf l (+ (* wmax cmax) (* wmid cmid) (* wmin cmin))) (setf h (* (+ k f) 60)) (setf s (if (<= l latq) (/ (- l cmin) l) (/ (- cmax l) (- M l))))))) (list l h s))) ;;a list or three separate parameters (defun hue-of (colour &key (model :triangle)) (second (rgb_to_lhs (red-of colour) (green-of colour) (blue-of colour) :model model))) (defun lightness-of (colour &key (model :triangle)) (first (rgb_to_lhs (red-of colour) (green-of colour) (blue-of colour) :model model))) (defun saturation-of (colour &key (model :triangle)) (third (rgb_to_lhs (red-of colour) (green-of colour) (blue-of colour) :model model))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Shading Colour Functions ;;; (defun lighten (colour &key (factor .2) (model :triangle)) ;;factor is additive (let* ((h (wb::hue-of colour)) (l (wb::lightness-of colour)) (s (wb::saturation-of colour)) (new-l (+ factor l)) ) (cond ((< new-l 0) (setf new-l 0)) ((> new-l 1) (setf new-l 1))) (apply #'wb::make-color (wb::lhs_to_rgb new-l h s :model model)))) (defun darken (colour &key (factor .2) (model :triangle)) (lighten colour :factor (* -1 factor) :model model)) #| ;alternative lighten function (defun lighten (colour &optional (factor .2)) ;; factor is additive (let* ((r (wb::red-of colour)) (g (wb::green-of colour)) (b (wb::blue-of colour)) (zeror (zerop r)) (zerog (zerop g)) (zerob (zerop b)) maxfactor) (if (and zeror zerog zerob) ;;if black (if (> factor 0) ;;then lighten (progn (if (<= factor 1) (wb::make-color (+ r factor) (+ g factor) (+ b factor)) wb::*white-color*)) wb::*black-color*) (if (and (<= (+ factor (max r g b)) 1) ;;within bounds (> (+ factor (min (if zeror 1 r) ;;nonzero minimum (if zerog 1 g) (if zerob 1 b))) 0)) (wb::make-color (if zeror 0 (+ r factor)) (if zerog 0 (+ g factor)) (if zerob 0 (+ b factor))) ;;otherwise modify size of factor (cond ((> factor 0) (setf maxfactor (min (- 1 r) (- 1 g) (- 1 b))) (wb::make-color (if zeror 0 (+ r maxfactor)) (if zerog 0 (+ g maxfactor)) (if zerob 0 (+ b maxfactor)))) (T (setf maxfactor (min (if zeror 1 r) (if zerog 1 g) (if zerob 1 b))) (wb::make-color (if zeror 0 (- r maxfactor)) (if zerog 0 (- g maxfactor)) (if zerob 0 (- b maxfactor))))))))) (defun darken (colour &optional (factor .2)) (lighten colour (* -1 factor))) |#
15,407
Common Lisp
.l
321
37.971963
164
0.525741
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
d6227e628c2a1174e4558f91f94b94d101408b0a2e76003511db14e4cfd9fbda
33,458
[ -1 ]
33,459
color-table.lsp
rwoldford_Quail/source/window-basics/color/color-table.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; color-table.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is an addition to Window-basics for moving pointclouds ;;; ;;; ;;; Authors: ;;; R.W. Oldford 1992 ;;; P. Poirier 1992 ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :window-basics) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-color-table))) (defun make-color-table (&key number colors (red? NIL) (green? NIL) (blue? NIL) (from-color NIL) (to-color NIL) (fast-colors? NIL)) "Creates and returns a vector of colours as determined by the values of ~ the supplied keywords. ~ If number is given it defines the number of colors to be used (default 10).~ If colors is supplied, then it should be a sequence containing the color ~ records to be used in the table. ~ If both colors and number are supplied then the first number from colors ~ are selected to be elements of the table (with wrapping if the length of ~ colors is less than number). ~ If number is given and not colors, then the keywords red? green? and blue? ~ come into play. ~ These are booleans which if non-nil mean ~ every color in the table will be saturated with the corresponding color. ~ For example, the ~ configuration red? = NIL green? = NIL and blue? = T produces ~ a table of colors of size number which vary from pure blue through ~ light blue to bright white. ~ The default ~ configuration is red? = NIL green? = NIL and blue? = NIL and produces ~ a table of colors of size number which vary from black to bright white. ~ If either from-color (default *black-color*) ~ or to-color (default *bright-white-color*) is given then a linear interpolation ~ on each rgb color component is made between these two colors. ~ If fast-colors? is T (default is NIL) then the color records used in the ~ table are of optimal record-type for the given machine." #-:sbcl(declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (declare (special *black-color* *bright-white-color*)) (unless (or colors number) (setf number 32)) (flet ((get-color-piece (index num-col color?) ;;(declare (special *max-color-saturation*)) (if color? 1.0 (/ index num-col) ;;(truncate (* index *max-color-saturation*) num-col) )) (smooth-color (s-r s-g s-b e-r e-g e-b index num-col) (make-color (+ s-r (/ (* index (- e-r s-r)) num-col)) (+ s-g (/ (* index (- e-g s-g)) num-col)) (+ s-b (/ (* index (- e-b s-b)) num-col)) ;;(truncate (+ s-r (/ (* index (- e-r s-r)) num-col))) ;;(truncate (+ s-g (/ (* index (- e-g s-g)) num-col))) ;;(truncate (+ s-b (/ (* index (- e-b s-b)) num-col))) )) ) (cond ((and number colors) (let ((ncolors (length colors))) (make-array (list number) :initial-contents (if fast-colors? (loop for i from 0 to (- number 1) with j = 0 collect (if (colorp (elt colors j)) (optimize-color-record (elt colors j)) (elt colors j)) do (if (= j ncolors) (setf j 0) (incf j)) ) (loop for i from 0 to (- number 1) with j = 0 collect (if (colorp (elt colors j)) (elt colors j) (deoptimize-color-record (elt colors j))) do (if (= j ncolors) (setf j 0) (incf j)) ))))) (number (let ((nc (- number 1))) (make-array (list number) :initial-contents (if (or from-color to-color) (let (start-red start-green start-blue end-red end-green end-blue) (unless from-color (setf from-color *black-color*)) (unless to-color (setf to-color *bright-white-color*)) (setf start-red (red-of from-color) start-green (green-of from-color) start-blue (blue-of from-color) end-red (red-of to-color) end-green (green-of to-color) end-blue (blue-of to-color)) (if fast-colors? (loop for i from 0 to nc collect (optimize-color-record (smooth-color start-red start-green start-blue end-red end-green end-blue i nc))) (loop for i from 0 to nc collect (smooth-color start-red start-green start-blue end-red end-green end-blue i nc)) )) (if fast-colors? (loop for i from 0 to nc collect (optimize-color-record (make-color (get-color-piece i nc red?) (get-color-piece i nc green?) (get-color-piece i nc blue?)))) (loop for i from 0 to nc collect (make-color (get-color-piece i nc red?) (get-color-piece i nc green?) (get-color-piece i nc blue?))) )))) ) (colors (make-array (length colors) :initial-contents (if fast-colors? (loop for j from 0 to (1- (length colors)) collect (if (colorp (elt colors j)) (optimize-color-record (elt colors j)) (elt colors j))) (loop for j from 0 to (1- (length colors)) collect (if (colorp (elt colors j)) (elt colors j) (deoptimize-color-record (elt colors j)))))))) ))
7,251
Common Lisp
.l
179
26.078212
86
0.438236
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
bafdd1de1de080a50839a538a0a1db2d3c9fbbb937a6d35c023b7aef784467da
33,459
[ -1 ]
33,460
cr-color.lsp
rwoldford_Quail/source/window-basics/color/cr-color.lsp
********************************************************************** (IN-PACKAGE :WB) ---------------------------------------------------------------------- ********************************************************************** (EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE) (EXPORT '(*LIGHT-GREY-COLOR* *GREY-COLOR* *DARK-GREY-COLOR* *CYAN-COLOUR* *BLACK-COLOUR* *WHITE-COLOUR* *PINK-COLOUR* *RED-COLOUR* *ORANGE-COLOUR* *YELLOW-COLOUR* *GREEN-COLOUR* *DARK-GREEN-COLOUR* *LIGHT-BLUE-COLOUR* *BLUE-COLOUR* *PURPLE-COLOUR* *BROWN-COLOUR* *TAN-COLOUR* *LIGHT-GRAY-COLOUR* *GRAY-COLOUR* *DARK-GRAY-COLOUR* *LIGHT-GREY-COLOUR* *GREY-COLOUR* *DARK-GREY-COLOUR* *BRIGHT-GREEN-COLOR* *MAGENTA-COLOR* *BRIGHT-GREEN-COLOUR* *MAGENTA-COLOUR* *COLORS* *BRIGHT-WHITE-COLOR* *DEFAULT-CANVAS-BACKGROUND-COLOR* *DEFAULT-CANVAS-PEN-COLOR* SHADE-TO-COLOR COLOR-TO-SHADE OPTIMIZE-COLOR-RECORD DEOPTIMIZE-COLOR-RECORD RGB_TO_LHS LHS_TO_RGB HUE-OF LIGHTNESS-OF SATURATION-OF LIGHTEN DARKEN))) ---------------------------------------------------------------------- ********************************************************************** (EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE) (EXPORT '(*BLACK-COLOR* *WHITE-COLOR* *PINK-COLOR* *RED-COLOR* *ORANGE-COLOR* *YELLOW-COLOR* *GREEN-COLOR* *DARK-GREEN-COLOR* *LIGHT-BLUE-COLOR* *BLUE-COLOR* *PURPLE-COLOR* *BROWN-COLOR* *TAN-COLOR* *LIGHT-GRAY-COLOR* *GRAY-COLOR* *DARK-GRAY-COLOR*))) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BLACK-COLOR* (MAKE-COLOR 0.0 0.0 0.0)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *WHITE-COLOR* (MAKE-COLOR 1.0 1.0 1.0)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *PINK-COLOR* (MAKE-COLOR 0.9490196 0.031372547 0.5176471)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *RED-COLOR* (MAKE-COLOR 0.8666667 0.031372547 0.023529412)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *ORANGE-COLOR* (MAKE-COLOR 1.0 0.39215687 0.007843137)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *YELLOW-COLOR* (MAKE-COLOR 0.9882353 0.9529412 0.019607844)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *GREEN-COLOR* (MAKE-COLOR 0.12156863 0.7176471 0.078431375)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *DARK-GREEN-COLOR* (MAKE-COLOR 0.0 0.39215687 0.06666667)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *LIGHT-BLUE-COLOR* (MAKE-COLOR 0.007843137 0.67058825 0.91764706)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BLUE-COLOR* (MAKE-COLOR 0.0 0.0 0.83137256)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER WB::*CYAN-COLOR* (WB:MAKE-COLOR 0.0 1.0 1.0)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *PURPLE-COLOR* (MAKE-COLOR 0.2745098 0.0 0.64705884)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BROWN-COLOR* (MAKE-COLOR 0.3372549 0.17254902 0.019607844)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *TAN-COLOR* (MAKE-COLOR 0.5647059 0.44313726 0.22745098)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *LIGHT-GRAY-COLOR* (MAKE-COLOR 0.7529412 0.7529412 0.7529412)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *GRAY-COLOR* (MAKE-COLOR 0.50196075 0.50196075 0.50196075)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *DARK-GRAY-COLOR* (MAKE-COLOR 0.25098038 0.25098038 0.25098038)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *GREY-COLOR* *GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *LIGHT-GREY-COLOR* *LIGHT-GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *DARK-GREY-COLOR* *DARK-GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BLACK-COLOUR* *BLACK-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *WHITE-COLOUR* *WHITE-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *PINK-COLOUR* *PINK-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *RED-COLOUR* *RED-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *ORANGE-COLOUR* *ORANGE-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *YELLOW-COLOUR* *YELLOW-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *GREEN-COLOUR* *GREEN-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *DARK-GREEN-COLOUR* *DARK-GREEN-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *LIGHT-BLUE-COLOUR* *LIGHT-BLUE-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BLUE-COLOUR* *BLUE-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *CYAN-COLOUR* *CYAN-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *PURPLE-COLOUR* *PURPLE-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BROWN-COLOUR* *BROWN-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *TAN-COLOUR* *TAN-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *LIGHT-GRAY-COLOUR* *LIGHT-GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *GRAY-COLOUR* *GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *DARK-GRAY-COLOUR* *DARK-GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *GREY-COLOUR* *GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *LIGHT-GREY-COLOUR* *LIGHT-GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *DARK-GREY-COLOUR* *DARK-GRAY-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BRIGHT-GREEN-COLOR* (MAKE-COLOR 0 1.0 0)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BRIGHT-GREEN-COLOUR* *BRIGHT-GREEN-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *MAGENTA-COLOR* (MAKE-COLOR 1.0 0 1.0)) ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *MAGENTA-COLOUR* *MAGENTA-COLOR*) ---------------------------------------------------------------------- ********************************************************************** (DEFVAR *COLORS* (LIST *WHITE-COLOR* *PINK-COLOR* *RED-COLOR* *ORANGE-COLOR* *YELLOW-COLOR* *GREEN-COLOR* *CYAN-COLOR* *BLUE-COLOR* *PURPLE-COLOR* *BROWN-COLOR* *TAN-COLOR* *GRAY-COLOR* *BLACK-COLOR* *DARK-GREEN-COLOR* *LIGHT-GRAY-COLOR* *LIGHT-BLUE-COLOR* *DARK-GRAY-COLOR*) "The list of predefined colors -- useful as an iteration sequence.") ---------------------------------------------------------------------- ********************************************************************** (DEFPARAMETER *BRIGHT-WHITE-COLOR* (MAKE-COLOR 1.0 1.0 1.0)) ---------------------------------------------------------------------- ********************************************************************** (DEFVAR *DEFAULT-CANVAS-BACKGROUND-COLOR* *WHITE-COLOR* "The default colour for the background of a canvas. ~ (:see-also *default-canvas-pen-color*)") ---------------------------------------------------------------------- ********************************************************************** (DEFVAR *DEFAULT-CANVAS-PEN-COLOR* *BLACK-COLOR* "The default colour for the pen of a canvas. ~ (:see-also *default-canvas-background-color*)") ---------------------------------------------------------------------- ********************************************************************** (DEFUN SHADE-TO-COLOR (SHADE) "Translates a shade to a color." (DECLARE (SPECIAL *BLACK-SHADE* *WHITE-SHADE* *LIGHT-GRAY-SHADE* *DARK-GRAY-SHADE* *GRAY-SHADE* *BLACK-COLOR* *WHITE-COLOR* *LIGHT-GRAY-COLOR* *DARK-GRAY-COLOR* *GRAY-COLOR*)) (COND ((EQ *BLACK-SHADE* SHADE) *BLACK-COLOR*) ((EQ *WHITE-SHADE* SHADE) *WHITE-COLOR*) ((EQ *LIGHT-GRAY-SHADE* SHADE) *LIGHT-GRAY-COLOR*) ((EQ *GRAY-SHADE* SHADE) *GRAY-COLOR*) ((EQ *DARK-GRAY-SHADE* SHADE) *DARK-GRAY-COLOR*) (T *GRAY-COLOR*))) ---------------------------------------------------------------------- USE-EQL: Unless something special is going on, use EQL, not EQ. ---------------------------------------------------------------------- ********************************************************************** (DEFUN COLOR-TO-SHADE (COLOR) "Translates a color into a shade." (DECLARE (SPECIAL *BLACK-SHADE* *WHITE-SHADE* *LIGHT-GRAY-SHADE* *DARK-GRAY-SHADE* *GRAY-SHADE* *BLACK-COLOR* *WHITE-COLOR* *LIGHT-GRAY-COLOR* *DARK-GRAY-COLOR*)) (COND ((EQ-COLORS *BLACK-COLOR* COLOR) *BLACK-SHADE*) ((EQ-COLORS *WHITE-COLOR* COLOR) *WHITE-SHADE*) ((EQ-COLORS *LIGHT-GRAY-COLOR* COLOR) *LIGHT-GRAY-SHADE*) ((EQ-COLORS *GRAY-COLOR* COLOR) *GRAY-SHADE*) ((EQ-COLORS *DARK-GRAY-COLOR* COLOR) *DARK-GRAY-SHADE*) (T *GRAY-SHADE*))) ---------------------------------------------------------------------- ********************************************************************** (DEFUN LHS_TO_RGB (L H S &KEY (MODEL :TRIANGLE)) (IF (AND (>= L 0) (<= L 1)) (IF (OR (NULL H) (AND (>= H 0) (< H 360))) (IF (AND (>= S 0) (<= S 1)) (LET (R G B) (IF (OR (ZEROP S) (NOT H)) (SETQ R L G L B L) (LET* ((M 1) (K (FLOOR H 60)) (F (- (/ H 60) K)) (FPRIME (IF (ODDP K) (- 1 F) F)) LATQ MIN MID MAX WMIN WMID WMAX) (COND ((EQUAL MODEL :TRIANGLE) (SETQ WMIN (/ 1 3) WMID (/ 1 3) WMAX (/ 1 3))) ((EQUAL MODEL :HEXCONE) (SETQ WMIN 0 WMID 0 WMAX 1)) ((EQUAL MODEL :DOUBLE-HEXCONE) (SETQ WMIN (/ 1 2) WMID 0 WMAX (/ 1 2))) (T (ERROR "Don't know this model ~s ." MODEL))) (SETF LATQ (* (+ (* WMID FPRIME) WMAX) M)) (IF (<= L LATQ) (PROGN (SETF MIN (* (- 1 S) L)) (SETF MID (/ (+ (* FPRIME L) (* MIN (- (* (- 1 FPRIME) WMAX) (* FPRIME WMIN)))) (+ WMAX (* FPRIME WMID)))) (SETF MAX (/ (- L (* WMID MID) (* WMIN MIN)) WMAX))) (PROGN (SETF MAX (+ (* S M) (* (- 1 S) L))) (SETF MID (/ (- (* (- 1 FPRIME) L) (* MAX (- (* (- 1 FPRIME) WMAX) (* FPRIME WMIN)))) (+ (* (- 1 FPRIME) WMID) WMIN))) (SETF MIN (IF (> WMIN 0) (/ (- L (* WMAX MAX) (* WMID MID)) WMIN) (/ (- MID (* FPRIME MAX)) (- 1 FPRIME)))))) (CASE K (0 (SETQ R MAX G MID B MIN)) (1 (SETQ R MID G MAX B MIN)) (2 (SETQ R MIN G MAX B MID)) (3 (SETQ R MIN G MID B MAX)) (4 (SETQ R MID G MIN B MAX)) (5 (SETQ R MAX G MIN B MID))))) (LIST R G B)) (ERROR "Saturation values range from 0 to 1: ~s " S)) (ERROR "Hue values range from 0 up to, but not including 360; ~%~ NIL for chromatic colours: ~s " H)) (ERROR "Lightness values range from 0 to 1: ~s " L))) ---------------------------------------------------------------------- FUNCTION-TOO-LONG: Definition way too long! ---------------------------------------------------------------------- NESTED-IFS: Avoid nested IF's. Use AND, if possible, or a single COND. ---------------------------------------------------------------------- PROGN-IN-IF: Don't use IF and PROGN, use COND ---------------------------------------------------------------------- PROGN-IN-IF: Don't use IF and PROGN, use COND ---------------------------------------------------------------------- LET-ATOMS: Always initialize LET variables like B with (B NIL), not just B. It's too easy to misread what's being initialized to what. ---------------------------------------------------------------------- LET-ATOMS: Always initialize LET variables like G with (G NIL), not just G. It's too easy to misread what's being initialized to what. ---------------------------------------------------------------------- LET-ATOMS: Always initialize LET variables like R with (R NIL), not just R. It's too easy to misread what's being initialized to what. ---------------------------------------------------------------------- USE-EQL: Unless something special is going on, use EQL, not EQUAL. ---------------------------------------------------------------------- ********************************************************************** (DEFUN RGB_TO_LHS (R G B &KEY (MODEL :TRIANGLE)) (LET* ((CMAX (MAX R G B)) (CMIN (MIN R G B)) (CMID (ELT (SORT (LIST R G B) #'<=) 1)) L H S) (IF (EQUAL CMAX CMIN) (SETQ L CMAX H NIL S 0) (LET* ((M 1) (K (COND ((AND (> R G) (>= G B)) 0) ((AND (>= G R) (> R B)) 1) ((AND (> G B) (>= B R)) 2) ((AND (>= B G) (> G R)) 3) ((AND (> B R) (>= R G)) 4) ((AND (>= R B) (> B G)) 5))) (F (IF (EVENP K) (/ (- CMID CMIN) (- CMAX CMIN)) (/ (- CMAX CMID) (- CMAX CMIN)))) WMIN WMID WMAX LATQ) (COND ((EQUAL MODEL :TRIANGLE) (SETQ WMIN (/ 1 3) WMID (/ 1 3) WMAX (/ 1 3))) ((EQUAL MODEL :HEXCONE) (SETQ WMIN 0 WMID 0 WMAX 1)) ((EQUAL MODEL :DOUBLE-HEXCONE) (SETQ WMIN (/ 1 2) WMID 0 WMAX (/ 1 2))) (T (ERROR "Don't know this model ~s ." MODEL))) (SETF LATQ (* (+ (* WMID F) WMAX) M)) (PROGN (SETF L (+ (* WMAX CMAX) (* WMID CMID) (* WMIN CMIN))) (SETF H (* (+ K F) 60)) (SETF S (IF (<= L LATQ) (/ (- L CMIN) L) (/ (- CMAX L) (- M L))))))) (LIST L H S))) ---------------------------------------------------------------------- FUNCTION-TOO-LONG: Definition way too long! ---------------------------------------------------------------------- COND-WITHOUT-DEFAULT: All COND's should have an ELSE branch, i.e., (T ...). ---------------------------------------------------------------------- USE-EQL: Unless something special is going on, use EQL, not EQUAL. ---------------------------------------------------------------------- ********************************************************************** (DEFUN HUE-OF (COLOUR &KEY (MODEL :TRIANGLE)) (SECOND (RGB_TO_LHS (RED-OF COLOUR) (GREEN-OF COLOUR) (BLUE-OF COLOUR) :MODEL MODEL))) ---------------------------------------------------------------------- ********************************************************************** (DEFUN LIGHTNESS-OF (COLOUR &KEY (MODEL :TRIANGLE)) (FIRST (RGB_TO_LHS (RED-OF COLOUR) (GREEN-OF COLOUR) (BLUE-OF COLOUR) :MODEL MODEL))) ---------------------------------------------------------------------- ********************************************************************** (DEFUN SATURATION-OF (COLOUR &KEY (MODEL :TRIANGLE)) (THIRD (RGB_TO_LHS (RED-OF COLOUR) (GREEN-OF COLOUR) (BLUE-OF COLOUR) :MODEL MODEL))) ---------------------------------------------------------------------- ********************************************************************** (DEFUN LIGHTEN (COLOUR &KEY (FACTOR 0.2) (MODEL :TRIANGLE)) (LET* ((H (WB::HUE-OF COLOUR)) (L (WB::LIGHTNESS-OF COLOUR)) (S (WB::SATURATION-OF COLOUR)) (NEW-L (+ FACTOR L))) (COND ((< NEW-L 0) (SETF NEW-L 0)) ((> NEW-L 1) (SETF NEW-L 1))) (APPLY #'WB:MAKE-COLOR (WB::LHS_TO_RGB NEW-L H S :MODEL MODEL)))) ---------------------------------------------------------------------- FUNCTION-TOO-LONG: Definition a little too long! ---------------------------------------------------------------------- COND-WITHOUT-DEFAULT: All COND's should have an ELSE branch, i.e., (T ...). ---------------------------------------------------------------------- ********************************************************************** (DEFUN DARKEN (COLOUR &KEY (FACTOR 0.2) (MODEL :TRIANGLE)) (LIGHTEN COLOUR :FACTOR (* -1 FACTOR) :MODEL MODEL)) ----------------------------------------------------------------------
22,768
Common Lisp
.l
406
46.022167
74
0.291116
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f502e36e4817c5f96a13237a396ffc8bbb8653dd6c9e0ebecf13376bf11a0ac4
33,460
[ -1 ]
33,462
color-mixin-sblx.lsp
rwoldford_Quail/source/window-basics/color/color-mixin-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; color-mixin-sblx.lsp ;;; Based on color-mixin-mcl ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(canvas-set-background-color canvas-background-color colored-canvas-p canvas-default-draw-color))) (defclass color-mixin () ((color? :initarg :color? :initform NIL :reader colored-canvas-p :documentation "Value is T when ~ the canvas is a color one, NIL otherwise.") ) (:documentation "A mixin to allow a test for color.")) ;;; Setting the background and drawing colour/shading of a canvas. #| (defun canvas-set-background-color (canvas color) (let ((mp (cg::frame-child canvas))) (with-display-mode canvas (display-mode-of canvas) (canvas-set-background-color canvas color) (when (and (colorp color) (colored-canvas-p canvas)) ;(cg::set-background-color mp color) 18oct05 (setf (cg::background-color mp) color) 18oct05 (cg::clear-page mp) (redisplay canvas) )))) (defun canvas-background-color (canvas) (declare (special *white-shade*)) (let ((mp (cg::frame-child canvas))) (if (colored-canvas-p canvas) (cg::background-color mp) *white-shade*))) |# (defun canvas-set-background-color (canvas color) (let ((mp (clim:get-frame-pane canvas 'host-pane))) (when (and (colorp color) (colored-canvas-p canvas)) (setf (clim::medium-background mp) color) (clim:window-refresh mp) ;; seem to be the way to change the background AND keep the contents ))) (defun canvas-background-color (canvas) (declare (special *white-color*)) (let ((mp (clim:get-frame-pane canvas 'host-pane))) (if (colored-canvas-p canvas) (clim::medium-background mp) *white-color*))) (defun canvas-default-draw-color (canvas) (declare (special *black-color* *white-color* *black-shade*)) (if (colored-canvas-p canvas) (or *default-canvas-pen-color* (if (eql (canvas-background-color canvas) *black-color*) *white-color* *black-color*) )))
2,864
Common Lisp
.l
75
33.626667
99
0.599784
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
e04982445455789be5a5ddd8a3d4f77e87630bf39c21dece645f799910fec4af
33,462
[ -1 ]
33,463
color-sblx.lsp
rwoldford_Quail/source/window-basics/color/color-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; color-sblx.lsp ;;; Based on color-clx.lsp ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-color))) ;;;;;;;;;;;;;;;;;;;;;; (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*max-color-saturation* wb::make-color red-of green-of blue-of colorp eq-colors order-colors prompt-user-for-color optimize-color-record deoptimize-color-record))) (defun make-color (red-arg green-arg blue-arg) "Returns a colour record. 0 0 0 is black 1 1 1 is white ~ (:required (:arg red-arg A number between 0 and 1.) ~ (:arg green-arg A number between 0 and 1.) (:arg blue-arg A number between 0 and 1.))" (clim:make-rgb-color red-arg green-arg blue-arg) ) ;;;======================================================================== ;;; Colors/Colours ;;;======================================================================== ;;; These follow a red green blue (RGB) model for representing colour. (defvar *max-color-saturation* 255.0 "The number which when given as the red green or blue of a colour ~ saturates that dimension of the color in the host system.") ;;; An rgb triple is a STRUCTURE with name rgb and fields red, blue, green. ;;; So we have rgb-red rgb-green rgb-blue as well as rgb-p and make-rgb ;;; already available #| (defun red-of (color) "Returns the red coordinate of the color." (declare (special *max-color-saturation*)) (min 1.0 (/ (cg::rgb-red (if (cg::rgb-p color) color (deoptimize-color-record color))) *max-color-saturation*) )) (defun green-of (color) "Returns the green coordinate of the color." (declare (special *max-color-saturation*)) (min 1.0 (/ (cg::rgb-green (if (cg::rgb-p color) color (deoptimize-color-record color))) *max-color-saturation*) )) (defun blue-of (color) "Returns the blue coordinate of the color." (declare (special *max-color-saturation*)) (min 1.0 (/ (cg::rgb-blue (if (cg::rgb-p color) color (deoptimize-color-record color))) *max-color-saturation*) )) |# (defun rgbs (color) "Returns a list of red, blue, green coordinates of color" (multiple-value-list (clim:color-rgb color))) (defun red-of (color) "Returns the red coordinate of color" (first (rgbs color))) (defun blue-of (color) "Returns the blue coordinate of color" (second (rgbs color))) (defun green-of (color) "Returns the green coordinate of color" (third (rgbs color))) (defun colorp (color) "Test whether the argument is a color." (if (eq (type-of color) 'CLIM-INTERNALS::NAMED-COLOR) T NIL) ) (defun eq-colors (color-1 color-2) "Test whether two colors are equal.~ Colors may be nil here" (cond ((and (null color-1) (null color-2)) t) ((null color-1) nil) ((null color-2) nil) ((and (eq (red-of color-1) (red-of color-2)) (eq (blue-of color-1) (blue-of color-2)) (eq (green-of color-1) (green-of color-2)) T)) (T NIL))) #| ;;; There is a built-in rgb-equal (defun real-color-equal (color-1 color-2) (cg::rgb-equal color-1 color-2)) |# (defun order-colors (colors) "Orders the colors in the list given" (flet ((lt-colors (color-1 color-2) (cond ((null color-2) t) ((null color-1) nil) ((<= (red-of color-1) (red-of color-2)) t) ((<= (green-of color-1) (green-of color-2)) t) ((<= (blue-of color-1) (blue-of color-2)) t)))) (sort colors #'lt-colors))) ;;; fuction to select r,g,b values (defun accepting-color (&key (stream *query-io*) (ow t)) "Collects red, blue, green floating point values." (let (red-arg blue-arg green-arg) (accepting-values (stream :initially-select-query-identifier 'the-tag :own-window ow :label "Enter floats for r,g,b") (terpri stream) (setq red-arg (accept 'float :prompt "Single float for red-arg" :stream stream)) (terpri stream) (setq blue-arg (accept 'float :prompt "Single-float for blue-arg" :query-identifier 'the-tag :stream stream)) (terpri stream) (setq green-arg (accept 'float :prompt "Single-float for green-arg" :stream stream))) (multiple-value-list (values red-arg blue-arg green-arg)))) ;;; make a custom color (defun prompt-user-for-color () "Prompts for r,g,b floating point values, normalises, makes a custom color." (let ((result-list (accepting-color))) (setf result-list (mapcar #'(lambda (x) (/ x (reduce #'+ result-list))) result-list)) (make-color (first result-list) (second result-list) (third result-list)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Optimized colours ;;; The following functions appear to do nothing to their arguments (defun optimize-color-record (color) "Returns a data structure optimized for the current machine that ~ represents the color." color) (defun deoptimize-color-record (optimized-color) "Returns the color record from an optimized-color ~ that was optimized for the current machine." optimized-color)
5,924
Common Lisp
.l
158
33.012658
101
0.607809
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
d3355c34bcb6a855672d6fb1f9cea5cd257a50c909af7f3aa8b961a00d287e05
33,463
[ -1 ]
33,466
color-mixin-pc.lsp
rwoldford_Quail/source/window-basics/color/color-mixin-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; color-mixin-pc.lsp ;;; Based on color-mixin-mcl ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(canvas-set-background-color canvas-background-color colored-canvas-p canvas-default-draw-color))) (defclass color-mixin () ((color? :initarg :color? :initform NIL :reader colored-canvas-p :documentation "Value is T when ~ the canvas is a color one, NIL otherwise.") ) (:documentation "A mixin to allow a test for color.")) ;;; Setting the background and drawing colour/shading of a canvas. (defun canvas-set-background-color (canvas color) (let ((mp (cg::frame-child canvas))) (with-display-mode canvas (display-mode-of canvas) (canvas-set-background-color canvas color) (when (and (colorp color) (colored-canvas-p canvas)) ;(cg::set-background-color mp color) 18oct05 (setf (cg::background-color mp) color) ;18oct05 25JUL2023 (cg::clear-page mp) (redisplay canvas) )))) (defun canvas-background-color (canvas) (declare (special *white-shade*)) (let ((mp (cg::frame-child canvas))) (if (colored-canvas-p canvas) (cg::background-color mp) *white-shade*))) (defun canvas-default-draw-color (canvas) (declare (special *black-color* *white-color* *black-shade*)) (if (colored-canvas-p canvas) (or *default-canvas-pen-color* (if (eql (canvas-background-color canvas) *black-color*) *white-color* *black-color*) )))
2,400
Common Lisp
.l
61
33.47541
94
0.564676
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
6ce3f5a2f9117ea9f6ff92df6578e4611332a7497c193117c0ba3802568e098a
33,466
[ -1 ]
33,467
color-pc.lsp
rwoldford_Quail/source/window-basics/color/color-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; color-pc.lsp ;;; Based on color-clx.lsp ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (defun make-color (red-arg green-arg blue-arg) "Returns a colour record. 0 0 0 is black 1 1 1 is white ~ (:required (:arg red-arg A number between 0 and 1.) ~ (:arg green-arg A number between 0 and 1.) (:arg blue-arg A number between 0 and 1.))" (cg::make-rgb :red red-arg :green green-arg :blue blue-arg) ) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-color))) ;;;;;;;;;;;;;;;;;;;;;; (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*max-color-saturation* wb::make-color red-of green-of blue-of colorp eq-colors order-colors prompt-user-for-color optimize-color-record deoptimize-color-record))) ;;;======================================================================== ;;; Colors/Colours ;;;======================================================================== ;;; These follow a red green blue (RGB) model for representing colour. (defvar *max-color-saturation* 255.0 "The number which when given as the red green or blue of a colour ~ saturates that dimension of the color in the host system.") ;;; An rgb triple is a STRUCTURE with name rgb and fields red, blue, green. ;;; So we have rgb-red rgb-green rgb-blue as well as rgb-p and make-rgb ;;; already available (defun red-of (color) "Returns the red coordinate of the color." (declare (special *max-color-saturation*)) (min 1.0 (/ (cg::rgb-red (if (cg::rgb-p color) color (deoptimize-color-record color))) *max-color-saturation*) )) (defun green-of (color) "Returns the green coordinate of the color." (declare (special *max-color-saturation*)) (min 1.0 (/ (cg::rgb-green (if (cg::rgb-p color) color (deoptimize-color-record color))) *max-color-saturation*) )) (defun blue-of (color) "Returns the blue coordinate of the color." (declare (special *max-color-saturation*)) (min 1.0 (/ (cg::rgb-blue (if (cg::rgb-p color) color (deoptimize-color-record color))) *max-color-saturation*) )) (defun colorp (color) "Test whether the argument is a color." (cg::rgb-p color)) (defun eq-colors (color-1 color-2) "Test whether two colors are equal.~ Colors may be nil here" (cond ((and (null color-1) (null color-2)) t) ((null color-1) nil) ((null color-2) nil) ((and (cg::rgb-p color-1) (cg::rgb-p color-2)) (real-color-equal color-1 color-2)) (T NIL))) ;;; There is a built-in rgb-equal (defun real-color-equal (color-1 color-2) (cg::rgb-equal color-1 color-2)) (defun order-colors (colors) "Orders the colors in the list given" (flet ((lt-colors (color-1 color-2) (cond ((null color-2) t) ((null color-1) nil) ((<= (red-of color-1) (red-of color-2)) t) ((<= (green-of color-1) (green-of color-2)) t) ((<= (blue-of color-1) (blue-of color-2)) t)))) (sort colors #'lt-colors))) ;; The function pick-one is in pick-on1.lsp inside wb\prompts (defun prompt-user-for-color () "Prompt the user for a colour." (cg::ask-user-for-color) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Optimized colours ;;; The following functions appear to do nothing to their arguments (defun optimize-color-record (color) "Returns a data structure optimized for the current machine that ~ represents the color." color) (defun deoptimize-color-record (optimized-color) "Returns the color record from an optimized-color ~ that was optimized for the current machine." optimized-color)
4,613
Common Lisp
.l
123
31.813008
90
0.568381
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
316b8bb1c5c170940fc35a117ee09a966bb922a8ec3348fe0fb7941235131f00
33,467
[ -1 ]
33,469
region.lsp
rwoldford_Quail/source/window-basics/region/region.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; region.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1991 ;;; J.O. Pedersen 1988-89 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-region copy-region region-p region-left region-bottom region-width region-height region-right region-top region-bounds subregion-p intersect-regions inside-p same-region-p position-in-region-p))) ;;;============================================================ ;;; Regionswidth ;;;============================================================ ;;; changed representation of regions from lists to vectors, jam, 11-17-88. ;;; --makes it possible to implement some graphics operations ;;; on the CM, because you can have array valued pvars, ;;; but not cons valued pvars. (defmacro make-region (left bottom width height) `(vector ,left ,bottom ,width ,height)) (defmacro copy-region (region) `(copy-seq ,region)) (defun region-p (object) (and (vectorp object) (= (length object) 4))) ;;;------------------------------------------------------------ (defmacro region-left (r) `(aref ,r 0)) (defmacro region-bottom (r) `(aref ,r 1)) (defmacro region-width (r) `(aref ,r 2)) (defmacro region-height (r) `(aref ,r 3)) (defun region-right (r) (+ -1 (region-left r) (region-width r))) (defun region-top (r) (+ -1 (region-bottom r) (region-height r))) (defun region-bounds (region) (values (region-left region) (region-right region) (region-bottom region) (region-top region))) ;;;------------------------------------------------------------ (defun subregion-p (larger smaller) (let ((large-left (region-left larger)) (large-bottom (region-bottom larger)) (small-left (region-left smaller)) (small-bottom (region-bottom smaller))) (and (<= large-bottom small-bottom (+ small-bottom (region-height smaller)) (+ large-bottom (region-height larger))) (<= large-left small-left (+ small-left (region-width smaller)) (+ large-left (region-width larger)))))) (defun intersect-regions (&rest regions) (assert (not (null regions))) (let ((left most-negative-fixnum) (bottom most-negative-fixnum) (right most-positive-fixnum) (top most-positive-fixnum) ) (dolist (region regions) (let ((r-left (region-left region)) (r-bottom (region-bottom region)) (r-right (region-right region)) (r-top (region-top region))) (when (> r-left left) (setq left r-left)) (when (> r-bottom bottom) (setq bottom r-bottom)) (when (< r-right right) (setq right r-right)) (when (< r-top top) (setq top r-top)))) (make-region left bottom (- right left -1) (- top bottom -1)))) (defun inside-p (region position) (let ((left (region-left region)) (bottom (region-bottom region))) (and (<= left (position-x position) (+ left (region-width region))) (<= bottom (position-y position) (+ bottom (region-height region)))))) (defun same-region-p (region-1 region-2) "Test whether two regions have the same coordinates." (and (= (region-bottom region-1) (region-bottom region-2)) (= (region-left region-1) (region-left region-2)) (= (region-width region-1) (region-width region-2)) (= (region-height region-1) (region-height region-2)))) (defun position-in-region-p (position region) "Returns T if the position is inside the region." (let ((x (position-x position)) (y (position-y position))) (and (<= (region-left region) x) (> (+ (region-left region) (region-width region)) x) (<= (region-bottom region) y) (> (+ (region-bottom region) (region-height region)) y))))
4,529
Common Lisp
.l
104
38.826923
111
0.56072
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
de04418b1eec8dd030113bcce10096d80fbd994c3a6de892ef6e4a1f2b705a55
33,469
[ -1 ]
33,470
shades-sblx.lsp
rwoldford_Quail/source/window-basics/bitmap/shades-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; shades-sblx.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*black-shade* *white-shade* *light-gray-shade* *dark-gray-shade* *gray-shade* *default-fill-shade*))) ;;;============================================================ ;;; Shades ;;;============================================================ (defvar *black-shade*) (defvar *white-shade*) (defvar *light-gray-shade*) (defvar *dark-gray-shade*) (defvar *gray-shade*) (defvar *default-fill-shade*) (defun setup-shades () (declare (special *black-shade* *black-color* *white-shade* *white-color* *light-gray-shade* *light-gray-color* *dark-gray-shade* *dark-gray-color* *gray-shade* *gray-color* *default-fill-shade* *colors*)) (setf *black-shade* *black-color*) (setf *white-shade* *white-color*) (setf *light-gray-shade* *light-gray-color*) (setf *dark-gray-shade* *dark-gray-color*) (setf *gray-shade* *gray-color*) #|(setf *gray-shade* (make-record :color :b0 170 :b1 85 :b2 170 :b3 85 :b4 170 :b5 85 :b6 170 :b7 85))|# (setf *default-fill-shade* *gray-color*) ) (add-restore-lisp-functions #'setup-shades) (eval-when (:load-toplevel) (setup-shades))
2,365
Common Lisp
.l
57
33
85
0.452609
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
fee3da43384847d4ba304c8ef6b236ea8e3c48739ca38908e746667b6ba596e0
33,470
[ -1 ]
33,471
cursor.lsp
rwoldford_Quail/source/window-basics/bitmap/cursor.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; cursor.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; Authors: ;;; R.W. Oldford 1991 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*box-cursor* *circle-cursor* restore-circle-cursor restore-box-cursor))) (defvar *box-cursor* NIL) (defun restore-box-cursor () "Restores the value of *box-cursor*" (declare (special *box-cursor*)) (setf *box-cursor* (make-cursor (make-box-bitmap 16 16) :mask (make-blank-bitmap 16 16)))) (eval-when (load) (restore-box-cursor)) (defvar *circle-cursor* NIL) (defun restore-circle-cursor () "Restores the value of *circle-cursor*" (declare (special *circle-cursor*)) (setf *circle-cursor* (make-cursor (make-circle-bitmap 16) :mask (make-blank-bitmap 16 16) :hotspot (h-draw:make-point 8 8)))) (eval-when (load) (restore-circle-cursor)) (add-restore-lisp-functions #'restore-box-cursor #'restore-circle-cursor)
1,578
Common Lisp
.l
42
32.928571
95
0.511214
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
4c29018672f089d0c02d09198209b431af090f487d7fc024d51465764f39aace
33,471
[ -1 ]
33,472
shades-pc.lsp
rwoldford_Quail/source/window-basics/bitmap/shades-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; shades-pc.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*black-shade* *white-shade* *light-gray-shade* *dark-gray-shade* *gray-shade* *default-fill-shade*))) ;;;============================================================ ;;; Shades ;;;============================================================ (defvar *black-shade*) (defvar *white-shade*) (defvar *light-gray-shade*) (defvar *dark-gray-shade*) (defvar *gray-shade*) (defvar *default-fill-shade*) (defun setup-shades () (declare (special *black-shade* color*black-color* *white-shade* *white-color* *light-gray-shade* *light-gray-color* *dark-gray-shade* *dark-gray-color* *gray-shade* *gray-color* *default-fill-shade* *colors*)) (setf *black-shade* *black-color*) (setf *white-shade* *white-color*) (setf *light-gray-shade* *light-gray-color*) (setf *dark-gray-shade* *dark-gray-color*) (setf *gray-shade* *gray-color*) #|(setf *gray-shade* (make-record :color :b0 170 :b1 85 :b2 170 :b3 85 :b4 170 :b5 85 :b6 170 :b7 85))|# (setf *default-fill-shade* *gray-color*) ) (add-restore-lisp-functions #'setup-shades) (eval-when (load) (setup-shades))
2,423
Common Lisp
.l
57
32.877193
86
0.440851
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f94c830740eace54f6f83e0c15c7b4766df9670075151581592f2c2f616e00f7
33,472
[ -1 ]
33,473
cursor-pc.lsp
rwoldford_Quail/source/window-basics/bitmap/cursor-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; cursor-pc.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; R.W. Oldford 1991 ;;; G.W. Bennett 1996 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;------------------------------------------------------------------------ ;;; Much experimenting to be done here! (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-cursor with-cursor))) (defun make-cursor (bitmap &key mask (hotspot (h-draw:make-point 0 0))) "Returns a cursor structure for use with with-cursor." (declare (ignore bitmap mask hotspot)) ; 25JUL2023 to avoid Warnings ;;; There is such a function in CG => ;;; (cg::make-cursor texture hot-spot mask) ;;; <hot-spot> is a position relative to the upper left corner of the ;;; cursor and <mask> is a bitmap indicating which points of the cursor ;;; should be opaque. ;;; <texture> is a texture which is a pixel-map or bitmap packages to ;;; work on a particular <device> ;;; See Ver2 Ch4 pp17 ff. )
1,522
Common Lisp
.l
31
45.741935
82
0.53468
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
8c3c260e4080e811d641b3c92adb9b14af78fbb9b15000c2ad0d1a7e020a3814
33,473
[ -1 ]
33,477
patterns.lsp
rwoldford_Quail/source/window-basics/bitmap/patterns.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; patterns.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*patterns* eq-patterns order-patterns *dash* ))) ;;;============================================================ ;;; Dashing Patterns ;;;============================================================ (defparameter *dash* '#(5 2)) ;;;============================================================ ;;; Texture Patterns ;;;============================================================ (defvar *patterns*) (defun setup-patterns () (declare (special *black-shade* *white-shade* *light-gray-shade* *dark-gray-shade* *gray-shade* *patterns*)) (setf *patterns* (list *white-shade* *light-gray-shade* *gray-shade* *dark-gray-shade* *black-shade*))) (add-restore-lisp-functions #'setup-patterns) (eval-when (:load-toplevel) (setup-patterns)) (defun eq-patterns (pattern-1 pattern-2) "Test whether two patterns are equal.~ Patterns may be nil here" (cond ((and (null pattern-1) (null pattern-2)) t) ((null pattern-1) nil) ((null pattern-2) nil) (t (eq pattern-1 pattern-2)))) (defun order-patterns (patterns) "Orders the patterns in the list given.~ WARNING: The list *patterns* is used to order the~ patterns, patterns not in *patterns* will be at the end~ of the orderd list in any order" (declare (special *patterns*)) (loop for p in *patterns* when (member p patterns) collect p into result finally (return (loop for p in patterns do (pushnew p result) finally (return (nreverse result))))))
2,683
Common Lisp
.l
72
30.944444
86
0.465216
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
7fc72ee5e3af85e3648fda9de6bc45cde682a76aae9d42a8e76e61da5eb3f269
33,477
[ -1 ]
33,478
shades.lsp
rwoldford_Quail/source/window-basics/bitmap/shades.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; shades.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(canvas-bltshade))) (defun canvas-bltshade (canvas shade &key (canvas-left 0) (canvas-bottom 0) (width (canvas-width canvas)) (height (canvas-height canvas)) (operation :boole-1)) "Draws a rectangle on the canvas using the shade as a color." (with-pen-values canvas shade NIL operation (canvas-draw-filled-rectangle canvas canvas-left (+ -1 canvas-left width) canvas-bottom (+ -1 canvas-bottom height))))
1,491
Common Lisp
.l
40
32.025
86
0.476784
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
7043d37d690ea8721f8779d22daaf387147a4cb1f34153c01a6492617662fc29
33,478
[ -1 ]
33,479
cursor-sblx.lsp
rwoldford_Quail/source/window-basics/bitmap/cursor-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; cursor-sblx.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; R.W. Oldford 1991 ;;; G.W. Bennett 1996 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;------------------------------------------------------------------------ ;;; Much experimenting to be done here! (in-package :wb) #| (eval-when (:compile-toplevel :load-toplevel :execute) (export '(make-cursor with-cursor))) (defun make-cursor (bitmap &key mask (hotspot (h-draw:make-point 0 0))) "Returns a cursor structure for use with with-cursor." ;;; There is such a function in CG => ;;; (cg::make-cursor texture hot-spot mask) ;;; <hot-spot> is a position relative to the upper left corner of the ;;; cursor and <mask> is a bitmap indicating which points of the cursor ;;; should be opaque. ;;; <texture> is a texture which is a pixel-map or bitmap packages to ;;; work on a particular <device> ;;; See Ver2 Ch4 pp17 ff. ) |#
1,425
Common Lisp
.l
32
42.34375
81
0.533429
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
2a33c86636dfec4758dc9661623b96420e0a939b9bb08e7cb9cc18c1bc262c1a
33,479
[ -1 ]
33,481
quail-bitmap.lsp
rwoldford_Quail/source/window-basics/bitmap/quail-bitmap.lsp
(defun array-decimal-to-hex (a) (let ((ha (make-array (array-dimensions a)))) (dotimes (i (array-dimension a 0)) (dotimes (j (array-dimension a 1)) (setf (aref ha i j) (format NIL "~2,48,x" (aref a i j))))) ha)) (defun array-decimal-to-binary (a) (let ((ha (make-array (array-dimensions a)))) (dotimes (i (array-dimension a 0)) (dotimes (j (array-dimension a 1)) (setf (aref ha i j) (format NIL "~8,48,b" (aref a i j))))) ha)) (defun format-binary-array (the-array &optional destination (begin 0) (end 50)) (let ((temp "")) (dotimes (y (array-dimension the-array 1)) (dotimes (x (array-dimension the-array 0)) (setf temp (concatenate 'string temp (format NIL "~a" (aref the-array x y))))) (format destination "~&~b" (subseq (format NIL "~a" temp) begin end )) (setf temp "")))) (defun list-to-array (list nrows ncols) (make-array (list nrows ncols) :initial-contents (qk:shape-as-array list (list nrows ncols) 'list))) (setf a '#2A((0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 255 255 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 255 255) (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 80 136 196 98 49 24 12 6 3 1 0 0 0 0 0 0 240 255 255 31 0 0 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255) (0 0 0 0 0 0 0 0 0 0 0 12 15 15 55 71 67 79 49 1 2 4 8 17 10 4 0 0 128 64 32 16 143 199 99 49 24 13 6 0 252 255 255 255 0 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255) (0 0 0 0 0 0 0 1 3 7 15 23 39 199 195 224 241 250 252 254 126 126 190 0 0 0 0 0 0 1 3 15 255 255 255 255 191 1 0 0 0 255 255 255 0 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255) (3 4 8 16 32 64 128 0 225 242 244 248 240 252 254 254 63 63 31 31 15 15 15 15 15 31 31 63 255 255 255 254 252 252 248 248 248 248 254 127 255 255 255 254 0 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255) (128 192 96 48 16 32 64 128 0 0 0 0 0 0 0 0 0 128 192 192 192 192 192 192 192 192 192 192 128 128 0 0 0 0 0 0 0 0 0 128 128 128 0 0 0 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 255) (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192))) (setf ha (array-decimal-to-hex a)) (setf ba (array-decimal-to-binary a)) (format-binary-array ba) (setf quail '(#x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x80 #x0f #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xc0 #x3f #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xc0 #x3f #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xe0 #x7f #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xe0 #x7f #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x60 #x7c #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x60 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x60 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xf8 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x06 #x03 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x01 #x04 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x01 #x04 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x80 #x00 #x08 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x80 #x00 #x08 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xf0 #x20 #x08 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x9c #x00 #x08 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x8e #x00 #x08 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x70 #x01 #x04 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xc0 #x03 #x0c #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x06 #x33 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xf8 #x80 #x03 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x80 #xff #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x60 #x00 #x03 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x18 #x00 #x0c #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x30 #x04 #x00 #x10 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x02 #x00 #x20 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x60 #x01 #x00 #x40 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xc0 #x00 #x00 #x80 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x40 #x00 #x00 #x00 #x01 #x08 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x40 #x00 #x00 #x00 #xe3 #x0f #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #xbe #x05 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x82 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x84 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x84 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #xc4 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x44 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x24 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x2c #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x06 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x06 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x10 #x00 #x00 #x00 #x04 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x02 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x00 #x02 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x40 #x00 #x00 #x00 #x01 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x40 #x00 #x00 #x00 #x01 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x80 #x00 #x00 #x80 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x01 #x00 #x40 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x02 #x00 #x20 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x04 #x00 #x10 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x18 #x00 #x0c #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x70 #x00 #x03 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x90 #xff #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x08 #x00 #x01 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x04 #x00 #x01 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x03 #x00 #x00 #x06 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x80 #x00 #x00 #x00 #x03 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x40 #x00 #x00 #x82 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x20 #x00 #x00 #x68 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #xa0 #x31 #xa0 #x00 #x38 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x7c #xcf #x00 #x3d #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x40 #x60 #x77 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x00)) (<- q1 (list-to-array quail 100 13)) (<- q1b (array-decimal-to-binary q1)) (format-binary-array q1b *terminal-io*)
10,672
Common Lisp
.l
170
52.429412
83
0.530647
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
b6cdd305e4321f29159b95bf0ac97a7d3dffcbe21fb4177ece3b0fa6a155dce5
33,481
[ -1 ]
33,482
bitmap-pc.lsp
rwoldford_Quail/source/window-basics/bitmap/bitmap-pc.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; bitmap-pc.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; R.W. Oldford 1989-1992 ;;; G.W. Bennett 1996 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(bitmap-p make-bitmap canvas-bitblt copy-canvas-region-to-bitmap with-bitmap-as-window canvas-bitblt copy-canvas-region-to-bitmap))) ;;;============================================================ ;;; Bitmaps seem to be known as Pixel-Maps in ACLPC3 ;;; See Ver2 manual 4-9 ff. ;;;============================================================ ;; From bitmap-mcl (defun make-window-use-bitmap (w bm) (declare (ignore w bm)) ; 25JUL2023 for Warnings #| "Make the window w use the host bitmap bm as its draw area." (let ((grafport (rref (wptr w) windowRecord.port))) (with-port grafport (_SetPBits :ptr bm) (_MovePortTo :word 0 :word 0) (_PortSize :word (+ 1 (- (rref bm bitmap.bounds.right) (rref bm bitmap.bounds.left))) :word (+ 1 (- (rref bm bitmap.bounds.bottom) (rref bm bitmap.bounds.top)))) (_RectRgn :ptr (rref grafport grafport.visrgn) :ptr (rref bm bitmap.bounds))))) |# (format *terminal-io* "~&make-window-use-bitmap unimplemented for PC~%") ) (defmacro with-bitmap-as-window (bm w &body body) (declare (ignore bm w body)) ; 25JUL2023 for Warning #| `(let ((,w (make-instance 'window :window-show nil))) (make-window-use-bitmap ,w ,bm) (h-draw::erase-rect ,w (rref ,bm bitmap.bounds)) ,@body (ccl:window-close ,w))) |# (format *terminal-io* "~&with-bitmap-as-window unimplemented for PC~%") ) (defun array-to-bitmap (the-array bitmap-width) (declare (ignore the-array bitmap-width)) ; 25JUL2023 for Warning ;;; make a bitmap with an array of integer and a width for the bitmap #| (let* ((the-bitmap (make-bitmap :width bitmap-width :height (array-dimension the-array 1))) (bm (ccl:rref (bitmap-host-bitmap the-bitmap) bitmap.baseaddr)) (offset 0)) (ccl:rset (bitmap-host-bitmap the-bitmap) bitmap.rowBytes (array-dimension the-array 0)) (dotimes (y (array-dimension the-array 1)) (dotimes (x (array-dimension the-array 0)) (ccl:%put-byte bm (aref the-array x y) offset) (setq offset (+ 1 offset)))) the-bitmap) |# ) (defun bitmap-to-array (the-bitmap bitmap-width) (declare (ignore the-bitmap bitmap-width)) ; 25JUL2023 for Warning ;;; make a bitmap with an array of integer and a width for the bitmap #| (let* ((the-bitmap (make-bitmap :width bitmap-width :height (array-dimension the-array 1))) (bm (ccl:rref (bitmap-host-bitmap the-bitmap) bitmap.baseaddr)) (offset 0)) (ccl:rset (bitmap-host-bitmap the-bitmap) bitmap.rowBytes (array-dimension the-array 0)) (dotimes (y (array-dimension the-array 1)) (dotimes (x (array-dimension the-array 0)) (ccl:%put-byte bm (aref the-array x y) offset) (setq offset (+ 1 offset)))) the-bitmap) |# ) (defun canvas-bitblt (canvas bitmap &key (canvas-left 0) (canvas-bottom 0) (bitmap-left 0) (bitmap-bottom 0) (width (bitmap-width bitmap)) (height (bitmap-height bitmap)) (operation :default)) (declare (ignorable canvas bitmap canvas-left canvas-bottom bitmap-left bitmap-bottom width height operation)) ; 25JUL2023 for Warnings ignore -> ignorable 25SEP2023 (format *terminal-io* "~&canvas-bitblt unimplemented for PC~%") #| (let* ((raw-bitmap (bitmap-host-bitmap bitmap)) (bitmap-y-adjust (rref raw-bitmap bitmap.bounds.bottom)) (canvas-window (wptr canvas)) (canvas-bitmap (rref canvas-window windowRecord.port.portbits)) (canvas-visRgn (rref canvas-window windowRecord.port.visRgn)) (bitblt-op (boole-to-op operation))) (rlet ((raw-rect :rect) (canvas-rect :rect)) (rset raw-rect rect.left bitmap-left) (rset raw-rect rect.top (- bitmap-y-adjust (+ bitmap-bottom height -1))) (rset raw-rect rect.right (+ bitmap-left width -1)) (rset raw-rect rect.bottom (- bitmap-y-adjust bitmap-bottom)) (rset canvas-rect rect.left canvas-left) (rset canvas-rect rect.top (canvas-to-host-y canvas (+ canvas-bottom height -1))) (rset canvas-rect rect.right (+ canvas-left width -1)) (rset canvas-rect rect.bottom (canvas-to-host-y canvas canvas-bottom)) (h-draw::copy-bits raw-bitmap canvas-bitmap raw-rect canvas-rect bitblt-op canvas-visRgn) ))) |# ) (defun copy-canvas-region-to-bitmap (source-canvas source-left source-top dest-bitmap width height) "Copy a region of the canvas to a bitmap." (declare (ignore source-canvas source-left source-top dest-bitmap width height)) ; 25JUL2023 for Warnings (format *terminal-io* "~&copy-canvas-region-to-bitmap unimplemented for PC~%") #| (with-port (wptr source-canvas) (rlet ((r-source :rect :top (- (+ source-top height)) :left source-left :bottom (- source-top) :right (+ source-left width)) (r-dest :rect :top 0 :left 0 :bottom height :right width)) (_CopyBits :ptr (rref (rref (wptr source-canvas) windowRecord.port) grafport.portbits) :ptr (bitmap-host-bitmap dest-bitmap) :ptr r-source :ptr r-dest :word (h-draw::mode-arg :patCopy) :ptr (%null-ptr)))) |# )
6,519
Common Lisp
.l
145
36.737931
109
0.569716
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
2fb90e1612fb04b54397af21d57923a039479dd7d9ec356ad4afdaf0f893aba3
33,482
[ -1 ]
33,485
bitmap.lsp
rwoldford_Quail/source/window-basics/bitmap/bitmap.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; bitmap.lisp ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; ;;; Authors: ;;; H.A. Chipman 1991 ;;; C.B. Hurley 1989-1991 ;;; J.A. McDonald 1988-89 ;;; R.W. Oldford 1989-1992 ;;; J.O. Pedersen 1988-89 ;;; ;;; ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) #| stubbed 11MAR2022 gwb (eval-when (:compile-toplevel :load-toplevel :execute) (export '(bitmap-width bitmap-height bitmap-host-bitmap bitmap *circle-bitmap* *cross-bitmap* *square-bitmap* *star-bitmap* make-blank-bitmap make-circle-bitmap make-box-bitmap plot-glyph-at))) |# (eval-when (:compile-toplevel :load-toplevel :execute) (export '(bitmap))) ;;;============================================================ ;;; Bitmaps ;;;============================================================ (defstruct bitmap width height host-bitmap) #| stubbed 11MAR2022 gwb (defvar *circle-bitmap* NIL) (defvar *cross-bitmap* NIL) (defvar *square-bitmap* NIL) (defvar *star-bitmap* NIL) (defun setup-bitmaps () (declare (special *circle-bitmap* *box-bitmap* *star-bitmap* *cross-bitmap*)) (setf *circle-bitmap* (make-bitmap :width 12 :height 12 :host-bitmap (let ((bm (h-draw::make-bitmap 0 0 11 11))) (with-bitmap-as-window bm w (h-draw::draw-arc w 0 360 0 0 5 5) ) bm) )) (setf *cross-bitmap* (make-bitmap :width 12 :height 12 :host-bitmap (let ((bm (h-draw::make-bitmap 0 0 11 11))) (with-bitmap-as-window bm w (h-draw::move-to w 0 0) (h-draw::line-to w 10 10) (h-draw::move-to w 10 0) (h-draw::line-to w 0 10) ) bm) )) (setf *square-bitmap* (make-bitmap :width 12 :height 12 :host-bitmap (let ((bm (h-draw::make-bitmap 0 0 11 11))) (with-bitmap-as-window bm w (h-draw::move-to w 0 0) (h-draw::line-to w 10 0) (h-draw::line-to w 10 10) (h-draw::line-to w 0 10) (h-draw::line-to w 0 0) ) bm) )) (setf *star-bitmap* (make-bitmap :width 12 :height 12 :host-bitmap (let ((bm (h-draw::make-bitmap 0 0 11 11))) (with-bitmap-as-window bm w (let ((ang (/ (* 2.0 pi) 8.0))) (dotimes (r 8) (h-draw::move-to w 5 5) (h-draw::line w (round (* 5 (sin (* r ang)))) (round (* 5 (cos (* r ang))))) ) ) ) bm) ))) (eval-when (load) (setup-bitmaps)) (add-restore-lisp-functions #'setup-bitmaps) (defun make-blank-bitmap (width height) (make-bitmap :width width :height height :host-bitmap (h-draw::make-bitmap 0 0 width height))) (defun make-circle-bitmap (diameter &key fill? pattern ) (declare (special *black-shade*)) (unless pattern (setf pattern *black-shade*)) (make-bitmap :height diameter :width diameter :host-bitmap (let ((bm (h-draw::make-bitmap 0 0 (1- diameter) (1- diameter))) (radius (truncate (/ diameter 2.0)))) (with-bitmap-as-window bm w (if (null fill?) (h-draw::draw-arc w 0 360 radius radius radius radius) (progn (h-draw::set-pen-pattern w pattern) (h-draw::fill-arc w 0 360 radius radius radius radius)) )) bm) )) (defun make-box-bitmap (width height &key fill? pattern ) (declare (special *black-shade*)) (unless pattern (setf pattern *black-shade*)) (make-bitmap :height height :width width :host-bitmap (let ((bm (h-draw::make-bitmap 0 0 (1- width) (1- height)))) (with-bitmap-as-window bm w (if (null fill?) (h-draw::draw-rectangle w 0 (1- width) 0 (1- height)) (progn (h-draw::set-pen-pattern w pattern) (h-draw::draw-filled-rectangle w 0 (1- width) 0 (1- height))))) bm) )) |# ;;; stubbed 12MAR2022 gwb (defun plot-glyph-at (canvas position-x position-y glyph &key (operation :default)) (declare (ignorable canvas position-x position-y glyph operation)) ; 10MAY2024 to avoid Warnings (format t "~%Not implements in mcclim yet") #| (let* ((glyph-width (bitmap-width glyph)) (glyph-height (bitmap-height glyph)) (newx (- position-x (truncate glyph-width 2))) (newy (- position-y (truncate glyph-height 2)))) (canvas-bitblt canvas glyph :canvas-left newx :canvas-bottom newy :operation operation)) |# )
5,850
Common Lisp
.l
163
25.803681
112
0.471307
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
43da308e8ec81024598513cffb1dffbc232832095f8abd21370ea2d722e23d2e
33,485
[ -1 ]
33,486
bitmap-sblx.lsp
rwoldford_Quail/source/window-basics/bitmap/bitmap-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; bitmap-sblx.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; R.W. Oldford 1989-1992 ;;; G.W. Bennett 1996 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(bitmap-p make-bitmap canvas-bitblt copy-canvas-region-to-bitmap with-bitmap-as-window canvas-bitblt copy-canvas-region-to-bitmap))) ;;;============================================================ ;;; Bitmaps seem to be known as Pixel-Maps in ACLPC3 ;;; See Ver2 manual 4-9 ff. ;;;============================================================ ;; From bitmap-mcl (defun bitmap-p (b) ;; cut in 11MAR2022 gwb (eq (class-name b) 'bitmap)) (defun make-window-use-bitmap (w bm) (declare (ignorable w bm)) ;10MAY2024 #| "Make the window w use the host bitmap bm as its draw area." (let ((grafport (rref (wptr w) windowRecord.port))) (with-port grafport (_SetPBits :ptr bm) (_MovePortTo :word 0 :word 0) (_PortSize :word (+ 1 (- (rref bm bitmap.bounds.right) (rref bm bitmap.bounds.left))) :word (+ 1 (- (rref bm bitmap.bounds.bottom) (rref bm bitmap.bounds.top)))) (_RectRgn :ptr (rref grafport grafport.visrgn) :ptr (rref bm bitmap.bounds))))) |# (format *terminal-io* "~&make-window-use-bitmap unimplemented for SBCL-LINUX~%") ) (defmacro with-bitmap-as-window (bm w &body body) (declare (ignorable bm w body)) #| `(let ((,w (make-instance 'window :window-show nil))) (make-window-use-bitmap ,w ,bm) (h-draw::erase-rect ,w (rref ,bm bitmap.bounds)) ,@body (ccl:window-close ,w))) |# (format *terminal-io* "~&with-bitmap-as-window unimplemented for SBCL-LINUX~%") ) (defun array-to-bitmap (the-array bitmap-width) (declare (ignorable the-array bitmap-width)) (format *terminal-io* "~&array-to-bitmap unimplemented for SBCL-LINUX~%") ;;; make a bitmap with an array of integer and a width for the bitmap #| (let* ((the-bitmap (make-bitmap :width bitmap-width :height (array-dimension the-array 1))) (bm (ccl:rref (bitmap-host-bitmap the-bitmap) bitmap.baseaddr)) (offset 0)) (ccl:rset (bitmap-host-bitmap the-bitmap) bitmap.rowBytes (array-dimension the-array 0)) (dotimes (y (array-dimension the-array 1)) (dotimes (x (array-dimension the-array 0)) (ccl:%put-byte bm (aref the-array x y) offset) (setq offset (+ 1 offset)))) the-bitmap) |# ) (defun bitmap-to-array (the-bitmap bitmap-width) (declare (ignorable the-bitmap bitmap-width)) (format *terminal-io* "~&bitmap-to-array unimplemented for SBCL-LINUX~%") ;;; make a bitmap with an array of integer and a width for the bitmap #| (let* ((the-bitmap (make-bitmap :width bitmap-width :height (array-dimension the-array 1))) (bm (ccl:rref (bitmap-host-bitmap the-bitmap) bitmap.baseaddr)) (offset 0)) (ccl:rset (bitmap-host-bitmap the-bitmap) bitmap.rowBytes (array-dimension the-array 0)) (dotimes (y (array-dimension the-array 1)) (dotimes (x (array-dimension the-array 0)) (ccl:%put-byte bm (aref the-array x y) offset) (setq offset (+ 1 offset)))) the-bitmap) |# ) (defun canvas-bitblt (canvas bitmap &key (canvas-left 0) (canvas-bottom 0) (bitmap-left 0) (bitmap-bottom 0) (width (bitmap-width bitmap)) (height (bitmap-height bitmap)) (operation :default)) (declare (ignorable canvas bitmap canvas-left canvas-bottom bitmap-left bitmap-bottom width height operation)) ;10MAY2024 (format *terminal-io* "~&canvas-bitblt unimplemented for SBCL-LINUX~%") #| (let* ((raw-bitmap (bitmap-host-bitmap bitmap)) (bitmap-y-adjust (rref raw-bitmap bitmap.bounds.bottom)) (canvas-window (wptr canvas)) (canvas-bitmap (rref canvas-window windowRecord.port.portbits)) (canvas-visRgn (rref canvas-window windowRecord.port.visRgn)) (bitblt-op (boole-to-op operation))) (rlet ((raw-rect :rect) (canvas-rect :rect)) (rset raw-rect rect.left bitmap-left) (rset raw-rect rect.top (- bitmap-y-adjust (+ bitmap-bottom height -1))) (rset raw-rect rect.right (+ bitmap-left width -1)) (rset raw-rect rect.bottom (- bitmap-y-adjust bitmap-bottom)) (rset canvas-rect rect.left canvas-left) (rset canvas-rect rect.top (canvas-to-host-y canvas (+ canvas-bottom height -1))) (rset canvas-rect rect.right (+ canvas-left width -1)) (rset canvas-rect rect.bottom (canvas-to-host-y canvas canvas-bottom)) (h-draw::copy-bits raw-bitmap canvas-bitmap raw-rect canvas-rect bitblt-op canvas-visRgn) ))) |# ) (defun copy-canvas-region-to-bitmap (source-canvas source-left source-top dest-bitmap width height) "Copy a region of the canvas to a bitmap." (declare (ignorable source-canvas source-left source-top dest-bitmap width height)) ;10MAY2024 (format *terminal-io* "~&copy-canvas-region-to-bitmap unimplemented for SBCL-LINUX~%") #| (with-port (wptr source-canvas) (rlet ((r-source :rect :top (- (+ source-top height)) :left source-left :bottom (- source-top) :right (+ source-left width)) (r-dest :rect :top 0 :left 0 :bottom height :right width)) (_CopyBits :ptr (rref (rref (wptr source-canvas) windowRecord.port) grafport.portbits) :ptr (bitmap-host-bitmap dest-bitmap) :ptr r-source :ptr r-dest :word (h-draw::mode-arg :patCopy) :ptr (%null-ptr)))) |# )
6,504
Common Lisp
.l
149
36.536913
96
0.584453
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
35e8822aa2bccbeb12d12e72f65481553caa9614668bb9248080f000f6d6b3f5
33,486
[ -1 ]
33,487
device-sblx.lsp
rwoldford_Quail/source/window-basics/monitor/device-sblx.lsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; device-sblx.lsp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) Statistical Computing Laboratory ;;; University of Waterloo ;;; Canada. ;;; This file is part of the Window-Basics package intended to provide a uniform ;;; window environment for Common Lisp programming. ;;; ;;; For copyright information and history, see window-basics-copyright.lisp ;;; Authors: ;;; R.W. Oldford 1992 ;;; G.W. Bennett 1996 ;;; ;;;---------------------------------------------------------------------------------- (in-package :wb) (eval-when (:compile-toplevel :load-toplevel :execute) (export '(*color-available* color-available-p))) ;;; ;;; *color-available* is a Mac Common Lisp variable that is T if ;;; the Mac has color and NIL otherwise. ;;; In window-basics, this information is stored as function. ;;; For the PC we are assuming that color is available (defvar *color-available* T) (defun color-available-p () "Returns T if colour (or gray-scale) ~ is available on the present monitor, NIL otherwise." T)
1,175
Common Lisp
.l
27
41.851852
104
0.558952
rwoldford/Quail
0
1
0
GPL-3.0
9/19/2024, 11:43:28 AM (Europe/Amsterdam)
f12e807778318b30a4be228d8d07e19f1f103842a3034120f45604889b6a914d
33,487
[ -1 ]