| [n,ix,incx,iy,incy]=icopy(n,ix,incx,iy,incy); |
function [n,ix,incx,iy,incy]=icopy(n,ix,incx,iy,incy);
persistent i iix iiy m mp1 ns ;
if isempty(i), i=0; end;
if isempty(iix), iix=0; end;
if isempty(iiy), iiy=0; end;
if isempty(m), m=0; end;
if isempty(mp1), mp1=0; end;
if isempty(ns), ns=0; end;
%***BEGIN PROLOGUE ICOPY
%***PURPOSE Copy a vector.
%***LIBRARY SLATEC (BLAS)
%***CATEGORY D1A5
%***TYPE INTEGER (ICOPY-S, DCOPY-D, CCOPY-C, ICOPY-I)
%***KEYWORDS BLAS, COPY, LINEAR ALGEBRA, VECTOR
%***AUTHOR Boland, W. Robert, (LANL)
% Clemens, Reginald, (PLK)
%***DESCRIPTION
%
% B L A S Subprogram
% Description of Parameters
%
% --Input--
% N number of elements in input vector(s)
% IX integer vector with N elements
% INCX storage spacing between elements of IX
% IY integer vector with N elements
% INCY storage spacing between elements of IY
%
% --Output--
% IY copy of vector IX (unchanged if N .LE. 0)
%
% Copy integer IX to integer IY.
% For I = 0 to N-1, copy IX(LX+I*INCX) to IY(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 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)
% 930201 DATE WRITTEN
%***end PROLOGUE ICOPY
ix_shape=size(ix);ix=reshape(ix,1,[]);
iy_shape=size(iy);iy=reshape(iy,1,[]);
%***FIRST EXECUTABLE STATEMENT ICOPY
if( n<=0 )
ix_shape=zeros(ix_shape);ix_shape(:)=ix(1:numel(ix_shape));ix=ix_shape;
iy_shape=zeros(iy_shape);iy_shape(:)=iy(1:numel(iy_shape));iy=iy_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;
iy(i) = fix(ix(i));
end; i = fix(m+1);
if( n<7 )
ix_shape=zeros(ix_shape);ix_shape(:)=ix(1:numel(ix_shape));ix=ix_shape;
iy_shape=zeros(iy_shape);iy_shape(:)=iy(1:numel(iy_shape));iy=iy_shape;
return;
end;
end;
mp1 = fix(m + 1);
for i = mp1 : 7: n ;
iy(i) = fix(ix(i));
iy(i+1) = fix(ix(i+1));
iy(i+2) = fix(ix(i+2));
iy(i+3) = fix(ix(i+3));
iy(i+4) = fix(ix(i+4));
iy(i+5) = fix(ix(i+5));
iy(i+6) = fix(ix(i+6));
end; i = fix(n +1);
ix_shape=zeros(ix_shape);ix_shape(:)=ix(1:numel(ix_shape));ix=ix_shape;
iy_shape=zeros(iy_shape);iy_shape(:)=iy(1:numel(iy_shape));iy=iy_shape;
return;
else;
%
% Code for equal, positive, non-unit increments.
%
ns = fix(n.*incx);
for i = 1 : incx: ns ;
iy(i) = fix(ix(i));
end; i = fix(ns +1);
ix_shape=zeros(ix_shape);ix_shape(:)=ix(1:numel(ix_shape));ix=ix_shape;
iy_shape=zeros(iy_shape);iy_shape(:)=iy(1:numel(iy_shape));iy=iy_shape;
return;
end;
end;
%
% Code for unequal or nonpositive increments.
%
iix = 1;
iiy = 1;
if( incx<0 )
iix =fix((-n+1).*incx + 1);
end;
if( incy<0 )
iiy =fix((-n+1).*incy + 1);
end;
for i = 1 : n;
iy(iiy) = fix(ix(iix));
iix = fix(iix + incx);
iiy = fix(iiy + incy);
end; i = fix(n+1);
ix_shape=zeros(ix_shape);ix_shape(:)=ix(1:numel(ix_shape));ix=ix_shape;
iy_shape=zeros(iy_shape);iy_shape(:)=iy(1:numel(iy_shape));iy=iy_shape;
return;
end
%DECK IDAMAX
|
|