[Master Index] [Index for PublicToolbox/regutools]

pythag

(PublicToolbox/regutools/pythag.m in BrainStorm 2.0 (Alpha))


Function Synopsis

x = pythag(y,z)

Help Text

PYTHAG Computes sqrt( y^2 + z^2 ).

 x = pythag(y,z)

 Returns sqrt(y^2 + z^2) but is careful to scale to avoid overflow.

Cross-Reference Information

This function is called by

Listing of function C:\BrainStorm_2001\PublicToolbox\regutools\pythag.m

function x = pythag(y,z)
%PYTHAG Computes sqrt( y^2 + z^2 ).
%
% x = pythag(y,z)
%
% Returns sqrt(y^2 + z^2) but is careful to scale to avoid overflow.

% Christian H. Bischof, Argonne National Laboratory, 03/31/89.

rmax = max(abs([y;z]));
if (rmax==0)
  x = 0;
else
  x = rmax*sqrt((y/rmax)^2 + (z/rmax)^2);
end

Produced by color_mat2html, a customized BrainStorm 2.0 (Alpha) version of mat2html on Tue Oct 12 12:05:14 2004
Cross-Directory links are: ON