MathGroup Archive 2005

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

Search the Archive

Re: managing order of magnitude instead of numbers


Format[OrdMagn[n_?NumberQ]]:=o[n]

OrdMagn /: HoldPattern[Times[a___,c_OrdMagn,b___]]:= Module[{al},
    al=DeleteCases[{a,c,b},x_/;FreeQ[x,OrdMagn]];
    OrdMagn[Total[al/.{OrdMagn[n_] :> n}]]
    ]

OrdMagn /: HoldPattern[Plus[a___,c_OrdMagn, b___]]:=Module[{al},
    al=DeleteCases[{a,c,b},x_/;FreeQ[x,OrdMagn]];
    OrdMagn[Max[al/.{OrdMagn[n_] :> n}]]
    ]

OrdMagn /: HoldPattern[Power[OrdMagn[n_], p_?NumberQ]] := OrdMagn[p*n]


Then,

In[6]:=
OrdMagn[1]-OrdMagn[1]

Out[6]=
o[1]

Play around with it and modify accorng to your needs.

Sasha


  • Prev by Date: Re: GUIkit problem
  • Next by Date: Re: Creating forms for user input in Mathematica
  • Previous by thread: Re: managing order of magnitude instead of numbers
  • Next by thread: Re: managing order of magnitude instead of numbers