Convert a function from mathematica to MATLAB
Show older comments
My question is how to write the following function that I have in Mathematica in MATLAB? Here is the function:
\[Gamma] =
Join[Table[{Riffle[Range[0, -\[ScriptL]0, -1],
Range[\[ScriptL]0]][[i]], 1}, {i, 1, 2 \[ScriptL]0 + 1}],
Table[{Riffle[Range[0, -\[ScriptL]0, -1],
Range[\[ScriptL]0]][[i]], -1}, {i, 1, 2 \[ScriptL]0 + 1}]];
factorFxn[\[ScriptL]_, m1_, m2_, p1_, p2_] :=
(If[\[Gamma][[m1, 2]] == \[Gamma][[p1, 2]] && \[Gamma][[m2,
2]] == \[Gamma][[p2, 2]],
If[\[Gamma][[p1, 1]] - \[Gamma][[m1, 1]] == \[Gamma][[m2,
1]] - \[Gamma][[p2, 1]],
Sum[(2 \[ScriptL] + 1)^2 Sum[
If[\[Gamma][[p1, 1]] - \[Gamma][[m1, 1]] ==
mval && \[Gamma][[m2, 1]] - \[Gamma][[p2, 1]] ==
mval, (-1)^(\[Gamma][[m1, 1]] + \[Gamma][[m2, 1]] +
mval) ThreeJSymbol[{\[ScriptL], -\[Gamma][[m1,
1]]}, {\[ScriptL], \[Gamma][[p1,
1]]}, {\[ScriptL]temp, -mval}] \
ThreeJSymbol[{\[ScriptL]temp,
mval}, {\[ScriptL], -\[Gamma][[m2,
1]]}, {\[ScriptL], \[Gamma][[p2,
1]]}] ThreeJSymbol[{\[ScriptL], 0}, {\[ScriptL],
0}, {\[ScriptL]temp, 0}]^2,
0], {mval, -\[ScriptL]temp, \[ScriptL]temp}], \
{\[ScriptL]temp, 0, 2 \[ScriptL]}], 0]
, 0] -
If[\[Gamma][[m1, 2]] == \[Gamma][[p2, 2]] && \[Gamma][[m2,
2]] == \[Gamma][[p1, 2]],
If[-\[Gamma][[p1, 1]] + \[Gamma][[m2,
1]] == -\[Gamma][[m1, 1]] + \[Gamma][[p2, 1]],
Sum[(2 \[ScriptL] + 1)^2 Sum[
If[-\[Gamma][[p1, 1]] + \[Gamma][[m2, 1]] ==
mval && -\[Gamma][[m1, 1]] + \[Gamma][[p2, 1]] ==
mval, (-1)^(\[Gamma][[m1, 1]] + \[Gamma][[m2, 1]] +
mval) ThreeJSymbol[{\[ScriptL], -\[Gamma][[m1,
1]]}, {\[ScriptL], \[Gamma][[p2,
1]]}, {\[ScriptL]temp, -mval}] \
ThreeJSymbol[{\[ScriptL]temp,
mval}, {\[ScriptL], -\[Gamma][[m2,
1]]}, {\[ScriptL], \[Gamma][[p1,
1]]}] ThreeJSymbol[{\[ScriptL], 0}, {\[ScriptL],
0}, {\[ScriptL]temp, 0}]^2,
0], {mval, -\[ScriptL]temp, \[ScriptL]temp}], \
{\[ScriptL]temp, 0, 2 \[ScriptL]}], 0]
, 0] );
1 Comment
Walter Roberson
on 22 May 2021
Edited: Walter Roberson
on 21 Jan 2025
Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!