Re: Upvalues related to "Times"
- To: mathgroup at smc.vnet.net
- Subject: [mg6329] Re: [mg6289] Upvalues related to "Times"
- From: "w.meeussen" <w.meeussen.vdmcc at vandemoortele.be>
- Date: Tue, 11 Mar 1997 01:29:30 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
At 00:26 8-03-97 -0500, Marlies wrote: >Hi, > >I'm having problems with defining an upvalue for the function S which is >related to the function "Times". In some cases (nr1 === nr2) the function S >should be treated as noncommutative. >To perform this I tried the following code: > >In:= S/: Times[S[nr1_,orient1_],S[nr2_,orient2_]]:= > S[nr1,orient1] ** S[nr2,orient2] /; nr1 === nr2 > >(* check: *) > >In:= S[1,y] S[1,x] > >Out= S[1,x]**S[1,y] > >As you can see the arguments of "Times" are rearranged. One possibility >to solve this would be to change the attributes of the (build-in) function >"Times" (remove Orderless). But the result of this would be that the function >"Times" wouldn't work as one expects it would (after loading the package in >which this code was entered). > >Does anyone know how to solve this? > >Thanks in advance! > >Marlies Brinksma > > > Marlies, isn't it an example of a more general case ? In:= y x/.Times->g Out= g[x,y] so the Orderless attribute of Times is active on the input BEFORE the user definitions get a hold on it. Of course, In:= Hold[y x]/.Times->g Out= Hold[g[y,x]] works, but cannot be used in a upvalue definition : TagSetDelayed::"tagpos": "Tag \!\(S\) in \!\(Hold[\(\(S[\(nr1_, orient1_\)]\)\\ \(S[\(nr2_, \ orient2_\)]\)\)]\) is too deep for an assigned rule to be found." In fact, you want to attach importance to order of the arguments, while introducing them as (intrinsically orderless) factors in the first place. Question: are the inputs (on which you want the definition to work) generated by Mma? In that case you would never find unsorted previous output to work on, unless you specifically disable 'Standard Order'. Here you could just as well add a rule so that the 'S' functions never get a '*' between them in the first place. are they input by hand? then do something about the input so that '*' becomes '**'. I hope I got the point, tell me if I didn't, Dr. Wouter L. J. MEEUSSEN eu000949 at pophost.eunet.be w.meeussen.vdmcc at vandemoortele.be