function retval = leastsq(x)
% usage:  y = leastsq(x)
% description: returns least squares scalar
% function 1/2*||r(x)||^2 based on parameter
% set myP and function parmfitfn.

vec = feval('leastsqvec',x);
retval = 0.5*vec'*vec;