function [c,s,r]=rot(f,g)

if (f==0)
    c=0;
    s=1;
    r=g;
elseif (abs(f)>abs(g))
    t=g/f;
    t1=(1+t^2)^(.5);
    c=1/t1; s=c*t; r=f*t1;
else
    t=f/g;
    t1=(1+t^2)^(.5);
    s=1/t1; c=s*t; r=g*t1;
end

    

