function P = mlsi(X,y,d,betta,gamma)
%MLSI MultiLabel Informed Latent Semantic Indexing
%   Xtrain: 1st feature matrix to project
%   Xval: 2nd feature matrix to project
%   X: NxD feature matrix
%   y: NxQ label matrix
%   betta[0;1]: parameter for tuning
%   gamma[0;...]: regularization parameter
%   d: the dimensionality to be reduced to

if ~exist('d','var')
    d = 80;
end
if ~exist('betta','var')
    betta = 0.5;
end
if ~exist('gamma','var')
    gamma = 0;
end

fprintf('Creating generalized eigenvalue problem...\n');
tic;
Kx = X*X';
Ky = y*y';
C = (1-betta)*Kx + betta*Ky;
A = Kx*Kx;
B = Kx/C*Kx+gamma*Kx;
toc;
clear C Kx Ky;

fprintf('Solving generalized eigenvalue problem...\n');
tic;
[V,L] = eigs(A,B,d);
toc;
clear A B;

fprintf('Calculating projecting matrix...\n');
tic;
P = sqrt(L)*V'*X;
toc;

end

