Is it possible to report built-in functions and provide alternative for further releases?

조회 수: 5 (최근 30일)
I've found that a pretty basic built-in function nchoosek is far from ideal, and I have a way to improve it. Is it possible to report it somehow? Here's the code for nchoosek:
function c = nchoosek(v,k)
% the function, not really interesting, only the combs part
end
%----------------------------------------
function c = binCoef(n,k,classOut)
%a helper function, also not important
end
%----------------------------------------
function P = combs(v,m)
%COMBS All possible combinations.
% ...
v = v(:).'; % Make sure v is a row vector.
n = length(v);
if n == m
P = v;
elseif m == 1
P = v.';
else
P = [];
if m < n && m > 1
for k = 1:n-m+1
Q = combs(v(k+1:n),m-1);
P = [P; [v(ones(size(Q,1),1),k) Q]]; %#ok %<--- here's the problem
end
end
end
end
The problem is obviously at the %#ok line. That is not OK and runs really slow. We know the size prior, so preallocating is not a problem. My proposition is the following really simple algorithm for combs(1:n,m)
function [P] = combs(n, m)
%COMBS
vals = 1:m;
total = nchoosek(n, m);
P = zeros(total, m);
for I=1:total
P(I, :) = vals;
for M = m:-1:1
if vals(M)<n-m+M
vals(M) = vals(M)+1;
for MM = (M+1):m
vals(MM) = vals(M) + MM - M;
end
break;
end
end
end
end
Clearly this problem received some exposure by this question but I wonder if there's a way to do this directly.
  댓글 수: 3
Stephen23
Stephen23 2018년 8월 26일
편집: Stephen23 2018년 8월 26일
@Bodnar Levente: when you start the bug report ("service request") process one of the first options is "Technical Support: Installation, product help, bugs, suggestions, documentation errors, outages"
Clearly what you have is a "suggestion".

댓글을 달려면 로그인하십시오.

채택된 답변

Steven Lord
Steven Lord 2018년 8월 25일
If you believe you've found a bug or have a suggestion for an enhancement request, please contact Technical Support using the Contact Us link in the upper-right corner of this page.
  댓글 수: 1
Lew
Lew 2018년 8월 25일
Thanks, I will. I've found the link you mentioned before, but I have a student license and it says for students that:
Technical support from MathWorks is available for activation, installation and bug-related issues.
So I just stopped there.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by