Boost logo

Boost :

Subject: Re: [boost] different matrix library?
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-08-14 18:06:28

On 14 Aug 2009, at 22:27, DE wrote:

> on 15.08.2009 at 1:12
> Edward Grace wrote :
>>>> it's terribly wrong to overload '^' in such a way
>> Why? The precedence rules? Fair enough - sometimes what's tempting
>> is bad for you, but you still want to try it anyway!
> because '^' is associated with bitwise xor operator and there is no
> such operation on vectors
> it is semantically wrong

Err - surely the point of overloading is to assign meaningful context
specific behaviour to the same operator, so.

  unsigned a,b,c; c = a ^ b; // ^ => XOR makes sense.

  pseudovector<3> c;
  vector<3> a,b; c = a ^ b; // ^ => Wedge product makes sense
XOR does not.

It seems reasonable - at least at first sight. I can understand the
objection vis-a-vis operator precedence and associativity constraints
though - e.g.

  pseudoscalar<double> s; vector<3> a,b,c; s = a ^ b ^ c; //
Equivalent to scalar triple product.

What's first (a ^ b) ^ c, a ^ (b ^ c) it shouldn't matter - I don't
recall the implicit associativity , precedence of the XOR
operator.... Anyhow, wedge(a,b) --- much less potential for
trouble ! ;-)

One thing to bare in mind, type trouble! Sticking with ^, since it's
easier to write. If each entity is a vector of length 3,

                     a ^ b ^ c
                          | |
                        directed area
                        a.k.a. bivector
                        [a pseudovector]
                    | |
                       directed volume
                       a.k.a. trivector
                       [a pseudovector]

If, for example, b and c were pseudovectors then s would be a (true)
scalar and could be assigned to the concrete type double. This is
where carrying along some (meta) information concerning the
transformation rules of these different entities would be both tricky
and crucial.

>>>>> w = wedge(u,v);
>>> w = cross_product(u,v) please :p
>> Err, that's only true in 3D (vectors of length 3). There's no such
>> thing as a cross product between (say) vectors of length 2,4 or
>> indeed anything else. The cross product is, in effect, a restricted
>> version of the exterior (wedge) product which exists for higher
>> dimensions.
> if i get the point right consider
> wedge_product(u,v)
> or
> exterior_product(u,v)

Yes indeed. Or, if the vector has exactly 3 elements you can say...

      vector<3> u,v;

but only then.


P.S. Anyone wondering what the heck a pseudo-vector/scalar is:

just when you thought the distinction between vectors / covectors was
confusing enough!

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