File: intro.tex

package info (click to toggle)
spooles 2.2-11
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,656 kB
  • ctags: 3,690
  • sloc: ansic: 146,836; sh: 7,571; csh: 3,615; makefile: 1,968; perl: 74
file content (46 lines) | stat: -rw-r--r-- 2,031 bytes parent folder | download | duplicates (7)
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
\chapter{{\tt ZV}: Double Complex Vector Object}
\par
The {\tt ZV} object is a wrapper around a {\tt double} precision
complex vector.
In Fortran's LINPACK and LAPACK libraries, a leading {\tt Z}
denotes double precision complex, and we have followed this
convention.
The driving force for its creation of this object 
is more convenience than performance.
There are three cases that led to its development.
\begin{itemize}
\item 
Often a method will create a vector (allocate storage for and fill
the entries) whose size is not known before the method call.
Instead of having a pointer to {\tt int} and a pointer to {\tt double*}
in the calling sequence, we can return a pointer to an {\tt ZV}
object that contains the newly created vector and its size.
\item
In many cases we need a persistent {\tt double} vector object,
and file IO is simplified if we have an object to deal with.
The filename is of the form {\tt *.zvf} for a formatted file
or {\tt *.zvb} for a binary file.
\item
Prototyping can go much faster with this object as opposed to
working with an {\tt double} array.
Consider the case when one wants to accumulate a list of doubles,
but one doesn't know how large the list will be.
The method {\tt ZV\_setSize()} can be used to set 
the size of the vector to zero.
Another method {\tt ZV\_push()} appends an element to the vector,
growing the storage if necessary.
\item
Sometimes an object needs to change its size, i.e., vectors need to
grow or shrink.
It is easier and more robust to tell an {\tt ZV} object to resize
itself (see the {\tt ZV\_setSize()} and {\tt ZV\_setMaxsize()}
methods) than it is to duplicate code to work on an {\tt double}
vector.
\end{itemize}
One must choose where to use this object.
There is a substantial performance penalty for doing the simplest
operations, and so when we need to manipulate an {\tt double} vector
inside a loop, we extract out the size and pointer to the base
array from the {\tt ZV} object.
On the other hand, the convenience makes it a widely used object.
\par