Interpolation and Integration
CompositeGrids.Interp
— ModuleProvide interpolation and integration.
CompositeGrids.Interp.dataslice
— Methodfunction dataslice(data, axes, indices)
Return a view of data sliced on given axes with given indices. Works like view(data, (:, ..., :, i1:f1, :, ..., in:fn, :, ..., :)). Type unstable unless slice dims are constant.
#Members:
- data: data to be sliced.
- axes: axes to be sliced. accept Int or NTuple{DIM, Int} for single or multiple axes. when omitted, assume all axes.
- indices: indices of slicing. accept UnitRange{Int} or Vector of UnitRange{Int} like 2:8 or [2:8, 3:7]
CompositeGrids.Interp.differentiate1D
— Methodfunction differentiate1D(data, xgrid, x; axis=1)
calculate integration of data[i] on xgrid. For 1D data, return a number; for multiple dimension, reduce the given axis.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- x: point to differentiate
- axis: axis to be differentiated in data
CompositeGrids.Interp.findneighbor
— Methodfunction findneighbor(xgrid::T, x; method=:default) where {T}
Find neighbor grid points and related information for extrapolating the value of x on xgrid.
#Members:
- xgrid: grid to be interpolated
- x: value to be interpolated
- method: :default use optimized method, :linear use linear interp.
CompositeGrids.Interp.integrate1D
— Methodfunction integrate1D(::ChebIntegrate, data, xgrid)
calculate integration of data[i] on xgrid works for grids that have integration weight stored
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
CompositeGrids.Interp.integrate1D
— Methodfunction integrate1D(::NoIntegrate, data, xgrid)
calculate integration of data[i] on xgrid works for grids that do not have integration weight stored
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
CompositeGrids.Interp.integrate1D
— Methodfunction integrate1D(::WeightIntegrate, data, xgrid)
calculate integration of data[i] on xgrid works for grids that have integration weight stored
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
CompositeGrids.Interp.integrate1D
— Methodfunction integrate1D(::CompositeIntegrate, data, xgrid)
calculate integration of data[i] on xgrid call integrate1D for each subgrid and return the sum.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
CompositeGrids.Interp.integrate1D
— Methodfunction integrate1D(data, xgrid, range; axis=1)
calculate integration of data[i] on xgrid. For 1D data, return a number; for multiple dimension, reduce the given axis.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- range: range of integration, [init, fin] within bound of xgrid.
- axis: axis to be integrated in data
CompositeGrids.Interp.integrate1D
— Methodfunction integrate1D(data, xgrid; axis=1)
calculate integration of data[i] on xgrid. For 1D data, return a number; for multiple dimension, reduce the given axis.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- axis: axis to be integrated in data
CompositeGrids.Interp.interp1D
— Methodfunction interp1D(::ChebInterp, data, xgrid, x)
linear interpolation of data(x), barycheb for BaryCheb grid
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- x: x
CompositeGrids.Interp.interp1D
— Methodfunction interp1D(::CompositeInterp,data, xgrid, x)
linear interpolation of data(x), first floor on panel to find subgrid, then call interp1D on subgrid
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- x: x
CompositeGrids.Interp.interp1D
— Methodfunction interp1D(::LinearInterp,data, xgrid, x)
linear interpolation of data(x), use floor and linear1D
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- x: x
CompositeGrids.Interp.interp1D
— Methodfunction interp1D(data, xgrid, x; axis=1, method=InterpStyle(T))
linear interpolation of data(x) with single or multiple dimension. For 1D data, return a number; for multiple dimension, reduce the given axis.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- x: x
- axis: axis to be interpolated in data
- method: by default use optimized method; use linear interp if Interp.LinearInterp()
CompositeGrids.Interp.interp1DGrid
— Methodfunction interp1DGrid(::CompositeInterp, data, xgrid, grid)
linear interpolation of data(grid[1:end]), return a Vector grid should be sorted.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- grid: points to be interpolated on
CompositeGrids.Interp.interp1DGrid
— Methodfunction interp1DGrid(::Union{LinearInterp,ChebInterp}, data, xgrid, grid)
linear interpolation of data(grid[1:end]), return a Vector simply call interp1D on each points
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- grid: points to be interpolated on
CompositeGrids.Interp.interp1DGrid
— Methodfunction interp1DGrid(data, xgrid, grid; axis=1, method=InterpStyle(T))
For 1D data, do interpolation of data(grid[1:end]), return a Vector. For ND data, do interpolation of data(grid[1:end]) at given axis, return data of same dimension.
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- grid: points to be interpolated on
- axis: axis to be interpolated in data
- method: by default use optimized method; use linear interp if :linear
CompositeGrids.Interp.interpsliced
— Methodfunction interpsliced(neighbor, data; axis=1)
Interpolate with given neighbor and sliced data. Assume data already sliced on given axis.
#Members:
- neighbor: neighbor from findneighbor()
- data: sliced data
- axis: axis sliced and to be interpolated
CompositeGrids.Interp.linear1D
— Methodfunction linear1D(data, xgrid, x)
linear interpolation of data(x)
#Arguments:
- xgrid: one-dimensional grid of x
- data: one-dimensional array of data
- x: x
CompositeGrids.Interp.linear2D
— Methodlinear2D(data, xgrid, ygrid, x, y)
linear interpolation of data(x, y)
#Arguments:
- xgrid: one-dimensional grid of x
- ygrid: one-dimensional grid of y
- data: two-dimensional array of data
- x: x
- y: y
CompositeGrids.Interp.linearND
— Methodfunction linearND(data, xgrids, xs)
linear interpolation of data(xs)
#Arguments:
- xgrids: n-dimensional grids, xgrids[i] is a 1D grid
- data: n-dimensional array of data
- xs: list of x, x[i] corresponds to xgrids[i]
CompositeGrids.Interp.locate
— Methodfunction locate(grid, x)
return the index of grid point closest to x. Useful for Monte Carlo algorithm when variable x is continuous while histogram is stored on grid.
#Arguments:
- grid: one-dimensional grid of x
- x: point to locate
CompositeGrids.Interp.volume
— Methodfunction volume(grid, i)
return the volume of grid point i. The volume is defined as the length/area/volume/... of histogram bar represented by grid point i. In 1D grids of this package, it is defined as the length of interval between (grid[i-1]+grid[i])/2 and (grid[i]+grid[i+1])/2, and for edge points one side is replaced by boundary points. When index i is omitted, the length of the whole grid is returned. It is guaranteed that volume(grid)==sum(volume(grid, i) for i in 1:length(grid)).
#Arguments:
- grid: one-dimensional grid
- i: index of grid point