% [f,e,sv,l,m,xi] = linsvmtrain(X,Y,C,dual) Train binary linear SVM
%
% This trains a linear SVM for binary classification. There are two cases:
% - Linearly separable case (C=NaN): optimal separating hyperplane, if one
%   exists (check the error code e to see whether the QP was feasible). It
%   doesn't return slack variables.
% - Not linearly separating case (0 < C < Inf): soft margin hyperplane.
%
% In:
%   X: NxL matrix, N L-dim data points rowwise.
%   Y: Nx1 vector, N labels in {-1,+1}.
%   C: nonnegative scalar, penalty parameter for the soft margin hyperplane.
%      C = NaN means the optimal separating hyperplane.
%   dual: 0 to solve the primal, 1 to solve the dual.
% Out:
%   f: (struct) the SVM.
%   e: quadprog's error code:
%      1 (KKT point), 0 (maxit exceeded), -2 (infeasible), -3 (unbounded), etc.
%   sv: list of indices in 1:N of the support vectors in X.
%   l: Nx1 vector, the Lagrange multiplier for each data point.
%   m: margin=1/|f.w|, distance from the hyperplane to its closest point in X.
%   xi: Nx1 vector, slack variable (constraint violation) for each data point
%      (not returned for the optimal separating hyperplane).

