SUB_WAVELET/Fortran/SUB_conv_valid.f90
2025-04-17 17:31:56 +08:00

34 lines
549 B
Fortran
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!向量卷积(valid模式去掉补零边缘)
!要求m>=n
!z的大小 = m-n+1
SUBROUTINE conv_valid(m,x,n,y,z)
implicit none
integer :: m,n
real*8 :: x(m),y(n),z(m-n+1)
real*8 :: temp(m+n-1)
integer :: i,j
!z = 0
!do i=1,m-n+1
! do j=1,n
! z(i) = z(i)+x(i+j-1)*y(j)
! end do
!end do
z = 0
temp = 0
do i=1,m
do j=1,n
temp(i+j-1) = temp(i+j-1)+x(i)*y(j)
end do
end do
z = temp(n:m)
end subroutine