~ubuntu-branches/ubuntu/karmic/axiom/karmic

« back to all changes in this revision

Viewing changes to src/interp/macros.lisp.pamphlet

  • Committer: Bazaar Package Importer
  • Author(s):
  • Date: 2005-02-21 17:08:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050221170837-34vm4j33v4t9hsk4
Tags: 20050201-1
* New upstream release
* Bug fix: "axiom graphics missing?", thanks to Daniel Lakeland (Closes:
  #277692).
* Bug fix: "axiom: Feb 2005 release for sarge would be nice", thanks to
  Balbir Thomas (Closes: #295000).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
\documentclass{article}
2
 
\usepackage{../../src/scripts/tex/axiom}
 
2
\usepackage{axiom}
3
3
\begin{document}
4
4
\title{\$SPAD/src/interp macros.lisp}
5
5
\author{Timothy Daly}
19
19
         there isn't a cleaner and non-VM-specific way of doing things.
20
20
 
21
21
\end{verbatim}
 
22
\section{Performance change}
 
23
Camm has identified a performace problem during compiles. There is
 
24
a loop that continually adds one element to a vector. This causes
 
25
the vector to get extended by 1 and copied. These patches fix the 
 
26
problem since vectors with fill pointers don't need to be copied.
 
27
 
 
28
These cut out the lion's share of the gc problem
 
29
on this compile.  30min {\tt ->} 7 min on my box.  There is still some gc
 
30
churning in cons pages due to many calls to 'list' with small n.  One
 
31
can likely improve things further with an appropriate (declare
 
32
(:dynamic-extent ...)) in the right place -- gcl will allocate such
 
33
lists on the C stack (very fast).
 
34
 
 
35
\subsection{lengthenvec}
 
36
The original code was:
 
37
\begin{verbatim}
 
38
(defun lengthenvec (v n)
 
39
  (if (adjustable-array-p v) (adjust-array v n)
 
40
    (replace (make-array n) v)))
 
41
\end{verbatim}
 
42
 
 
43
<<lengthenvec>>=
 
44
(defun lengthenvec (v n)
 
45
  (if 
 
46
    (and (array-has-fill-pointer-p v) (adjustable-array-p v))
 
47
    (if 
 
48
      (>= n (array-total-size v)) 
 
49
        (adjust-array v (* n 2) :fill-pointer n) 
 
50
        (progn 
 
51
          (setf (fill-pointer v) n) 
 
52
          v))
 
53
    (replace (make-array n :fill-pointer t) v)))
 
54
 
 
55
@
 
56
\subsection{make-init-vector}
 
57
The original code was
 
58
\begin{verbatim}
 
59
(defun make-init-vector (n val) (make-array n :initial-element val))
 
60
\end{verbatim}
 
61
 
 
62
<<make-init-vector>>=
 
63
(defun make-init-vector (n val) 
 
64
  (make-array n :initial-element val :fill-pointer t))
 
65
 
 
66
@
22
67
\section{License}
23
68
<<license>>=
24
69
;; Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
1111
1156
 
1112
1157
; 17.6 Changing the Dimensions of an Array
1113
1158
 
1114
 
 
1115
 
(defun lengthenvec (v n)
1116
 
  (if (adjustable-array-p v) (adjust-array v n)
1117
 
    (replace (make-array n) v)))
1118
1159
 
1119
 
(defun make-init-vector (n val) (make-array n :initial-element val))
 
1160
<<lengthenvec>>
 
1161
<<make-init-vector>> 
1120
1162
 
1121
1163
; 22 INPUT/OUTPUT
1122
1164