Search Comments and Ratings

go

Comments and Ratings

   
Date File Comment by Comment Rating
25 Nov 2009 N-dimensional histogram Compute n-dimensional histogram Author: Bruno Luong Luong, Bruno

Will, you better post the plotting problem on the newsgroup. I suggest to take a look at BAR3 function for the moment.

24 Nov 2009 'c' language style code for dilation A 'c' style code for dilation Author: Rama Chandra Rao Naradasu Luong, Bruno

Matlab programming requires different approach and style than C programming. I suggest the OP to consider seriously the two comments the code has received and I hope he will improve his code.

23 Nov 2009 Random Hermitian Matrix Generator Generates a random nxn Hermitian matrix. Author: Marcus Luong, Bruno

No H1 line
there is zero comment in the code
unnecessary loops
no preallocation
no probability distribution is given or user configurable

23 Nov 2009 Fast 2D histogram calculation Fast calculation of 2D histogram. Optionally displays surf plot of histogram. Author: Amanda Luong, Bruno

Speed is decent, but still cannot beat another more generic histogram submission:

>> tic; [Hout xbins ybins] = hist2d(x); toc
Elapsed time is 0.282145 seconds.

>> tic; [count xbins ybins] = histcn(x,xbins,ybins); toc
Elapsed time is 0.218104 seconds.

http://www.mathworks.com/matlabcentral/fileexchange/23897-n-dimensional-histogram

Let alone an even faster mex implementation
http://www.mathworks.com/matlabcentral/fileexchange/3957

So I would change the implicit speed claim in the title.

Bruno

12 Nov 2009 polyvalm2 - A faster matrix polynomial evaluator polyvalm2 evaluates a polynomial with a matrix argument faster than the MATLAB function polyvalm. Author: James Tursa Luong, Bruno

Neatly coded. How often do you see a Matlab stock matrix function get beaten in speed?

10 Nov 2009 polyvalm2 - A faster matrix polynomial evaluator polyvalm2 evaluates a polynomial with a matrix argument faster than the MATLAB function polyvalm. Author: James Tursa Luong, Bruno

I wish James could do a treatment for SPARSE matrix, because initialize an intermediate matrix with EYE is sometime not an option with large (sparse matrix).

23 Oct 2009 Conjugate Gradient Optimizer This routine lets you optimize large scale linear systems Author: Peter Luong, Bruno

Not sure what advantage of conjgrad over Matlab builtin function LSQR (where preconditioning is possible):

x = lsqr(@afun,b);
    
function y = afun(x,transp_flag)
        if strcmp(transp_flag,'transp')
            y = A'*x;
        else
            y = A*x;
        end
    end

10 Oct 2009 ISMEMBERF Floating-point ISMEMBER (i.e., with round-off tolerance) Author: Bruno Luong Luong, Bruno

Thank you David for pointing out the bug. I better workaround IMO is change the line #257 to:
dS = realmin(class(S));
while the new version of ISMEMBERF is submitted.

28 Sep 2009 Min/Max selection Search for k smallest or largest elements in the array Author: Bruno Luong Luong, Bruno

Marcello,

Do you have MEX setup? If not, type he following in command line:
>> mex -setup

If it's already installed you have to locate mexopts.bat file somewhere under the directory $MATLABROOT (where the Matlab is installed), then modify OPTPATH variable in line #8 and line #12 of GETMEXOPTS.

then try installation again.

Bruno

27 Sep 2009 Don't let that INV go past your eyes; to solve that system, FACTORIZE! A simple-to-use object-oriented method for solving linear systems and least-squares problems. Author: Tim Davis Luong, Bruno

What mathworks are waiting to incorporate this package into Matlab?

05 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu Luong, Bruno

To make the function work for other integer class, I would suggest to modify the two lines:

d=diff([NaN; x]);
d=[true; d~=0];

to:

d=diff(x);
d=[true; d~=0];

Otherwise unexpected result is obtained with
[u p]=numunique(uint8([0 1]))

04 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu Luong, Bruno

Good coding

15 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Luong, Bruno

What a relief to have finally a basic int64 arithmetic operators supported.

14 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Luong, Bruno

It is also puzzling this can work

a=int64([0 1; 2 3])
b=int64([4 5 6 7]')
a+b

14 Jul 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter Luong, Bruno

After a quick look I have few comments that I wish the author could correct:

As stated, the C Mex can't be compiled by the popular MS VISUAL C (type LONG LONG must be replaced by __int64)

It is dangerous when no checking is performed after mxDuplicateArray that could returns NULL and results in a crash if there is not enough memory.

14 Jul 2009 nearest_neighbour_3D This function compute the nearest neighbours by Euclidean distance. Author: Andreas Richter Luong, Bruno

- Computing the minimum distances for all pair of points is not a good way to compute nearest neighbor, and it's certainly not a fast one when the set of given points is large.

- As the author has warned, this method cannot handle large size data.

- The mfile miss the H1 line. When user type "help compute_nearest_neighbour' he/she would not know how to call the function, unless he is the author.

This function can accomplish with an equivalent stock function, which performs much faster. Here is the demo using new stock class in 2009A which is 10 time faster. For older Matlab version similar Delanay technique can be used to accomplish the same task as well.

% Data
n = 5000;
canditate_points=randn(n,3);
given_points=randn(n,3);

tic
nearest_neighbour=nearestNeighbor(DelaunayTri(canditate_points),given_points);
toc % Elapsed time is 0.322600 seconds.
clear idx

tic
[nearest_neighbour]=compute_nearest_neighbour(canditate_points,given_points);
toc % Elapsed time is 3.445318 seconds.
clear

03 Jul 2009 Longest Common Substring Gives the longest common substring between two stings. Author: David Cumin Luong, Bruno

30 Jun 2009 flattin/merging nested cells {{a}, b, {c,{d;e}}} --> {a,b,c,d,e} Author: Oleg Komarov Luong, Bruno

To Oleg: you could probably "simulate" the recursion algorithm by managing an artificial stack, which can be expanded when the limit is reached

30 Jun 2009 Longest Common Substring Gives the longest common substring between two stings. Author: David Cumin Luong, Bruno

Thank you, I see now. I suggest to update the help and describe more clearly what function does. It is also good if you could add few words about memory requirement/complexity and algorithm.

29 Jun 2009 Longest Common Substring Gives the longest common substring between two stings. Author: David Cumin Luong, Bruno

I still do not function understand what the function does:

X = [ 8 8 9 3 7 1 2 4 5 1 ]
Y = [ 7 6 6 10 2 7 9 4 1 1]

[D, dist, aLongestString] = LCS(X,Y)
D = 0.6000
dist = 4
aLongestString = [ 7 2 4 1]

% Furthermore what is the limit of the function?

>> X=ceil(10*rand(1,1e4));
>> Y=ceil(10*rand(1,1e4));
>> [D, dist, aLongestString] = LCS(X,Y)
??? Out of memory. Type HELP MEMORY for your options.

Error in ==> LCS at 20
b = zeros(n+1,m+1);
  

26 Jun 2009 Longest Common Substring Gives the longest common substring between two stings. Author: David Cumin Luong, Bruno

Code seems Buggy, even for the example provided

>> X='test', Y='stingtocompare'

X =

test

Y =

stingtocompare

>> [D, dist, aLongestString] = LCS(X,Y)
??? Attempted to access b(2,0); index must be a positive integer or logical.

Error in ==> LCS at 55
    if(b(i,j) == 3)
 
>>

26 Jun 2009 flattin/merging nested cells {{a}, b, {c,{d;e}}} --> {a,b,c,d,e} Author: Oleg Komarov Luong, Bruno

I'm no longer allowed to rate the submission, but I appreciate Oleg for his open mind (change the engine) for the benefit of the user community.

25 Jun 2009 flattin/merging nested cells {{a}, b, {c,{d;e}}} --> {a,b,c,d,e} Author: Oleg Komarov Luong, Bruno

FEX means "File Exchange". The recursion solution has its drawback, since Matlab the stack needs to be enlarged with respect to the cell nested level. The challenge is to have a method that is fast and requires less stack.

25 Jun 2009 flattin/merging nested cells {{a}, b, {c,{d;e}}} --> {a,b,c,d,e} Author: Oleg Komarov Luong, Bruno

Useful but this implementation runs slow for large and deep nested cell:

function benchflatcell

% Nested level
N = 100;
% Generate nested cell, the final size is N*(N+1)/2 = 5050
c={};
for i=1:N
    c = {num2cell(1:i) c};
end

tic
f1 = fcellrecurse(c); % receurse engine
toc % Elapsed time is 0.083139 seconds.

tic
f2 = flatcell(c); % FEX engine
toc % Elapsed time is 13.151985 seconds.

isequal(f1,f2) % OK

end

function c=fcellrecurse(c)
if iscell(c)
    c = cellfun(@fcellrecurse, c, 'UniformOutput', 0);
    c = cat(2,c{:});
else
    c = {c};
end

end % fcellrecurse

25 Jun 2009 kronecker Kronecker tensor product Author: Bruno Luong Luong, Bruno

To Matt's comment #2: 2D error checking is introduced in KRON in recent Matlab version. KORNECKER is designed to replicate the same behavior (desirable?).

A workaround (beside delete the error checing line) is:

A = reshape(A,size(A,1),[]);
B = reshape(B,size(B,1),[]);
C = kronecker(A,B);

15 Jun 2009 A*B = k*B*A Solves the homogeneous linear system A*B = k*B*A Author: John D'Errico Luong, Bruno

A small bug at line 70. It should be (transpose, not conjugate transpose in the second kron)
M = kron(eye(n),A) - kron(k*A.',eye(n))

15 Jun 2009 incircle.m In-circle of a convex polygon, or of the convex hull of a set of points in two dimensions Author: John D'Errico Luong, Bruno

The maximal inner circle problem is nicely formulated into LP problem. I only wish to extend the possibility to pass a list of edges with non-duplicated first/end points.

02 Jun 2009 COMBINATOR -combinations AND permutations Returns 1 of 4 different samplings on the set 1:N, taken K at a time. Author: Matt Fig Luong, Bruno

Two words: excellent job!

31 May 2009 N-dimensional histogram Compute n-dimensional histogram Author: Bruno Luong Luong, Bruno

To Bin Zhang:

The way HISTCN is design: If user supply m-edges [e1, e2, ..., e_m] then there are m-1 bins:

bin1 : e1 <= X < x2
bin2: e2 <= X < x3
...
bin-{m-1}: e_m-1 <= X < e_m

The Bin #m does not exist, unless if there is point hitting the right border:

X == e_m

You can indeed force the number of output bins to m by changing the line #66. to

sz(d) = length(ed)-1

Thanks,

Bruno

22 May 2009 FAST K-NEAREST NEIGHBORS SEARCH Simple but very fast algorithm for nearest neighbors search. Supports KNN and radius search. Author: Luigi Giaccari Luong, Bruno

Impressive running speed. I have tested against Matlab Delaunay/dsearch nearest point for 2 x 10^5 points and the code won hand down in speed. Very good work. I would like to see the author to provide mean/worse complexity of his algorithm, which is always necessary step when integrating in reliable software project.

19 May 2009 PARTITIONS Finds all partitions of a set, or only those partitions of a specified length. Includes a viewer. Author: Matt Fig Luong, Bruno

It needs some guts to tackle the partitioning problem in a non-recursive way. Matt has done it, great educational code.

18 May 2009 Set partition List all partitions a set n elements Author: Bruno Luong Luong, Bruno

Darren, thank you for the suggestion. I'll add an example of usage. Functions with more efficient engine will be soon upgraded.

21 Mar 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall Luong, Bruno

Inside the code, the author uses ACCUMARRAY on the values of the input array. This is a poor choice because it might create a large chunk of memory and slow down greatly.

Here is a code to check this effect. On my computer the worse time is 2.5 s, and unique can accomplish in less than 1 ms.

power=1:64;
time=zeros(length(power),2);

for k=1:length(power)
    
    twoelem=[0 2.^power(k)-1];
    disp(twoelem)
    
    tic
    count_unique(twoelem);
    time(k,1) = toc;
    
    tic
    unique(twoelem);
    time(k,2) = toc;
end
fprintf('worse time = %g s\n', max(time,[],1))
plot(power,time);
ylabel('second');
title('Time for array of two elements')
legend('count unique','unique')

02 Mar 2009 workspace create and manipulate variable names in the target workspace by using strings Author: Bruno Luong Luong, Bruno

Originally the WORKSPACE was developed under Matlab 2008B.
I (the author) have upgraded and tested the new version of the package (27 Jan 2009) for backward compatible to 2006B (tested under 2006B, 2007A, 2008B, and 2009A-prerelease). The workspace used the object-oriented programming (OOP) introduced officially by The Mathworks since 2008A. The file uses undocumented OOP feature and Java hashing for backward compatible.
I will be graceful if users of this package can report any eventual incompatible issue with previous versions.

24 Feb 2009 find_idx Fractional binning Author: Bruno Luong Luong, Bruno

Hi John,

Thanks for your comment. Fair enough. histc is fater than interp1. I also discovered this fact recently (after I developed this code and benchmark various methods in fact), and this is something I did not expected.

24 Feb 2009 workspace create and manipulate variable names in the target workspace by using strings Author: Bruno Luong Luong, Bruno

Hi us,

Thank you for your comment. In depth, despite of your note, there are two advantages of the code and it is totally fair to compare WORKSPACE with EVAL IMHO:

First: Within the WORKSPACE methods evalin is used for the sole purpose of retrieving the value of variable(s) from the workspace. Never evalin is evaluated with the RHS (statement with '=' sign').

Second: From the user point of view, he/she does not to worry about building EVAL with full statement. Expressions are evaluated directly, and no longer through string (except for the variable name) as with EVAL.

Bruno

 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com