initial work towards getting xarray support into CLS.
[CommonLispStat.git] / TODO.lisp
blob08bc779185f45ccd18ff8717f656a47102205df3
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-06-18 18:43:02 tony>
4 ;;; Creation: <2008-09-08 08:06:30 tony>
5 ;;; File: TODO.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c) 2007-2008, AJ Rossini <blindglobe@gmail.com>. BSD.
8 ;;; Purpose: Stuff that needs to be made working sits inside the
9 ;;; progns... This file contains the current challenges to
10 ;;; solve, including a description of the setup and the work
11 ;;; to solve....
13 ;;; What is this talk of 'release'? Klingons do not make software
14 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
15 ;;; designers and quality assurance people in its wake.
17 ;;; SET UP
19 (in-package :cl-user)
20 ;;(asdf:oos 'asdf:load-op 'lisp-matrix)
21 ;;(asdf:oos 'asdf:compile-op 'lispstat :force t)
22 ;;(asdf:oos 'asdf:load-op 'lispstat)
24 (in-package :lisp-stat-unittests)
26 ;; tests = 80, failures = 8, errors = 15
27 (run-tests :suite 'lisp-stat-ut)
28 (describe (run-tests :suite 'lisp-stat-ut))
30 ;; FIXME: Example: currently not relevant, yet
31 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
32 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
34 (describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
35 (lift::run-tests :suite 'lisp-stat-ut-dataframe)
37 (describe
38 (lift::run-test
39 :test-case 'lisp-stat-unittests::create-proto
40 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
42 (describe 'lisp-stat-ut)
44 (in-package :ls-user)
47 #+nil
48 (progn
49 (asdf:oos 'asdf:load-op 'xarray)
51 *features*
52 *package*
54 ;; need to consider CLS features: CFFI, CL-BLAPACK, LISP-MATRIX, XARRAY
55 ;; CL-PLPLOT, CL-CAIRO2/CL-2D.
57 ;; SBCL/CCL -> ...
58 ;; CLISP/... -> ...
61 #+nil
62 (progn
63 ;; Plotting -- need to figure out the core-dump, or change libraries.
64 ;; (asdf:oos 'asdf:load-op 'cl-plplot)
66 ;; (defparameter *gdev* "xwin")
67 (defparameter *gdev* "xcairo")
68 ;; (cl-plplot::plsdev *gdev*) ; -- usually handled within call.
69 (plot-ex)
70 (plot-ex)
71 ;; Boom! -- there is currently a loose pointer floating around that
72 ;; causes errors the 3rd time that we create a plot (and crashes
73 ;; SBCL the 4th time). Order independent.
74 (plot-ex)
76 (contour-plot-ex)
77 (fn-contour-plot-ex)
78 (shade-plot-ex)
79 (3D-plot-ex))
82 (progn
83 ;; REVIEW: general Lisp use guidance
85 (fdefinition 'make-matrix)
86 (documentation 'make-matrix 'function)
88 #| Examples from CLHS, a bit of guidance.
90 ;; This function assumes its callers have checked the types of the
91 ;; arguments, and authorizes the compiler to build in that assumption.
92 (defun discriminant (a b c)
93 (declare (number a b c))
94 "Compute the discriminant for a quadratic equation."
95 (- (* b b) (* 4 a c))) => DISCRIMINANT
96 (discriminant 1 2/3 -2) => 76/9
98 ;; This function assumes its callers have not checked the types of the
99 ;; arguments, and performs explicit type checks before making any assumptions.
100 (defun careful-discriminant (a b c)
101 "Compute the discriminant for a quadratic equation."
102 (check-type a number)
103 (check-type b number)
104 (check-type c number)
105 (locally (declare (number a b c))
106 (- (* b b) (* 4 a c)))) => CAREFUL-DISCRIMINANT
107 (careful-discriminant 1 2/3 -2) => 76/9
112 #+nil
113 (progn ;; experiments with GSL and the Lisp interface.
114 (asdf:oos 'asdf:load-op 'gsll)
115 (asdf:oos 'asdf:load-op 'gsll-tests) ; requires lisp-unit
117 ;; the following should be equivalent
118 (defparameter *t1* (LIST 6.18d0 6.647777777777779d0 6.18d0))
119 (defparameter *t2* (MULTIPLE-VALUE-LIST
120 (LET ((VEC
121 (gsll:make-marray 'DOUBLE-FLOAT
122 :INITIAL-CONTENTS '(-3.21d0 1.0d0 12.8d0)))
123 (WEIGHTS
124 (gsll:MAKE-MARRAY 'DOUBLE-FLOAT
125 :INITIAL-CONTENTS '(3.0d0 1.0d0 2.0d0))))
126 (LET ((MEAN (gsll:MEAN VEC)))
127 (LIST (gsll:ABSOLUTE-DEVIATION VEC)
128 (gsll:WEIGHTED-ABSOLUTE-DEVIATION VEC WEIGHTS)
129 (gsll:ABSOLUTE-DEVIATION VEC MEAN))))))
130 (eql *t1* *t2*)
131 (equal *t1* *t2*)
133 ;; from (gsll:examples 'gsll::numerical-integration) ...
134 (gsll:integration-qng gsll::one-sine 0.0d0 PI)
136 (gsll:defun-single axpb (x) (+ (* 2 x) 3)) ;; a<-2, b<-3
137 (gsll:integration-qng axpb 1d0 2d0)
139 (let ((a 2)
140 (b 3))
141 (defun-single axpb2 (x) (+ (* a x) b)))
142 (gsll:integration-qng axpb2 1d0 2d0)
144 ;; BAD
145 ;; (gsll:integration-qng
146 ;; (let ((a 2)
147 ;; (b 3))
148 ;; (defun-single axpb2 (x) (+ (* a x) b)))
149 ;; 1d0 2d0)
151 ;; right, but weird expansion...
152 (gsll:integration-qng
153 (let ((a 2)
154 (b 3))
155 (defun axpb2 (x) (+ (* a x) b))
156 (gsll:def-single-function axpb2)
157 axpb2)
158 1d0 2d0)
160 ;; Linear least squares
162 (gsll:gsl-lookup "gsl_linalg_LU_decomp") ; => gsll:lu-decomposition
163 (gsll:gsl-lookup "gsl_linalg_LU_solve") ; => gsll:lu-solve
167 #+nil
168 (progn
169 (asdf:oos 'asdf:load-op 'versioned-objects)
170 (asdf:oos 'asdf:load-op 'validations)
175 ;; SETUP FOR PLOT EXAMPLE:
177 (asdf:oos 'asdf:load-op 'lispstat)
178 (asdf:oos 'asdf:load-op 'cl-cairo2-x11)
179 (asdf:oos 'asdf:load-op 'cl-2d)
181 (defpackage :cl-2d-user-x11
182 (:use :cl :cl-cairo2 :cl-2d :cl-numlib :cl-colors :bind))
184 (in-package :cl-2d-user-x11)
186 ;; PLOT EXAMPLE
187 #+nil
188 (progn
191 ;; this is how you create an X11 frame. If you supply a
192 ;; background-color to as-frame, each plot will clear the frame with
193 ;; this color.
195 (defparameter *frame1* (as-frame (create-xlib-image-context 300 300)
196 :background-color +white+))
198 ;; or netbook size, picture is similar but on a lower-res display window.
199 (defparameter *frame2* (as-frame (create-xlib-image-context 200 200)
200 :background-color +white+))
202 (plot-function *frame1*
203 #'exp (interval-of 0 2)
204 :x-title "x"
205 :y-title "exp(x)")
207 ;; split the frame, and you can draw on the subframes independently.
208 ;; I do this a lot.
210 (bind ((#2A((f1 f2) (f3 f4))
211 (split-frame *frame2* (percent 50) (percent 50))))
212 (defparameter *f1* f1)
213 (defparameter *f2* f2)
214 (defparameter *f3* f3)
215 (defparameter *f4* f4))
217 (plot-function *f1* #'sin (interval-of 0 2) :x-title "x" :y-title "sin(x)")
218 (plot-function *f2* #'cos (interval-of 0 2) :x-title "x" :y-title "cos(x)")
219 (plot-function *f3* #'tan (interval-of 0 2) :x-title "x" :y-title "tan(x)")
220 (plot-function *f4* #'/ (interval-of 0 2) :x-title "x" :y-title "1/x")
222 (clear *frame1*)
225 (let* ((n 500)
226 (xs (num-sequence :from 0 :to 10 :length n))
227 (ys (map 'vector #'(lambda (x) (+ x 8 (random 4.0))) xs))
228 (weights (replicate #'(lambda () (1+ (random 10))) n 'fixnum))
229 (da (plot-simple frame (interval-of 0 10) (interval-of 10 20)
230 :x-title "x" :y-title "y")))
231 (draw-symbols da xs ys :weights weights))
237 ;; back to normal application
238 (in-package :ls-user)