| Description of sllemap |
sllemap
PURPOSE 
SLLEMAP Solves Laplacian Eigenmap Embedding
SYNOPSIS 
function [Y, spectrum] = sllemap(G, d, sch)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- slmulrowcols SLMULROWCOLS Multiplies the vectors to all rows and all columns
- slmulvec SLMULVEC multiplies a vector to columns or rows of a matrix
- slsymeig SLSYMEIG Compute the eigenvalues and eigenvectors for symmetric matrix
- sladjmat SLADJMAT Constructs the adjacency matrix representation of a graph
- slgraphinfo SLGRAPHINFO Extracts basic information of a given graph representation
- raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:
SUBFUNCTIONS 
SOURCE CODE 
0001 function [Y, spectrum] = sllemap(G, d, sch)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 if nargin < 2
0071 raise_lackinput('sllemap', 2);
0072 end
0073
0074 gi = slgraphinfo(G, {'square'});
0075 n = gi.n;
0076 if strcmp(gi, 'adjmat')
0077 if isnumeric(G)
0078 W = G;
0079 else
0080 W = double(G);
0081 end
0082 else
0083 W = sladjmat(G);
0084 end
0085
0086 if d >= n
0087 error('sltoolbox:invalidarg', ...
0088 'The embeded dimension d should be strictly less than n');
0089 end
0090
0091 if nargin < 3 || isempty(sch)
0092 sch = 'maxWD';
0093 end
0094
0095
0096
0097
0098
0099
0100
0101
0102 W = W + W';
0103
0104 switch sch
0105 case 'maxWD'
0106 [Y, spectrum] = solve_maxWD(W, d);
0107 case 'minLD'
0108 [Y, spectrum] = solve_minLD(W, d);
0109 case 'minLI'
0110 [Y, spectrum] = solve_minLI(W, d);
0111 otherwise
0112 error('sltoolbox:invalidarg', ...
0113 'Invalid scheme for solving eigenmap: %s', sch);
0114 end
0115
0116
0117
0118 function [Y, spectrum] = solve_maxWD(W, d)
0119
0120 vD = calcDv(W);
0121 W = calcNormalizeMat(W, vD);
0122
0123 [spectrum, Y] = slsymeig(W, d+1, 'descend');
0124 spectrum = spectrum(2:d+1);
0125 Y = Y(:, 2:d+1)';
0126 Y = denormY(Y, vD);
0127
0128 function [Y, spectrum] = solve_minLD(W, d)
0129
0130 vD = calcDv(W);
0131 L = calcL(vD, W);
0132 L = calcNormalizeMat(L, vD);
0133
0134 [spectrum, Y] = slsymeig(L, d+1, 'ascend');
0135 spectrum = spectrum(2:d+1);
0136 Y = Y(:, 2:d+1)';
0137 Y = denormY(Y, vD);
0138
0139
0140 function [Y, spectrum] = solve_minLI(W, d)
0141
0142 vD = calcDv(W);
0143 L = calcL(vD, W);
0144
0145 [spectrum, Y] = slsymeig(L, d+1, 'ascend');
0146 spectrum = spectrum(2:d+1);
0147 Y = Y(:, 2:d+1)';
0148
0149
0150
0151
0152 function vD = calcDv(W)
0153
0154 vD = sum(W, 1)';
0155
0156 function L = calcL(vD, W)
0157
0158 n = length(vD);
0159 if issparse(W)
0160 D = sparse((1:n)', (1:n)', vD, n, n, n);
0161 L = D - W;
0162 else
0163 L = -W;
0164 dinds = (1:n)'*(n+1) - n;
0165 L(dinds) = L(dinds) + vD;
0166 end
0167
0168 function Mn = calcNormalizeMat(M, vD)
0169
0170 vD(vD < eps) = eps;
0171 cv = 1 ./ sqrt(vD);
0172
0173 if issparse(M)
0174 n = size(M,1);
0175 Mn = M;
0176 for i = 1 : n
0177 Mn(:,i) = Mn(:,i) * cv(i);
0178 end
0179 for i = 1 : n
0180 Mn(i,:) = Mn(i,:) * cv(i);
0181 end
0182 else
0183 rv = cv';
0184 Mn = slmulrowcols(M, rv, cv);
0185 end
0186
0187 function Y = denormY(Y, vD)
0188
0189 vD = vD';
0190 vD(vD < eps) = eps;
0191 Y = slmulvec(Y, 1 ./ sqrt(vD), 2);
0192
0193
0194
0195
Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003
|
|