From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,791ecb084fdaba75 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-11 22:34:39 PST Path: bga.com!news.sprintlink.net!hookup!news.kei.com!MathWorks.Com!europa.eng.gtefsd.com!library.ucla.edu!ihnp4.ucsd.edu!network.ucsd.edu!mbk From: mbk@inls1.ucsd.edu (Matt Kennel) Newsgroups: comp.lang.ada Subject: Re: Types with physical dimension Date: 12 Oct 1994 03:43:23 GMT Organization: Institute For Nonlinear Science, UCSD Message-ID: <37fm0r$72r@network.ucsd.edu> References: NNTP-Posting-Host: lyapunov.ucsd.edu X-Newsreader: TIN [version 1.1 PL8] Date: 1994-10-12T03:43:23+00:00 List-Id: Robert I. Eachus (eachus@spectre.mitre.org) wrote: : In article sal714@rs710.gsfc.nasa.gov (Stephen A. Leake) writes: : > I run robots with Ada, so I deal with real dimensions all the time. : > Very early on, I started to write a package that enforced : > dimensionality; I defined METERS, METERS_PER_SECOND, etc. I quickly : > discovered that even simple equations need up to cubic dimensions, : > in all combinations of length, mass and time. Defining all these : > types and the associated operators was far too time-consuming to be : > worth it. So now I rely on code reviews and careful testing. : > The moral; strong typing is nice, but is no substitute for careful design : > and thorough testing. : Paul Hilfinger did a nice paper on using discriminants to check : dimensionality. I don't have the paper in front of me but it works : something like this: : type Measure(Length,Mass,Time: Integer) is record : Value: Float; : end record; : subtype Meters is Measure(1,0,0); : subtype Kilograms is Measure(0,1,0); : subtype Time is Measure(0,0,1); : ...etc. At one point I thought this was a good idea. Now my feeling is that you should have already non-dimensionalized your equations into systems of units specific for the problem. That way you get more understanding and "less number". Paradoxically, once you DON'T have physical units on your variables, it's easier to say whether something is "big" or "small". -- -Matt Kennel mbk@inls1.ucsd.edu -Institute for Nonlinear Science, University of California, San Diego -*** AD: Archive for nonlinear dynamics papers & programs: FTP to -*** lyapunov.ucsd.edu, username "anonymous".