Skip to content

Commit

Permalink
refined doc for common and other functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Feb 21, 2016
1 parent 5f08e90 commit 0260b34
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions common/gsog.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function [Q, R] = gsog(X)
% Gram-Schmidt orthogonalization
% Written by Mo Chen ([email protected]).
[d,n] = size(X);
m = min(d,n);
R = eye(m,n);
Expand Down
1 change: 1 addition & 0 deletions common/gson.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function [Q, R] = gson(X)
% Gram-Schmidt orthonormalization which produces the same result as [Q,R]=qr(X,0)
% Written by Mo Chen ([email protected]).
[d,n] = size(X);
m = min(d,n);
R = zeros(m,n);
Expand Down
3 changes: 2 additions & 1 deletion common/invpd.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function W = invpd(M)
% Compute A\B where A is a positive definite matrix
% A: a positive difinie matrix
% Input:
% M: a positive difinie matrix
% Written by Michael Chen ([email protected]).
[U,p] = chol(M);
if p > 0
Expand Down
2 changes: 1 addition & 1 deletion common/log1pexp.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function y = log1pexp(x)
% accurately compute y = log(1+exp(x))
% Accurately compute y = log(1+exp(x))
% reference: Accurately Computing log(1-exp(|a|)) Martin Machler
seed = 33.3;
y = x;
Expand Down
2 changes: 1 addition & 1 deletion common/logsumexp.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function s = logsumexp(X, dim)
% Compute log(sum(exp(X),dim)) while avoiding numerical underflow.
% By default dim = 1 (columns).
% Written by Michael Chen ([email protected]).
% Written by Mo Chen ([email protected]).
if nargin == 1,
% Determine which dimension sum will use
dim = find(size(X)~=1,1);
Expand Down
1 change: 1 addition & 0 deletions common/mgsog.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function [Q, R] = mgsog(X)
% Modified Gram-Schmidt orthogonalization
% Written by Mo Chen ([email protected]).
[d,n] = size(X);
m = min(d,n);
R = eye(m,n);
Expand Down
1 change: 1 addition & 0 deletions common/mgson.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function [Q, R] = mgson(X)
% Modified Gram-Schmidt orthonormalization (numerical stable version of Gram-Schmidt algorithm)
% which produces the same result as [Q,R]=qr(X,0)
% Written by Mo Chen ([email protected]).
[d,n] = size(X);
m = min(d,n);
R = zeros(m,n);
Expand Down
2 changes: 1 addition & 1 deletion common/solvpd.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function V = solvpd(A,B)
% Compute A\B where A is a positive definite matrix
% A: a positive difinie matrix
% Written by Michael Chen ([email protected]).
% Written by Mo Chen ([email protected]).
[U,p] = chol(A);
if p > 0
error('ERROR: the matrix is not positive definite.');
Expand Down
2 changes: 1 addition & 1 deletion common/standardize.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function [Y, s] = standardize(X)
% Unitize the vectors to be unit length
% By default dim = 1 (columns).
% Written by Michael Chen ([email protected]).
% Written by Mo Chen ([email protected]).
if nargin == 1,
% Determine which dimension sum will use
dim = find(size(X)~=1,1);
Expand Down
2 changes: 1 addition & 1 deletion common/symeig.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% Compute eigenvalues and eigenvectors of symmetric matrix
% m == 's' smallest (default)
% m == 'l' largest
% Written by Michael Chen ([email protected]).
% Written by Mo Chen ([email protected]).
if nargin == 2
m = 's';
end
Expand Down
1 change: 1 addition & 0 deletions common/ud.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function [U, D] = ud(X)
% UD factorization U'*D*U=X'*X;
% Written by Mo Chen ([email protected]).
[~,R] = qr(X,0);
d = diag(R);
D = d.^2;
Expand Down
2 changes: 1 addition & 1 deletion common/unitize.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function [Y, s] = unitize(X, dim)
% Unitize the vectors to be unit length
% By default dim = 1 (columns).
% Written by Michael Chen ([email protected]).
% Written by Mo Chen ([email protected]).
if nargin == 1,
% Determine which dimension sum will use
dim = find(size(X)~=1,1);
Expand Down
3 changes: 2 additions & 1 deletion other/loggmpdf.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function r = loggmpdf(X, model)

% Compute log pdf of a Gaussian mixture model.
% Written by Mo Chen ([email protected]).
mu = model.mu;
Sigma = model.Sigma;
w = model.weight;
Expand Down
3 changes: 2 additions & 1 deletion other/plotgm.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function plotgm(X, model)
% Written by Michael Chen ([email protected]).
% Plot 2d Gaussian mixture model.
% Written by Mo Chen ([email protected]).
level = 64;
n = 256;

Expand Down
4 changes: 2 additions & 2 deletions other/plotkde.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function plotkde(X, sigma2)
% Written by Michael Chen ([email protected]).

% Plot 2d kernel density.
% Written by Mo Chen ([email protected]).
if nargin < 2
sigma2 = 1e-1;
end
Expand Down

0 comments on commit 0260b34

Please sign in to comment.