In hoc signo vinces (Was: Revamping the numeric classes)
William Lee Irwin III
wli@holomorphy.com
Mon, 12 Feb 2001 13:31:29 -0800
On Mon, Feb 12, 2001 at 02:13:38PM -0700, Joe Fasel wrote:
> For fromInteger, fromInt, and abs, the result should be a scalar matrix.
> For the two coercions, I don't think there would be much controversy
> about this. I agree that it would be nice if abs could return a
> scalar, but this requires multiparameter classes, so we have to make
> do with a scalar matrix.
I'm not a big fan of this approach. I'd like to see at least some
attempt to statically type dimensionality going on, and that flies in
the face of it. Worse yet, coercing integers to matrices is likely to
be a programmer error.
On Mon, Feb 12, 2001 at 02:13:38PM -0700, Joe Fasel wrote:
> signum does make sense. You want abs and signum to obey these laws:
>
> x == abs x * signum x
> abs (signum x) == (if abs x == 0 then 0 else 1)
>
> Thus, having fixed an appropriate matrix norm, signum is a normalization
> function, just as with reals and complexes.
This works fine for matrices of reals, for matrices of integers and
polynomials over integers and the like, it breaks down quite quickly.
It's unclear that in domains like that, the norm would be meaningful
(in the sense of something we might want to compute) or that it would
have a type that meshes well with a class hierarchy we might want to
design. Matrices over Z/nZ for various n and Galois fields, and perhaps
various other unordered algebraically incomplete rings explode this
further still.
On Mon, Feb 12, 2001 at 02:13:38PM -0700, Joe Fasel wrote:
> If we make the leap to multiparameter classes, I think this is
> the signature we want:
Well, nothing is going to satisfy everyone. It's pretty reasonable,
though.
Cheers,
Bill