Software Listing of Author : "Bruno Luong"
- 2D Polygon edges intersection
- License: Shareware
- Price:


Find the intersection points of the edges of two 2D polygons, a simple function made to follow up a Newsgroup discussion
- Publisher: Bruno Luong
- Date Released: 19-05-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- 2D polygon interior detection
- License: Shareware
- Price:


This function tries to improve the slow Matlab INPOLYGON function. There are few other fast codes on FEX (e.g., by Darren Engwirda). After exploring many different ways, I come to the conclusion that Darren Engwirda's approach is close to optimal. So here you'll find a general method that share many common aspects, but implemented in C-Mex. I have makes few contributions: (1) a lean C-implementation, (2) Using Matlab SORT and HISTC for binning, (3) Derive an empirical rule when to apply the sorting, (4) a more rigorous on-boundary detection.
- Publisher: Bruno Luong
- Date Released: 12-01-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- BSXCAT
- License: Shareware
- Price:


Examples: Insert the zeros-row on top of 3x3 matrix M = magic(3) bsxcat(1,0,M) Concatenate the ones-column on right of 3x3 matrix M = magic(3) bsxcat(2,M,1)
- Publisher: Bruno Luong
- Date Released: 08-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Cubed sphere
- License: Freeware
- Price: 0.00


Generate a Cartesian coordinates of the cubed-sphere of radius 1 the grid is gnomonic equiangular/equidistance central projection Inspired from this thread http://www.mathworks.com/matlabcentral/new...w_thread/258457
- Publisher: Bruno Luong
- Date Released: 16-04-2013
- Download Size: 369 KB
- Download
- Platform: Matlab, Scripts
- Euclidian projection on ellipsoid and conic
- License: Freeware
- Price: 0.00


Find the projection of point P in R^n on the ellipsoid E = { x = x0 + U*(z.*radii) : |z| = 1 }, where U is orthogonal matrix of the orientation of E, radii are the axis lengths, and x0 is the center. Or on generalized conic E = { x : x'*A*x + b'*x + c = 0 }. The projection is the minimization problem: min | x - P | (or max | x - P|) for x in E. Method: solve the Euler Lagrange equation with respect to the Lagrange multiplier, which can be written as polynomial equation (from an idea by Roger Stafford)
- Publisher: Bruno Luong
- Date Released: 19-05-2013
- Download Size: 31 KB
- Download
- Platform: Matlab, Scripts
- featurememstats
- License: Freeware
- Price: 0.00


Return same information than with Matlab command feature('memstats') but in structure form.
- Publisher: Bruno Luong
- Date Released: 18-06-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Least-square with 2-norm constraint
- License: Shareware
- Price:


This kind of problem arises in statistics, linear algebra, and regularization. The method uses quadratic eigen-value problem (QEP).
- Publisher: Bruno Luong
- Date Released: 20-01-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Merge sorted arrays
- License: Shareware
- Price:


Using this function avoids to call Matlab SORT(), which does unnecessary work since the two inputs is already sorted. Mex implementation for speed. 'rows' option supported
- Publisher: Bruno Luong
- Date Released: 01-06-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Min/Max filter
- License: Shareware
- Price:


The filter computes the minima and/or maxima of an array over sliding window with a given size. Multidimensional array is fully supported: running filter in 1D, 2D filter for image processing applications (erosion/dilatation), 3D and more. This package has been implemented with a special care on the running speed: the MEX engine uses an algorithms that requires no more than three (3) comparisons per element and per dimension in all configurations. All numerical and logical class arrays are supported. Contributor (beside author) is Vaclav Potesil
- Publisher: Bruno Luong
- Date Released: 12-04-2013
- Download Size: 31 KB
- Download
- Platform: Matlab, Scripts
- Min/Max filter for Mathematics
- License: Freeware
- Price: 0.00


It can eprform the following multidimensional array filtering: running filters in 1D and 2D, filters for image processing applications (erosion/dilatation), 3D and more. The MEX engine uses an algorithms that requires no more than three comparisons per element and per dimension in all configurations.
- Publisher: Bruno Luong
- Date Released: 01-04-2013
- Download Size: 20 KB
- Download
- Platform: Matlab, Scripts
- mmtimes: matrix chain product
- License: Shareware
- Price:


Because the matrix multiplication is associative; the product can be carried with different order, leading to the same result up to round-off error, MMTIMES usings "optimal" order of binary product to reduce the computational effort (probably accuracy is also improved) The function assumes the cost of the product of (m x n) with (n x p) matrices is (m*n*p). This assumption is typically true for full matrix.
- Publisher: Bruno Luong
- Date Released: 15-06-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- MPS format exporting tool
- License: Freeware
- Price: 0.00


Build MPS matrix string that contains linear programming problem: Minimizing (for x in R^n): f(x) = cost'*x, subject to A*x <= b (LE) Aeq*x = beq (EQ) L <= x <= U (BD). Only single rhs (b and beq) is supported. The MPS file format was introduced for an IBM program, but has also been accepted by most subsequent linear programming codes. To learn about MPS format, please see: http://lpsolve.sourceforge.net/5.5/mps-format.htm http://www-fp.mcs.anl.gov/OTC/Guide/OptWeb...arprog/mps.html
- Publisher: Bruno Luong
- Date Released: 05-06-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Multiple eigen-values for 2x2 and 3x3 matrices
- License: Shareware
- Price:


Note that this function do not return EIGEN VECTORS. This function is faster than looping on EIG when eigenvalues must be computed for a large number of matrices. The test shows it can speed up by 10 times
- Publisher: Bruno Luong
- Date Released: 23-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Multiple-Colon
- License: Shareware
- Price:


Return a concatenation of multiple colon-intervals. User provides left, step, and right bound. >> mcolon([0 10],[1 2],[2 14]) ans = 0 1 2 10 12 14
- Publisher: Bruno Luong
- Date Released: 24-02-2013
- Download Size: 20 KB
- Download
- Platform: Matlab, Scripts
- N-dimensional histogram
- License: Shareware
- Price:


Like histc but for n-dimension. Unlike the other nd histogram http://www.mathworks.com/matlabcentral/fileexchange/3957 beside counting, this function returns also the location of points in the bins. Coded entirely in Matlab (no mex required). Speed slightly slower (but quite decent). User can data and/or function for specific need of accumulator on each patch
- Publisher: Bruno Luong
- Date Released: 22-01-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Plot earth
- License: Freeware
- Price: 0.00


Plot earth in 3D sphere Several maps and resolutions are available More comprehensive map collection is available at http://www.mediafire.com/?m2mn1mgdngt
- Publisher: Bruno Luong
- Date Released: 23-01-2013
- Download Size: 18248 KB
- Download
- Platform: Matlab, Scripts
- Pseudo-inverse
- License: Shareware
- Price: 79.95


With Pseudo-inverse you can factorize a matrix for pseudo-inverse to solve the normal equation:
A*x = b
There are two advantages of pseudo-inverse compared to MATLAB pinv:
PINV requires costly SVD
PINV does not operated with sparse matrix.
The solution x minimize the 2-norm of the residual |Ax - b|.
In case of underdetermined system, i.e., rank(A) < length(x), the solution returned by pseudoinverse(A)*b is the least 2-norm among all solutions. Note that this property does *not* meet if backslash operator is used: x = A*.
- Publisher: Bruno Luong
- Date Released:
- Download Size: 10 KB
- Download
- Platform: WinOther
- RANDSUBSET
- License: Shareware
- Price:


A = RANDSUBSET(N, K) is equivalent to ALLSUBSETS = NCHOOSEK(1:N,K); A = ALLSUBSETS(RANDI(NCHOOSEK(N,K))); % or A = RANDPERM(N); A = SORT(A(1:k)); This function can also be used to generate random sampling without replacement by calling RANDPERM on the output. It works advantageously with large N (but "reasonable" K), and fast!
- Publisher: Bruno Luong
- Date Released: 25-06-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Small size linear solver
- License: Shareware
- Price:


Solve multiple (2x2) or (3x3) linear systems: A(:,:,k)*X(:,:,k) = B(:,:,k) for k=1,2,...,N The method used here is basic cofactor/determinant. DISADVANTAGE: This method may be less accurate than Matlab backslash (using in for-loop) when the matrices are ill-conditioned. ADVANTAGE: for a large number of systems - the speed-up is about 15-30 fold.
- Publisher: Bruno Luong
- Date Released: 09-06-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts
- Vectorized FIND with 'FIRST' option
- License: Shareware
- Price:


Up to now, to find the first non-zero element of a matrix along a column (for example) user might: 1. Use for-loop with FIND command for j=1:size(A,2) ... = find(A(:,j), 1, 'first'); end 2. Use other vectorized methods, often time not very straight-forwards (MAX, LOGICAL, SPARSE, etc...). This method creates temporary arrays and scan such the arrays few times while doing some calculation. 3. Write the basic FOR-LOOP algorithm to accomplish the task. The FINDFIRST command does just the same, but implemented using MEX engine which should be faster than any of the above. It can handle 'FIRST', 'LAST' option, and return more than one FIND count. NOTE: not yet tested on Linux (gcc)
- Publisher: Bruno Luong
- Date Released: 12-02-2013
- Download Size: 10 KB
- Download
- Platform: Matlab, Scripts