No BSD License  

Highlights from
Clebsch Gordan Coefficient Solver GUI

image thumbnail
from Clebsch Gordan Coefficient Solver GUI by james jun
Easy to use Clebsch-Gordan coefficient solver for adding two angular momentums.

calcallcgcoef( j1, j2 )
function [ ret_cellstr, ret_table ] = calcallcgcoef( j1, j2 )
%CALCCGCOEF : calculate clebisch-gordon coefficients
%output: 
%   cellstr: cell of string output
%   rettable: a table with a recordset [J, M, m1, m2, coeff]
ret_cellstr = {};
ret_table = [];

Js = j1+j2:-1:abs(j1-j2);
for J=Js
    init_rhs_i = findinitindex(j1, j2, J);
    init_rhs_c = solveinitcoef(init_rhs_i);
    [lhs cell_rhs_i cell_rhs_c] = cgcoeff_stage2(J, init_rhs_i, init_rhs_c); %append all
    
    %construct n*2 matrix
    [numRecords temp] = size(lhs); %lhs is nx2 containing [J,M]
    for i1 = 1:numRecords
        lhsRecord = lhs(i1,:);  %lhs: total momentum space
        arhs_i = cell_rhs_i{i1};  %rhs: direct product space
        arhs_c = cell_rhs_c{i1};
        for i2=1:numel(arhs_c)
            [astr arecord] = record2str(lhsRecord, arhs_i(i2,:), arhs_c(i2));
            ret_cellstr = {ret_cellstr{:}, astr};
            ret_table = [ret_table; arecord];
        end
    end
end

Contact us at files@mathworks.com