LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_grnmol.m
1%{
2%{
3 % @file pfqn_grnmol.m
4 % @brief Normalizing constant using Grundmann-Moeller quadrature.
5%}
6%}
7
8%{
9%{
10 % @brief Normalizing constant using Grundmann-Moeller quadrature.
11 % @fn pfqn_grnmol(L, N)
12 % @param L Service demand matrix.
13 % @param N Population vector.
14 % @return G Normalizing constant.
15%}
16%}
17function G=pfqn_grnmol(L,N)
18[M,R]=size(L);
19G=0;
20% ceil binds to the whole quotient: written as ceil(sum(N)-1)/2 it produced a
21% HALF-INTEGER S for even sum(N), and zeros(1+S,1) then errored outright, so
22% the function was uncallable for even populations. Identical for odd sum(N).
23S=ceil((sum(N)-1)/2);
24H=zeros(1+S,1);
25c=zeros(1,1+S);
26w=zeros(1,1+S);
27for i=0:S
28 c(1+i)=2*(S-i)+M;
29 w(1+i)=2^-(2*S)*(-1)^i*c(1+i)^(2*S+1)/factorial(i)/factorial(i+c(1+i));
30 [s,bvec,SD,D]=sprod(M,S-i); bvec=bvec';
31 while bvec(1)>=0
32 H(1+i) = H(1+i) + prod((((2*bvec+1)/c(1+i))*L).^N);
33 [s,bvec]=sprod(s,SD,D); bvec=bvec';
34 end
35 G = G + w(1+i)*H(1+i);
36end
37G=G*factorial(sum(N)+M-1)/prod(factorial(N));
38end