sfstoolbox / sfs-matlab

SFS Toolbox for Matlab/Octave
https://sfs-matlab.readthedocs.io
MIT License
97 stars 39 forks source link

Gauss quadrature #111

Closed trettberg closed 7 years ago

trettberg commented 7 years ago

This should fix the quadrature weights for Gauss-Legendre spherical sampling. Below, you see how the old weights fail to ensure orthonormality. gauss_old

Nmax = 5;
conf = SFS_config;
conf.secondary_sources.grid = 'gauss';
[grid,weights] = get_spherical_grid(2*(Nmax+1)^2,conf);
[phi,theta] = cart2sph(grid(:,1),grid(:,2),grid(:,3));

Ynm = [];
for n = 0:Nmax
    for m = -n:n
        Ynm  = [Ynm sphharmonics(n,m,theta,phi)];
    end
end
inner_products = Ynm'*diag(weights)*Ynm;

figure
imagesc([0,(Nmax+1)^2],[0,(Nmax+1)^2],abs(inner_products));
xlabel('n^2 + n + m');
ylabel('n^2 + n + m');
hagenw commented 7 years ago

Cool, thanks for he fix.