## Glas :## Re: [glas] Skalar-Like concepts from GLAS and MTL |

**From:** Peter Gottschling (*pgottsch_at_[hidden]*)

**Date:** 2005-05-26 18:12:59

**Next message:**Peter Gottschling: "Re: [glas] pure algebraic concepts cfr additive"**Previous message:**Toon Knapen: "[glas] pure algebraic concepts cfr additive"**In reply to:**Toon Knapen: "Re: [glas] Skalar-Like concepts from GLAS and MTL"

On May 26, 2005, at 2:30 AM, Toon Knapen wrote:

> Here I am again. I have a bit further experimented in the direction of

> Peter's proposal and it seems to work out nice. I've been

> concentrating on the pure algebraic concepts (up until Group) for the

> moment. I've uploaded the updated concepts here:

> http://glas.sourceforge.net/doc/index.html.

>

> Let me comment on the main points of the changes:

>

> 1) Magma is not a refinement of Assignable (anymore). Instead probably

> we need to add the requirement that the set is a refinment of

> Assigneable.

>

> 2) In the Magma I added the definition of the type of the 'operator'

> saying that it is a BinaryFunctor.

>

Agreed, multi-type concepts require more specific refinements than I

proposed. I corrected this in the attached file.

> 3) inverse and identity are functors as well that depend on the type

> of the Set as well as on the operation. Since the inverse and identity

> are also dependent on the 'value_type', the inverse function is able

> to return identity-matrices, scalars or whatever.

>

This is a very good idea because it provides more flexibility. Functors

can be used for different types. If the identity is not part of a

functor, operator alone could be templated instead of the whole class

(because the compiler can use the parameters for the instantiation).

Toon's example would look like this

struct ScalarAdd

{

template < class T >

T operator()(const T& a, const T& b) const

{ return a + b ; }

} ;

On the other hand, it might complicate programming with these concepts

a little by introducing two types more (which should be mentioned in

the 'associated types' subsection of the concepts). We shall write some

more examples and/or adapt the examples in my paper to this. I don't

know yet, which version I prefer and we should discuss this further.

> 4) Note that identity is also a meta-function

>

> 5) I have made changes up to Group and also added two examples (which

> can easily be compiled with boost-build) which show the use of

> 'identity' and 'inverse'.

>

> I would like to change all higher-level concepts accordingly but first

> I'm going to wait for some feedback to know if we're synced and going

> in the right direction.

>

>

> BTW, I mention Assigneable above but I'm also thinking about what we

> should do with EqualityComparable. Would'nt it be good to introduce an

> equality operation that takes a tolerance into account?

This might be convenient in many situations working with floating

points but we should be very careful with this. Adding a tolerance

windows breaks the transitivity

a==b and b==c does not imply a==c

and algebraic structures wouldn't even be isomorphic to themselves

a==b and c==d does not imply op(a,c) == op(b,d)

I think this behavior would be too strange. It might be okay in special

cases but to introduce this in general looks way to dangerous to me.

Peter

------------

Peter Gottschling

Research Associate

Open Systems Laboratory

Indiana University

301i Lindley Hall

Bloomington, IN 47405

Tel.: +1 812 855-8898 Fax: +1 812 856 0853

http://www.osl.iu.edu/~pgottsch

- text/html attachment: magma.html