getting rid of sequencep across the codebase.
[CommonLispStat.git] / src / packages.lisp
blobfcbff2838a82fa72ae24c160bc392f5011528e3a
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2008-11-12 10:02:03 tony>
4 ;;; Creation: <2008-03-11 19:18:34 user>
5 ;;; File: packages.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2007--2008, AJ Rossini. BSD, LLGPL, or GPLv2, depending
8 ;;; on how it arrives.
9 ;;; Purpose: package structure description for lispstat
11 ;;; What is this talk of 'release'? Klingons do not make software
12 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
13 ;;; designers and quality assurance people in its wake.
15 ;;; This organization and structure is new to the 21st Century
16 ;;; version.
18 (in-package :cl-user)
20 ;;; LispStat Basics
22 (in-package :cl-user)
24 (defpackage :lisp-stat-object-system
25 (:nicknames :ls-objects :lsos)
26 (:use :common-lisp)
27 (:shadow :call-method :call-next-method :slot-value)
28 (:export ls-object objectp *object* kind-of-p make-object
29 *message-hook*
30 *set-slot-hook* slot-value self
31 send call-next-method call-method
32 defmeth defproto instance-slots proto-name))
38 (defpackage :lisp-stat-types
39 (:documentation "Provides some typeing for LispStat, but is clearly
40 a bit incomplete.")
41 (:use :common-lisp)
42 (:export fixnump
43 check-nonneg-fixnum check-one-nonneg-fixnum
44 check-one-fixnum check-one-real check-one-number))
47 ;;; Package Setup
49 (in-package :cl-user)
51 (defpackage :lisp-stat-float
52 (:use :common-lisp)
53 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
54 machine-epsilon base-float makedouble
56 make-base-trans-fun-2 make-base-trans-fun
58 base-log base-exp base-expt base-sqrt base-sin base-cos
59 base-tan base-asin base-acos base-atan base-sinh
60 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
61 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
62 BASE-FROUND BASE-SIGNUM BASE-CIS))
65 (defpackage :lisp-stat-compound-data
66 (:use :common-lisp
67 :lisp-stat-object-system
68 :lisp-stat-types)
69 (:shadowing-import-from :lisp-stat-object-system
70 slot-value
71 call-next-method call-method)
72 (:export compound-data-p *compound-data-proto*
73 compound-object-p
74 compound-data-seq compound-data-length
75 element-list element-seq
76 sort-data order rank
77 recursive-map-elements map-elements repeat
78 check-sequence
79 get-next-element make-next-element set-next-element
80 ;; sequencep
81 iseq ordered-nneg-seq
82 select split-list which
83 difference rseq
84 flatten-list ))
86 (defpackage :lisp-stat-macros
87 (:use :common-lisp
88 :lisp-stat-compound-data)
89 (:export make-rv-function make-rv-function-1))
91 (defpackage :lisp-stat-basics
92 (:use :common-lisp
93 :lisp-stat-object-system
94 :lisp-stat-types
95 :lisp-stat-float
96 :lisp-stat-macros
97 :lisp-stat-compound-data)
98 (:shadowing-import-from :lisp-stat-object-system
99 slot-value call-method call-next-method)
100 (:export permute-array sum prod count-elements mean
101 if-else sample))
105 (defpackage :lisp-stat-float
106 (:use :common-lisp)
107 (:export +stat-float-typing+ +stat-cfloat-typing+ +stat-float-template+
108 machine-epsilon base-float makedouble
110 make-base-trans-fun-2 make-base-trans-fun
112 BASE-LOG BASE-EXP BASE-EXPT BASE-SQRT BASE-SIN BASE-COS
113 BASE-TAN BASE-ASIN BASE-ACOS BASE-ATAN BASE-SINH
114 BASE-COSH BASE-TANH BASE-ASINH BASE-ACOSH BASE-ATANH
115 BASE-ABS BASE-PHASE BASE-FFLOOR BASE-FCEILING BASE-FTRUNCATE
116 BASE-FROUND BASE-SIGNUM BASE-CIS))
118 ;;;
120 (defpackage :lisp-stat-macros
121 (:use :common-lisp
122 :lisp-stat-compound-data)
123 (:export make-rv-function make-rv-function-1))
125 ;;; NEW CLOS STRUCTURE
127 (defpackage :lisp-stat-data-clos
128 (:use :common-lisp
129 :lisp-matrix)
130 (:export get-variable-matrix get-variable-vector
131 ;; generic container class for data -- if small enough
132 ;; could be value, otherwise might be reference.
133 data-pointer))
135 (defpackage :lisp-stat-regression-linear-clos
136 (:use :common-lisp
137 :lisp-matrix
138 :lisp-stat-data-clos)
139 (:export regression-model))
143 ;;; USER PACKAGES
145 (defpackage :lisp-stat-ffi-int
146 (:use :common-lisp
147 :cffi)
148 (:export ccl-store-integer ccl-store-double ccl-store-ptr
149 get-buf ))
151 (defpackage :lisp-stat-probability
152 (:use :common-lisp
153 :cffi
154 :lisp-stat-ffi-int
155 :lisp-stat-macros)
156 (:export log-gamma set-seed
157 uniform-rand
158 normal-cdf normal-quant normal-dens normal-rand
159 bivnorm-cdf
160 cauchy-cdf cauchy-quant cauchy-dens cauchy-rand
161 gamma-cdf gamma-quant gamma-dens gamma-rand
162 chisq-cdf chisq-quant chisq-dens chisq-rand
163 beta-cdf beta-quant beta-dens beta-rand
164 t-cdf t-quant t-dens t-rand
165 f-cdf f-quant f-dens f-rand
166 poisson-cdf poisson-quant poisson-pmf poisson-rand
167 binomial-cdf binomial-quant binomial-pmf binomial-rand))
171 (defpackage :lisp-stat-matrix
172 (:use :common-lisp
173 :cffi
174 :lisp-stat-compound-data)
175 (:export matrixp ;; matrix -- conflicts!
176 num-rows num-cols matmult identity-matrix diagonal
177 row-list column-list inner-product outer-product
178 cross-product transpose bind-columns bind-rows
179 array-data-vector vector-to-array
181 check-matrix check-square-matrix
183 copy-array copy-vector
186 (defpackage :lisp-stat-linalg-data
187 (:use :common-lisp
188 :cffi
189 :lisp-stat-ffi-int
190 :lisp-stat-types
191 :lisp-stat-compound-data
192 :lisp-stat-matrix)
193 (:export ;; more to add
194 +mode-in+ +mode-re+ +mode-cx+ mode-of
196 la-data-mode la-allocate la-free
198 la-get-double la-put-double
199 la-put-integer
201 la-matrix la-free-matrix la-matrix-to-data la-data-to-matrix
202 la-vector la-free-vector la-vector-to-data la-data-to-vector ))
205 (defpackage :lisp-stat-math
206 (:use :common-lisp
207 :lisp-stat-object-system
208 :lisp-stat-macros
209 :lisp-stat-compound-data
210 :lisp-stat-float)
211 (:shadowing-import-from :lisp-stat-object-system
212 slot-value call-method call-next-method)
213 (:shadow expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
214 asin acos atan sinh cosh tanh asinh acosh atanh float random
215 truncate floor ceiling round minusp zerop plusp evenp oddp
216 < <= = /= >= > ;; complex
217 conjugate realpart imagpart phase
218 min max logand logior logxor lognot ffloor fceiling
219 ftruncate fround signum cis)
220 (:export ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
221 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
222 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
223 /= >= > ;; complex
224 conjugate realpart imagpart phase min max
225 logand logior logxor lognot ffloor fceiling ftruncate fround
226 signum cis)
227 (:documentation "Vectorization of numerical functions"))
230 (defpackage :lisp-stat-linalg
231 (:use :common-lisp
232 :cffi
233 :lisp-stat-ffi-int
234 :lisp-stat-math
235 :lisp-stat-types
236 :lisp-stat-float
237 :lisp-stat-compound-data
238 :lisp-stat-linalg-data
239 :lisp-stat-matrix)
240 (:shadowing-import-from :lisp-stat-math
241 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
242 asin acos atan sinh cosh tanh asinh acosh atanh float random
243 truncate floor ceiling round minusp zerop plusp evenp oddp
244 < <= = /= >= > complex conjugate realpart imagpart phase
245 min max logand logior logxor lognot ffloor fceiling
246 ftruncate fround signum cis)
247 (:export chol-decomp lu-decomp lu-solve determinant inverse
248 sv-decomp qr-decomp rcondest make-rotation spline
249 kernel-dens kernel-smooth
250 fft make-sweep-matrix sweep-operator ax+y eigen
252 check-real ;; for optimize
254 covariance-matrix matrix print-matrix solve
255 backsolve eigenvalues eigenvectors accumulate cumsum combine
256 lowess))
259 (defpackage :lisp-stat-config
260 (:use :common-lisp)
261 (:export *default-path*
262 *lsos-files* *basic-files* *ls-files*
263 *lispstat-data-dir* *lispstat-examples-dir*))
266 (defpackage :lisp-stat-data
267 (:documentation "Data management, integration, I/O, and other data technologies.")
268 (:nicknames :ls-data)
269 (:use :common-lisp
270 :lisp-stat-object-system
271 :lisp-stat-config
272 :lisp-stat-types
273 :lisp-stat-compound-data)
274 (:shadowing-import-from :lisp-stat-object-system
275 slot-value call-method call-next-method)
276 (:export open-file-dialog read-data-file read-data-columns load-data
277 load-example *variables* *ask-on-redefine*
278 def variables savevar undef))
280 (defpackage :lisp-stat-descriptive-statistics
281 (:use :common-lisp
282 :lisp-stat-data
283 :lisp-stat-math
284 :lisp-stat-compound-data
285 :lisp-stat-matrix
286 :lisp-stat-linalg-data
287 :lisp-stat-linalg
288 :lisp-stat-basics)
289 (:shadowing-import-from :lisp-stat-math ;; life is a vector!
290 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
291 asin acos atan sinh cosh tanh asinh acosh atanh float random
292 truncate floor ceiling round minusp zerop plusp evenp oddp
293 < <= = /= >= > ;; complex
294 conjugate realpart imagpart phase
295 min max logand logior logxor lognot ffloor fceiling
296 ftruncate fround signum cis)
297 (:export standard-deviation quantile median interquartile-range
298 fivnum sample))
301 (defpackage :lisp-stat-regression-linear
302 (:use :common-lisp
303 :lisp-stat-object-system
304 :lisp-stat-basics
305 :lisp-stat-compound-data
306 :lisp-stat-math
307 :lisp-stat-matrix
308 :lisp-stat-linalg
309 :lisp-stat-descriptive-statistics)
310 (:shadowing-import-from :lisp-stat-object-system
311 slot-value call-method call-next-method)
312 (:shadowing-import-from :lisp-stat-math
313 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
314 asin acos atan sinh cosh tanh asinh acosh atanh float random
315 truncate floor ceiling round minusp zerop plusp evenp oddp
316 < <= = /= >= > ;; complex
317 conjugate realpart imagpart phase
318 min max logand logior logxor lognot ffloor fceiling
319 ftruncate fround signum cis)
320 (:export regression-model regression-model-proto x y intercept sweep-matrix
321 basis weights included total-sum-of-squares residual-sum-of-squares
322 predictor-names response-name case-labels))
324 (defpackage :lisp-stat
325 (:documentation "Experimentation package for LispStat. Serious
326 work should be packaged up elsewhere for reproducibility. By this
327 I mean, creating a data/analytics/analysis package with the
328 minimal set of objects required.")
329 (:use :common-lisp
330 :lisp-stat-object-system
331 :lisp-stat-compound-data
332 :lisp-stat-probability
333 :lisp-stat-types
334 :lisp-stat-float
335 :lisp-stat-basics
336 :lisp-stat-data
337 :lisp-stat-math
338 :lisp-stat-matrix
339 :lisp-stat-linalg
340 :lisp-stat-descriptive-statistics
341 :lisp-stat-regression-linear)
342 (:shadowing-import-from :lisp-stat-object-system
343 slot-value call-method call-next-method)
344 (:shadowing-import-from :lisp-stat-math
345 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
346 asin acos atan sinh cosh tanh asinh acosh atanh float random
347 truncate floor ceiling round minusp zerop plusp evenp oddp
348 < <= = /= >= > ;;complex
349 conjugate realpart imagpart phase
350 min max logand logior logxor lognot ffloor fceiling
351 ftruncate fround signum cis)
352 (:export
353 ;; lsobjects :
354 defproto defproto2
355 defmeth send
357 ;; lstypes :
358 fixnump check-nonneg-fixnum check-one-fixnum
359 check-one-real check-one-number
361 ;; lsmacros:
363 ;; lsfloat :
364 machine-epsilon
366 ;; compound :
367 compound-data-p *compound-data-proto* compound-object-p
368 compound-data-seq compound-data-length
369 element-list element-seq
370 sort-data order rank
371 recursive-map-elements map-elements
372 repeat
373 check-sequence
374 get-next-element make-next-element set-next-element
375 ;; sequencep
376 iseq
377 ordered-nneg-seq
378 select which
379 difference rseq
381 ;; lsmath.lsp
382 ^ ** expt + - * / mod rem pmin pmax abs 1+ 1- log exp sqrt sin cos
383 tan asin acos atan sinh cosh tanh asinh acosh atanh float random
384 truncate floor ceiling round minusp zerop plusp evenp oddp < <= =
385 /= >= > ;; complex
386 conjugate realpart imagpart phase min max
387 logand logior logxor lognot ffloor fceiling ftruncate fround
388 signum cis
390 ;; matrices.lisp
391 matrixp num-rows num-cols matmult identity-matrix diagonal row-list
392 column-list inner-product outer-product cross-product transpose
393 bind-columns bind-rows
395 ;; linalg.lisp
396 chol-decomp lu-decomp lu-solve determinant inverse
397 sv-decomp qr-decomp rcondest make-rotation spline
398 kernel-dens kernel-smooth
399 fft make-sweep-matrix sweep-operator ax+y eigen
400 check-real
401 covariance-matrix matrix print-matrix solve
402 backsolve eigenvalues eigenvectors accumulate cumsum combine
403 lowess
405 ;; in linalg.lisp, possibly not supported by matlisp
406 spline kernel-dens kernel-smooth
408 ;; optimize.lsp
409 newtonmax nelmeadmax
411 ;; lispstat-macros
412 make-rv-function make-rv-function-1
414 ;; data.lisp
415 open-file-dialog read-data-file read-data-columns load-data
416 load-example *variables* *ask-on-redefine*
417 def variables savevar undef
419 ;; statistics.lsp
420 standard-deviation quantile median interquartile-range
421 fivnum sample
423 ;; dists
424 log-gamma set-seed
425 uniform-rand normal-cdf normal-quant normal-dens
426 normal-rand bivnorm-cdf cauchy-cdf cauchy-quant cauchy-dens
427 cauchy-rand gamma-cdf gamma-quant gamma-dens gamma-rand
428 chisq-cdf chisq-quant chisq-dens chisq-rand beta-cdf beta-quant
429 beta-dens beta-rand t-cdf t-quant t-dens t-rand f-cdf f-quant
430 f-dens f-rand poisson-cdf poisson-quant poisson-pmf poisson-rand
431 binomial-cdf binomial-quant binomial-pmf binomial-rand
433 ;;; Here is where we have a problem -- lispstat core should be core
434 ;;; data management and config problems, with packages providing
435 ;;; specialized extensions to LispStat, i.e. regression, nonlin
436 ;;; regression, bayesian regression via laplace approximation, etc.
438 ;;; The following could be considered "recommended packages", similar
439 ;;; to the idea of the recommended packages in R.
441 ;; regression.lsp
442 regression-model regression-model-proto x y intercept sweep-matrix
443 basis weights included total-sum-of-squares residual-sum-of-squares
444 predictor-names response-name case-labels
446 ;; nonlin.lsp
447 nreg-model nreg-model-proto mean-function theta-hat epsilon
448 count-limit verbose
450 ;; bayes.lsp
451 bayes-model bayes-model-proto bayes-internals))
454 ;;;; PACKAGES FOR USEABILITY
456 (defpackage :lisp-stat-data-examples
457 (:documentation "Example data for unittests, examples, illustrations,")
458 (:use :common-lisp
459 :lisp-stat)
460 (:shadowing-import-from :lisp-stat
461 slot-value call-method call-next-method
463 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
464 asin acos atan sinh cosh tanh asinh acosh atanh float random
465 truncate floor ceiling round minusp zerop plusp evenp oddp
466 < <= = /= >= > > ;; complex
467 conjugate realpart imagpart phase
468 min max logand logior logxor lognot ffloor fceiling
469 ftruncate fround signum cis
471 <= float imagpart)
472 (:export iron aluminum absorbtion
473 diabetes dlabs))
476 (defpackage :lisp-stat-user
477 (:documentation "Experimentation package for LispStat.
478 Serious work should be placed in a similar package elsewhere for
479 reproducibility. But this should hint as to what needs to be
480 done for a user- or analysis-package.")
481 (:nicknames :ls-user)
482 (:use :common-lisp
483 :lisp-stat
484 :lisp-stat-data-examples) ;; this last is to have 'things to play with'
485 (:shadowing-import-from :lisp-stat
486 slot-value call-method call-next-method
488 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
489 asin acos atan sinh cosh tanh asinh acosh atanh float random
490 truncate floor ceiling round minusp zerop plusp evenp oddp
491 < <= = /= >= > > ;; complex
492 conjugate realpart imagpart phase
493 min max logand logior logxor lognot ffloor fceiling
494 ftruncate fround signum cis
496 <= float imagpart))
498 (defpackage :lisp-stat-unittests
499 (:use :common-lisp :lift :lisp-stat :lisp-stat-data-examples)
500 (:shadowing-import-from :lisp-stat
501 slot-value call-method call-next-method ;; objects
502 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath
503 asin acos atan sinh cosh tanh asinh acosh atanh float random
504 truncate floor ceiling round minusp zerop plusp evenp oddp
505 < <= = /= >= > ;; complex
506 conjugate realpart imagpart phase
507 min max logand logior logxor lognot ffloor fceiling
508 ftruncate fround signum cis)
509 (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec
510 almost= almost=lists numerical=)) ; compare
512 (defpackage :lisp-stat-data-clos-example
513 (:use :common-lisp
514 :lift :lisp-stat-unittests
515 :lisp-stat-data-examples
516 :lisp-stat-data-clos)
517 (:export absorbtion aluminum iron))