Code covered by the BSD License  

Highlights from
slatec

from slatec by Ben Barrowes
The slatec library converted into matlab functions.

[n,sx,incx,sy,incy,sc,ss]=srot(n,sx,incx,sy,incy,sc,ss);
function [n,sx,incx,sy,incy,sc,ss]=srot(n,sx,incx,sy,incy,sc,ss);
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  SROT
%***PURPOSE  Apply a plane Givens rotation.
%***LIBRARY   SLATEC (BLAS)
%***CATEGORY  D1A8
%***TYPE      SINGLE PRECISION (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)
%       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
%       SC  element of rotation matrix
%       SS  element of rotation matrix
%
%     --Output--
%       SX  rotated vector SX (unchanged if N .LE. 0)
%       SY  rotated vector SY (unchanged if N .LE. 0)
%
%     Multiply the 2 x 2 matrix  ( SC SS) times the 2 x N matrix (SX**T)
%                                (-SS SC)                        (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.
%
%***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  SROT
if isempty(zero), zero=0; end;
if isempty(one), one=0; end;
if isempty(w), w=0; end;
if isempty(z), z=0; end;
sx_shape=size(sx);sx=reshape(sx,1,[]);
sy_shape=size(sy);sy=reshape(sy,1,[]);
if firstCall,   zero =[0.0e0];  end;
if firstCall,  one=[1.0e0];  end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT  SROT
if( ~(n<=0 ||(ss==zero && sc==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 = sx(kx);
z = sy(ky);
sx(kx) = sc.*w + ss.*z;
sy(ky) = -ss.*w + sc.*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 = sx(i);
z = sy(i);
sx(i) = sc.*w + ss.*z;
sy(i) = -ss.*w + sc.*z;
end; i = fix(nsteps +1);
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 SROTG

Contact us at files@mathworks.com