| [n,ca,cx,incx,cy,incy]=caxpy(n,ca,cx,incx,cy,incy); |
function [n,ca,cx,incx,cy,incy]=caxpy(n,ca,cx,incx,cy,incy);
persistent i kx ky ns ;
if isempty(i), i=0; end;
if isempty(kx), kx=0; end;
if isempty(ky), ky=0; end;
if isempty(ns), ns=0; end;
%***BEGIN PROLOGUE CAXPY
%***PURPOSE Compute a constant times a vector plus a vector.
%***LIBRARY SLATEC (BLAS)
%***CATEGORY D1A7
%***TYPE COMPLEX (SAXPY-S, DAXPY-D, CAXPY-C)
%***KEYWORDS BLAS, LINEAR ALGEBRA, TRIAD, 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)
% CA complex scalar multiplier
% CX complex vector with N elements
% INCX storage spacing between elements of CX
% CY complex vector with N elements
% INCY storage spacing between elements of CY
%
% --Output--
% CY complex result (unchanged if N .LE. 0)
%
% Overwrite complex CY with complex CA*CX + CY.
% For I = 0 to N-1, replace CY(LY+I*INCY) with CA*CX(LX+I*INCX) +
% CY(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)
% 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)
% 920801 Removed variable CANORM. (RWC, WRB)
%***end PROLOGUE CAXPY
cx_shape=size(cx);cx=reshape(cx,1,[]);
cy_shape=size(cy);cy=reshape(cy,1,[]);
%***FIRST EXECUTABLE STATEMENT CAXPY
if( n<=0 || ca==complex(0.0e0,0.0e0) )
cx_shape=zeros(cx_shape);cx_shape(:)=cx(1:numel(cx_shape));cx=cx_shape;
cy_shape=zeros(cy_shape);cy_shape(:)=cy(1:numel(cy_shape));cy=cy_shape;
return;
end;
if( incx==incy && incx>0 )
%
% Code for equal, positive, non-unit increments.
%
ns = fix(n.*incx);
for i = 1 : incx: ns ;
cy(i) = ca.*cx(i) + cy(i);
end; i = fix(ns +1);
else;
%
% Code for unequal or nonpositive increments.
%
kx = 1;
ky = 1;
if( incx<0 )
kx = fix(1 +(1-n).*incx);
end;
if( incy<0 )
ky = fix(1 +(1-n).*incy);
end;
for i = 1 : n;
cy(ky) = cy(ky) + ca.*cx(kx);
kx = fix(kx + incx);
ky = fix(ky + incy);
end; i = fix(n+1);
cx_shape=zeros(cx_shape);cx_shape(:)=cx(1:numel(cx_shape));cx=cx_shape;
cy_shape=zeros(cy_shape);cy_shape(:)=cy(1:numel(cy_shape));cy=cy_shape;
return;
end;
cx_shape=zeros(cx_shape);cx_shape(:)=cx(1:numel(cx_shape));cx=cx_shape;
cy_shape=zeros(cy_shape);cy_shape(:)=cy(1:numel(cy_shape));cy=cy_shape;
end
%DECK CBABK2
|
|