• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

AUTHORSH A D05-Jul-200665 21

COPYINGH A D05-Jul-200617.6 KiB341281

COPYRIGHTH A D05-Jul-2006782 1816

ChangeLogH A D05-Jul-20067.5 KiB306173

INSTALLH A D16-Feb-20059.3 KiB237179

Makefile.amH A D05-Jul-2006826 3421

Makefile.inH A D03-May-202226 KiB786697

NEWSH A D05-Jul-20061.9 KiB6439

READMEH A D05-Jul-20069.9 KiB240180

aclocal.m4H A D05-Jul-2006235.2 KiB6,8106,090

acx_blas.m4H A D05-Jul-20064.5 KiB150131

acx_lapack.m4H A D05-Jul-20063.1 KiB9282

check.hH A D05-Jul-20061.3 KiB3714

config.guessH A D24-Apr-200542.8 KiB1,4661,268

config.h.inH A D05-Jul-20062.7 KiB10571

config.subH A D24-Apr-200530.8 KiB1,5701,429

configureH A D05-Jul-2006748.1 KiB24,33319,747

configure.acH A D05-Jul-20064.4 KiB136103

copyright.hH A D05-Jul-2006846 1816

depcompH A D16-Feb-200515.5 KiB530329

harminv-int.hH A D05-Jul-20062.3 KiB7944

harminv-main.cH A D05-Jul-200612.8 KiB488415

harminv.1H A D05-Jul-20069.3 KiB230200

harminv.cH A D05-Jul-200626.5 KiB870563

harminv.hH A D05-Jul-20062.6 KiB7336

harminv.pc.inH A D05-Jul-2006248 119

install-shH A D16-Feb-20059 KiB324189

ltmain.shH A D01-Apr-2005179.7 KiB6,4275,058

missingH A D16-Feb-200510.6 KiB358267

sines.cH A D05-Jul-20065.6 KiB209168

README

1			       Harminv:
2		  Harmonic Inversion of Time Signals
3	      by the Filter Diagonalization Method (FDM)
4
5	       Steven G. Johnson <stevenj@alum.mit.edu>
6		Massachusetts Institute of Technology
7
8------------------------------------------------------------------------------
9
10Introduction:
11=============
12
13Harminv is a free program (and accompanying library) to solve the
14problem of "harmonic inversion."  Given a discrete, finite-length
15signal that consists of a sum of finitely-many sinusoids (possibly
16exponentially decaying), it determines the frequencies, decay
17constants, amplitudes, and phases of those sinusoids.
18
19It can, in principle, provide much better accuracy than
20straightforward FFT based methods, essentially because it assumes a
21specific form for the signal.  (Fourier transforms, in contrast,
22attempt to represent *any* data as a sum of sinusoidal components.)
23
24We use a low-storage "filter diagonalization method" (FDM) for
25finding the sinusoids near a given frequency interval, described in:
26
27   V. A. Mandelshtam and H. S. Taylor, "Harmonic inversion of time
28   signals," J. Chem. Phys., vol. 107, no. 17, p. 6756-6769 (Nov. 1
29   1997).  See also erratum, ibid, vol. 109, no. 10, p. 4128 (Sep. 8
30   1998).
31
32This kind of spectral analysis has wide applications in many areas of
33physics and engineering, as well as other fields.  For example, it
34could be used to extract the vibrational or "eigen" modes of a system
35from its response to some stimulus, and also their rates of decay in
36dissipative systems.  FDM has been applied to analyze, e.g., NMR
37experimental data and numerical simulations of quantum mechanics.
38
39See also:
40
41   Rongqing Chen and Hua Guo, "Efficient calculation of matrix
42   elements in low storate filter diagonalization," J. Chem. Phys.,
43   vol. 111, no. 2, p. 464-471(Jul. 8 1999).
44
45   Michael R. Wall and Daniel Neuhauser, "Extraction, through
46   filter-diagonalization, of general quantum eigenvalues or classical
47   normal mode frequencies from a small number of residues or a
48   short-time segment of a signal. I. Theory and application to a
49   quantum-dynamics model," J. Chem. Phys., 102, no. 20, p. 8011-8022
50   (May 22 1995).
51
52   V. A. Mandelshtam, "On harmonic inversion of cross-correlation
53   functions by the filter diagonalization method," J. Theoretical and
54   Computational Chemistry 2 (4), 497-505 (2003).
55
56Essentially, FDM works by considering the time-series to be the
57autocorrelation function of a fictitious dynamical system, such that
58the problem of finding the frequencies and decay constants is
59re-expressed as the problem of finding the eigenvalues of the
60complex-symmetric time-evolution operator of this system.  The key
61point is that, if you are only interested in frequencies within a
62known band-limited region, the matrix elements of this operator can be
63expressed purely in terms of Fourier transforms (or, really, z
64transforms) of your time-series.  Then, one can simply diagonalize a
65small matrix (size proportional to the bandwidth and the number of
66frequencies) to find the desired result.
67
68In general, for M data points and J frequencies, the time required is
69O(M J + J^3).  The main point of the algorithm is not so much speed,
70however, but the effective solution of a very ill-conditioned fitting
71problem.  (Even closely-spaced frequencies and/or weak decay rates can
72be resolved much more reliably by FDM than by straightforward fits of
73the data or its spectrum.)
74
75Program Usage:
76==============
77
78The usage of the harminv program is described by its man page ('man
79harminv'), included in the installation below.  To briefly summarize,
80it takes a sequence of numbers (real or complex) from standard input
81and a range of frequencies to search and outputs the frequencies it
82finds.
83
84Library Usage:
85==============
86
87The usage of the library -lharminv is analogous to the program.  In C
88or C++, you first #include <harminv.h>, then specify the data and the
89frequency range by calling harminv_data_create, returning a
90harminv_data data structure:
91
92	harminv_data harminv_data_create(int n,
93                                         const harminv_complex *signal,
94                                         double fmin, double fmax, int nf);
95
96signal is a pointer to an array of n complex numbers.  In C++,
97harminv_complex is std::complex<double>.  In C, harminv_complex is a
98double[2] with the real parts in signal[i][0] and the imaginary parts
99in signal[i][1].  (For a real signal, set the imaginary parts to
100zero.)  fmin and fmax are the frequency range to search, and nf is the
101number of spectral basis functions (see below).  Frequencies are in
102units corresponding to a sampling interval of 1 time unit--if your
103actual sampling interval is dt, then you should rescale your
104frequencies by multiplying them by dt.
105
106A good default for nf is min(300, (fmax - fmin) * n * 1.1),
107corresponding to a spectral "density" of at most 1.1 (see also the -d
108option of the command-line tool).  That is, this uses a number of
109initial basis functions corresponding to the Fourier resolution of
1101/n.  This does *not* determine the frequency resolution of the
111outputs, which can be much greater than the Fourier resolution.  It
112sets an upper bound on the number of modes to search for, and in some
113sense is the density with which the bandwidth is initially "searched"
114for modes.  Spectral densities much larger than 1 are not recommended,
115as they lead to large and singular matrices and unstable results.
116Note also that the computation time goes as O(n * nf) + O(nf^3).
117
118Then, you solve for the frequencies by calling:
119
120	void harminv_solve(harminv_data d);
121
122Then, the frequencies and other data can be extracted from d by the
123following routines.  The number N of frequencies found is returned by:
124
125	int harminv_get_num_freqs(harminv_data d);
126
127Then, for each index 0 <= k < N, the corresponding frequency and decay
128constant (as defined in 'man harminv') are returned by:
129
130	double harminv_get_freq(harminv_data d, int k);
131	double harminv_get_decay(harminv_data d, int k);
132
133Alternative, you can get the complex angular frequency (omega =
1342*pi*freq - i*decay) by:
135
136	harminv_complex harminv_get_omega(harminv_data d, int k);
137
138You can get the "quality factor" Q (pi |freq| / decay) by:
139
140	double harminv_get_Q(harminv_data d, int k);
141
142The complex amplitude (|amp| * exp(-I phase)) for each k is returned by:
143
144	harminv_complex harminv_get_amplitude(harminv_data d, int k);
145
146A crude estimate of the relative error in the (complex) frequency is:
147
148	double harminv_get_freq_error(harminv_data d, int k);
149
150As described in 'man harminv', this is not really an error bar, and
151should be treated more as a figure of merit (smaller is better).
152
153*** Linking to -lharminv: ***
154
155To link to the library, you need to not only link to -lharminv, but
156also to the math library, the BLAS and LAPACK libraries (see below),
157and any libraries that are required to link C with Fortran code (like
158LAPACK).  If you have the pkg-config program installed (standard on most
159GNU/Linux systems), you can simply do:
160	pkg-config --cflags harminv
161	pkg-config --libs harminv
162to get the flags for compiling and linking, respectively.  You may
163need to tell pkg-config where to find harminv.pc if harminv was
164installed under /usr/local (the default)...in this case, you would
165specify "/usr/local/lib/pkgconfig/harminv.pc" instead of "harminv"
166above.
167
168There is an additional wrinkle.  If you configured harminv with
169--with-cxx, or if your C compiler did not support C99 complex numbers
170and the configure script automatically switched to C++, then you will
171need to link to harminv with the C++ linker, even if your program is
172written in C, in order to link the C++ libraries.
173
174Installation:
175=============
176
177Harminv is designed to run on any Unix-like system (GNU/Linux is
178fine).  (It may also be possible to compile it on other systems, as it
179is mainly ANSI C with the exception of one or two POSIX functions like
180getopt.)
181
182However, you do need a couple of prerequisites:
183
184* BLAS (http://www.netlib.org/blas/)
185
186Basic Linear Algebra Subroutines (matrix-multiplications, etcetera),
187following a standard interface, for use by LAPACK (see below).  There
188are many optimized versions of BLAS available, e.g. a free library
189called ATLAS (http://www.netlib.org/atlas/).
190
191* LAPACK (http://www.netlib.org/lapack/)
192
193A standard, free, linear-algebra package.  Note that the default
194configuration script looks for LAPACK by linking with -llapack.  This
195means that the library must be called liblapack.a and be installed in
196a standard directory like /usr/local/lib (alternatively, you can
197specify another directory via the LDFLAGS environment variable; see
198below).
199
200See also http://ab-initio.mit.edu/mpb/doc/installation.html#blas for
201links to other information on installing BLAS and LAPACK.
202
203Once you have those installed, you can compile and install harminv.
204harminv comes with a GNU-style configure script, so on Unix systems
205compilation is ideally just a matter of:
206
207	./configure && make
208
209and then switching to root and running:
210
211	make install
212
213In order to compile, harminv requires either:
214
215* An ANSI C compiler supporting complex numbers, as defined in
216  the ANSI C99 standard (or a reasonable approximation thereof).
217  For example, gcc-2.95 with GNU libc is fine.
218
219* A C++ compiler supporting the complex<double> standard template class.
220
221The configure script looks for a C compiler with complex numbers first,
222and then for a C++ compiler.  You can force it to use C++ by passing
223--with-cxx to configure.
224
225If you need to, you can have further control over the configure
226script's behavior by setting enviroment variables.  This can be useful
227especially if you have libraries installed in nonstandard locations
228(e.g. in your home directory, if you are not root), to tell the
229compiler where to look.  The most common variables to set are:
230
231CC: the name of the C compiler
232CPPFLAGS: -I<dir> flags to tell the C compiler where to look for header files
233CFLAGS: C compiler flags
234F77: the name of the Fortran compiler
235FFLAGS: Fortran compiler flags
236LDFLAGS: linker flags (e.g. -L<dir> to look for libraries in <dir>)
237
238------------------------------------------------------------------------------
239
240