Prev: Relationship between vertices and indices with GraphDistanceMatrix
Next: Plotting a parametric equation
From: Tom D on 4 Aug 2010 05:50 I am trying to create an indexed function that would be of the form M_(j,,j+1) [a,b] := func(j,a,b) , where M has the two subscripts j and j+1, i. e. I need the 2nd subscript to match only when it is 1 more than the first. I know how to do this if I made the argument 'j' a normal argument, that is, not a subscript. (Use the /; operator.) How can I do this for the subscripts? (These are propagator matrices that either go one level up, or one down, so I'll have two M's, a (j, j+1) and a (j,,j-1) version.) Thanks, Tom
From: Peter Pein on 4 Aug 2010 07:40
Am Wed, 4 Aug 2010 09:50:13 +0000 (UTC) schrieb Tom D <tomdickens(a)att.net>: > I am trying to create an indexed function that would be of the form > > M_(j,,j+1) [a,b] := func(j,a,b) , > > where M has the two subscripts j and j+1, i. e. I need the 2nd > subscript to match only when it is 1 more than the first. > > I know how to do this if I made the argument 'j' a normal argument, > that is, not a subscript. (Use the /; operator.) > > How can I do this for the subscripts? > > (These are propagator matrices that either go one level up, or one > down, so I'll have two M's, a (j, j+1) and a (j,,j-1) version.) > > Thanks, > > Tom > Hi Tom, this works similar to the definition of a function: In[7]:= Clear[M] Subscript[M, j_, j_ + 1][a_, b_] := func[j, a, b] In[9]:= Subscript[M, 5, 6][x, y] Out[9]= func[j, x, y] In[10]:= Subscript[M, 6, 5][p, q] Out[10]= Subscript[M, 6, 5][p, q] hth, Peter |