On Mon, 2012-01-23 at 05:14 -0800, Colin Yates wrote:
> Hi all,
>
>
> There are some excellent resources on this mailing list regarding
> literate resources, but they are more based around the theory rather
> than actual use.
>
>
> Has anybody got any "real world usage reports" regarding using
> literate programming in emacs? In particular, does paredit and slime
> work inside the clojure "fragments" when using org.babel for example?
I've been using literate programming for years in Axiom.
Basically I write in a buffer containing latex, my literate tool
of choice. I have a *shell* buffer open running Lisp.
The lisp code is in a "chunk" delimited by
\begin{chunk}{chunkname}
(this is the lisp code)
\end{chunk}
All I have to do is clip the lisp code, yank it into the *shell*
buffer, and it gets evaluated.
Once I've developed a small piece of program (about 20 lines
or so), I do a complete system rebuild and run all of the tests.
If all of the tests pass I git-commit the result, push it to
the public servers, and start writing again.
>
>
> Finally - how are people finding practising TDD with literate
> programming? I imagine that Clojure's excellent REPL (+ evaluating
> clojure forms from within a buffer) mean there are far less "type,
> extract tangled code, run tests" needed. Hmmm, not sure that is
> clear. What I mean is, do people find that the ability to evaluate a
> clojure form from within org.babel (assuming that is possible!) is
> sufficient for TDD or do you find you need to type, extract the
> tangled code and then run lein (for example) to run the tests?
Axiom has a directory of tests, all of which are also literate
documents. When I create a new test I write the new tests, run
the tests, and capture the output. The captured output is part
of the literate test document.
When I do a system build the new test is run as part of the whole
test suite. The test results are compared against the stored
results and failures are noted.
I've attached an example of a literate test case.
>
>
> Basically - how do y'all get on with TDDing in emacs following the
> approach of literate programming - any advice welcome!
>
>
> Thanks all.
>
>
> Col
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
\documentclass{article}
\usepackage{axiom}
\setlength{\textwidth}{400pt}
\begin{document}
\title{\$SPAD/src/input clifford.input}
\author{Timothy Daly}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{Overview}
CliffordAlgebra(n, K, Q) defines a vector space of dimension 2**n
over K, given a quadratic form Q on K**n.
\begin{verbatim}
If e[i] 1<=i<=n is a basis for K**n then
1, e[i] 1<=i<=n, e[i1]*e[i2] 1<=i1<i2<=n,...,e[1]*e[2]*..*e[n]
is a basis for the Clifford Algebra.
The algebra is defined by the relations
e[i]*e[j] = -e[j]*e[i] i ^= j,
e[i]*e[i] = Q(e[i])
\end{verbatim}
Examples of Clifford Algebras are:
gaussians, quaternions, exterior algebras and spin algebras.
Choose rational functions as the ground field.
\section{License}
\begin{chunk}{license}
--Copyright The Numerical Algorithms Group Limited 1991.
\end{chunk}
\begin{chunk}{*}
)set break resume
)spool clifford.output
)set message test on
)set message auto off
)clear all
--S 1 of 39
K := FRAC POLY INT
--R
--R
--R (1) Fraction Polynomial Integer
--R Type: Domain
--E 1
--% The complex numbers as a Clifford Algebra
)clear p qf
--S 2 of 39
qf: QFORM(1, K) := quadraticForm(matrix([[-1]])$(SQMATRIX(1,K)))
--R
--R
--R (2) [- 1]
--R Type: QuadraticForm(1,Fraction Polynomial Integer)
--E 2
--S 3 of 39
C := CLIF(1, K, qf)
--R
--R
--R (3) CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--R Type: Domain
--E 3
--S 4 of 39
i := e(1)$C
--R
--R
--R (4) e
--R 1
--R Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--E 4
--S 5 of 39
x := a + b * i
--R
--R
--R (5) a + b e
--R 1
--R Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--E 5
--S 6 of 39
y := c + d * i
--R
--R
--R (6) c + d e
--R 1
--R Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--E 6
--S 7 of 39
x * y
--R
--R
--R (7) - b d + a c + (a d + b c)e
--R 1
--R Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--E 7
--S 8 of 39
recip %
--R
--R
--R - b d + a c - a d - b c
--R (8) ------------------------- + ------------------------- e
--R 2 2 2 2 2 2 2 2 2 2 2 2 1
--R (b + a )d + (b + a )c (b + a )d + (b + a )c
--R Type: Union(CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX),...)
--E 8
--S 9 of 39
x*%
--R
--R
--R c d
--R (9) ------- - ------- e
--R 2 2 2 2 1
--R d + c d + c
--R Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--E 9
--S 10 of 39
%*y
--R
--R
--R (10) 1
--R Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
--E 10
--% The quaternions as a Clifford Algebra
)clear p qf
--S 11 of 39
qf:QFORM(2, K) :=quadraticForm matrix([[-1, 0], [0, -1]])$(SQMATRIX(2,K))
--R
--R
--R +- 1 0 +
--R (11) | |
--R + 0 - 1+
--R Type: QuadraticForm(2,Fraction Polynomial Integer)
--E 11
--S 12 of 39
H := CLIF(2, K, qf)
--R
--R
--R (12) CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--R Type: Domain
--E 12
--S 13 of 39
i := e(1)$H
--R
--R
--R (13) e
--R 1
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 13
--S 14 of 39
j := e(2)$H
--R
--R
--R (14) e
--R 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 14
--S 15 of 39
k := i * j
--R
--R
--R (15) e e
--R 1 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 15
--S 16 of 39
x := a + b * i + c * j + d * k
--R
--R
--R (16) a + b e + c e + d e e
--R 1 2 1 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 16
--S 17 of 39
y := e + f * i + g * j + h * k
--R
--R
--R (17) e + f e + g e + h e e
--R 1 2 1 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 17
--S 18 of 39
x + y
--R
--R
--R (18) e + a + (f + b)e + (g + c)e + (h + d)e e
--R 1 2 1 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 18
--S 19 of 39
x * y
--R
--R
--R (19)
--R - d h - c g - b f + a e + (c h - d g + a f + b e)e
--R 1
--R +
--R (- b h + a g + d f + c e)e + (a h + b g - c f + d e)e e
--R 2 1 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 19
--S 20 of 39
y * x
--R
--R
--R (20)
--R - d h - c g - b f + a e + (- c h + d g + a f + b e)e
--R 1
--R +
--R (b h + a g - d f + c e)e + (a h - b g + c f + d e)e e
--R 2 1 2
--R Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
--E 20
--% The exterior algebra on a 3 space.
)clear p qf
--S 21 of 39
qf: QFORM(3, K) := quadraticForm(0::SQMATRIX(3,K))
--R
--R
--R +0 0 0+
--R | |
--R (21) |0 0 0|
--R | |
--R +0 0 0+
--R Type: QuadraticForm(3,Fraction Polynomial Integer)
--E 21
--S 22 of 39
Ext := CLIF(3,K,qf)
--R
--R
--R (22) CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--R Type: Domain
--E 22
--S 23 of 39
i := e(1)$Ext
--R
--R
--R (23) e
--R 1
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 23
--S 24 of 39
j := e(2)$Ext
--R
--R
--R (24) e
--R 2
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 24
--S 25 of 39
k := e(3)$Ext
--R
--R
--R (25) e
--R 3
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 25
--S 26 of 39
x := x1*i + x2*j + x3*k
--R
--R
--R (26) x1 e + x2 e + x3 e
--R 1 2 3
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 26
--S 27 of 39
y := y1*i + y2*j + y3*k
--R
--R
--R (27) y1 e + y2 e + y3 e
--R 1 2 3
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 27
--S 28 of 39
x + y
--R
--R
--R (28) (y1 + x1)e + (y2 + x2)e + (y3 + x3)e
--R 1 2 3
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 28
--S 29 of 39
x * y + y * x
--R
--R
--R (29) 0
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 29
\end{chunk}
In n space, a grade p form has a dual n-p form.
In particular, in 3 space the dual of a grade 2 element identifies
\begin{verbatim}
e1*e2->e3, e2*e3->e1, e3*e1->e2.
\end{verbatim}
\begin{chunk}{*}
--S 30 of 39
dual2 a ==
coefficient(a,[2,3])$Ext * i + _
coefficient(a,[3,1])$Ext * j + _
coefficient(a,[1,2])$Ext * k
--R
--R Type: Void
--E 30
\end{chunk}
The vector cross product is then given by
\begin{chunk}{*}
--S 31 of 39
dual2(x*y)
--R
--R Compiling function dual2 with type CliffordAlgebra(3,Fraction
--R Polynomial Integer,MATRIX) -> CliffordAlgebra(3,Fraction
--R Polynomial Integer,MATRIX)
--R
--R (31) (x2 y3 - x3 y2)e + (- x1 y3 + x3 y1)e + (x1 y2 - x2 y1)e
--R 1 2 3
--R Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
--E 31
\end{chunk}
The Dirac Algebra used in Quantum Field Theory.
\begin{chunk}{*}
)clear p qf
--S 32 of 39
K := FRAC INT
--R
--R
--R (32) Fraction Integer
--R Type: Domain
--E 32
--S 33 of 39
g: SQMATRIX(4, K) := [[1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,-1]]
--R
--R
--R +1 0 0 0 +
--R | |
--R |0 - 1 0 0 |
--R (33) | |
--R |0 0 - 1 0 |
--R | |
--R +0 0 0 - 1+
--R Type: SquareMatrix(4,Fraction Integer)
--E 33
--S 34 of 39
qf: QFORM(4, K) := quadraticForm g
--R
--R
--R +1 0 0 0 +
--R | |
--R |0 - 1 0 0 |
--R (34) | |
--R |0 0 - 1 0 |
--R | |
--R +0 0 0 - 1+
--R Type: QuadraticForm(4,Fraction Integer)
--E 34
--S 35 of 39
D := CLIF(4,K,qf)
--R
--R
--R (35) CliffordAlgebra(4,Fraction Integer,MATRIX)
--R Type: Domain
--E 35
\end{chunk}
The usual notation is $\gamma^i$.
\begin{chunk}{*}
--S 36 of 39
gam := [e(i)$D for i in 1..4]
--R
--R
--R (36) [e ,e ,e ,e ]
--R 1 2 3 4
--R Type: List CliffordAlgebra(4,Fraction Integer,MATRIX)
--E 36
\end{chunk}
There are various contraction identities of the form:
\begin{verbatim}
g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t) =
2*(gam(s)gam(m)gam(n)gam(r) + gam(r)*gam(n)*gam(m)*gam(s))
\end{verbatim}
where the sum over l and t is implied.
\begin{chunk}{*}
-- Verify this identity for m=1,n=2,r=3,s=4
--S 37 of 39
m := 1; n:= 2; r := 3; s := 4;
--R
--R
--R Type: PositiveInteger
--E 37
--S 38 of 39
lhs := reduce(+,[reduce(+,[g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t)
for l in 1..4]) for t in 1..4])
--R
--R
--R (38) - 4e e e e
--R 1 2 3 4
--R Type: CliffordAlgebra(4,Fraction Integer,MATRIX)
--E 38
--S 39 of 39
rhs := 2*(gam s * gam m*gam n*gam r + gam r*gam n*gam m*gam s)
--R
--R
--R (39) - 4e e e e
--R 1 2 3 4
--R Type: CliffordAlgebra(4,Fraction Integer,MATRIX)
--E 39
)spool
)lisp (bye)
\end{chunk}
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}