For large N most of the time is spent in the two for loops.
To remove them bsxfun is useful. Replace the lines in Kabsch.m:
------------------------------------
Pdm = zeros(D,N) ;
for i=1:N
Pdm(:,i) = m(i)*P(:,i) ;
end
C = Pdm*Q' ;
------------------------------------
by
------------------------------------
C = bsxfun(@times,m,P)*Q';
------------------------------------
and the lines
------------------------------------
lrms = 0 ;
for i=1:N
lrms = lrms + m(i)*Diff(:,i)'*Diff(:,i) ;
end
lrms = sqrt(lrms) ;
------------------------------------
by
------------------------------------
lrms = sqrt(sum(sum(bsxfun(@times,m,Diff).*Diff))) ;
------------------------------------
and the execution speed will be increased by ~70 for N=3'000'000

22 Oct 2012

Kabsch algorithm
Find the rigid transformation & Least Root Mean Square distance between two paired sets of points
Author: Ehud Schreiber

For large N most of the time is spent in the two for loops.
To remove them bsxfun is useful. Replace the lines in Kabsch.m:
------------------------------------
Pdm = zeros(D,N) ;
for i=1:N
Pdm(:,i) = m(i)*P(:,i) ;
end
C = Pdm*Q' ;
------------------------------------
by
------------------------------------
C = bsxfun(@times,m,P)*Q';
------------------------------------
and the lines
------------------------------------
lrms = 0 ;
for i=1:N
lrms = lrms + m(i)*Diff(:,i)'*Diff(:,i) ;
end
lrms = sqrt(lrms) ;
------------------------------------
by
------------------------------------
lrms = sqrt(sum(sum(bsxfun(@times,m,Diff).*Diff))) ;
------------------------------------
and the execution speed will be increased by ~70 for N=3'000'000

5

14 Apr 2013

fexact( varargin )
Hypergeometric cumulative distribution (left, right and two-tailed) including permutation testing.

I found a little mistake that results in numerical jitter under some circumstances.
If you change the line:
"if (det(C) < 0)" into "if (det(W*V') < 0)"
all works fine.
Cheers, Andreas

4

01 Oct 2012

fexact( varargin )
Hypergeometric cumulative distribution (left, right and two-tailed) including permutation testing.

Yosiaki. Sorry you are having difficulty. inputParser is a built-in Matlab function that was introduced around 2010. As stated in the information section of this function, the program was tested on Matlab 2010b. You will need to upgrade your Matlab software to a more recent version.

Comment only