[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] Unit package question
From: |
Martin Rubey |
Subject: |
Re: [Axiom-developer] Unit package question |
Date: |
Mon, 22 Aug 2005 14:19:55 +0200 |
Dear Ralf, CY,
in fact, I like this idea even better than mine. In private communication, we
developed the domain below, but your idea is conceptually better, I think. The
full blown thing would then be a category Units, that has as domains Mass,
Time, Length, ... I suppose.
Martin
)abb domain UNITS Units
Units(R: Field): Exports == Implementation where
U == Fraction Polynomial Integer
Exports == with
"*": (%,%) -> %
"+": (%,%) -> %
coerce: % -> OutputForm
withUnits: (R, U) -> %
setUnitSystem!: String -> String
Implementation == add
Rep := Record(expr: R, units: U)
system: String := "MKS"
setUnitSystem! s ==
t := system
system := s
t
transform: U -> Record(scalar: R, units: U)
transform u ==
m := 'm::Symbol::Polynomial(Integer)::U
v := u
if system = "MKS"
then v := eval(u, ['cm, 'dm], _
[m*1/100::U, m*1/10::U])$RationalFunction(Integer)
s: Fraction Integer := leadingCoefficient(numer(v)) _
/ leadingCoefficient(denom(v))
r: U := leadingMonomial(numer(v))::U _
/ leadingMonomial(denom(v))::U _
/ s ::U
[s::R, r]
withUnits(e, u) == [e, u]::Rep
x * y == [(x::Rep).expr * (y::Rep).expr, (x::Rep).units * (y::Rep).units]
x + y ==
ux := transform((x::Rep).units)
uy := transform((y::Rep).units)
if ux.units = uy.units
then [(x::Rep).expr*ux.scalar + (y::Rep).expr*uy.scalar, ux.units]
else error "+: Units have to match"
coerce x == coerce((x::Rep).expr)$R * coerce((x::Rep).units)$U
- [Axiom-developer] Re: integration, Martin Rubey, 2005/08/19
- [Axiom-developer] Re: integration, Martin Rubey, 2005/08/19
- [Axiom-developer] Re: integration, C Y, 2005/08/19
- [Axiom-developer] Re: integration, Martin Rubey, 2005/08/19
- [Axiom-developer] Re: integration, C Y, 2005/08/19
- [Axiom-developer] Unit package question, C Y, 2005/08/19
- RE: [Axiom-developer] Unit package question, Bill Page, 2005/08/19
- RE: [Axiom-developer] Unit package question, C Y, 2005/08/19
- Re: [Axiom-developer] Unit package question, Ralf Hemmecke, 2005/08/22
- Re: [Axiom-developer] Unit package question,
Martin Rubey <=
- Re: [Axiom-developer] Unit package question, C Y, 2005/08/23
- Re: [Axiom-developer] Unit package question, Ralf Hemmecke, 2005/08/23
- Re: [Axiom-developer] Unit package question, C Y, 2005/08/23
- Re: [Axiom-developer] Unit package question, Ralf Hemmecke, 2005/08/23
- Re: [Axiom-developer] Unit package question, Martin Rubey, 2005/08/23
- Re: [Axiom-developer] Unit package question, C Y, 2005/08/23
- Re: [Axiom-developer] Unit package question, C Y, 2005/08/23
- Re: [Axiom-developer] Aldor / Axiom, Martin Rubey, 2005/08/23
- Re: [Axiom-developer] Unit package question, Martin Rubey, 2005/08/23
- Re: [Axiom-developer] Unit package question, William Sit, 2005/08/23