Message Boards Message Boards

0
|
2626 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

how to get the required list

Posted 10 years ago
I have the two variables L,m such that
L=0 => m=0
L=1 =>m=-1,0,1
L=2 =>m = -2,-1,0,1,2
(for each value of L, m is from -L to +L with increment 1)
now I want to generate a list with the order like
list= {{0,0},{1,0},{2,0},{1,-1},{2,-1},{1,1},{2,1},{2,-2},{2,2}}//
  //all values of L for m=0
    all values of L for m=-1
    all values of L for m=1
    all values of L for m=-2
    all values of L for m=2
What should be the code for this list? kindly help and sorry for mistake in the text
POSTED BY: adil qayyum
3 Replies
Posted 10 years ago
Just an alternative:
m[l_] := Range[-l, l]
You can produce list:
res = Join @@ Function[x, {x, #} & /@ m[x]] /@ Range[0, 2]
This yields:
{{0, 0}, {1, -1}, {1, 0}, {1, 1}, {2, -2}, {2, -1}, {2, 0}, {2,
1}, {2, 2}}

Gathering:
GatherBy[res, Last]
yields:
{{{0, 0}, {1, 0}, {2, 0}}, {{1, -1}, {2, -1}}, {{1, 1}, {2, 1}}, {{2, -2}}, {{2, 2}}}
POSTED BY: Mark Dooris
Posted 10 years ago
Hi Adil,
Happy QM work!
 In[70]:= (* create the list *)
 nestedList = Table[{l, m}, {l, 0, 2}, {m, -l, l}];
 
 In[71]:= (* flatten to individual states *)
 lMlist = Flatten[nestedList, 1];
 
 In[72]:= (* gather by the m state *)
 gatherdByM = GatherBy[lMlist, #[[2]] &]
 
Out[72]= {{{0, 0}, {1, 0}, {2, 0}}, {{1, -1}, {2, -1}}, {{1, 1}, {2,
   1}}, {{2, -2}}, {{2, 2}}}
POSTED BY: David Keith
Posted 10 years ago
Thanks David !!  it really works emoticon
POSTED BY: adil qayyum
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract