function [gam, x, P] = sextract(v, m, n)
% extract the 3 variables from the vector v, using smat, not mat
% the "s" in the name "sextract" is for symmetric, as in "smat"
gam = v(1);
x = v(2:m+1);
P = smat(v(m+2:m+1+n*(n+1)/2),n);
