Boost logo

Glas :

Re: [glas] arithmetic operations

From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2005-10-28 02:23:52


Andrew Lumsdaine wrote:

>I think this would be a very dangerous path to go down.
>
>One important reason for introducing operator notation for linear
>algebra operations is so that the program notation can match the
>corresponding mathematics. This is a very powerful correspondence.
>It makes code more straightforward to write, but just as importantly
>(or perhaps even more importantly) it makes the code more
>straightforward to read. By corresponding to an established language
>of mathematics, the code itself communicates significant mathematical
>meanings.
>
>If we start introducing non-mathematical meanings to operators, that
>subverts in a very significant way the expressiveness of the
>mathematical operator notation. There may be a few more things that
>can be expressed with operators in this case, but the clarity of
>expression is ruined -- the reader (and writer) of the code can no
>longer have confidence in the "language" being used -- it is no
>longer the well established language of mathematics.
>

A computer language cannot reflect the richness of mats notation,
otherwise we would not have this discussion.

It makes sense to use * for a product. But what does it mean for a
vector? inner product, outer product, element wise product? And why
prefer one to another?

To make the choice easier, we could assume that a vector is a column (as
is always the case in linear algebra). In this case
trans(x)*y = dot product
x*trans(y) = outer product
herm(x)*y = hermitian inner product

This is probably the closest we can get to linear algebra notation.

Karl

>
>Even worse is the case where the meaning of the operators might not
>have any fixed meaning at all. In that case, the expression of
>statements with operators has no fixed meaning and doesn't
>communicate anything.
>
>I really think that for mathematical libraries, the use of
>mathematical notation absolutely must conform to their mathematical
>meanings.
>
>
>