Code covered by the BSD License  

Highlights from
slatec

from slatec by Ben Barrowes
The slatec library converted into matlab functions.

[n,da,dx,incx]=dscal(n,da,dx,incx);
function [n,da,dx,incx]=dscal(n,da,dx,incx);
%***BEGIN PROLOGUE  DSCAL
%***PURPOSE  Multiply a vector by a constant.
%***LIBRARY   SLATEC (BLAS)
%***CATEGORY  D1A6
%***TYPE      doubleprecision (SSCAL-S, DSCAL-D, CSCAL-C)
%***KEYWORDS  BLAS, LINEAR ALGEBRA, SCALE, 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)
%       DA  doubleprecision scale factor
%       DX  doubleprecision vector with N elements
%     INCX  storage spacing between elements of DX
%
%     --Output--
%       DX  doubleprecision result (unchanged if N.LE.0)
%
%     Replace doubleprecision DX by doubleprecision DA*DX.
%     For I = 0 to N-1, replace DX(IX+I*INCX) with  DA * DX(IX+I*INCX),
%     where IX = 1 if INCX .GE. 0, else IX = 1+(1-N)*INCX.
%
%***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)
%   900821  Modified to correct problem with a negative increment.
%           (WRB)
%   920501  Reformatted the REFERENCES section.  (WRB)
%***end PROLOGUE  DSCAL
persistent i ix m mp1 ; 

dx_shape=size(dx);dx=reshape(dx,1,[]);
if isempty(i), i=0; end;
if isempty(ix), ix=0; end;
if isempty(m), m=0; end;
if isempty(mp1), mp1=0; end;
%***FIRST EXECUTABLE STATEMENT  DSCAL
if( n<=0 )
dx_shape=zeros(dx_shape);dx_shape(:)=dx(1:numel(dx_shape));dx=dx_shape;
return;
end;
if( incx==1 )
%
%     Code for increment 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;
dx(i) = da.*dx(i);
end; i = fix(m+1);
if( n<5 )
dx_shape=zeros(dx_shape);dx_shape(:)=dx(1:numel(dx_shape));dx=dx_shape;
return;
end;
end;
mp1 = fix(m + 1);
for i = mp1 : 5: n ;
dx(i) = da.*dx(i);
dx(i+1) = da.*dx(i+1);
dx(i+2) = da.*dx(i+2);
dx(i+3) = da.*dx(i+3);
dx(i+4) = da.*dx(i+4);
end; i = fix(n +1);
else;
%
%     Code for increment not equal to 1.
%
ix = 1;
if( incx<0 )
ix =fix((-n+1).*incx + 1);
end;
for i = 1 : n;
dx(ix) = da.*dx(ix);
ix = fix(ix + incx);
end; i = fix(n+1);
dx_shape=zeros(dx_shape);dx_shape(:)=dx(1:numel(dx_shape));dx=dx_shape;
return;
end;
dx_shape=zeros(dx_shape);dx_shape(:)=dx(1:numel(dx_shape));dx=dx_shape;
end
%DECK DSD2S

Contact us