MathGroup Archive 2011

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

Search the Archive

Re: Precedence question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119267] Re: Precedence question
  • From: Arturas.Acus at tfai.vu.lt
  • Date: Sat, 28 May 2011 07:18:24 -0400 (EDT)

Following David's suggestion I wrote the following
function

myPreFunction[{x},ReplaceAll[ToExpression[StringReplace[ToString[x],{"\[Wedge]"->"\[CircleDot]","\[CenterDot]"->"\[SmallCircle]"}],StandardForm],{CircleDot->Wedge,SmallCircle->CenterDot}],{HoldAll}]

which seems do the job.

However I notice that if the following function


$PreFunction[{x},ReplaceAll[ToExpression[StringReplace[ToString[x],
{"\[CenterDot]"->"\[SmallCircle]","\[Wedge]"->"\[CircleDot]"}]],{SmallCircle->>CenterDot,CircleDot->Wedge}],{HoldAll}]


is evaluated inside package private context (package context impors Global`)
I encounter the problems (for example FullForm do not work properly).

I think this function should be evaluated in the very beginning, however
I have no idea how to include it into package structure. (init.m ?)




David Bailey <dave at removedbailey.co.uk> ra=C5=A1=C4=97:

> On 25/05/2011 10:57, Arturas.Acus at tfai.vu.lt wrote:
>>
>> Dear Group
>> In order to implement some geometric algebra code I need
>> to reverse the order of the following operators which have no built in
>> meaning:
>>
>> Precedence/@{NonCommutativeMultiply,Wedge,CenterDot}
>>
>> Acording to geometric algebra rules the highest precedence has inner
>> product operator =C2=A0(I plan to use CenterDot symbol to denote this),
>> then goes Wedge (outer multiplication) and last is geometric product
>> (will definetely use NonCommutativeMultiply for that)
>>
>> Because of Mathematica predefined precedences the following input
>>
>> MV[a]\[Wedge]MV[b]\[CenterDot]MV[c]**MV[d]//FullForm
>>
>> is interpreted as
>>
>> CenterDot[Wedge[MV[a],MV[b]],NonCommutativeMultiply[MV[c],MV[d]]]
>>
>> whereas I need
>>
>> NonCommutativeMultiply[Wedge[MV[a],CenterDot[MV[b],MV[c]]],MV[d]]]
>>
>>
>> Few hours of Mathematica documentation reading did not yield any simple solution.
>>
>> Sure, instead of operators with no build in meaning I can use symbols
>> with user precedence level =C2=A0( for example =C2=A0\[RawWedge] instead of
>> \[Wedge]).
>> =C2=A0 The problem then is to define proper Infix INPUT notation+ alias.
>> This can be done with Notation package, hovewer this is what I would
>> like to avoid, because the task becomes complicated from the very
>> begining.
>>
>>
>> Could anybody suggest more simple alternative?
>>
>>
>> Sincerely, Arturas Acus
>>
>
> One possible approach would be to supply your expressions as strings,
> and then use StringReplace to replace the operator characters with
> another set with the correct order of precedences (and no built-in
> meaning). Then you could use ToExpression on the result, and work from
> there.
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
>
>


  • Prev by Date: Re: ViewPoint selector (Stan Wagon's)
  • Next by Date: Re: NDSolve issues with initial and boundary conditions (corrected characters)
  • Previous by thread: Re: Precedence question
  • Next by thread: Re: Precedence question