Questions from New-Old User

Matthew Donadio m.p.donadio@ieee.org
Thu, 02 Jan 2003 23:50:45 -0500


Hi all,

I hope everyone had a nice holiday season.

I am picking up a project that I started a few years ago, but for
various reasons stopped working on.  It was the Libraries for Digital
Signal Processing listed in the Numerical Algorithms and Mathematics
section on the haskell.org website.  I am going to revisit those
libraries and expand the scope a little bit to include spectral
estimation and some matrix math routines.

Anyway, since I haven't done any Haskell in about three years, I am a
bit rusty. :)  I have one question right now, and would like some advice
on another matter.  I am sure I will have other questions until the
proper section of my brain wakes up.

First, I cannot get a function to type.  The basic definition is:

rxx x k | k >= 0 = sum [ (conjugate (x!k)) * x!(n+k) | k <- [0..(n-1-k)]
] / n
	| k < 0  = conjugate (rxx x (-k))
	where n = snd (bounds x) + 1

This function performs autocorrelation for a complex array, and returns
a complex value.  The array indexes are integral in the general sense,
but could be safely Int.  I have tried various combinations of explicit
types and numeric type coersion functions without any success.  Any help
would be appreciated.

The second question has to do with the numeric class system.  In signal
processing and spectral estimation, there are a lot of algorithms that
can operate on real and complex data.  In most cases, the only
difference is the complex versions have conjugates in various places. 
In the function above, the equivalent real valued version is the same if
you either get rid of the conjugate applications, or assume that the
conjugate function for real numbers is the identity function.

What is the best way to handle this?  I don't want to have separate
functions for real and complex data, but I'm not sure of the proper way
to add conjugate=I to to the class system for non-complex numbers.

Thanks.

PS, if anyone wants a preview of my LU decomposition module (ie, it
could stand a bit more testing), please let me know.

-- 
Matthew Donadio (m.p.donadio@ieee.org)