| [n,sx,incx,sy,incy,sparam]=srotm(n,sx,incx,sy,incy,sparam); |
function [n,sx,incx,sy,incy,sparam]=srotm(n,sx,incx,sy,incy,sparam);
persistent firstCall i kx ky nsteps sflag sh11 sh12 sh21 sh22 two w z zero ; if isempty(firstCall),firstCall=1;end;
if isempty(i), i=0; end;
if isempty(kx), kx=0; end;
if isempty(ky), ky=0; end;
if isempty(nsteps), nsteps=0; end;
if isempty(sflag), sflag=0; end;
if isempty(sh11), sh11=0; end;
if isempty(sh12), sh12=0; end;
if isempty(sh21), sh21=0; end;
if isempty(sh22), sh22=0; end;
if isempty(two), two=0; end;
if isempty(w), w=0; end;
if isempty(z), z=0; end;
if isempty(zero), zero=0; end;
%***BEGIN PROLOGUE SROTM
%***PURPOSE Apply a modified Givens transformation.
%***LIBRARY SLATEC (BLAS)
%***CATEGORY D1A8
%***TYPE SINGLE PRECISION (SROTM-S, DROTM-D)
%***KEYWORDS BLAS, LINEAR ALGEBRA, MODIFIED GIVENS ROTATION, VECTOR
%***AUTHOR Lawson, C. L., (JPL)
% Hanson, R. J., (SNLA)
% Kincaid, D. R., (U. of Texas)
% Krogh, F. T., (JPL)
%***DESCRIPTION
%
% B L A S Subprogram
% Description of Parameters
%
% --Input--
% N number of elements in input vector(s)
% SX single precision vector with N elements
% INCX storage spacing between elements of SX
% SY single precision vector with N elements
% INCY storage spacing between elements of SY
% SPARAM 5-element vector. SPARAM(1) is SFLAG described below.
% Locations 2-5 of SPARAM contain elements of the
% transformation matrix H described below.
%
% --Output--
% SX rotated vector (unchanged if N .LE. 0)
% SY rotated vector (unchanged if N .LE. 0)
%
% Apply the modified Givens transformation, H, to the 2 by N matrix
% (SX**T)
% (SY**T) , where **T indicates transpose. The elements of SX are
% in SX(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else
% LX = 1+(1-N)*INCX, and similarly for SY using LY and INCY.
%
% With SPARAM(1)=SFLAG, H has one of the following forms:
%
% SFLAG=-1.0E0 SFLAG=0.0E0 SFLAG=1.0E0 SFLAG=-2.0E0
%
% (SH11 SH12) (1.0E0 SH12) (SH11 1.0E0) (1.0E0 0.0E0)
% H=( ) ( ) ( ) ( )
% (SH21 SH22), (SH21 1.0E0), (-1.0E0 SH22), (0.0E0 1.0E0).
%
% See SROTMG for a description of data storage in SPARAM.
%
%***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
% Krogh, Basic linear algebra subprograms for Fortran
% usage, Algorithm No. 539, Transactions on Mathematical
% Software 5, 3 (September 1979), pp. 308-323.
%***ROUTINES CALLED (NONE)
%***REVISION HISTORY (YYMMDD)
% 791001 DATE WRITTEN
% 861211 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
% 920310 Corrected definition of LX in DESCRIPTION. (WRB)
% 920501 Reformatted the REFERENCES section. (WRB)
%***end PROLOGUE SROTM
sx_shape=size(sx);sx=reshape(sx,1,[]);
sy_shape=size(sy);sy=reshape(sy,1,[]);
if firstCall, zero =[0.0e0]; end;
if firstCall, two=[2.0e0]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT SROTM
sflag = sparam(1);
if( n>0 &&(sflag+two~=zero) )
if( incx~=incy || incx<=0 )
kx = 1;
ky = 1;
if( incx<0 )
kx = fix(1 +(1-n).*incx);
end;
if( incy<0 )
ky = fix(1 +(1-n).*incy);
end;
%
if( sflag<0 )
sh11 = sparam(2);
sh12 = sparam(4);
sh21 = sparam(3);
sh22 = sparam(5);
for i = 1 : n;
w = sx(kx);
z = sy(ky);
sx(kx) = w.*sh11 + z.*sh12;
sy(ky) = w.*sh21 + z.*sh22;
kx = fix(kx + incx);
ky = fix(ky + incy);
end; i = fix(n+1);
elseif( sflag==0 ) ;
sh12 = sparam(4);
sh21 = sparam(3);
for i = 1 : n;
w = sx(kx);
z = sy(ky);
sx(kx) = w + z.*sh12;
sy(ky) = w.*sh21 + z;
kx = fix(kx + incx);
ky = fix(ky + incy);
end; i = fix(n+1);
else;
sh11 = sparam(2);
sh22 = sparam(5);
for i = 1 : n;
w = sx(kx);
z = sy(ky);
sx(kx) = w.*sh11 + z;
sy(ky) = -w + sh22.*z;
kx = fix(kx + incx);
ky = fix(ky + incy);
end; i = fix(n+1);
end;
else;
%
nsteps = fix(n.*incx);
if( sflag<0 )
sh11 = sparam(2);
sh12 = sparam(4);
sh21 = sparam(3);
sh22 = sparam(5);
for i = 1 : incx: nsteps ;
w = sx(i);
z = sy(i);
sx(i) = w.*sh11 + z.*sh12;
sy(i) = w.*sh21 + z.*sh22;
end; i = fix(nsteps +1);
elseif( sflag==0 ) ;
sh12 = sparam(4);
sh21 = sparam(3);
for i = 1 : incx: nsteps ;
w = sx(i);
z = sy(i);
sx(i) = w + z.*sh12;
sy(i) = w.*sh21 + z;
end; i = fix(nsteps +1);
else;
sh11 = sparam(2);
sh22 = sparam(5);
for i = 1 : incx: nsteps ;
w = sx(i);
z = sy(i);
sx(i) = w.*sh11 + z;
sy(i) = -w + sh22.*z;
end; i = fix(nsteps +1);
end;
end;
end;
sx_shape=zeros(sx_shape);sx_shape(:)=sx(1:numel(sx_shape));sx=sx_shape;
sy_shape=zeros(sy_shape);sy_shape(:)=sy(1:numel(sy_shape));sy=sy_shape;
end
%DECK SROTMG
|
|