Filter1D Function

function Filter1D(n, nc, s, v, invv)

Create an exponential filter matrix that can be used to filter out high-frequency noise.

The filter matrix is defined as where the diagonal matrix, has the entries for and the filter function, has the form Here , where is the machine precision in working precision, is the order of the element, is a cutoff, below which the low modes are left untouched and (has to be even) is the order of the filter.

Arguments

Type IntentOptional AttributesName
integer(kind=ip), intent(in) :: n

The order of the element.

integer(kind=ip), intent(in) :: nc

The cutoff, below which the low modes are left untouched.

integer(kind=ip), intent(in) :: s

The order of the filter.

real(kind=wp), intent(in), dimension(:,:):: v

The Vandermonde matrix, .

real(kind=wp), intent(in), dimension(:,:):: invv

The inverse of the Vandermonde matric, .

Return Value real(kind=wp), dimension(n+1,n+1)

The return value is the filter matrix, .


Called by

proc~~filter1d~~CalledByGraph proc~filter1d Filter1D proc~init_ref_element init_ref_element proc~init_ref_element->proc~filter1d interface~init_ref_element init_ref_element interface~init_ref_element->proc~init_ref_element interface~ref_element ref_element interface~ref_element->interface~init_ref_element proc~scal_schw_init scal_schw_init proc~scal_schw_init->interface~ref_element program~test test program~test->interface~ref_element interface~scal_schw_init scal_schw_init interface~scal_schw_init->proc~scal_schw_init

Contents

Source Code


Source Code

    function Filter1D ( n, nc, s, v, invv )
    !! Create an exponential filter matrix that can be used to filter out
    !! high-frequency noise.
    !!
    !! The filter matrix \(\mathcal{F}\) is defined as \(\mathcal{F}=
    !! \mathcal{V}\Lambda\mathcal{V}^{-1}\) where the diagonal matrix, 
    !! \(\Lambda\) has the entries \(\Lambda_{ii}=\sigma(i-1)\) for
    !! \(i=1,\ldots,n+1\) and the filter function, \(\sigma(i)\) has the form
    !! \[
    !!   \sigma(i) =
    !!     \begin{cases}
    !!         1 & 0\le i\le n_c \\
    !!         e^{-\alpha\left (\frac{i-n_c}{n-n_c}\right )^s} & n_c<i\le n.
    !!     \end{cases}
    !! \]
    !! Here \(\alpha=-\log(\epsilon_M)\), where \(\epsilon_M\) is the machine
    !! precision in working precision, \(n\) is the order of the element,
    !! \(n_c\) is a cutoff, below which the low modes are left untouched and
    !! \(s\) (has to be even) is the order of the filter.
      integer(ip), intent(in) :: n
      !! The order of the element.
      integer(ip), intent(in) :: nc
      !! The cutoff, below which the low modes are left untouched.
      integer(ip), intent(in) :: s
      !! The order of the filter.
      real(wp), dimension(:,:), intent(in) :: v
      !! The Vandermonde matrix, \(\mathcal{V}\).
      real(wp), dimension(:,:), intent(in) :: invv
      !! The inverse of the Vandermonde matric, \(\mathcal{V}^{-1}\).
      real(wp), dimension(n+1,n+1) :: Filter1D
      !! The return value is the filter matrix, \(\mathcal{F}\).
      real(wp), dimension(n+1,n+1) :: tmp

      real(wp) :: alpha
      integer(ip) :: i

      alpha = -log(epsilon(1.0_wp))
      Filter1D = 0.0_wp
      forall(i=1:nc) Filter1D(i,i) = 1.0_wp
      forall(i=nc:n) Filter1D(i+1,i+1) = exp(-alpha*(real(i-nc,wp)/real(n-nc,wp))**s)
!      Filter1D = matmul(Filter1D,invv)
!      Filter1D = matmul(v,Filter1D)

      tmp = matmul(Filter1D,invv)
      Filter1D = matmul(v,tmp)

      return
    end function Filter1D