| [ddotresult,n,dx,incx,dy,incy]=ddot(n,dx,incx,dy,incy); |
function [ddotresult,n,dx,incx,dy,incy]=ddot(n,dx,incx,dy,incy);
ddotresult=[];
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 DDOT
%***PURPOSE Compute the inner product of two vectors.
%***LIBRARY SLATEC (BLAS)
%***CATEGORY D1A4
%***TYPE doubleprecision (SDOT-S, DDOT-D, CDOTU-C)
%***KEYWORDS BLAS, INNER PRODUCT, LINEAR ALGEBRA, 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
%
% --Output--
% DDOT doubleprecision dot product (zero if N .LE. 0)
%
% Returns the dot product of doubleprecision DX and DY.
% DDOT = sum for I = 0 to N-1 of DX(LX+I*INCX) * DY(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
% 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)
% 920501 Reformatted the REFERENCES section. (WRB)
%***end PROLOGUE DDOT
dx_shape=size(dx);dx=reshape(dx,1,[]);
dy_shape=size(dy);dy=reshape(dy,1,[]);
%***FIRST EXECUTABLE STATEMENT DDOT
ddotresult = 0.0d0;
if( n<=0 )
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;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',n); evalin('caller',[inputname(1),'=FUntemp;']); end
if csnil&&~isempty(inputname(5)), assignin('caller','FUntemp',incy); evalin('caller',[inputname(5),'=FUntemp;']); end
if csnil&&~isempty(inputname(3)), assignin('caller','FUntemp',incx); evalin('caller',[inputname(3),'=FUntemp;']); end
if csnil&&~isempty(inputname(4)), assignin('caller','FUntemp',dy); evalin('caller',[inputname(4),'=FUntemp;']); end
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',dx); evalin('caller',[inputname(2),'=FUntemp;']); end
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 5.
%
m = fix(rem(n,5));
if( m~=0 )
for i = 1 : m;
ddotresult = ddotresult + dx(i).*dy(i);
end; i = fix(m+1);
if( n<5 )
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;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',n); evalin('caller',[inputname(1),'=FUntemp;']); end
if csnil&&~isempty(inputname(5)), assignin('caller','FUntemp',incy); evalin('caller',[inputname(5),'=FUntemp;']); end
if csnil&&~isempty(inputname(3)), assignin('caller','FUntemp',incx); evalin('caller',[inputname(3),'=FUntemp;']); end
if csnil&&~isempty(inputname(4)), assignin('caller','FUntemp',dy); evalin('caller',[inputname(4),'=FUntemp;']); end
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',dx); evalin('caller',[inputname(2),'=FUntemp;']); end
return;
end;
end;
mp1 = fix(m + 1);
for i = mp1 : 5: n ;
ddotresult = ddotresult + dx(i).*dy(i) + dx(i+1).*dy(i+1) + dx(i+2).*dy(i+2)+ dx(i+3).*dy(i+3) + dx(i+4).*dy(i+4);
end; i = fix(n +1);
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;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',n); evalin('caller',[inputname(1),'=FUntemp;']); end
if csnil&&~isempty(inputname(5)), assignin('caller','FUntemp',incy); evalin('caller',[inputname(5),'=FUntemp;']); end
if csnil&&~isempty(inputname(3)), assignin('caller','FUntemp',incx); evalin('caller',[inputname(3),'=FUntemp;']); end
if csnil&&~isempty(inputname(4)), assignin('caller','FUntemp',dy); evalin('caller',[inputname(4),'=FUntemp;']); end
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',dx); evalin('caller',[inputname(2),'=FUntemp;']); end
return;
else;
%
% Code for equal, positive, non-unit increments.
%
ns = fix(n.*incx);
for i = 1 : incx: ns ;
ddotresult = ddotresult + dx(i).*dy(i);
end; i = fix(ns +1);
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;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',n); evalin('caller',[inputname(1),'=FUntemp;']); end
if csnil&&~isempty(inputname(5)), assignin('caller','FUntemp',incy); evalin('caller',[inputname(5),'=FUntemp;']); end
if csnil&&~isempty(inputname(3)), assignin('caller','FUntemp',incx); evalin('caller',[inputname(3),'=FUntemp;']); end
if csnil&&~isempty(inputname(4)), assignin('caller','FUntemp',dy); evalin('caller',[inputname(4),'=FUntemp;']); end
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',dx); evalin('caller',[inputname(2),'=FUntemp;']); end
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;
ddotresult = ddotresult + dx(ix).*dy(iy);
ix = fix(ix + incx);
iy = fix(iy + incy);
end; i = fix(n+1);
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;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',n); evalin('caller',[inputname(1),'=FUntemp;']); end
if csnil&&~isempty(inputname(5)), assignin('caller','FUntemp',incy); evalin('caller',[inputname(5),'=FUntemp;']); end
if csnil&&~isempty(inputname(3)), assignin('caller','FUntemp',incx); evalin('caller',[inputname(3),'=FUntemp;']); end
if csnil&&~isempty(inputname(4)), assignin('caller','FUntemp',dy); evalin('caller',[inputname(4),'=FUntemp;']); end
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',dx); evalin('caller',[inputname(2),'=FUntemp;']); end
return;
end
%DECK DDPSC
|
|