MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Units, simplification

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59611] Re: Units, simplification
  • From: albert <awnl at arcor.de>
  • Date: Sun, 14 Aug 2005 04:38:00 -0400 (EDT)
  • References: <ddh9a8$cde$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Bill, hi Chris, 
 
thanks to Bill for that tip, maybe the following will be of use to any of
you both...

> There are a couple of consequences of solving the issue in this manner.
> 
> I have modified one of the standard distribution packages. So, every
> upgrade to Mathematica will overwrite these changes and you will lose this
> behaviour until you edit the new Units.m file.

This you can solve by putting the following code into a file named
UnitsExtension.m in a directory where Mathematica looks for packages
(for 5.1 e.g.  ToFileName[{$UserAddOnsDirectory},"Applications"] ):

BeginPackage["UnitsExtension`",{"Miscellaneous`Units`"}];
EndPackage[];
BeginPackage["Miscellaneous`Units`"];
FundamentalSI::usage = StringJoin[
"FundamentalSI[expr] converts expr to", 
"fundamental SI units (International System)."
];
Begin["`Private`"];
FundamentalSI[expr_]:=SI[expr]//.$ToFundamental;
End[];
EndPackage[];

and can then be used like this:

In[1]:= Needs["UnitsExtension`"]

In[2]:= FundamentalSI[Ampere Meter Meter/Joule Tesla]

Out[2]= 1

Of course this is still kind of a hack and only works as long as the
interiors of the Units` package won't change. But at least you can keep
your fingers off the mathematica installation and it should work even when
you have no write access to the installation directory or when using
multiple versions on the same machine/account. It also saves you from
(miss)typing Miscellaneous (which I do all the time...), you could even
call it something shorter than UnitsExtension if you use it often...

> Since I have not modified the stub that gets called when doing
> <<Miscellaneous` this new function will not be loaded. That is, to get
> this new functionality as I have modified things you must explictly load
> the Miscellaneous`Units` package using Needs, Get or <<.

this is not solved by my suggestion, of course...

regards,

Albert


  • Prev by Date: Re: what does this parentheses mean?
  • Next by Date: Re: Re: Linear Differential Equations with Matrices
  • Previous by thread: Re: Units, simplification
  • Next by thread: Re: Units, simplification