OpenLibm/slatec/radb4.f
Viral B. Shah c977aa998f Add Makefile.extras to build libopenlibm-extras.
Replace amos with slatec
2012-12-31 16:37:05 -05:00

109 lines
3.7 KiB
Fortran

*DECK RADB4
SUBROUTINE RADB4 (IDO, L1, CC, CH, WA1, WA2, WA3)
C***BEGIN PROLOGUE RADB4
C***SUBSIDIARY
C***PURPOSE Calculate the fast Fourier transform of subvectors of
C length four.
C***LIBRARY SLATEC (FFTPACK)
C***TYPE SINGLE PRECISION (RADB4-S)
C***AUTHOR Swarztrauber, P. N., (NCAR)
C***ROUTINES CALLED (NONE)
C***REVISION HISTORY (YYMMDD)
C 790601 DATE WRITTEN
C 830401 Modified to use SLATEC library source file format.
C 860115 Modified by Ron Boisvert to adhere to Fortran 77 by
C (a) changing dummy array size declarations (1) to (*),
C (b) changing definition of variable SQRT2 by using
C FORTRAN intrinsic function SQRT instead of a DATA
C statement.
C 881128 Modified by Dick Valent to meet prologue standards.
C 890831 Modified array declarations. (WRB)
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900402 Added TYPE section. (WRB)
C***END PROLOGUE RADB4
DIMENSION CC(IDO,4,*), CH(IDO,L1,4), WA1(*), WA2(*), WA3(*)
C***FIRST EXECUTABLE STATEMENT RADB4
SQRT2 = SQRT(2.)
DO 101 K=1,L1
TR1 = CC(1,1,K)-CC(IDO,4,K)
TR2 = CC(1,1,K)+CC(IDO,4,K)
TR3 = CC(IDO,2,K)+CC(IDO,2,K)
TR4 = CC(1,3,K)+CC(1,3,K)
CH(1,K,1) = TR2+TR3
CH(1,K,2) = TR1-TR4
CH(1,K,3) = TR2-TR3
CH(1,K,4) = TR1+TR4
101 CONTINUE
IF (IDO-2) 107,105,102
102 IDP2 = IDO+2
IF((IDO-1)/2.LT.L1) GO TO 108
DO 104 K=1,L1
CDIR$ IVDEP
DO 103 I=3,IDO,2
IC = IDP2-I
TI1 = CC(I,1,K)+CC(IC,4,K)
TI2 = CC(I,1,K)-CC(IC,4,K)
TI3 = CC(I,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