home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
maths
/
rlab
/
controls
/
CTB
/
givens
< prev
next >
Wrap
Text File
|
1995-11-15
|
583b
|
34 lines
//-----------------------------------------------------------
//
// Givens rotation matrix (pp. 202 Golub and Van Loan)
//
//-----------------------------------------------------------
givens = function ( a , b )
{
local (b, c, s, tau);
if (a.n != 1 || b.n != 1)
{
error ("givens: A and B must be scalar");
}
if (b == 0)
{
c = 1;
s = 0;
else
if (abs (b) > abs (a))
{
tau = -a/b;
s = 1/sqrt (1 + tau^2);
c = s*tau;
else
tau = -b/a;
c = 1/sqrt (1 + tau^2);
s = c*tau;
}
}
return [c, s; -s, c];
};