File: introduction.tex

package info (click to toggle)
python-numarray 1.5.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,668 kB
  • ctags: 11,384
  • sloc: ansic: 113,864; python: 22,422; makefile: 197; sh: 11
file content (185 lines) | stat: -rw-r--r-- 10,383 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
\chapter{Introduction}
\label{cha:introduction}

\begin{quote}
   This chapter introduces the numarray Python extension and outlines the rest
   of the document.
\end{quote}

Numarray is a set of extensions to the Python programming language which allows
Python programmers to efficiently manipulate large sets of objects organized in
grid-like fashion. These sets of objects are called arrays, and they can have
any number of dimensions. One-dimensional arrays are similar to standard Python
sequences, and two-dimensional arrays are similar to matrices from linear
algebra. Note that one-dimensional arrays are also different from any other
Python sequence, and that two-dimensional matrices are also different from the
matrices of linear algebra. One significant difference is that numarray objects
must contain elements of homogeneous type, while standard Python sequences can
contain elements of mixed type. Two-dimensional arrays differ from matrices
primarily in the way multiplication is performed; 2-D arrays are multiplied
element-by-element.

This is a reimplementation of the earlier Numeric module (aka numpy). For the
most part, the syntax of numarray is identical to that of Numeric, although
there are significant differences. The differences are primarily in new
features. For Python 2.2 and later, the syntax is completely backwards
compatible. See the High-Level Overview (chapter \ref{cha:high-level-overview})
for incompatibilities for earlier versions of Python. The reasons for rewriting
Numeric and a comparison between Numeric and numarray are also described in
chapter \ref{cha:high-level-overview}. Portions of the present document are
almost word-for-word identical to the Numeric manual. It has been updated to
reflect the syntax and behavior of numarray, and there is a new section
(~\ref{sec:diff-numarray-numpy}) on differences between Numeric and numarray.

Why are these extensions needed? The core reason is a very prosaic one:
manipulating a set of a million numbers in Python with the
standard data structures such as lists, tuples or classes is much too slow and
uses too much space. A more subtle
reason for these extensions, however, is that the kinds of operations that
programmers typically want to do on arrays, while sometimes very complex, can
often be decomposed into a set of fairly standard operations. This
decomposition has been similarly developed in many array languages. In some
ways, numarray is simply the application of this experience to the Python
language.  Thus many of the operations described in numarray work the way they
do because experience has shown that way to be a good one, in a variety of
contexts. The languages which were used to guide the development of numarray
include the infamous APL family of languages, Basis, MATLAB, FORTRAN, S and S+,
and others.  This heritage will be obvious to users of numarray who already
have experience with these other languages.  This manual, however, does not
assume any such background, and all that is expected of the reader is a
reasonable working knowledge of the standard Python language.

This document is the ``official'' documentation for numarray. It is both a
tutorial and the most authoritative source of information about numarray with
the exception of the source code. The tutorial material will walk you through a
set of manipulations of simple, small arrays of numbers. This choice was made
because:
\begin{itemize}
\item A concrete data set makes explaining the behavior of some functions much
   easier to motivate than simply talking about abstract operations on abstract
   data sets.
\item Every reader will have at least an intuition as to the meaning of the
   data and organization of image files.  \remark{These ``image files'' are not
      mentioned anywhere before, and not really used later...?}
\end{itemize}
All users of numarray, whether interested in image processing or not, are
encouraged to follow the tutorial with a working numarray installed,
testing the examples, and more importantly, transferring the
understanding gained by working on arrays to their specific domain. The best
way to learn is by doing --- the aim of this tutorial is to guide you along
this "doing."

This manual contains:
\begin{description}
\item[Installing numarray] Chapter \ref{cha:installation} provides information
   on testing Python, numarray, and compiling and installing numarray if
   necessary.
\item[High-Level Overview] Chapter \ref{cha:high-level-overview} gives a
   high-level overview of the components of the numarray system as a whole.
\item[Array Basics] Chapter \ref{cha:array-basics} provides a detailed
   step-by-step introduction to the most important aspect of numarray, the
   multidimensional array objects.
\item[Ufuncs] Chapter \ref{cha:ufuncs} provides information on universal
   functions, the mathematical functions which operate on arrays and other
   sequences elementwise.
\item[Pseudo Indices] Chapter \ref{cha:pseudo-indices} covers syntax for some
   special indexing operators.
\item[Array Functions] Chapter \ref{cha:array-functions} is a catalog of each
   of the utility functions which allow easy algorithmic processing of arrays.
\item[Array Methods] Chapter \ref{cha:array-methods} discusses the methods of
   array objects.
\item[Array Attributes] Chapter \ref{cha:array-attributes} presents the
   attributes of array objects.
\item[Character Array] Chapter \ref{cha:character-array} describes the
  \code{numarray.strings} module that provides support for arrays of fixed
  length strings.
\item[Record Array] Chapter \ref{cha:record-array} describes the
   \code{numarray.records} module that supports arrays of fixed length records
   of string or numerical data.
\item[Object Array] Chapter \ref{cha:object-array} describes the
   \code{numarray.objects} module that supports arrays of Python objects.
\item[C extension API] Chapter \ref{cha:C-API} describes the C-APIs provided
   for \module{numarray} based extension modules.
\item[Convolution] Chapter \ref{cha:convolve} describes the
   \module{numarray.convolve} module for computing one-D and two-D convolutions
   and correlations of \class{numarray} objects.
\item[Fast-Fourier-Transform] Chapter \ref{cha:fft} describes the
   \module{numarray.fft} module for computing Fast-Fourier-Transforms
   (FFT) and Inverse FFTs over \class{numarray} objects in one- or
   two-dimensional manner.  Ported from Numeric.
\item[Linear Algebra] Chapter \ref{cha:linear-algebra} describes the
   \module{numarray.linear_algebra} module which provides a simple
   interface to some commonly used linear algebra routines; 
   \program{LAPACK}.   Ported from Numeric.
\item[Masked Arrays] Chapter \ref{cha:masked-arrays} describes the
   \module{numarray.ma} module which supports Masked Arrays: arrays which
   potentially have missing or invalid elements.  Ported from Numeric.
\item[Random Numbers] Chapter \ref{cha:random-array} describes the
   \module{numarray.random_array} module which supports generation of arrays of
   random numbers.  Ported from Numeric.
\item[Multidimentional image analysis functions] Chapter \ref{cha:ndimage}
   describes the \module{numarray.ndimage} module which provides
   functions for multidimensional image analysis such as filtering,
   morphology or interpolation.
\item[Glossary] Appendix \ref{cha:glossary} gives a glossary of terms.
\end{description}


\section{Where to get information and code}

Numarray and its documentation are available at SourceForge
(\ulink{sourceforge.net}{http://sourceforge.net}; SourceForge addresses can
also be abbreviated as \ulink{sf.net}{http://sf.net}). The main web site is:
\url{http://numpy.sourceforge.net}. Downloads, bug reports, a patch facility,
and releases are at the main project page, reachable from the above site or
directly at: \url{http://sourceforge.net/projects/numpy} (see Numarray under
"Latest File Releases").  The Python web site is \url{http://www.python.org}.
For up-to-date status on compatible modules available for numarray, please 
check \url{http://www.stsci.edu/resources/software_hardware/numarray/}.

NOTE: because numarray shares the numpy Source Forge project with Numeric and
Numeric3, there are dedicated Source Forge ``Trackers'' for numarray, .e.g.
``Numarray Bugs'' rather than just ``Bugs''.  When submitting bug reports,
patches, or requests, please look for the numarray version of the tracker under
the top level menu item ``Tracker'', nominally here:
\url{http://sourceforge.net/tracker/?group_id=1369}.

\section{Acknowledgments}

Numerical Python was the outgrowth of a long collaborative design process
carried out by the Matrix SIG of the Python Software Activity (PSA). Jim
Hugunin, while a graduate student at MIT, wrote most of the code and initial
documentation. When Jim joined CNRI and began working on JPython, he didn't
have the time to maintain Numerical Python so Paul Dubois at LLNL agreed to
become the maintainer of Numerical Python. David Ascher, working as a
consultant to LLNL, wrote most of the Numerical Python version of this
document, incorporating contributions from Konrad Hinsen and Travis Oliphant,
both of whom are major contributors to Numerical Python.  The reimplementation
of Numeric as numarray was done primarily by Perry Greenfield, Todd Miller, and
Rick White, with some assistance from J.C. Hsu and Paul Barrett. Although
numarray is almost a completely new implementation, it owes a great deal to the
ideas, interface and behavior expressed in the Numeric implementation. It is
not an overstatement to say that the existence of Numeric made the
implementation of numarray far, far easier that it would otherwise have been.
Since the source for the original Numeric module was moved to SourceForge, the
numarray user community has become a significant part of the process.
Numeric/numarray illustrates the power of the open source software concept.
Please send comments and corrections to this manual to
\ulink{perry@stsci.edu}{mailto:perry@stsci.edu}, or to Perry Greenfield, 3700
San Martin Dr, Baltimore, MD 21218, U.S.A.




%% Local Variables:
%% mode: LaTeX
%% mode: auto-fill
%% fill-column: 79
%% indent-tabs-mode: nil
%% ispell-dictionary: "american"
%% reftex-fref-is-default: nil
%% TeX-auto-save: t
%% TeX-command-default: "pdfeLaTeX"
%% TeX-master: "numarray"
%% TeX-parse-self: t
%% End: