Boost logo

Boost :

From: Leland Brown (lelandbrown_at_[hidden])
Date: 2006-06-09 00:31:28

Andy Little <andy <at>> writes:
> However AFAIK a matrix can have matrix or
> maybe vector or complex elements so perhaps there are other candidates than
> physical quantities for the elements?

Actually, yes! In fact, I played around quite a bit with allowing my matrix
elements to be matrices themselves, and even implemented some of it. Mostly
just for fun, and to prove to myself it could be done - I'm not sure how much
anyone actually needs this. Essentially, these can be thought of as
partitioned matrices.

When you do that, though, you have to be a lot more careful in your arithmetic
inside the matrix functions. A step in your algorithm that says "a * b" with
scalar elements can become any of these with matrices:

   A * B, A * B', A' * B, A' * B'
   B * A, B * A', B' * A, B' * A'

(where I use the prime ' here to represent matrix transpose). In other words,
you have to get your multiplications in the right order and know when to do a
transpose. (Actually, for me, that's the fun part! I'm a mathematician at
heart.) But if you write your matrix operations carefully this way, it is in
fact possible to have matrices of matrices and have the results work out
correctly! This can even be done with something more esoteric like a Cholesky

I'm less familiar with handling complex elements, but I think a similar issue
comes up with making sure you know when to take the complex conjugate of an
element. However, standard matrix libraries are probably more used to dealing
with complex values.

-- Leland

Boost list run by bdawes at, gregod at, cpdaniel at, john at