Code covered by the BSD License  

Highlights from
slatec

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

[n,ijump,fnum,fden,a]=cmpcsg(n,ijump,fnum,fden,a);
function [n,ijump,fnum,fden,a]=cmpcsg(n,ijump,fnum,fden,a);
persistent dum i k k1 k2 k3 k4 k5 np1 pi pibyn x y ; 

if isempty(dum), dum=0; end;
if isempty(pi), pi=0; end;
if isempty(pibyn), pibyn=0; end;
if isempty(x), x=0; end;
if isempty(y), y=0; end;
if isempty(i), i=0; end;
if isempty(k), k=0; end;
if isempty(k1), k1=0; end;
if isempty(k2), k2=0; end;
if isempty(k3), k3=0; end;
if isempty(k4), k4=0; end;
if isempty(k5), k5=0; end;
if isempty(np1), np1=0; end;
%***BEGIN PROLOGUE  CMPCSG
%***SUBSIDIARY
%***PURPOSE  Subsidiary to CMGNBN
%***LIBRARY   SLATEC
%***TYPE      COMPLEX (COSGEN-S, CMPCSG-C)
%***AUTHOR  (UNKNOWN)
%***DESCRIPTION
%
%     This subroutine computes required cosine values in ascending
%     order.  When IJUMP .GT. 1 the routine computes values
%
%        2*COS(J*PI/L) , J=1,2,...,L and J .NE. 0(MOD N/IJUMP+1)
%
%     where L = IJUMP*(N/IJUMP+1).
%
%
%     when IJUMP = 1 it computes
%
%            2*COS((J-FNUM)*PI/(N+FDEN)) ,  J=1, 2, ... ,N
%
%     where
%        FNUM = 0.5, FDEN = 0.0,  for regular reduction values.
%        FNUM = 0.0, FDEN = 1.0, for B-R and C-R when ISTAG = 1
%        FNUM = 0.0, FDEN = 0.5, for B-R and C-R when ISTAG = 2
%        FNUM = 0.5, FDEN = 0.5, for B-R and C-R when ISTAG = 2
%                                in CMPOSN only.
%
%***SEE ALSO  CMGNBN
%***ROUTINES CALLED  PIMACH
%***REVISION HISTORY  (YYMMDD)
%   801001  DATE WRITTEN
%   890531  Changed all specific intrinsics to generic.  (WRB)
%   891214  Prologue converted to Version 4.0 format.  (BAB)
%   900402  Added TYPE section.  (WRB)
%***end PROLOGUE  CMPCSG
a_shape=size(a);a=reshape(a,1,[]);
%
%
%***FIRST EXECUTABLE STATEMENT  CMPCSG
[pi ,dum]=pimach(dum);
if( n~=0 )
if( ijump==1 )
np1 = fix(n + 1);
y = pi./(n+fden);
for i = 1 : n;
x = np1 - i - fnum;
a(i) = complex(2..*cos(x.*y),0.);
end; i = fix(n+1);
else;
k3 = fix(fix(n./ijump) + 1);
k4 = fix(k3 - 1);
pibyn = pi./(n+ijump);
for k = 1 : ijump;
k1 =fix((k-1).*k3);
k5 =fix((k-1).*k4);
for i = 1 : k4;
x = k1 + i;
k2 = fix(k5 + i);
a(k2) = complex(-2..*cos(x.*pibyn),0.);
end; i = fix(k4+1);
end; k = fix(ijump+1);
end;
end;
a_shape=zeros(a_shape);a_shape(:)=a(1:numel(a_shape));a=a_shape;
end
%DECK CMPOSD

Contact us