| [m,n,alpha,x,incx,y,incy,a,lda]=sger(m,n,alpha,x,incx,y,incy,a,lda); |
function [m,n,alpha,x,incx,y,incy,a,lda]=sger(m,n,alpha,x,incx,y,incy,a,lda);
%***BEGIN PROLOGUE SGER
%***PURPOSE Perform rank 1 update of a real general matrix.
%***LIBRARY SLATEC (BLAS)
%***CATEGORY D1B4
%***TYPE SINGLE PRECISION (SGER-S)
%***KEYWORDS LEVEL 2 BLAS, LINEAR ALGEBRA
%***AUTHOR Dongarra, J. J., (ANL)
% Du Croz, J., (NAG)
% Hammarling, S., (NAG)
% Hanson, R. J., (SNLA)
%***DESCRIPTION
%
% SGER performs the rank 1 operation
%
% A := alpha*x*y' + A,
%
% where alpha is a scalar, x is an m element vector, y is an n element
% vector and A is an m by n matrix.
%
% Parameters
% ==========
%
% M - INTEGER.
% On entry, M specifies the number of rows of the matrix A.
% M must be at least zero.
% Unchanged on exit.
%
% N - INTEGER.
% On entry, N specifies the number of columns of the matrix A.
% N must be at least zero.
% Unchanged on exit.
%
% ALPHA - REAL .
% On entry, ALPHA specifies the scalar alpha.
% Unchanged on exit.
%
% X - REAL array of dimension at least
% ( 1 + ( m - 1)*abs( INCX)).
% Before entry, the incremented array X must contain the m
% element vector x.
% Unchanged on exit.
%
% INCX - INTEGER.
% On entry, INCX specifies the increment for the elements of
% X. INCX must not be zero.
% Unchanged on exit.
%
% Y - REAL array of dimension at least
% ( 1 + ( n - 1 )*abs( INCY ) ).
% Before entry, the incremented array Y must contain the n
% element vector y.
% Unchanged on exit.
%
% INCY - INTEGER.
% On entry, INCY specifies the increment for the elements of
% Y. INCY must not be zero.
% Unchanged on exit.
%
% A - REAL array of DIMENSION ( LDA, n ).
% Before entry, the leading m by n part of the array A must
% contain the matrix of coefficients. On exit, A is
% overwritten by the updated matrix.
%
% LDA - INTEGER.
% On entry, LDA specifies the first dimension of A as declared
% in the calling (sub) program. LDA must be at least
% max( 1, m ).
% Unchanged on exit.
%
%***REFERENCES Dongarra, J. J., Du Croz, J., Hammarling, S., and
% Hanson, R. J. An extended set of Fortran basic linear
% algebra subprograms. ACM TOMS, Vol. 14, No. 1,
% pp. 1-17, March 1988.
%***ROUTINES CALLED XERBLA
%***REVISION HISTORY (YYMMDD)
% 861022 DATE WRITTEN
% 910605 Modified to meet SLATEC prologue standards. Only comment
% lines were modified. (BKS)
%***end PROLOGUE SGER
% .. Scalar Arguments ..
% .. Array Arguments ..
persistent i info ix j jy kx temp zero ;
a_shape=size(a);a=reshape([a(:).',zeros(1,ceil(numel(a)./prod([lda])).*prod([lda])-numel(a))],lda,[]);
x_shape=size(x);x=reshape(x,1,[]);
y_shape=size(y);y=reshape(y,1,[]);
% .. Parameters ..
if isempty(zero), zero=0.0e+0 ; end;
% .. Local Scalars ..
if isempty(temp), temp=0; end;
if isempty(i), i=0; end;
if isempty(info), info=0; end;
if isempty(ix), ix=0; end;
if isempty(j), j=0; end;
if isempty(jy), jy=0; end;
if isempty(kx), kx=0; end;
% .. External Subroutines ..
% .. Intrinsic Functions ..
%***FIRST EXECUTABLE STATEMENT SGER
%
% Test the input parameters.
%
info = 0;
if( m<0 )
info = 1;
elseif( n<0 ) ;
info = 2;
elseif( incx==0 ) ;
info = 5;
elseif( incy==0 ) ;
info = 7;
elseif( lda<max(1,m) ) ;
info = 9;
end;
if( info~=0 )
[dumvar1,info]=xerbla('SGER ',info);
a_shape=zeros(a_shape);a_shape(:)=a(1:numel(a_shape));a=a_shape;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
y_shape=zeros(y_shape);y_shape(:)=y(1:numel(y_shape));y=y_shape;
return;
end;
%
% Quick return if possible.
%
if((m==0) ||(n==0) ||(alpha==zero) )
a_shape=zeros(a_shape);a_shape(:)=a(1:numel(a_shape));a=a_shape;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
y_shape=zeros(y_shape);y_shape(:)=y(1:numel(y_shape));y=y_shape;
return;
end;
%
% Start the operations. In this version the elements of A are
% accessed sequentially with one pass through A.
%
if( incy>0 )
jy = 1;
else;
jy = fix(1 -(n-1).*incy);
end;
if( incx==1 )
for j = 1 : n;
if( y(jy)~=zero )
temp = alpha.*y(jy);
for i = 1 : m;
a(i,j) = a(i,j) + x(i).*temp;
end; i = fix(m+1);
end;
jy = fix(jy + incy);
end; j = fix(n+1);
else;
if( incx>0 )
kx = 1;
else;
kx = fix(1 -(m-1).*incx);
end;
for j = 1 : n;
if( y(jy)~=zero )
temp = alpha.*y(jy);
ix = fix(kx);
for i = 1 : m;
a(i,j) = a(i,j) + x(ix).*temp;
ix = fix(ix + incx);
end; i = fix(m+1);
end;
jy = fix(jy + incy);
end; j = fix(n+1);
end;
%
%
% end of SGER .
%
a_shape=zeros(a_shape);a_shape(:)=a(1:numel(a_shape));a=a_shape;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
y_shape=zeros(y_shape);y_shape(:)=y(1:numel(y_shape));y=y_shape;
end
%DECK SGESL
|
|