Basic Grids

CompositeGrids.SimpleGridModule

Basic grids including common grids like arbitrary grids, uniform grids, log grids, and optimized grids like barycheb for interpolation and gausslegendre for integration.

source
CompositeGrids.SimpleGrid.ArbitraryType

struct Arbitrary{T<:AbstractFloat} <: ClosedGrid

Arbitrary grid generated from given sorted grid.

#Members:

  • bound : boundary of the grid
  • size : number of grid points
  • grid : grid points
  • weight : integration weight
source
CompositeGrids.SimpleGrid.BaryChebType

struct BaryCheb{T<:AbstractFloat} <: OpenGrid

BaryCheb grid generated on [bound[1], bound[2]] with order N.

#Members:

  • bound : boundary of the grid
  • size : number of grid points
  • grid : grid points
  • weight : interpolation weight
source
CompositeGrids.SimpleGrid.GaussLegendreType

struct GaussLegendre{T<:AbstractFloat} <: OpenGrid

GaussLegendre grid generated on [bound[1], bound[2]] with order N.

#Members:

  • bound : boundary of the grid
  • size : number of grid points
  • grid : grid points
  • weight : integration weight
source
CompositeGrids.SimpleGrid.LogType

struct Log{T<:AbstractFloat} <: ClosedGrid

Log grid generated on [bound[1], bound[2]] with N grid points.

Minimal interval is set to be minterval. Dense to sparse if d2s, vice versa.

On [0, 1], a typical d2s Log grid looks like [0, λ^(N-1), ..., λ^2, λ, 1].

#Members:

  • bound : boundary of the grid

  • size : number of grid points

  • grid : grid points

  • weight : integration weight

  • λ : scale parameter

  • d2s : dense to sparse or not

source
CompositeGrids.SimpleGrid.UniformType

struct Uniform{T<:AbstractFloat} <: ClosedGrid

Uniform grid generated on [bound[1], bound[2]] with N points

#Members:

  • bound : boundary of the grid
  • size : number of grid points
  • grid : grid points
  • weight : integration weight
source
Base.floorMethod

function Base.floor(grid::AbstractGrid, x) #where {T}

use basic searchsorted function to find the index of largest

grid point smaller than x.

return 1 for x<grid[1] and grid.size-1 for x>grid[end].
source
Base.floorMethod

function Base.floor(grid::Log{T}, x) where {T}

find the index of largest

grid point smaller than x.

return 1 for x<grid[1] and grid.size-1 for x>grid[end].
source
Base.floorMethod

function Base.floor(grid::Uniform{T}, x) where {T}

find the index of largest

grid point smaller than x.

return 1 for x<grid[1] and grid.size-1 for x>grid[end].
source
CompositeGrids.SimpleGrid.barychebMethod

function barycheb(n, x, f, wc, xc)

Barycentric Lagrange interpolation at Chebyshev nodes Reference: Berrut, J.P. and Trefethen, L.N., 2004. Barycentric lagrange interpolation. SIAM review, 46(3), pp.501-517.

Arguments

  • n: order of the Chebyshev interpolation
  • x: coordinate to interpolate
  • f: array of size n, function at the Chebyshev nodes
  • wc: array of size n, Barycentric Lagrange interpolation weights
  • xc: array of size n, coordinates of Chebyshev nodes

Returns

  • Interpolation result
source
CompositeGrids.SimpleGrid.barychebinitMethod

barychebinit(n)

Get Chebyshev nodes of first kind and corresponding barycentric Lagrange interpolation weights. Reference: Berrut, J.P. and Trefethen, L.N., 2004. Barycentric lagrange interpolation. SIAM review, 46(3), pp.501-517.

Arguments

  • n: order of the Chebyshev interpolation

Returns

  • Chebyshev nodes
  • Barycentric Lagrange interpolation weights
source