Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2712

Re: Precedence question

From David Bailey <dave@removedbailey.co.uk>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Precedence question
Date 2011-05-25 23:32 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <irk3it$79b$1@smc.vnet.net> (permalink)
References <irijqf$qfi$1@smc.vnet.net>

Show all headers | View raw


On 25/05/2011 10:57, Arturas.Acus@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  (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  ( for example  \[RawWedge] instead of
> \[Wedge]).
>    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

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Precedence  question Arturas.Acus@tfai.vu.lt - 2011-05-25 09:57 +0000
  Re: Precedence  question David Bailey <dave@removedbailey.co.uk> - 2011-05-25 23:32 +0000

csiph-web