function [gX,normgX] = calcgx(net,X,PD,BZ,IWZ,LWZ,N,Ac,E,perf,Q,TS);
%CALCGX Calculate weight and bias performance gradient as a single vector.
%
%	Syntax
%
%	  [gX,normgX] = calcgx(net,X,PD,BZ,IWZ,LWZ,N,Ac,E,perf,Q,TS);
%
%	Warning!!
%
%	  This function may be altered or removed in future
%	  releases of the Neural Network Toolbox. We recommend
%	  you do not write code which calls this function.

% Mark Beale, 11-31-97
% Copyright (c) 1992-1998 by The MathWorks, Inc.
% $Revision: 1.4 $

dPerformFcn = feval(net.performFcn,'deriv');
gE = feval(dPerformFcn,'e',E,X,perf,net.performParam);
[gB,gIW,gLW] = calcgrad(net,Q,PD,BZ,IWZ,LWZ,N,Ac,gE,TS);
gX = formgx(net,gB,gIW,gLW) + feval(dPerformFcn,'x',E,X,perf,net.performParam);
normgX = sqrt(sum(sum(gX.^2)));
