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]=scopym(n,sx,incx,sy,incy);
function [n,sx,incx,sy,incy]=scopym(n,sx,incx,sy,incy);
persistent i ix iy m mp1 ns ; 

if isempty(i), i=0; end;
if isempty(ix), ix=0; end;
if isempty(iy), iy=0; end;
if isempty(m), m=0; end;
if isempty(mp1), mp1=0; end;
if isempty(ns), ns=0; end;
%***BEGIN PROLOGUE  SCOPYM
%***PURPOSE  Copy the negative of a vector to a vector.
%***LIBRARY   SLATEC (BLAS)
%***CATEGORY  D1A5
%***TYPE      SINGLE PRECISION (SCOPYM-S, DCOPYM-D)
%***KEYWORDS  BLAS, COPY, VECTOR
%***AUTHOR  Kahaner, D. K., (NBS)
%***DESCRIPTION
%
%       Description of Parameters
%           The * Flags Output Variables
%
%       N   Number of elements in vector(s)
%      SX   Real vector with N elements
%    INCX   Storage spacing between elements of SX
%      SY*  Real negative copy of SX
%    INCY   Storage spacing between elements of SY
%
%      ***  Note that SY = -SX  ***
%
%     Copy negative of real SX to real SY.  For I=0 to N-1,
%     copy  -SX(LX+I*INCX) to SY(LY+I*INCY), where LX=1 if
%     INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is defined
%     in a similar way using INCY.
%
%***REFERENCES  (NONE)
%***ROUTINES CALLED  (NONE)
%***REVISION HISTORY  (YYMMDD)
%   801001  DATE WRITTEN
%   890831  Modified array declarations.  (WRB)
%   890831  REVISION DATE from Version 3.2
%   891214  Prologue converted to Version 4.0 format.  (BAB)
%   920310  Corrected definition of LX in DESCRIPTION.  (WRB)
%***end PROLOGUE  SCOPYM
sx_shape=size(sx);sx=reshape(sx,1,[]);
sy_shape=size(sy);sy=reshape(sy,1,[]);
%***FIRST EXECUTABLE STATEMENT  SCOPYM
if( n<=0 )
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;
return;
end;
if( incx==incy )
if( incx<1 )
elseif( incx==1 ) ;
%
%     Code for both increments equal to 1.
%
%     Clean-up loop so remaining vector length is a multiple of 7.
%
m = fix(rem(n,7));
if( m~=0 )
for i = 1 : m;
sy(i) = -sx(i);
end; i = fix(m+1);
if( n<7 )
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;
return;
end;
end;
mp1 = fix(m + 1);
for i = mp1 : 7: n ;
sy(i) = -sx(i);
sy(i+1) = -sx(i+1);
sy(i+2) = -sx(i+2);
sy(i+3) = -sx(i+3);
sy(i+4) = -sx(i+4);
sy(i+5) = -sx(i+5);
sy(i+6) = -sx(i+6);
end; i = fix(n +1);
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;
return;
else;
%
%     Code for equal, positive, non-unit increments.
%
ns = fix(n.*incx);
for i = 1 : incx: ns ;
sy(i) = -sx(i);
end; i = fix(ns +1);
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;
return;
end;
end;
%
%     Code for unequal or nonpositive increments.
%
ix = 1;
iy = 1;
if( incx<0 )
ix =fix((-n+1).*incx + 1);
end;
if( incy<0 )
iy =fix((-n+1).*incy + 1);
end;
for i = 1 : n;
sy(iy) = -sx(ix);
ix = fix(ix + incx);
iy = fix(iy + incy);
end; i = fix(n+1);
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;
return;
end
%DECK SCOV

Contact us at files@mathworks.com