Well, it's still my firm view that this algorithm (not the implementation) is awfully slow and no bit more general than other algorithms for restricted integer compositions.

For example, when I set n=16; a=1; b=4; and run

tic; jdoric(n,1,16,a,b); toc

this yields, on my computer, a run time of 21 seconds. Contrarily, when I run

tic; for k=1:16; colex(n,k,a,b); toc

this runs in 2.5 seconds. (Colex is the Vajnovszki/Vernay algorithm that is also available as a matlab implementation).

When I set n=18, run times become 289 seconds and 25.6 seconds, respectively.

So, why on earth would anyone want to use this slow algorithm?

Other issues:
1) The good rating of this algorithm here on mathworks appears to be manipulated.
2) You may wish to google "Corrections" to the Opdyke algorithm "A unified approach ..."

Alright, I agree, John D'Errico, that the argumentation should remain factual.

It's just really difficult to argue with Mr. Opdyke because he apparently doesn't understand some basic principles of the things he has published about. Writing problematic papers is one thing, defending errors beyond reason is another. Whatever his contributions in his paper have been, they have neither been the provision of solutions to open problems nor the provision of a general algorithm for solving the restricted integer composition/partition problem. I think that the "success" of his paper is due to self-promotion - and recipients of his work should be made aware of his paper's and algorithm's deficiencies.

In the interest of his readers, I have summarized my points of critique in a pdf file.
http://www.adiuvaris.org/correction.pdf

Well, it is really extremely simple. The JD Opdyke paper has the following major flaws:

1) The Odyke algorithm takes O(k) time per composition of n with k parts. Thus, the algorithm is inefficient.

2) The counting formulae are copied from previous work and sold as new. It is well-known that the number of compositions of n with k parts, each in a set A, satisfies the recursion:

c_A(n,k) = sum_{a in A} c_A(n-a,k-1)

(see Heubach and Mansour, Compositions of n with parts in a set A, Proof of Theorem 2.1)
Specializing to A={1,...,r} gives the formulas that the JD Opdyke paper derives as "novel".

3) All errors made concerning compositions translate to partitions (which are just ordered compositions)

4) An algorithm that runs in time O(k) per composition needs not solve the restricted integer composition problem in its full generality (arbitrary lower and upper bounds a and b) since the general case can be reduced to a=0.

5) To worsen things for the Opdyke paper, the algorithm solves the problem with upper and lower bounds on the NUMBER OF PARTS in a quite silly way by simply invoking the inefficient Opdyke algorithm for each part.

6) This said, the Vajnovszki algorithm is trivially as general as the Opdyke algorithm is and runs incredibly much faster as k increases since it is not inefficient.

[a,v]=seqAlign(x,y,steps,@mysimilarity);
% Output will be in this case
%a =
%
% 1 1 2 1 1 1 1
% 2 1 2 1 1 1 1
%
%v = 18
%
% Return value <a> corresponds to the
% alignment:
%
% 1 2 2 3 3 2 1 2
% 1 3 2 3 2 3 2 1 2
end

function sim=mysimilarity(sub1,sub2);
% just a very silly similarity function
% <sub1> and <sub2> are subsequences

sim=-2;
k1 = length(sub1);
k2 = length(sub2);

if isequal([k1 k2],[1 1])
if sub1==sub2 % 1-1 identity (match)
sim = 3;
end
end

if isequal([k1 k2],[2 2])
if sub1(1)==sub2(2) && sub1(2)==sub2(1) % transposition
sim = 2;
end
end

if isequal([k1 k2],[1 2]) || isequal([k1 k2],[2 1])
sim = sum(sub1==sub2); % in case of squashing or expansion, we let similarity be the number of matches