axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] Anybody up for a few basic Aldor questions?


From: Ralf Hemmecke
Subject: Re: [Axiom-developer] Anybody up for a few basic Aldor questions?
Date: Sat, 19 Aug 2006 03:00:44 +0200
User-agent: Thunderbird 1.5.0.5 (X11/20060719)

Hi Cliff,

if I think about dimensions then that is a multiplicative structure. In fact, to me it looks like a commutative group where the free generators are the basic SI dimensions.

So an implementation would be

Dimension: with {
    *: (%, %) -> %;
    /: (%, %) -> %;
    kilogramm: %;
    meter: %;
    second: %;
    ...
} == add {
    Rep == Array Integer;
    import from Rep;
    -- Suppose we have n basic units then the array would ALWAYS be
    -- of length n. For simplicity I set n = 4;
    local new(): Rep == per new(4, 0); -- create array of size 4
    kilogram: % == {x := new(); x.1 := 1; per x}
    meter: %    == {x := new(); x.2 := 1; per x}
    second: %   == {x := new(); x.3 := 1; per x}
    (x: %) * (y: %): % == per [xx+yy for xx in rep x for yy in rep y];
    (x: %) / (y: %): % == per [xx-yy for xx in rep x for yy in rep y];
    ...
}

You can easily recognize if your dimension is a basic unit by just running through the array and testing whether there is exactly ONE 1.

Why would you want anything else? Can you give an explicit pointer to the text you have already written about units and dimensions?

If you like, you could change the representation to allow infinitely many basic dimensions (= infinitely many variables).

Your suggestion

> BasicDimension: Abelian with {
>   "*": (%,%) -> DerivedDimension
> }
> == add {
>   Rep = Record(name : String, definition : String, system : String)
> }

looks completely unnatural to me.

How would you ever define * explicitly?

To me it looks more like you define a box that contains name and definition of the dimension, but no multiplicative structure. Remove the * signature. That would appear in DerivedDimension anyway.

And if you want BasicDimension, just add an exponent entry to your representation

Rep = Record(exponent: Integer,
             name : String,
             definition : String,
             system : String)

and change my representation to

Rep == Array BasicDimension;

(And of course adapt the functions.)

On 08/19/2006 02:12 AM, C Y wrote:
Well, it's Friday night and I decided to take a first look at doing
some Dimension related stuff in Aldor.  So I don't flounder uselessly
about, could someone guide me to the right things to read to answer the
following?

1)  For anyone who has slogged through the old draft of the units
paper, you know some of the problems with defining the ideas of basic
and derived dimensions.  I may be a little off course here, but this is
what I'm thinking:

a)  A basic dimension cannot be multiplied and remain a basic dimension
- the result is always a derived dimension.

b)  A derived dimension is always defined in terms of one or more basic
definitions and uses the multiplicative operator both in its definition
and its exported function.

So we have two types of dimension - the BasicDimension, and the
DerivedDimension.  The multiplication rules are:

basic * basic -> derived
basic * derived -> derived
derived * derived -> derived

However, derived / derived MIGHT yield a basic dimension, e.g.
Force*Acceleration/Length -> Mass.  Is there a way to conditionalize
the type of the output?  (BTY, the dimension 1 is always assumed part
of the set of basic dimensions).

I'm also looking at a bit of a problem with definitions.  If I do
something like this for BasicDimension (I suppose I'm writing this
wrong):

BasicDimension: Abelian with {
  "*": (%,%) -> DerivedDimension
}
== add {
        Rep = Record(name : String, definition : String, system : String)
}

DerivedDimension is undefined at this stage, because (presumably) part
of the representation of DerivedDimension is going to have to be
defined in terms of some kind of Abelian Polynomial of Basic
Dimensions.  Am I thinking about this incorrectly?

Unfortunately the difficulties don't stop there - some DerivedDimension
in the SI system have no definitive definition in terms of
BasicDimensions, so some DerivedDimensions will have to have parts of
their structure undefined.

Can you give an example.

I'm not quite sure how to do this - I'm floundering around:

DerivedDimension: Abelian with{
  "*": (%,%) -> %
}
==add {
  D == BasicDimension Polynomial
        Rep = Record(name: String, definitiverepresentation : D,
reducedrepresentation : D)
  x * y  == if (x::Rep).definitiverepresentation = "" then
[(x::Rep).name::DerivedDimension * (y::Rep).definitiverepresentation]
else if (x::Rep).definitiverepresentation = "" then
[(x::Rep).definitiverepresentation * (y::Rep).name::DerivedDimension]
else [(x::Rep).definitiverepresentation *
(y::Rep).definitiverepresentation]
}

Looking at your code, I find it unreadable. And if that is the case one should clearly think about another way of doing it.

And I cannot follow why you would like "Polynomial" to appear. Is there a dimension that looks like

  4*m^2 + 5*kg/s

???

Anyway.  Any advice appreciated.

Thanks,
CY

Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]