|
!'HARTLEY変換(テストルーチン)
OPTION BASE 0
RANDOMIZE
LET N=8
DIM A(N),B(N)
PRINT "初期値"
FOR I=0 TO N-1
LET A(I)=INT(RND*100)
PRINT A(I);
NEXT I
PRINT
CALL DHT1(A,N,B) !'DHT1変換
PRINT "DHT1 変換"
FOR I=0 TO N-1
PRINT B(I);
NEXT I
PRINT
CALL DHT1(B,N,A) !'DHT1逆変換
PRINT "DHT1 逆変換"
FOR I=0 TO N-1
PRINT INT(A(I)+.01);
NEXT I
PRINT
PRINT "初期値"
FOR I=0 TO N-1
LET A(I)=INT(RND*100)
PRINT A(I);
NEXT I
PRINT
CALL DHT2(A,N,B) !'ハートレー変換
PRINT "DHT2 変換"
FOR I=0 TO N-1
PRINT B(I);
NEXT I
PRINT
CALL DHT3(B,N,A) !'ハートレー逆変換
PRINT "DHT3 逆変換"
FOR I=0 TO N-1
PRINT INT(A(I)+.01);
NEXT I
PRINT
PRINT "初期値"
FOR I=0 TO N-1
LET A(I)=INT(RND*100)
PRINT A(I);
NEXT I
PRINT
CALL DHT4(A,N,B) !'DHT4変換
PRINT "DHT4 変換"
FOR I=0 TO N-1
PRINT B(I);
NEXT I
PRINT
CALL DHT4(B,N,A) !'DHT4逆変換
PRINT "DHT4 逆変換"
FOR I=0 TO N-1
PRINT INT(A(I)+.01);
NEXT I
END
EXTERNAL SUB DHT1(A(),N,B())
FOR K=0 TO N-1
LET S=0
FOR J=0 TO N-1
LET S = S + A(J) * CAS(2*PI*J*K/N)
NEXT J
LET B(K) = S * SQR(1 / N)
NEXT K
END SUB
EXTERNAL SUB DHT2(A(),N,B())
FOR K=0 TO N-1
LET S=0
FOR J=0 TO N-1
LET S = S + A(J) * CAS(2*PI*(J+1/2)*K/N)
NEXT J
LET B(K) = S * SQR(1 / N)
NEXT K
END SUB
EXTERNAL SUB DHT3(A(),N,B())
FOR K=0 TO N-1
LET S=0
FOR J=0 TO N-1
LET S = S + A(J) * CAS(2*PI*J*(K+1/2)/N)
NEXT J
LET B(K) = S * SQR(1 / N)
NEXT K
END SUB
EXTERNAL SUB DHT4(A(),N,B())
FOR K=0 TO N-1
LET S=0
FOR J=0 TO N-1
LET S = S + A(J) * CAS(2*PI*(J+1/2)*(K+1/2)/N)
NEXT J
LET B(K) = S * SQR(1 / N)
NEXT K
END SUB
EXTERNAL FUNCTION CAS(X)
LET CAS=COS(X)+SIN(X)
!'CAS=SQR(2)*SIN(PI/4+X)
END FUNCTION
|
|