e-champenois / CPBASEX

pBASEX Abel Transform Inversion without Polar Rebinning
MIT License
7 stars 7 forks source link

Encountering singularity #2

Closed nsaikat closed 6 years ago

nsaikat commented 7 years ago

Great stuff! Very useful... While generating the .h5 file using save_gData.m, for xkratio=1, the SVD algorithm encounters a singularity (NaN or Inf). Any suggestion on how to avoid that? Thanks in advance!

e-champenois commented 7 years ago

Sorry, looks like I changed something without checking some ramifications here. In save_gData.m, line 13, the radial basis functions are normalized by dividing the exponential by "k.^2". With xkratio=1, the first k value is equal to 0, so this division makes that basis function diverge. A quick fix would be to remove the division by "k.^2", or divide by "(k+0.1).^2" to avoid a singularity. The normalization shouldn't be needed, but I remember having a quick thought (that I didn't look much into) that it might help with the conditioning of the matrix and the SVD process. I will try to fix and properly test this as well when I get a chance, thanks for pointing it out.

nsaikat commented 7 years ago

Thanks for the suggestion! That way it's working fine...

e-champenois commented 6 years ago

Uploaded new code with the normalization (division by k.^2) removed. The simple test images still invert correctly so there is probably no matrix conditioning issue.