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 leastsqfn.

global myP;
global parmfitjac;

m = size(myP,1); % get row number of myP
n = size(x,1); % for column number of jacobian
retval = zeros(m,n);
for ii = 1:m
  retval(ii,:) = feval(parmfitjac,x,myP(ii,:));
end;
