| [n,dx,incx,dy,incy,dc,ds]=drot(n,dx,incx,dy,incy,dc,ds); |
function [n,dx,incx,dy,incy,dc,ds]=drot(n,dx,incx,dy,incy,dc,ds);
persistent firstCall i kx ky nsteps one 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;
%***BEGIN PROLOGUE DROT
%***PURPOSE Apply a plane Givens rotation.
%***LIBRARY SLATEC (BLAS)
%***CATEGORY D1A8
%***TYPE doubleprecision (SROT-S, DROT-D, CSROT-C)
%***KEYWORDS BLAS, GIVENS ROTATION, GIVENS TRANSFORMATION,
% LINEAR ALGEBRA, PLANE 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)
% DX doubleprecision vector with N elements
% INCX storage spacing between elements of DX
% DY doubleprecision vector with N elements
% INCY storage spacing between elements of DY
% DC D.P. element of rotation matrix
% DS D.P. element of rotation matrix
%
% --Output--
% DX rotated vector DX (unchanged if N .LE. 0)
% DY rotated vector DY (unchanged if N .LE. 0)
%
% Multiply the 2 x 2 matrix ( DC DS) times the 2 x N matrix (DX**T)
% (-DS DC) (DY**T)
% where **T indicates transpose. The elements of DX are in
% DX(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else
% LX = 1+(1-N)*INCX, and similarly for DY using LY and INCY.
%
%***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 DROT
if isempty(zero), zero=0; end;
if isempty(one), one=0; end;
if isempty(w), w=0; end;
if isempty(z), z=0; end;
dx_shape=size(dx);dx=reshape(dx,1,[]);
dy_shape=size(dy);dy=reshape(dy,1,[]);
if firstCall, zero =[0.0d0]; end;
if firstCall, one=[1.0d0]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT DROT
if( ~(n<=0 ||(ds==zero && dc==one)) )
if( incx~=incy || incx<=0 )
%
% Code for unequal or nonpositive increments.
%
kx = 1;
ky = 1;
%
if( incx<0 )
kx = fix(1 -(n-1).*incx);
end;
if( incy<0 )
ky = fix(1 -(n-1).*incy);
end;
%
for i = 1 : n;
w = dx(kx);
z = dy(ky);
dx(kx) = dc.*w + ds.*z;
dy(ky) = -ds.*w + dc.*z;
kx = fix(kx + incx);
ky = fix(ky + incy);
end; i = fix(n+1);
else;
%
% Code for equal and positive increments.
%
nsteps = fix(incx.*n);
for i = 1 : incx: nsteps ;
w = dx(i);
z = dy(i);
dx(i) = dc.*w + ds.*z;
dy(i) = -ds.*w + dc.*z;
end; i = fix(nsteps +1);
end;
end;
%
dx_shape=zeros(dx_shape);dx_shape(:)=dx(1:numel(dx_shape));dx=dx_shape;
dy_shape=zeros(dy_shape);dy_shape(:)=dy(1:numel(dy_shape));dy=dy_shape;
end
%DECK DROTG
|
|